From 6607e702539f0affa2d1b2926d4e69a1e032c242 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 18 Jun 2013 23:50:31 +0200 Subject: [PATCH 1/7] test: open stdout fd in write-only mode Fixes #771. --- test/test-tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-tty.c b/test/test-tty.c index f3003efa..c26f7fa9 100644 --- a/test/test-tty.c +++ b/test/test-tty.c @@ -81,10 +81,10 @@ TEST_IMPL(tty) { ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); - r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); + r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ ASSERT(r == 0); - r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 2); + r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 0); /* Writable. */ ASSERT(r == 0); r = uv_tty_get_winsize(&tty_out, &width, &height); From 495d1a09fb863354e5de1c6ab4547be3672ace00 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 19 Jun 2013 00:14:58 +0200 Subject: [PATCH 2/7] windows: uv_spawn shouldn't reject reparse points This fixes an issue where uv_spawn would not try to run a reparse point, and continue to scan the PATH instead. Effectively, it was impossible to spawn a symlinked binary. This commit fixes that. Also see #748 --- src/win/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win/process.c b/src/win/process.c index f98767a4..fb445b6c 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -225,7 +225,7 @@ static WCHAR* search_path_join_test(const WCHAR* dir, attrs = GetFileAttributesW(result); if (attrs != INVALID_FILE_ATTRIBUTES && - !(attrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT))) { + !(attrs & FILE_ATTRIBUTE_DIRECTORY)) { return result; } From c8c775bd9739e0c9562b925ec482a378b50f97c2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 26 Jun 2013 01:03:36 +0200 Subject: [PATCH 3/7] windows: use WSAGetLastError(), not errno setsockopt() doesn't touch errno on failure. Use WSAGetLastError() instead. This is a back-port of commit 30a8b44 from the master branch. --- src/win/tcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win/tcp.c b/src/win/tcp.c index c3ef6533..59a36de0 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -50,7 +50,7 @@ static int uv__tcp_nodelay(uv_tcp_t* handle, SOCKET socket, int enable) { TCP_NODELAY, (const char*)&enable, sizeof enable) == -1) { - uv__set_sys_error(handle->loop, errno); + uv__set_sys_error(handle->loop, WSAGetLastError()); return -1; } return 0; @@ -63,7 +63,7 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign SO_KEEPALIVE, (const char*)&enable, sizeof enable) == -1) { - uv__set_sys_error(handle->loop, errno); + uv__set_sys_error(handle->loop, WSAGetLastError()); return -1; } @@ -72,7 +72,7 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign TCP_KEEPALIVE, (const char*)&delay, sizeof delay) == -1) { - uv__set_sys_error(handle->loop, errno); + uv__set_sys_error(handle->loop, WSAGetLastError()); return -1; } From a0bc4cca74be7de2a540439920c8f15d0a671b74 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 26 Jun 2013 13:06:26 +0200 Subject: [PATCH 4/7] build: darwin: disable -fstrict-aliasing warnings gcc 4.2.1 as shipped with Xcode complains incessantly about aliasing warnings, which, while technically true, disregards the fact that the aliased types have the same layout in memory. Squelch the warnings. --- common.gypi | 1 + 1 file changed, 1 insertion(+) diff --git a/common.gypi b/common.gypi index c3462821..67291fdc 100644 --- a/common.gypi +++ b/common.gypi @@ -36,6 +36,7 @@ }, 'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '0', + 'OTHER_CFLAGS': [ '-Wno-strict-aliasing' ], }, 'conditions': [ ['OS != "win"', { From 488b43ecc5a79143d0697e5e49d834c86c7c9894 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 26 Jun 2013 13:26:45 +0200 Subject: [PATCH 5/7] test: fix signed/unsigned compiler warning --- test/test-fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-fs.c b/test/test-fs.c index 0016b3be..ca2ff2bd 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -1391,7 +1391,8 @@ TEST_IMPL(fs_symlink_dir) { #ifdef _WIN32 ASSERT(((struct stat*)req.ptr)->st_size == strlen(test_dir + 4)); #else - ASSERT(((struct stat*)req.ptr)->st_size == strlen(test_dir)); + /* st_size has type off_t. Cast to avoid signed/unsigned warnings. */ + ASSERT((size_t) ((struct stat*)req.ptr)->st_size == strlen(test_dir)); #endif uv_fs_req_cleanup(&req); From 5841852703c02e46d7220f1eb8d89bb8414d7cf3 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 26 Jun 2013 13:02:39 +0200 Subject: [PATCH 6/7] test: add 'start timer from check handle' test Check that a timer that is started from a check handle gets picked up correctly, i.e. that it influences the timeout used in the next tick of the event loop. --- build.mk | 1 + test/test-list.h | 2 + test/test-timer-from-check.c | 80 ++++++++++++++++++++++++++++++++++++ uv.gyp | 1 + 4 files changed, 84 insertions(+) create mode 100644 test/test-timer-from-check.c diff --git a/build.mk b/build.mk index 5ff713e0..7d8a3be7 100644 --- a/build.mk +++ b/build.mk @@ -130,6 +130,7 @@ TESTS= \ test/test-threadpool.o \ test/test-threadpool-cancel.o \ test/test-timer-again.o \ + test/test-timer-from-check.o \ test/test-timer.o \ test/test-tty.o \ test/test-udp-dgram-too-big.o \ diff --git a/test/test-list.h b/test/test-list.h index 4c015858..7a9b1a29 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -101,6 +101,7 @@ TEST_DECLARE (timer_start_twice) TEST_DECLARE (timer_order) TEST_DECLARE (timer_huge_timeout) TEST_DECLARE (timer_huge_repeat) +TEST_DECLARE (timer_from_check) TEST_DECLARE (idle_starvation) TEST_DECLARE (loop_handles) TEST_DECLARE (get_loadavg) @@ -348,6 +349,7 @@ TASK_LIST_START TEST_ENTRY (timer_order) TEST_ENTRY (timer_huge_timeout) TEST_ENTRY (timer_huge_repeat) + TEST_ENTRY (timer_from_check) TEST_ENTRY (idle_starvation) diff --git a/test/test-timer-from-check.c b/test/test-timer-from-check.c new file mode 100644 index 00000000..2aa3fe41 --- /dev/null +++ b/test/test-timer-from-check.c @@ -0,0 +1,80 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" + +static uv_prepare_t prepare_handle; +static uv_check_t check_handle; +static uv_timer_t timer_handle; + +static int prepare_cb_called; +static int check_cb_called; +static int timer_cb_called; + + +static void prepare_cb(uv_prepare_t* handle, int status) { + ASSERT(0 == uv_prepare_stop(&prepare_handle)); + ASSERT(0 == prepare_cb_called); + ASSERT(1 == check_cb_called); + ASSERT(0 == timer_cb_called); + prepare_cb_called++; +} + + +static void timer_cb(uv_timer_t* handle, int status) { + ASSERT(0 == uv_timer_stop(&timer_handle)); + ASSERT(1 == prepare_cb_called); + ASSERT(1 == check_cb_called); + ASSERT(0 == timer_cb_called); + timer_cb_called++; +} + + +static void check_cb(uv_check_t* handle, int status) { + ASSERT(0 == uv_check_stop(&check_handle)); + ASSERT(0 == uv_timer_stop(&timer_handle)); /* Runs before timer_cb. */ + ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 50, 0)); + ASSERT(0 == uv_prepare_start(&prepare_handle, prepare_cb)); + ASSERT(0 == prepare_cb_called); + ASSERT(0 == check_cb_called); + ASSERT(0 == timer_cb_called); + check_cb_called++; +} + + +TEST_IMPL(timer_from_check) { + ASSERT(0 == uv_prepare_init(uv_default_loop(), &prepare_handle)); + ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle)); + ASSERT(0 == uv_check_start(&check_handle, check_cb)); + ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 50, 0)); + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT(1 == prepare_cb_called); + ASSERT(1 == check_cb_called); + ASSERT(1 == timer_cb_called); + uv_close((uv_handle_t*) &prepare_handle, NULL); + uv_close((uv_handle_t*) &check_handle, NULL); + uv_close((uv_handle_t*) &timer_handle, NULL); + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + MAKE_VALGRIND_HAPPY(); + return 0; +} diff --git a/uv.gyp b/uv.gyp index 54c771ee..f61ebb53 100644 --- a/uv.gyp +++ b/uv.gyp @@ -353,6 +353,7 @@ 'test/test-barrier.c', 'test/test-condvar.c', 'test/test-timer-again.c', + 'test/test-timer-from-check.c', 'test/test-timer.c', 'test/test-tty.c', 'test/test-udp-dgram-too-big.c', From 88a2c7ff209935d736f02e79b3369f2e7b646bb8 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 26 Jun 2013 17:13:26 +0200 Subject: [PATCH 7/7] build: `all` now builds static and dynamic lib The `make all` target now builds both libuv.a and libuv.{so,dylib} rather than just libuv.a. --- build.mk | 6 +----- config-unix.mk | 9 ++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.mk b/build.mk index 7d8a3be7..6cba169f 100644 --- a/build.mk +++ b/build.mk @@ -143,7 +143,7 @@ TESTS= \ test/test-util.o \ test/test-walk-handles.o \ -all: libuv.a +.PHONY: all bench clean clean-platform distclean test run-tests$(E): test/run-tests.o test/runner.o $(RUNNER_SRC) $(TESTS) libuv.a $(CC) $(CPPFLAGS) $(RUNNER_CFLAGS) -o $@ $^ $(RUNNER_LIBS) $(RUNNER_LDFLAGS) @@ -153,10 +153,6 @@ run-benchmarks$(E): test/run-benchmarks.o test/runner.o $(RUNNER_SRC) $(BENCHMAR test/echo.o: test/echo.c test/echo.h - -.PHONY: clean clean-platform distclean test bench - - test: run-tests$(E) $(CURDIR)/$< diff --git a/config-unix.mk b/config-unix.mk index 90887305..d230bb25 100644 --- a/config-unix.mk +++ b/config-unix.mk @@ -29,7 +29,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64 RUNNER_SRC=test/runner-unix.c RUNNER_CFLAGS=$(CFLAGS) -I$(SRCDIR)/test -RUNNER_LDFLAGS=-L"$(CURDIR)" -luv +RUNNER_LDFLAGS= DTRACE_OBJS= DTRACE_HEADER= @@ -159,6 +159,13 @@ endif RUNNER_LDFLAGS += $(LDFLAGS) +all: + # Force a sequential build of the static and the shared library. + # Works around a make quirk where it forgets to (re)build either + # the *.o or *.pic.o files, depending on what target comes first. + $(MAKE) -f $(SRCDIR)/Makefile libuv.a + $(MAKE) -f $(SRCDIR)/Makefile libuv.$(SOEXT) + libuv.a: $(OBJS) $(AR) rcs $@ $^