Merge remote-tracking branch 'origin/v0.10'

Conflicts:
	test/test-fs.c
	test/test-list.h
This commit is contained in:
Ben Noordhuis 2013-06-26 10:35:41 +02:00
commit ce2458c053
8 changed files with 97 additions and 9 deletions

View File

@ -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 \
@ -142,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)
@ -152,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)/$<

View File

@ -36,6 +36,7 @@
},
'xcode_settings': {
'GCC_OPTIMIZATION_LEVEL': '0',
'OTHER_CFLAGS': [ '-Wno-strict-aliasing' ],
},
'conditions': [
['OS != "win"', {

View File

@ -28,7 +28,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=
@ -165,6 +165,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 $@ $^

View File

@ -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;
}

View File

@ -102,6 +102,7 @@ TEST_DECLARE (timer_order)
TEST_DECLARE (timer_huge_timeout)
TEST_DECLARE (timer_huge_repeat)
TEST_DECLARE (timer_run_once)
TEST_DECLARE (timer_from_check)
TEST_DECLARE (idle_starvation)
TEST_DECLARE (loop_handles)
TEST_DECLARE (get_loadavg)
@ -352,6 +353,7 @@ TASK_LIST_START
TEST_ENTRY (timer_huge_timeout)
TEST_ENTRY (timer_huge_repeat)
TEST_ENTRY (timer_run_once)
TEST_ENTRY (timer_from_check)
TEST_ENTRY (idle_starvation)

View File

@ -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;
}

View File

@ -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);

1
uv.gyp
View File

@ -368,6 +368,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',