diff --git a/Makefile b/Makefile index 87aa699b..dcae5bb3 100644 --- a/Makefile +++ b/Makefile @@ -355,6 +355,7 @@ $(UV_OBJS): CFLAGS += \ -Wno-incompatible-pointer-types \ -Wno-maybe-uninitialized \ -Wno-sign-compare \ + -Wno-unused-but-set-parameter \ -Wno-unused-but-set-variable \ -Wno-unused-result \ -Wno-unused-variable diff --git a/deps/libuv/.github/workflows/CI-unix.yml b/deps/libuv/.github/workflows/CI-unix.yml index c912a6fa..993cfb74 100644 --- a/deps/libuv/.github/workflows/CI-unix.yml +++ b/deps/libuv/.github/workflows/CI-unix.yml @@ -125,7 +125,7 @@ jobs: # this ensure install latest qemu on ubuntu, apt get version is old env: QEMU_SRC: "http://archive.ubuntu.com/ubuntu/pool/universe/q/qemu" - QEMU_VER: "qemu-user-static_7\\.0+dfsg-.*_amd64.deb$" + QEMU_VER: "qemu-user-static_7\\.2+dfsg-.*_amd64.deb$" run: | DEB=`curl -s $QEMU_SRC/ | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | grep $QEMU_VER | tail -1` wget $QEMU_SRC/$DEB diff --git a/deps/libuv/.github/workflows/CI-win.yml b/deps/libuv/.github/workflows/CI-win.yml index a8810ead..149f9ca0 100644 --- a/deps/libuv/.github/workflows/CI-win.yml +++ b/deps/libuv/.github/workflows/CI-win.yml @@ -26,6 +26,8 @@ jobs: - {toolchain: Visual Studio 17 2022, arch: Win32, server: 2022} - {toolchain: Visual Studio 17 2022, arch: x64, server: 2022} - {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: ASAN} + - {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: UBSAN} + - {toolchain: Visual Studio 17 2022, arch: arm64, server: 2022} steps: - uses: actions/checkout@v2 - name: Envinfo @@ -35,30 +37,33 @@ jobs: run: cmake -S . -B build -DBUILD_TESTING=ON -G "${{ matrix.config.toolchain }}" -A ${{ matrix.config.arch }} - ${{ matrix.config.config == 'ASAN' && '-DASAN=on -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' || '' }} + ${{ matrix.config.config == 'ASAN' && '-DASAN=on -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' || + matrix.config.config == 'UBSAN' && '-DUBSAN=on' || '' }} cmake --build build --config RelWithDebInfo ls -l build - name: platform_output + if: ${{ matrix.config.arch != 'arm64' }} shell: cmd run: build\\RelWithDebInfo\\uv_run_tests.exe platform_output - name: platform_output_a + if: ${{ matrix.config.arch != 'arm64' }} shell: cmd run: build\\RelWithDebInfo\\uv_run_tests_a.exe platform_output - name: Test # only valid with libuv-master with the fix for # https://github.com/libuv/leps/blob/master/005-windows-handles-not-fd.md - if: ${{ matrix.config.config != 'ASAN' }} + if: ${{ matrix.config.config != 'ASAN' && matrix.config.arch != 'arm64' }} shell: cmd run: cd build ctest -C RelWithDebInfo -V - name: Test only static - if: ${{ matrix.config.config == 'ASAN' }} + if: ${{ matrix.config.config == 'ASAN' && matrix.config.arch != 'arm64' }} shell: cmd run: build\\RelWithDebInfo\\uv_run_tests_a.exe diff --git a/deps/libuv/.github/workflows/sanitizer.yml b/deps/libuv/.github/workflows/sanitizer.yml index 8173c822..4fca161d 100644 --- a/deps/libuv/.github/workflows/sanitizer.yml +++ b/deps/libuv/.github/workflows/sanitizer.yml @@ -13,7 +13,7 @@ on: - master jobs: - sanitizers: + sanitizers-linux: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -60,3 +60,64 @@ jobs: - name: UBSAN Test run: | ./build-ubsan/uv_run_tests_a + + sanitizers-macos: + runs-on: macos-11 + steps: + - uses: actions/checkout@v2 + + - name: Envinfo + run: npx envinfo + + - name: ASAN Build + run: | + mkdir build-asan + (cd build-asan && cmake .. -DBUILD_TESTING=ON -DASAN=ON -DCMAKE_BUILD_TYPE=Debug) + cmake --build build-asan + - name: ASAN Test + run: | + ./build-asan/uv_run_tests_a + + - name: TSAN Build + run: | + mkdir build-tsan + (cd build-tsan && cmake .. -DBUILD_TESTING=ON -DTSAN=ON -DCMAKE_BUILD_TYPE=Release) + cmake --build build-tsan + - name: TSAN Test + run: | + ./build-tsan/uv_run_tests_a + + - name: UBSAN Build + run: | + mkdir build-ubsan + (cd build-ubsan && cmake .. -DBUILD_TESTING=ON -DUBSAN=ON -DCMAKE_BUILD_TYPE=Debug) + cmake --build build-ubsan + - name: UBSAN Test + run: | + ./build-ubsan/uv_run_tests_a + + sanitizers-windows: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v2 + - name: Setup + run: | + choco install ninja + + # Note: clang shipped with VS2022 has an issue where the UBSAN runtime doesn't link. + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1 + with: + version: "17" + + - name: Envinfo + run: npx envinfo + + - name: UBSAN Build + run: | + mkdir build-ubsan + cmake -B build-ubsan -G Ninja -DBUILD_TESTING=ON -DUBSAN=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang + cmake --build build-ubsan + - name: UBSAN Test + run: | + ./build-ubsan/uv_run_tests_a diff --git a/deps/libuv/AUTHORS b/deps/libuv/AUTHORS index 9b89421c..6bf1a9fa 100644 --- a/deps/libuv/AUTHORS +++ b/deps/libuv/AUTHORS @@ -548,3 +548,15 @@ liuxiang88 <94350585+liuxiang88@users.noreply.github.com> Jeffrey H. Johnson Abdirahim Musse <33973272+abmusse@users.noreply.github.com> 小明 <7737673+caobug@users.noreply.github.com> +Shuduo Sang +Keith Winstein +michalbiesek +Alois Klink +SmorkalovG +Pleuvens +jolai <58589285+laijonathan@users.noreply.github.com> +Julien Roncaglia +prubel +Per Allansson <65364157+per-allansson@users.noreply.github.com> +Matheus Izvekov +Christian Heimlich diff --git a/deps/libuv/CMakeLists.txt b/deps/libuv/CMakeLists.txt index 93733dd0..72377851 100644 --- a/deps/libuv/CMakeLists.txt +++ b/deps/libuv/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.9) if(POLICY CMP0091) cmake_policy(SET CMP0091 NEW) # Enable MSVC_RUNTIME_LIBRARY setting @@ -186,7 +186,8 @@ if(WIN32) ws2_32 dbghelp ole32 - uuid) + uuid + shell32) list(APPEND uv_sources src/win/async.c src/win/core.c @@ -477,7 +478,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS390") endif() target_link_libraries(uv_a ${uv_libraries}) set_target_properties(uv_a PROPERTIES OUTPUT_NAME "uv") -if(MSVC) +if(WIN32) set_target_properties(uv_a PROPERTIES PREFIX "lib") endif() diff --git a/deps/libuv/ChangeLog b/deps/libuv/ChangeLog index e2cd8825..f40fcc60 100644 --- a/deps/libuv/ChangeLog +++ b/deps/libuv/ChangeLog @@ -1,4 +1,113 @@ -2023.06.30, Version 1.46.0 (Stable) +2023.11.06, Version 1.47.0 (Stable) + +Changes since version 1.46.0: + +* test: fix license blurb (Ben Noordhuis) + +* linux: fix harmless warn_unused_result warning (Shuduo Sang) + +* darwin: fix build warnings (小明) + +* linux: don't use io_uring on pre-5.10.186 kernels (Ben Noordhuis) + +* fs: fix WTF-8 decoding issue (Jameson Nash) + +* test: enable disabled tcp_connect6_error_fault (Ben Noordhuis) + +* test: enable disabled fs_link (Ben Noordhuis) + +* test: enable disabled spawn_same_stdout_stderr (Ben Noordhuis) + +* linux: handle UNAME26 personality (Ben Noordhuis) + +* build: move cmake_minimum_required version to 3.9 (Keith Winstein) + +* unix: set ipv6 scope id for link-local addresses (Ben Noordhuis) + +* unix: match kqueue and epoll code (Trevor Norris) + +* win,spawn: allow `%PATH%` to be unset (Kyle Edwards) + +* doc: switch to Furo, a more modern Sphinx theme (Saúl Ibarra Corretgé) + +* darwin: make TCP_KEEPINTVL and TCP_KEEPCNT available (小明) + +* win,fs: avoid winapi macro redefinition (Brad King) + +* linux: add missing riscv syscall numbers (michalbiesek) + +* doc: fix broken "Shared library" Wikipedia link (Alois Klink) + +* unix: get mainline kernel version in Ubuntu (Santiago Gimeno) + +* unix: get mainline kernel version in Debian (Ben Noordhuis) + +* build: fix qemu install in CI-unix workflow (Santiago Gimeno) + +* unix: disable io_uring close on selected kernels (Santiago Gimeno) + +* test: skip tests when ipv6 is not available (Santiago Gimeno) + +* ibmi: implement ifaddrs, getifaddrs, freeifaddrs (Abdirahim Musse) + +* unix: reset signal counters after fork (SmorkalovG) + +* win,process: avoid assert after spawning Store app (Jameson Nash) + +* unix: remove pread/preadv conditionals (Ben Noordhuis) + +* unix: remove pwrite/pwritev conditionals (Ben Noordhuis) + +* darwin: remove workaround for data corruption bug (Ben Noordhuis) + +* src: default to stream=stderr in handle printer (Ben Noordhuis) + +* test: switch to new-style ASSERT_EQ macros (Pleuvens) + +* zos: correctly get cpu model in uv_cpu_info() (jolai) + +* test: fix get_passwd2 on IBM i (Abdirahim Musse) + +* unix: don't malloc on sync uv_fs_read (Ben Noordhuis) + +* freebsd: get fs event path with fcntl(F_KINFO) (David Carlier) + +* test: switch from ASSERT_* to ASSERT_PTR_* (Pleuvens) + +* darwin: workaround apple pthread_cond_wait bug (Julien Roncaglia) + +* doc: uv_close should be called after exit callback (Pleuvens) + +* test: 192.0.2.0/24 is the actual -TEST-NET-1 (prubel) + +* unix: add back preadv/pwritev fallback (Ben Noordhuis) + +* unix: rename variable for consistency (Ben Noordhuis) + +* unix: merge read/write code into single functions (Ben Noordhuis) + +* doc: filename arg to uv_fs_event_cb can be NULL (Ben Noordhuis) + +* build,win: we need to link against shell32.lib (Per Allansson) + +* unix: no preadv/pwritev workaround if not needed (Jeffrey H. Johnson) + +* build: add CI for Windows ARM64 (build only) (Per Allansson) + +* linux: disable io_uring on 32 bits arm systems (Ben Noordhuis) + +* build: run sanitizers on macos ci (Ben Noordhuis) + +* misc: export WTF8 conversion utilities (Jameson Nash) + +* build: fix libuv.a file name for cmake (Jameson Nash) + +* build: add windows ubsan and clang ci (Matheus Izvekov) + +* win: improve accuracy of ProductName between arch (Christian Heimlich) + + +2023.06.30, Version 1.46.0 (Stable), f0bb7e40f0508bedf6fad33769b3f87bb8aedfa6 Changes since version 1.45.0: diff --git a/deps/libuv/configure.ac b/deps/libuv/configure.ac index deb08360..0a1042ce 100644 --- a/deps/libuv/configure.ac +++ b/deps/libuv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.46.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.47.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) @@ -74,7 +74,7 @@ AM_CONDITIONAL([OS400], [AS_CASE([$host_os],[os400], [true], [false]) AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])]) AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])]) AS_CASE([$host_os],[mingw*], [ - LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32 -ldbghelp -lole32 -luuid" + LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32 -ldbghelp -lole32 -luuid -lshell32" ]) AS_CASE([$host_os], [solaris2.10], [ CFLAGS="$CFLAGS -DSUNOS_NO_IFADDRS" diff --git a/deps/libuv/docs/requirements.txt b/deps/libuv/docs/requirements.txt index b037de46..2e310ebe 100644 --- a/deps/libuv/docs/requirements.txt +++ b/deps/libuv/docs/requirements.txt @@ -1,27 +1,36 @@ # primary -sphinx==6.1.3 +furo==2023.5.20 +Sphinx==6.1.3 # dependencies alabaster==0.7.13 Babel==2.11.0 +beautifulsoup4==4.12.2 certifi==2022.12.7 charset-normalizer==3.0.1 +colorama==0.4.6 docutils==0.19 idna==3.4 imagesize==1.4.1 importlib-metadata==6.0.0 Jinja2==3.1.2 +livereload==2.6.3 MarkupSafe==2.1.2 packaging==23.0 Pygments==2.14.0 pytz==2022.7.1 requests==2.28.2 +six==1.16.0 snowballstemmer==2.2.0 -sphinxcontrib-applehelp==1.0.3 +soupsieve==2.4.1 +sphinx-autobuild==2021.3.14 +sphinx-basic-ng==1.0.0b2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 +sphinxcontrib.applehelp==1.0.3 +tornado==6.3.2 urllib3==1.26.14 zipp==3.11.0 diff --git a/deps/libuv/docs/src/conf.py b/deps/libuv/docs/src/conf.py index f6f43253..354759a2 100644 --- a/deps/libuv/docs/src/conf.py +++ b/deps/libuv/docs/src/conf.py @@ -118,7 +118,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'nature' +html_theme = 'furo' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/deps/libuv/docs/src/fs_event.rst b/deps/libuv/docs/src/fs_event.rst index e28ec625..54a776ae 100644 --- a/deps/libuv/docs/src/fs_event.rst +++ b/deps/libuv/docs/src/fs_event.rst @@ -39,8 +39,12 @@ Data types .. c:type:: void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename, int events, int status) Callback passed to :c:func:`uv_fs_event_start` which will be called repeatedly - after the handle is started. If the handle was started with a directory the - `filename` parameter will be a relative path to a file contained in the directory. + after the handle is started. + + If the handle was started with a directory the `filename` parameter will + be a relative path to a file contained in the directory, or `NULL` if the + file name cannot be determined. + The `events` parameter is an ORed mask of :c:type:`uv_fs_event` elements. .. c:type:: uv_fs_event diff --git a/deps/libuv/docs/src/guide/processes.rst b/deps/libuv/docs/src/guide/processes.rst index c1278f17..99d65c40 100644 --- a/deps/libuv/docs/src/guide/processes.rst +++ b/deps/libuv/docs/src/guide/processes.rst @@ -53,6 +53,8 @@ ID of the child process. The exit callback will be invoked with the *exit status* and the type of *signal* which caused the exit. +Note that it is important **not** to call ``uv_close`` before the exit callback. + .. rubric:: spawn/main.c .. literalinclude:: ../../code/spawn/main.c :language: c @@ -126,7 +128,8 @@ of ``uv_kill`` is:: For processes started using libuv, you may use ``uv_process_kill`` instead, which accepts the ``uv_process_t`` watcher as the first argument, rather than -the pid. In this case, **remember to call** ``uv_close`` on the watcher. +the pid. In this case, **remember to call** ``uv_close`` on the watcher _after_ +the exit callback has been called. Signals ------- diff --git a/deps/libuv/docs/src/guide/utilities.rst b/deps/libuv/docs/src/guide/utilities.rst index c67515a0..44e4370d 100644 --- a/deps/libuv/docs/src/guide/utilities.rst +++ b/deps/libuv/docs/src/guide/utilities.rst @@ -363,7 +363,7 @@ to get the error message. argument. ``init_plugin_function`` is a function pointer to the sort of function we are looking for in the application's plugins. -.. _shared libraries: https://en.wikipedia.org/wiki/Shared_library#Shared_libraries +.. _shared libraries: https://en.wikipedia.org/wiki/Shared_library TTY --- diff --git a/deps/libuv/docs/src/misc.rst b/deps/libuv/docs/src/misc.rst index 8c3a00e9..98961830 100644 --- a/deps/libuv/docs/src/misc.rst +++ b/deps/libuv/docs/src/misc.rst @@ -839,3 +839,50 @@ API Causes the calling thread to sleep for `msec` milliseconds. .. versionadded:: 1.34.0 + +String manipulation functions +----------------------------- + +These string utilities are needed internally for dealing with Windows, and are +exported to allow clients to work uniformly with this data when the libuv API +is not complete. + +.. c:function:: size_t uv_utf16_length_as_wtf8(const uint16_t* utf16, ssize_t utf16_len) + + Get the length of a UTF-16 (or UCS-2) `utf16` value after converting it to + WTF-8. If `utf16` is NUL terminated, `utf16_len` can be set to -1, + otherwise it must be specified. + + .. versionadded:: 1.47.0 + +.. c:function:: int uv_utf16_to_wtf8(const uint16_t* utf16, ssize_t utf16_len, char** wtf8_ptr, size_t* wtf8_len_ptr) + + Convert UTF-16 (or UCS-2) data in `utf16` to WTF-8 data in `*wtf8_ptr`. The + `utf16_len` count (in characters) gives the length of `utf16`. If `utf16` + is NUL terminated, `utf16_len` can be set to -1, otherwise it must be + specified. If `wtf8_ptr` is `NULL`, no result will be computed, but the + length (equal to `uv_utf16_length_as_wtf8`) will be stored in `wtf8_ptr`. + If `*wtf8_ptr` is `NULL`, space for the conversion will be allocated and + returned in `wtf8_ptr` and the length will be returned in `wtf8_len_ptr`. + Otherwise, the length of `*wtf8_ptr` must be passed in `wtf8_len_ptr`. The + `wtf8_ptr` must contain an extra space for an extra NUL after the result. + If the result is truncated, `UV_ENOBUFS` will be returned and + `wtf8_len_ptr` will be the length of the required `wtf8_ptr` to contain the + whole result. + + .. versionadded:: 1.47.0 + +.. c:function:: ssize_t uv_wtf8_length_as_utf16(const char* wtf8) + + Get the length in characters of a NUL-terminated WTF-8 `wtf8` value + after converting it to UTF-16 (or UCS-2), including NUL terminator. + + .. versionadded:: 1.47.0 + +.. c:function:: void uv_wtf8_to_utf16(const char* utf8, uint16_t* utf16, size_t utf16_len) + + Convert NUL-terminated WTF-8 data in `wtf8` to UTF-16 (or UCS-2) data + in `utf16`. The `utf16_len` count (in characters) must include space + for the NUL terminator. + + .. versionadded:: 1.47.0 diff --git a/deps/libuv/include/uv.h b/deps/libuv/include/uv.h index 02397dd0..5642101c 100644 --- a/deps/libuv/include/uv.h +++ b/deps/libuv/include/uv.h @@ -1885,6 +1885,18 @@ struct uv_loop_s { UV_EXTERN void* uv_loop_get_data(const uv_loop_t*); UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data); +/* String utilities needed internally for dealing with Windows. */ +size_t uv_utf16_length_as_wtf8(const uint16_t* utf16, + ssize_t utf16_len); +int uv_utf16_to_wtf8(const uint16_t* utf16, + ssize_t utf16_len, + char** wtf8_ptr, + size_t* wtf8_len_ptr); +ssize_t uv_wtf8_length_as_utf16(const char* wtf8); +void uv_wtf8_to_utf16(const char* wtf8, + uint16_t* utf16, + size_t utf16_len); + /* Don't export the private CPP symbols. */ #undef UV_HANDLE_TYPE_PRIVATE #undef UV_REQ_TYPE_PRIVATE diff --git a/deps/libuv/include/uv/version.h b/deps/libuv/include/uv/version.h index 24fac8d8..b17220fc 100644 --- a/deps/libuv/include/uv/version.h +++ b/deps/libuv/include/uv/version.h @@ -31,7 +31,7 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 46 +#define UV_VERSION_MINOR 47 #define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/libuv/src/idna.c b/deps/libuv/src/idna.c index 93d982ca..1c0a60cf 100644 --- a/deps/libuv/src/idna.c +++ b/deps/libuv/src/idna.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, 2018 Ben Noordhuis +/* Copyright libuv contributors. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -18,11 +18,56 @@ */ #include "uv.h" +#include "uv-common.h" #include "idna.h" #include #include #include /* UINT_MAX */ + +static int32_t uv__wtf8_decode1(const char** input) { + uint32_t code_point; + uint8_t b1; + uint8_t b2; + uint8_t b3; + uint8_t b4; + + b1 = **input; + if (b1 <= 0x7F) + return b1; /* ASCII code point */ + if (b1 < 0xC2) + return -1; /* invalid: continuation byte */ + code_point = b1; + + b2 = *++*input; + if ((b2 & 0xC0) != 0x80) + return -1; /* invalid: not a continuation byte */ + code_point = (code_point << 6) | (b2 & 0x3F); + if (b1 <= 0xDF) + return 0x7FF & code_point; /* two-byte character */ + + b3 = *++*input; + if ((b3 & 0xC0) != 0x80) + return -1; /* invalid: not a continuation byte */ + code_point = (code_point << 6) | (b3 & 0x3F); + if (b1 <= 0xEF) + return 0xFFFF & code_point; /* three-byte character */ + + b4 = *++*input; + if ((b4 & 0xC0) != 0x80) + return -1; /* invalid: not a continuation byte */ + code_point = (code_point << 6) | (b4 & 0x3F); + if (b1 <= 0xF4) { + code_point &= 0x1FFFFF; + if (code_point <= 0x10FFFF) + return code_point; /* four-byte character */ + } + + /* code point too large */ + return -1; +} + + static unsigned uv__utf8_decode1_slow(const char** p, const char* pe, unsigned a) { @@ -89,6 +134,7 @@ static unsigned uv__utf8_decode1_slow(const char** p, return a; } + unsigned uv__utf8_decode1(const char** p, const char* pe) { unsigned a; @@ -102,6 +148,7 @@ unsigned uv__utf8_decode1(const char** p, const char* pe) { return uv__utf8_decode1_slow(p, pe, a); } + static int uv__idna_toascii_label(const char* s, const char* se, char** d, char* de) { static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789"; @@ -267,7 +314,8 @@ static int uv__idna_toascii_label(const char* s, const char* se, return 0; } -long uv__idna_toascii(const char* s, const char* se, char* d, char* de) { + +ssize_t uv__idna_toascii(const char* s, const char* se, char* d, char* de) { const char* si; const char* st; unsigned c; @@ -313,3 +361,195 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) { return d - ds; /* Number of bytes written. */ } + + +ssize_t uv_wtf8_length_as_utf16(const char* source_ptr) { + size_t w_target_len = 0; + int32_t code_point; + + do { + code_point = uv__wtf8_decode1(&source_ptr); + if (code_point < 0) + return -1; + if (code_point > 0xFFFF) + w_target_len++; + w_target_len++; + } while (*source_ptr++); + + return w_target_len; +} + + +void uv_wtf8_to_utf16(const char* source_ptr, + uint16_t* w_target, + size_t w_target_len) { + int32_t code_point; + + do { + code_point = uv__wtf8_decode1(&source_ptr); + /* uv_wtf8_length_as_utf16 should have been called and checked first. */ + assert(code_point >= 0); + if (code_point > 0x10000) { + assert(code_point < 0x10FFFF); + *w_target++ = (((code_point - 0x10000) >> 10) + 0xD800); + *w_target++ = ((code_point - 0x10000) & 0x3FF) + 0xDC00; + w_target_len -= 2; + } else { + *w_target++ = code_point; + w_target_len -= 1; + } + } while (*source_ptr++); + + assert(w_target_len == 0); +} + + +static int32_t uv__get_surrogate_value(const uint16_t* w_source_ptr, + ssize_t w_source_len) { + uint16_t u; + uint16_t next; + + u = w_source_ptr[0]; + if (u >= 0xD800 && u <= 0xDBFF && w_source_len != 1) { + next = w_source_ptr[1]; + if (next >= 0xDC00 && next <= 0xDFFF) + return 0x10000 + ((u - 0xD800) << 10) + (next - 0xDC00); + } + return u; +} + + +size_t uv_utf16_length_as_wtf8(const uint16_t* w_source_ptr, + ssize_t w_source_len) { + size_t target_len; + int32_t code_point; + + target_len = 0; + while (w_source_len) { + code_point = uv__get_surrogate_value(w_source_ptr, w_source_len); + /* Can be invalid UTF-8 but must be valid WTF-8. */ + assert(code_point >= 0); + if (w_source_len < 0 && code_point == 0) + break; + if (code_point < 0x80) + target_len += 1; + else if (code_point < 0x800) + target_len += 2; + else if (code_point < 0x10000) + target_len += 3; + else { + target_len += 4; + w_source_ptr++; + if (w_source_len > 0) + w_source_len--; + } + w_source_ptr++; + if (w_source_len > 0) + w_source_len--; + } + + return target_len; +} + + +int uv_utf16_to_wtf8(const uint16_t* w_source_ptr, + ssize_t w_source_len, + char** target_ptr, + size_t* target_len_ptr) { + size_t target_len; + char* target; + char* target_end; + int32_t code_point; + + /* If *target_ptr is provided, then *target_len_ptr must be its length + * (excluding space for NUL), otherwise we will compute the target_len_ptr + * length and may return a new allocation in *target_ptr if target_ptr is + * provided. */ + if (target_ptr == NULL || *target_ptr == NULL) { + target_len = uv_utf16_length_as_wtf8(w_source_ptr, w_source_len); + if (target_len_ptr != NULL) + *target_len_ptr = target_len; + } else { + target_len = *target_len_ptr; + } + + if (target_ptr == NULL) + return 0; + + if (*target_ptr == NULL) { + target = uv__malloc(target_len + 1); + if (target == NULL) { + return UV_ENOMEM; + } + *target_ptr = target; + } else { + target = *target_ptr; + } + + target_end = target + target_len; + + while (target != target_end && w_source_len) { + code_point = uv__get_surrogate_value(w_source_ptr, w_source_len); + /* Can be invalid UTF-8 but must be valid WTF-8. */ + assert(code_point >= 0); + if (w_source_len < 0 && code_point == 0) { + w_source_len = 0; + break; + } + if (code_point < 0x80) { + *target++ = code_point; + } else if (code_point < 0x800) { + *target++ = 0xC0 | (code_point >> 6); + if (target == target_end) + break; + *target++ = 0x80 | (code_point & 0x3F); + } else if (code_point < 0x10000) { + *target++ = 0xE0 | (code_point >> 12); + if (target == target_end) + break; + *target++ = 0x80 | ((code_point >> 6) & 0x3F); + if (target == target_end) + break; + *target++ = 0x80 | (code_point & 0x3F); + } else { + *target++ = 0xF0 | (code_point >> 18); + if (target == target_end) + break; + *target++ = 0x80 | ((code_point >> 12) & 0x3F); + if (target == target_end) + break; + *target++ = 0x80 | ((code_point >> 6) & 0x3F); + if (target == target_end) + break; + *target++ = 0x80 | (code_point & 0x3F); + /* uv__get_surrogate_value consumed 2 input characters */ + w_source_ptr++; + if (w_source_len > 0) + w_source_len--; + } + target_len = target - *target_ptr; + w_source_ptr++; + if (w_source_len > 0) + w_source_len--; + } + + if (target != target_end && target_len_ptr != NULL) + /* Did not fill all of the provided buffer, so update the target_len_ptr + * output with the space used. */ + *target_len_ptr = target - *target_ptr; + + /* Check if input fit into target exactly. */ + if (w_source_len < 0 && target == target_end && w_source_ptr[0] == 0) + w_source_len = 0; + + *target++ = '\0'; + + /* Characters remained after filling the buffer, compute the remaining length now. */ + if (w_source_len) { + if (target_len_ptr != NULL) + *target_len_ptr = target_len + uv_utf16_length_as_wtf8(w_source_ptr, w_source_len); + return UV_ENOBUFS; + } + + return 0; +} diff --git a/deps/libuv/src/idna.h b/deps/libuv/src/idna.h index 8e0c592f..ea6b4df9 100644 --- a/deps/libuv/src/idna.h +++ b/deps/libuv/src/idna.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, 2018 Ben Noordhuis +/* Copyright libuv contributors. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -26,6 +26,6 @@ unsigned uv__utf8_decode1(const char** p, const char* pe); * is the number of bytes written to |d|, including the trailing nul byte. * A return value < 0 is a libuv error code. |s| and |d| can not overlap. */ -long uv__idna_toascii(const char* s, const char* se, char* d, char* de); +ssize_t uv__idna_toascii(const char* s, const char* se, char* d, char* de); #endif /* UV_SRC_IDNA_H_ */ diff --git a/deps/libuv/src/unix/darwin.c b/deps/libuv/src/unix/darwin.c index 90790d70..5e764a65 100644 --- a/deps/libuv/src/unix/darwin.c +++ b/deps/libuv/src/unix/darwin.c @@ -209,7 +209,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { if (cpuspeed == 0) /* If sysctl hw.cputype == CPU_TYPE_ARM64, the correct value is unavailable * from Apple, but we can hard-code it here to a plausible value. */ - cpuspeed = 2400000000; + cpuspeed = 2400000000U; if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numcpus, (processor_info_array_t*)&info, @@ -235,7 +235,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { cpu_info->cpu_times.irq = 0; cpu_info->model = uv__strdup(model); - cpu_info->speed = cpuspeed/1000000; + cpu_info->speed = (int)(cpuspeed / 1000000); } vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type); diff --git a/deps/libuv/src/unix/fs.c b/deps/libuv/src/unix/fs.c index 6b051c12..891306da 100644 --- a/deps/libuv/src/unix/fs.c +++ b/deps/libuv/src/unix/fs.c @@ -41,25 +41,10 @@ #include #include #include -#include #include #include #include -#if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# define HAVE_PREADV 1 -#else -# define HAVE_PREADV 0 -#endif - -/* preadv() and pwritev() were added in Android N (level 24) */ -#if defined(__linux__) && !(defined(__ANDROID__) && __ANDROID_API__ < 24) -# define TRY_PREADV 1 -#endif - #if defined(__linux__) # include #endif @@ -97,6 +82,15 @@ # include #endif +#if defined(__CYGWIN__) || \ + (defined(__HAIKU__) && B_HAIKU_VERSION < B_HAIKU_VERSION_1_PRE_BETA_5) || \ + (defined(__sun) && !defined(__illumos__)) +#define preadv(fd, bufs, nbufs, off) \ + pread(fd, (bufs)->iov_base, (bufs)->iov_len, off) +#define pwritev(fd, bufs, nbufs, off) \ + pwrite(fd, (bufs)->iov_base, (bufs)->iov_len, off) +#endif + #if defined(_AIX) && _XOPEN_SOURCE <= 600 extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */ #endif @@ -410,123 +404,57 @@ static ssize_t uv__fs_open(uv_fs_t* req) { } -#if !HAVE_PREADV -static ssize_t uv__fs_preadv(uv_file fd, - uv_buf_t* bufs, - unsigned int nbufs, - off_t off) { - uv_buf_t* buf; - uv_buf_t* end; - ssize_t result; - ssize_t rc; - size_t pos; - - assert(nbufs > 0); - - result = 0; - pos = 0; - buf = bufs + 0; - end = bufs + nbufs; - - for (;;) { - do - rc = pread(fd, buf->base + pos, buf->len - pos, off + result); - while (rc == -1 && errno == EINTR); - - if (rc == 0) - break; - - if (rc == -1 && result == 0) - return UV__ERR(errno); - - if (rc == -1) - break; /* We read some data so return that, ignore the error. */ - - pos += rc; - result += rc; - - if (pos < buf->len) - continue; - - pos = 0; - buf += 1; - - if (buf == end) - break; - } - - return result; -} -#endif - - static ssize_t uv__fs_read(uv_fs_t* req) { -#if TRY_PREADV - static _Atomic int no_preadv; -#endif + const struct iovec* bufs; unsigned int iovmax; - ssize_t result; + size_t nbufs; + ssize_t r; + off_t off; + int fd; + + fd = req->file; + off = req->off; + bufs = (const struct iovec*) req->bufs; + nbufs = req->nbufs; iovmax = uv__getiovmax(); - if (req->nbufs > iovmax) - req->nbufs = iovmax; + if (nbufs > iovmax) + nbufs = iovmax; - if (req->off < 0) { - if (req->nbufs == 1) - result = read(req->file, req->bufs[0].base, req->bufs[0].len); - else - result = readv(req->file, (struct iovec*) req->bufs, req->nbufs); + r = 0; + if (off < 0) { + if (nbufs == 1) + r = read(fd, bufs->iov_base, bufs->iov_len); + else if (nbufs > 1) + r = readv(fd, bufs, nbufs); } else { - if (req->nbufs == 1) { - result = pread(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - goto done; - } - -#if HAVE_PREADV - result = preadv(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); -#else -# if TRY_PREADV - if (atomic_load_explicit(&no_preadv, memory_order_relaxed)) retry: -# endif - { - result = uv__fs_preadv(req->file, req->bufs, req->nbufs, req->off); - } -# if TRY_PREADV - else { - result = preadv(req->file, - (struct iovec*) req->bufs, - req->nbufs, - req->off); - if (result == -1 && errno == ENOSYS) { - atomic_store_explicit(&no_preadv, 1, memory_order_relaxed); - goto retry; - } - } -# endif -#endif + if (nbufs == 1) + r = pread(fd, bufs->iov_base, bufs->iov_len, off); + else if (nbufs > 1) + r = preadv(fd, bufs, nbufs, off); } -done: - /* Early cleanup of bufs allocation, since we're done with it. */ - if (req->bufs != req->bufsml) - uv__free(req->bufs); - - req->bufs = NULL; - req->nbufs = 0; - #ifdef __PASE__ /* PASE returns EOPNOTSUPP when reading a directory, convert to EISDIR */ - if (result == -1 && errno == EOPNOTSUPP) { + if (r == -1 && errno == EOPNOTSUPP) { struct stat buf; ssize_t rc; - rc = uv__fstat(req->file, &buf); + rc = uv__fstat(fd, &buf); if (rc == 0 && S_ISDIR(buf.st_mode)) { errno = EISDIR; } } #endif - return result; + /* We don't own the buffer list in the synchronous case. */ + if (req->cb != NULL) + if (req->bufs != req->bufsml) + uv__free(req->bufs); + + req->bufs = NULL; + req->nbufs = 0; + + return r; } @@ -1161,65 +1089,34 @@ static ssize_t uv__fs_lutime(uv_fs_t* req) { static ssize_t uv__fs_write(uv_fs_t* req) { -#if TRY_PREADV - static _Atomic int no_pwritev; -#endif + const struct iovec* bufs; + size_t nbufs; ssize_t r; + off_t off; + int fd; - /* Serialize writes on OS X, concurrent write() and pwrite() calls result in - * data loss. We can't use a per-file descriptor lock, the descriptor may be - * a dup(). - */ -#if defined(__APPLE__) - static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + fd = req->file; + off = req->off; + bufs = (const struct iovec*) req->bufs; + nbufs = req->nbufs; - if (pthread_mutex_lock(&lock)) - abort(); -#endif - - if (req->off < 0) { - if (req->nbufs == 1) - r = write(req->file, req->bufs[0].base, req->bufs[0].len); - else - r = writev(req->file, (struct iovec*) req->bufs, req->nbufs); + r = 0; + if (off < 0) { + if (nbufs == 1) + r = write(fd, bufs->iov_base, bufs->iov_len); + else if (nbufs > 1) + r = writev(fd, bufs, nbufs); } else { - if (req->nbufs == 1) { - r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - goto done; - } -#if HAVE_PREADV - r = pwritev(req->file, (struct iovec*) req->bufs, req->nbufs, req->off); -#else -# if TRY_PREADV - if (atomic_load_explicit(&no_pwritev, memory_order_relaxed)) retry: -# endif - { - r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off); - } -# if TRY_PREADV - else { - r = pwritev(req->file, - (struct iovec*) req->bufs, - req->nbufs, - req->off); - if (r == -1 && errno == ENOSYS) { - atomic_store_explicit(&no_pwritev, 1, memory_order_relaxed); - goto retry; - } - } -# endif -#endif + if (nbufs == 1) + r = pwrite(fd, bufs->iov_base, bufs->iov_len, off); + else if (nbufs > 1) + r = pwritev(fd, bufs, nbufs, off); } -done: -#if defined(__APPLE__) - if (pthread_mutex_unlock(&lock)) - abort(); -#endif - return r; } + static ssize_t uv__fs_copyfile(uv_fs_t* req) { uv_fs_t fs_req; uv_file srcfd; @@ -1979,9 +1876,14 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, if (bufs == NULL || nbufs == 0) return UV_EINVAL; + req->off = off; req->file = file; - + req->bufs = (uv_buf_t*) bufs; /* Safe, doesn't mutate |bufs| */ req->nbufs = nbufs; + + if (cb == NULL) + goto post; + req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) req->bufs = uv__malloc(nbufs * sizeof(*bufs)); @@ -1991,12 +1893,10 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); - req->off = off; - - if (cb != NULL) - if (uv__iou_fs_read_or_write(loop, req, /* is_read */ 1)) - return 0; + if (uv__iou_fs_read_or_write(loop, req, /* is_read */ 1)) + return 0; +post: POST; } diff --git a/deps/libuv/src/unix/kqueue.c b/deps/libuv/src/unix/kqueue.c index b78242d3..94ace586 100644 --- a/deps/libuv/src/unix/kqueue.c +++ b/deps/libuv/src/unix/kqueue.c @@ -30,6 +30,9 @@ #include #include #include +#if defined(__FreeBSD__) +#include +#endif #include #include #include @@ -262,6 +265,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (nfds == -1) assert(errno == EINTR); + else if (nfds == 0) + /* Unlimited timeout should only return with events or signal. */ + assert(timeout != -1); if (pset != NULL) pthread_sigmask(SIG_UNBLOCK, pset, NULL); @@ -286,8 +292,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { timeout = user_timeout; reset_timeout = 0; } else if (nfds == 0) { - /* Reached the user timeout value. */ - assert(timeout != -1); return; } @@ -479,6 +483,16 @@ static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags) { */ if (fcntl(handle->event_watcher.fd, F_GETPATH, pathbuf) == 0) path = uv__basename_r(pathbuf); +#elif defined(F_KINFO) + /* We try to get the file info reference from the file descriptor. + * the struct's kf_structsize must be initialised beforehand + * whether with the KINFO_FILE_SIZE constant or this way. + */ + struct kinfo_file kf; + kf.kf_structsize = sizeof(kf); + + if (fcntl(handle->event_watcher.fd, F_KINFO, &kf) == 0) + path = uv__basename_r(kf.kf_path); #endif handle->cb(handle, path, events, 0); diff --git a/deps/libuv/src/unix/linux.c b/deps/libuv/src/unix/linux.c index 48b9c2c4..8eeb352e 100644 --- a/deps/libuv/src/unix/linux.c +++ b/deps/libuv/src/unix/linux.c @@ -79,6 +79,8 @@ # define __NR_copy_file_range 379 # elif defined(__arc__) # define __NR_copy_file_range 285 +# elif defined(__riscv) +# define __NR_copy_file_range 285 # endif #endif /* __NR_copy_file_range */ @@ -95,6 +97,8 @@ # define __NR_statx 383 # elif defined(__s390__) # define __NR_statx 379 +# elif defined(__riscv) +# define __NR_statx 291 # endif #endif /* __NR_statx */ @@ -111,6 +115,8 @@ # define __NR_getrandom 359 # elif defined(__s390__) # define __NR_getrandom 349 +# elif defined(__riscv) +# define __NR_getrandom 278 # endif #endif /* __NR_getrandom */ @@ -317,17 +323,64 @@ unsigned uv__kernel_version(void) { unsigned major; unsigned minor; unsigned patch; + char v_sig[256]; + char* needle; version = atomic_load_explicit(&cached_version, memory_order_relaxed); if (version != 0) return version; + /* Check /proc/version_signature first as it's the way to get the mainline + * kernel version in Ubuntu. The format is: + * Ubuntu ubuntu_kernel_version mainline_kernel_version + * For example: + * Ubuntu 5.15.0-79.86-generic 5.15.111 + */ + if (0 == uv__slurp("/proc/version_signature", v_sig, sizeof(v_sig))) + if (3 == sscanf(v_sig, "Ubuntu %*s %u.%u.%u", &major, &minor, &patch)) + goto calculate_version; + if (-1 == uname(&u)) return 0; + /* In Debian we need to check `version` instead of `release` to extract the + * mainline kernel version. This is an example of how it looks like: + * #1 SMP Debian 5.10.46-4 (2021-08-03) + */ + needle = strstr(u.version, "Debian "); + if (needle != NULL) + if (3 == sscanf(needle, "Debian %u.%u.%u", &major, &minor, &patch)) + goto calculate_version; + if (3 != sscanf(u.release, "%u.%u.%u", &major, &minor, &patch)) return 0; + /* Handle it when the process runs under the UNAME26 personality: + * + * - kernels >= 3.x identify as 2.6.40+x + * - kernels >= 4.x identify as 2.6.60+x + * + * UNAME26 is a poorly conceived hack that doesn't let us distinguish + * between 4.x kernels and 5.x/6.x kernels so we conservatively assume + * that 2.6.60+x means 4.x. + * + * Fun fact of the day: it's technically possible to observe the actual + * kernel version for a brief moment because uname() first copies out the + * real release string before overwriting it with the backcompat string. + */ + if (major == 2 && minor == 6) { + if (patch >= 60) { + major = 4; + minor = patch - 60; + patch = 0; + } else if (patch >= 40) { + major = 3; + minor = patch - 40; + patch = 0; + } + } + +calculate_version: version = major * 65536 + minor * 256 + patch; atomic_store_explicit(&cached_version, version, memory_order_relaxed); @@ -422,6 +475,9 @@ int uv__io_uring_register(int fd, unsigned opcode, void* arg, unsigned nargs) { static int uv__use_io_uring(void) { #if defined(__ANDROID_API__) return 0; /* Possibly available but blocked by seccomp. */ +#elif defined(__arm__) && __SIZEOF_POINTER__ == 4 + /* See https://github.com/libuv/libuv/issues/4158. */ + return 0; /* All 32 bits kernels appear buggy. */ #else /* Ternary: unknown=0, yes=1, no=-1 */ static _Atomic int use_io_uring; @@ -431,8 +487,14 @@ static int uv__use_io_uring(void) { use = atomic_load_explicit(&use_io_uring, memory_order_relaxed); if (use == 0) { + /* Older kernels have a bug where the sqpoll thread uses 100% CPU. */ + use = uv__kernel_version() >= /* 5.10.186 */ 0x050ABA ? 1 : -1; + + /* But users can still enable it if they so desire. */ val = getenv("UV_USE_IO_URING"); - use = val == NULL || atoi(val) ? 1 : -1; + if (val != NULL) + use = atoi(val) ? 1 : -1; + atomic_store_explicit(&use_io_uring, use, memory_order_relaxed); } @@ -756,7 +818,9 @@ static void uv__iou_submit(struct uv__iou* iou) { int uv__iou_fs_close(uv_loop_t* loop, uv_fs_t* req) { struct uv__io_uring_sqe* sqe; struct uv__iou* iou; + int kv; + kv = uv__kernel_version(); /* Work around a poorly understood bug in older kernels where closing a file * descriptor pointing to /foo/bar results in ETXTBSY errors when trying to * execve("/foo/bar") later on. The bug seems to have been fixed somewhere @@ -764,10 +828,17 @@ int uv__iou_fs_close(uv_loop_t* loop, uv_fs_t* req) { * but good candidates are the several data race fixes. Interestingly, it * seems to manifest only when running under Docker so the possibility of * a Docker bug can't be completely ruled out either. Yay, computers. + * Also, disable on non-longterm versions between 5.16.0 (non-longterm) and + * 6.1.0 (longterm). Starting with longterm 6.1.x, the issue seems to be + * solved. */ - if (uv__kernel_version() < /* 5.15.90 */ 0x050F5A) + if (kv < /* 5.15.90 */ 0x050F5A) return 0; + if (kv >= /* 5.16.0 */ 0x050A00 && kv < /* 6.1.0 */ 0x060100) + return 0; + + iou = &uv__get_internal_fields(loop)->iou; sqe = uv__iou_get_sqe(iou, loop, req); @@ -1364,41 +1435,20 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { */ SAVE_ERRNO(uv__update_time(loop)); - if (nfds == 0) { + if (nfds == -1) + assert(errno == EINTR); + else if (nfds == 0) + /* Unlimited timeout should only return with events or signal. */ assert(timeout != -1); + if (nfds == 0 || nfds == -1) { if (reset_timeout != 0) { timeout = user_timeout; reset_timeout = 0; + } else if (nfds == 0) { + return; } - if (timeout == -1) - continue; - - if (timeout == 0) - break; - - /* We may have been inside the system call for longer than |timeout| - * milliseconds so we need to update the timestamp to avoid drift. - */ - goto update_timeout; - } - - if (nfds == -1) { - if (errno != EINTR) - abort(); - - if (reset_timeout != 0) { - timeout = user_timeout; - reset_timeout = 0; - } - - if (timeout == -1) - continue; - - if (timeout == 0) - break; - /* Interrupted by a signal. Update timeout and poll again. */ goto update_timeout; } @@ -1509,13 +1559,13 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { break; } +update_timeout: if (timeout == 0) break; if (timeout == -1) continue; -update_timeout: assert(timeout > 0); real_timeout -= (loop->time - base); @@ -1718,7 +1768,8 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) { return UV__ERR(errno); } - fgets(buf, sizeof(buf), fp); /* Skip first line. */ + if (NULL == fgets(buf, sizeof(buf), fp)) + abort(); for (;;) { memset(&t, 0, sizeof(t)); @@ -1729,7 +1780,8 @@ int uv_cpu_info(uv_cpu_info_t** ci, int* count) { if (n != 7) break; - fgets(buf, sizeof(buf), fp); /* Skip rest of line. */ + if (NULL == fgets(buf, sizeof(buf), fp)) + abort(); if (cpu >= ARRAY_SIZE(*cpus)) continue; @@ -1809,7 +1861,8 @@ nocpuinfo: if (fp == NULL) continue; - fscanf(fp, "%llu", &(*cpus)[cpu].freq); + if (1 != fscanf(fp, "%llu", &(*cpus)[cpu].freq)) + abort(); fclose(fp); fp = NULL; } diff --git a/deps/libuv/src/unix/os390.c b/deps/libuv/src/unix/os390.c index bbd37692..1b277292 100644 --- a/deps/libuv/src/unix/os390.c +++ b/deps/libuv/src/unix/os390.c @@ -19,6 +19,7 @@ * IN THE SOFTWARE. */ +#include "uv.h" #include "internal.h" #include #include @@ -30,6 +31,7 @@ #include #include #include "zos-base.h" +#include "zos-sys-info.h" #if defined(__clang__) #include "csrsic.h" #else @@ -66,9 +68,6 @@ /* Total number of frames currently on all available frame queues. */ #define RCEAFC_OFFSET 0x088 -/* CPC model length from the CSRSI Service. */ -#define CPCMODEL_LENGTH 16 - /* Pointer to the home (current) ASCB. */ #define PSAAOLD 0x224 @@ -258,9 +257,12 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { idx = 0; while (idx < *count) { cpu_info->speed = *(int*)(info.siv1v2si22v1.si22v1cpucapability); - cpu_info->model = uv__malloc(CPCMODEL_LENGTH + 1); - memset(cpu_info->model, '\0', CPCMODEL_LENGTH + 1); - memcpy(cpu_info->model, info.siv1v2si11v1.si11v1cpcmodel, CPCMODEL_LENGTH); + cpu_info->model = uv__malloc(ZOSCPU_MODEL_LENGTH + 1); + if (cpu_info->model == NULL) { + uv_free_cpu_info(*cpu_infos, idx); + return UV_ENOMEM; + } + __get_cpu_model(cpu_info->model, ZOSCPU_MODEL_LENGTH + 1); cpu_info->cpu_times.user = cpu_usage_avg; /* TODO: implement the following */ cpu_info->cpu_times.sys = 0; diff --git a/deps/libuv/src/unix/signal.c b/deps/libuv/src/unix/signal.c index 63aba5a6..bc4206e6 100644 --- a/deps/libuv/src/unix/signal.c +++ b/deps/libuv/src/unix/signal.c @@ -279,6 +279,8 @@ static int uv__signal_loop_once_init(uv_loop_t* loop) { int uv__signal_loop_fork(uv_loop_t* loop) { + struct uv__queue* q; + if (loop->signal_pipefd[0] == -1) return 0; uv__io_stop(loop, &loop->signal_io_watcher, POLLIN); @@ -286,6 +288,19 @@ int uv__signal_loop_fork(uv_loop_t* loop) { uv__close(loop->signal_pipefd[1]); loop->signal_pipefd[0] = -1; loop->signal_pipefd[1] = -1; + + uv__queue_foreach(q, &loop->handle_queue) { + uv_handle_t* handle = uv__queue_data(q, uv_handle_t, handle_queue); + uv_signal_t* sh; + + if (handle->type != UV_SIGNAL) + continue; + + sh = (uv_signal_t*) handle; + sh->caught_signals = 0; + sh->dispatched_signals = 0; + } + return uv__signal_loop_once_init(loop); } diff --git a/deps/libuv/src/unix/tcp.c b/deps/libuv/src/unix/tcp.c index d6c848f4..a6b53e59 100644 --- a/deps/libuv/src/unix/tcp.c +++ b/deps/libuv/src/unix/tcp.c @@ -27,6 +27,17 @@ #include #include +#include +#include + +#if defined(__PASE__) +#include +#define ifaddrs ifaddrs_pase +#define getifaddrs Qp2getifaddrs +#define freeifaddrs Qp2freeifaddrs +#else +#include +#endif static int maybe_bind_socket(int fd) { union uv__sockaddr s; @@ -198,11 +209,50 @@ int uv__tcp_bind(uv_tcp_t* tcp, } +static int uv__is_ipv6_link_local(const struct sockaddr* addr) { + const struct sockaddr_in6* a6; + uint8_t b[2]; + + if (addr->sa_family != AF_INET6) + return 0; + + a6 = (const struct sockaddr_in6*) addr; + memcpy(b, &a6->sin6_addr, sizeof(b)); + + return b[0] == 0xFE && b[1] == 0x80; +} + + +static int uv__ipv6_link_local_scope_id(void) { + struct sockaddr_in6* a6; + struct ifaddrs* ifa; + struct ifaddrs* p; + int rv; + + if (getifaddrs(&ifa)) + return 0; + + for (p = ifa; p != NULL; p = p->ifa_next) + if (uv__is_ipv6_link_local(p->ifa_addr)) + break; + + rv = 0; + if (p != NULL) { + a6 = (struct sockaddr_in6*) p->ifa_addr; + rv = a6->sin6_scope_id; + } + + freeifaddrs(ifa); + return rv; +} + + int uv__tcp_connect(uv_connect_t* req, uv_tcp_t* handle, const struct sockaddr* addr, unsigned int addrlen, uv_connect_cb cb) { + struct sockaddr_in6 tmp6; int err; int r; @@ -220,6 +270,14 @@ int uv__tcp_connect(uv_connect_t* req, if (err) return err; + if (uv__is_ipv6_link_local(addr)) { + memcpy(&tmp6, addr, sizeof(tmp6)); + if (tmp6.sin6_scope_id == 0) { + tmp6.sin6_scope_id = uv__ipv6_link_local_scope_id(); + addr = (void*) &tmp6; + } + } + do { errno = 0; r = connect(uv__stream_fd(handle), addr, addrlen); @@ -374,28 +432,39 @@ int uv__tcp_nodelay(int fd, int on) { int uv__tcp_keepalive(int fd, int on, unsigned int delay) { + int intvl; + int cnt; + + (void) &intvl; + (void) &cnt; + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on))) return UV__ERR(errno); + if (!on) + return 0; + #ifdef TCP_KEEPIDLE - if (on) { - int intvl = 1; /* 1 second; same as default on Win32 */ - int cnt = 10; /* 10 retries; same as hardcoded on Win32 */ - if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay))) - return UV__ERR(errno); - if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl))) - return UV__ERR(errno); - if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt))) - return UV__ERR(errno); - } + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay))) + return UV__ERR(errno); +/* Solaris/SmartOS, if you don't support keep-alive, + * then don't advertise it in your system headers... + */ +/* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */ +#elif defined(TCP_KEEPALIVE) && !defined(__sun) + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay))) + return UV__ERR(errno); #endif - /* Solaris/SmartOS, if you don't support keep-alive, - * then don't advertise it in your system headers... - */ - /* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */ -#if defined(TCP_KEEPALIVE) && !defined(__sun) - if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay))) +#ifdef TCP_KEEPINTVL + intvl = 1; /* 1 second; same as default on Win32 */ + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl))) + return UV__ERR(errno); +#endif + +#ifdef TCP_KEEPCNT + cnt = 10; /* 10 retries; same as hardcoded on Win32 */ + if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt))) return UV__ERR(errno); #endif diff --git a/deps/libuv/src/unix/thread.c b/deps/libuv/src/unix/thread.c index 4d6f4b82..f05e6fe0 100644 --- a/deps/libuv/src/unix/thread.c +++ b/deps/libuv/src/unix/thread.c @@ -789,11 +789,33 @@ void uv_cond_broadcast(uv_cond_t* cond) { abort(); } +#if defined(__APPLE__) && defined(__MACH__) + +void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { + int r; + + errno = 0; + r = pthread_cond_wait(cond, mutex); + + /* Workaround for a bug in OS X at least up to 13.6 + * See https://github.com/libuv/libuv/issues/4165 + */ + if (r == EINVAL) + if (errno == EBUSY) + return; + + if (r) + abort(); +} + +#else /* !(defined(__APPLE__) && defined(__MACH__)) */ + void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) { if (pthread_cond_wait(cond, mutex)) abort(); } +#endif int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { int r; diff --git a/deps/libuv/src/uv-common.c b/deps/libuv/src/uv-common.c index 916f3f4e..2200fe3f 100644 --- a/deps/libuv/src/uv-common.c +++ b/deps/libuv/src/uv-common.c @@ -559,6 +559,9 @@ static void uv__print_handles(uv_loop_t* loop, int only_active, FILE* stream) { if (loop == NULL) loop = uv_default_loop(); + if (stream == NULL) + stream = stderr; + uv__queue_foreach(q, &loop->handle_queue) { h = uv__queue_data(q, uv_handle_t, handle_queue); diff --git a/deps/libuv/src/win/dl.c b/deps/libuv/src/win/dl.c index 676be4dc..7880c959 100644 --- a/deps/libuv/src/win/dl.c +++ b/deps/libuv/src/win/dl.c @@ -27,18 +27,17 @@ static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno); int uv_dlopen(const char* filename, uv_lib_t* lib) { WCHAR filename_w[32768]; + ssize_t r; lib->handle = NULL; lib->errmsg = NULL; - if (!MultiByteToWideChar(CP_UTF8, - 0, - filename, - -1, - filename_w, - ARRAY_SIZE(filename_w))) { - return uv__dlerror(lib, filename, GetLastError()); - } + r = uv_wtf8_length_as_utf16(filename); + if (r < 0) + return uv__dlerror(lib, filename, ERROR_NO_UNICODE_TRANSLATION); + if ((size_t) r > ARRAY_SIZE(filename_w)) + return uv__dlerror(lib, filename, ERROR_INSUFFICIENT_BUFFER); + uv_wtf8_to_utf16(filename, filename_w, r); lib->handle = LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (lib->handle == NULL) { diff --git a/deps/libuv/src/win/fs-event.c b/deps/libuv/src/win/fs-event.c index 6758c7c7..4a0ca1f7 100644 --- a/deps/libuv/src/win/fs-event.c +++ b/deps/libuv/src/win/fs-event.c @@ -157,7 +157,8 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags) { - int name_size, is_path_dir, size; + int is_path_dir; + size_t size; DWORD attr, last_error; WCHAR* dir = NULL, *dir_to_watch, *pathw = NULL; DWORD short_path_buffer_len; @@ -176,23 +177,9 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv__handle_start(handle); - /* Convert name to UTF16. */ - - name_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0) * - sizeof(WCHAR); - pathw = (WCHAR*)uv__malloc(name_size); - if (!pathw) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - path, - -1, - pathw, - name_size / sizeof(WCHAR))) { - return uv_translate_sys_error(GetLastError()); - } + last_error = uv__convert_utf8_to_utf16(path, &pathw); + if (last_error) + goto error_uv; /* Determine whether path is a file or a directory. */ attr = GetFileAttributesW(pathw); @@ -333,6 +320,9 @@ short_path_done: return 0; error: + last_error = uv_translate_sys_error(last_error); + +error_uv: if (handle->path) { uv__free(handle->path); handle->path = NULL; @@ -365,7 +355,7 @@ error: uv__free(short_path); - return uv_translate_sys_error(last_error); + return last_error; } diff --git a/deps/libuv/src/win/fs.c b/deps/libuv/src/win/fs.c index fc209c54..99c8a2bf 100644 --- a/deps/libuv/src/win/fs.c +++ b/deps/libuv/src/win/fs.c @@ -31,13 +31,16 @@ #include #include "uv.h" + +/* requires , included via "uv.h" above, but needs to + be included before our "winapi.h", included via "internal.h" below. */ +#include + #include "internal.h" #include "req-inl.h" #include "handle-inl.h" #include "fs-fd-hash-inl.h" -#include - #define UV_FS_FREE_PATHS 0x0002 #define UV_FS_FREE_PTR 0x0008 @@ -144,279 +147,6 @@ void uv__fs_init(void) { } -static int32_t fs__decode_wtf8_char(const char** input) { - uint32_t code_point; - uint8_t b1; - uint8_t b2; - uint8_t b3; - uint8_t b4; - - b1 = **input; - if (b1 <= 0x7F) - return b1; /* ASCII code point */ - if (b1 < 0xC2) - return -1; /* invalid: continuation byte */ - code_point = b1; - - b2 = *++*input; - if ((b2 & 0xC0) != 0x80) - return -1; /* invalid: not a continuation byte */ - code_point = (code_point << 6) | (b2 & 0x3F); - if (b1 <= 0xDF) - return 0x7FF & code_point; /* two-byte character */ - - b3 = *++*input; - if ((b3 & 0xC0) != 0x80) - return -1; /* invalid: not a continuation byte */ - code_point = (code_point << 6) | (b3 & 0x3F); - if (b1 <= 0xEF) - return 0xFFFF & code_point; /* three-byte character */ - - b4 = *++*input; - if ((b4 & 0xC0) != 0x80) - return -1; /* invalid: not a continuation byte */ - code_point = (code_point << 6) | (b4 & 0x3F); - if (b1 <= 0xF4) - if (code_point <= 0x10FFFF) - return code_point; /* four-byte character */ - - /* code point too large */ - return -1; -} - - -static ssize_t fs__get_length_wtf8(const char* source_ptr) { - size_t w_target_len = 0; - int32_t code_point; - - do { - code_point = fs__decode_wtf8_char(&source_ptr); - if (code_point < 0) - return -1; - if (code_point > 0xFFFF) - w_target_len++; - w_target_len++; - } while (*source_ptr++); - return w_target_len; -} - - -static void fs__wtf8_to_wide(const char* source_ptr, WCHAR* w_target) { - int32_t code_point; - - do { - code_point = fs__decode_wtf8_char(&source_ptr); - /* fs__get_length_wtf8 should have been called and checked first. */ - assert(code_point >= 0); - if (code_point > 0x10000) { - assert(code_point < 0x10FFFF); - *w_target++ = (((code_point - 0x10000) >> 10) + 0xD800); - *w_target++ = ((code_point - 0x10000) & 0x3FF) + 0xDC00; - } else { - *w_target++ = code_point; - } - } while (*source_ptr++); -} - - -INLINE static int fs__capture_path(uv_fs_t* req, const char* path, - const char* new_path, const int copy_path) { - WCHAR* buf; - WCHAR* pos; - size_t buf_sz = 0; - size_t path_len = 0; - ssize_t pathw_len = 0; - ssize_t new_pathw_len = 0; - - /* new_path can only be set if path is also set. */ - assert(new_path == NULL || path != NULL); - - if (path != NULL) { - pathw_len = fs__get_length_wtf8(path); - if (pathw_len < 0) - return ERROR_INVALID_NAME; - buf_sz += pathw_len * sizeof(WCHAR); - } - - if (path != NULL && copy_path) { - path_len = 1 + strlen(path); - buf_sz += path_len; - } - - if (new_path != NULL) { - new_pathw_len = fs__get_length_wtf8(new_path); - if (new_pathw_len < 0) - return ERROR_INVALID_NAME; - buf_sz += new_pathw_len * sizeof(WCHAR); - } - - - if (buf_sz == 0) { - req->file.pathw = NULL; - req->fs.info.new_pathw = NULL; - req->path = NULL; - return 0; - } - - buf = uv__malloc(buf_sz); - if (buf == NULL) { - return ERROR_OUTOFMEMORY; - } - - pos = buf; - - if (path != NULL) { - fs__wtf8_to_wide(path, pos); - req->file.pathw = pos; - pos += pathw_len; - } else { - req->file.pathw = NULL; - } - - if (new_path != NULL) { - fs__wtf8_to_wide(new_path, pos); - req->fs.info.new_pathw = pos; - pos += new_pathw_len; - } else { - req->fs.info.new_pathw = NULL; - } - - req->path = path; - if (path != NULL && copy_path) { - memcpy(pos, path, path_len); - assert(path_len == buf_sz - (pos - buf) * sizeof(WCHAR)); - req->path = (char*) pos; - } - - req->flags |= UV_FS_FREE_PATHS; - - return 0; -} - - - -INLINE static void uv__fs_req_init(uv_loop_t* loop, uv_fs_t* req, - uv_fs_type fs_type, const uv_fs_cb cb) { - uv__once_init(); - UV_REQ_INIT(req, UV_FS); - req->loop = loop; - req->flags = 0; - req->fs_type = fs_type; - req->sys_errno_ = 0; - req->result = 0; - req->ptr = NULL; - req->path = NULL; - req->cb = cb; - memset(&req->fs, 0, sizeof(req->fs)); -} - - -static int32_t fs__get_surrogate_value(const WCHAR* w_source_ptr, - size_t w_source_len) { - WCHAR u; - WCHAR next; - - u = w_source_ptr[0]; - if (u >= 0xD800 && u <= 0xDBFF && w_source_len > 1) { - next = w_source_ptr[1]; - if (next >= 0xDC00 && next <= 0xDFFF) - return 0x10000 + ((u - 0xD800) << 10) + (next - 0xDC00); - } - return u; -} - - -static size_t fs__get_length_wide(const WCHAR* w_source_ptr, - size_t w_source_len) { - size_t target_len; - int32_t code_point; - - target_len = 0; - for (; w_source_len; w_source_len--, w_source_ptr++) { - code_point = fs__get_surrogate_value(w_source_ptr, w_source_len); - /* Can be invalid UTF-8 but must be valid WTF-8. */ - assert(code_point >= 0); - if (code_point < 0x80) - target_len += 1; - else if (code_point < 0x800) - target_len += 2; - else if (code_point < 0x10000) - target_len += 3; - else { - target_len += 4; - w_source_ptr++; - w_source_len--; - } - } - return target_len; -} - - -static int fs__wide_to_wtf8(WCHAR* w_source_ptr, - size_t w_source_len, - char** target_ptr, - size_t* target_len_ptr) { - size_t target_len; - char* target; - int32_t code_point; - - /* If *target_ptr is provided, then *target_len_ptr must be its length - * (excluding space for null), otherwise we will compute the target_len_ptr - * length and may return a new allocation in *target_ptr if target_ptr is - * provided. */ - if (target_ptr == NULL || *target_ptr == NULL) { - target_len = fs__get_length_wide(w_source_ptr, w_source_len); - if (target_len_ptr != NULL) - *target_len_ptr = target_len; - } else { - target_len = *target_len_ptr; - } - - if (target_ptr == NULL) - return 0; - - if (*target_ptr == NULL) { - target = uv__malloc(target_len + 1); - if (target == NULL) { - SetLastError(ERROR_OUTOFMEMORY); - return -1; - } - *target_ptr = target; - } else { - target = *target_ptr; - } - - for (; w_source_len; w_source_len--, w_source_ptr++) { - code_point = fs__get_surrogate_value(w_source_ptr, w_source_len); - /* Can be invalid UTF-8 but must be valid WTF-8. */ - assert(code_point >= 0); - - if (code_point < 0x80) { - *target++ = code_point; - } else if (code_point < 0x800) { - *target++ = 0xC0 | (code_point >> 6); - *target++ = 0x80 | (code_point & 0x3F); - } else if (code_point < 0x10000) { - *target++ = 0xE0 | (code_point >> 12); - *target++ = 0x80 | ((code_point >> 6) & 0x3F); - *target++ = 0x80 | (code_point & 0x3F); - } else { - *target++ = 0xF0 | (code_point >> 18); - *target++ = 0x80 | ((code_point >> 12) & 0x3F); - *target++ = 0x80 | ((code_point >> 6) & 0x3F); - *target++ = 0x80 | (code_point & 0x3F); - w_source_ptr++; - w_source_len--; - } - } - assert((size_t) (target - *target_ptr) == target_len); - - *target++ = '\0'; - - return 0; -} - - INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr, size_t* target_len_ptr) { @@ -550,7 +280,98 @@ INLINE static int fs__readlink_handle(HANDLE handle, } assert(target_ptr == NULL || *target_ptr == NULL); - return fs__wide_to_wtf8(w_target, w_target_len, target_ptr, target_len_ptr); + return uv_utf16_to_wtf8(w_target, w_target_len, target_ptr, target_len_ptr); +} + + +INLINE static int fs__capture_path(uv_fs_t* req, const char* path, + const char* new_path, const int copy_path) { + WCHAR* buf; + WCHAR* pos; + size_t buf_sz = 0; + size_t path_len = 0; + ssize_t pathw_len = 0; + ssize_t new_pathw_len = 0; + + /* new_path can only be set if path is also set. */ + assert(new_path == NULL || path != NULL); + + if (path != NULL) { + pathw_len = uv_wtf8_length_as_utf16(path); + if (pathw_len < 0) + return ERROR_INVALID_NAME; + buf_sz += pathw_len * sizeof(WCHAR); + } + + if (path != NULL && copy_path) { + path_len = 1 + strlen(path); + buf_sz += path_len; + } + + if (new_path != NULL) { + new_pathw_len = uv_wtf8_length_as_utf16(new_path); + if (new_pathw_len < 0) + return ERROR_INVALID_NAME; + buf_sz += new_pathw_len * sizeof(WCHAR); + } + + + if (buf_sz == 0) { + req->file.pathw = NULL; + req->fs.info.new_pathw = NULL; + req->path = NULL; + return 0; + } + + buf = uv__malloc(buf_sz); + if (buf == NULL) { + return ERROR_OUTOFMEMORY; + } + + pos = buf; + + if (path != NULL) { + uv_wtf8_to_utf16(path, pos, pathw_len); + req->file.pathw = pos; + pos += pathw_len; + } else { + req->file.pathw = NULL; + } + + if (new_path != NULL) { + uv_wtf8_to_utf16(new_path, pos, new_pathw_len); + req->fs.info.new_pathw = pos; + pos += new_pathw_len; + } else { + req->fs.info.new_pathw = NULL; + } + + req->path = path; + if (path != NULL && copy_path) { + memcpy(pos, path, path_len); + assert(path_len == buf_sz - (pos - buf) * sizeof(WCHAR)); + req->path = (char*) pos; + } + + req->flags |= UV_FS_FREE_PATHS; + + return 0; +} + + +INLINE static void uv__fs_req_init(uv_loop_t* loop, uv_fs_t* req, + uv_fs_type fs_type, const uv_fs_cb cb) { + uv__once_init(); + UV_REQ_INIT(req, UV_FS); + req->loop = loop; + req->flags = 0; + req->fs_type = fs_type; + req->sys_errno_ = 0; + req->result = 0; + req->ptr = NULL; + req->path = NULL; + req->cb = cb; + memset(&req->fs, 0, sizeof(req->fs)); } @@ -1569,7 +1390,7 @@ void fs__scandir(uv_fs_t* req) { continue; /* Compute the space required to store the filename as WTF-8. */ - wtf8_len = fs__get_length_wide(&info->FileName[0], wchar_len); + wtf8_len = uv_utf16_length_as_wtf8(&info->FileName[0], wchar_len); /* Resize the dirent array if needed. */ if (dirents_used >= dirents_size) { @@ -1597,8 +1418,8 @@ void fs__scandir(uv_fs_t* req) { /* Convert file name to UTF-8. */ wtf8 = &dirent->d_name[0]; - if (fs__wide_to_wtf8(&info->FileName[0], wchar_len, &wtf8, &wtf8_len) == -1) - goto win32_error; + if (uv_utf16_to_wtf8(&info->FileName[0], wchar_len, &wtf8, &wtf8_len) != 0) + goto out_of_memory_error; /* Fill out the type field. */ if (info->FileAttributes & FILE_ATTRIBUTE_DEVICE) @@ -2824,7 +2645,7 @@ static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { } assert(*realpath_ptr == NULL); - r = fs__wide_to_wtf8(w_realpath_ptr, w_realpath_len, realpath_ptr, NULL); + r = uv_utf16_to_wtf8(w_realpath_ptr, w_realpath_len, realpath_ptr, NULL); uv__free(w_realpath_buf); return r; } diff --git a/deps/libuv/src/win/getaddrinfo.c b/deps/libuv/src/win/getaddrinfo.c index dfab860a..8b8406ad 100644 --- a/deps/libuv/src/win/getaddrinfo.c +++ b/deps/libuv/src/win/getaddrinfo.c @@ -104,13 +104,14 @@ static void uv__getaddrinfo_work(struct uv__work* w) { */ static void uv__getaddrinfo_done(struct uv__work* w, int status) { uv_getaddrinfo_t* req; - int addrinfo_len = 0; - int name_len = 0; + size_t addrinfo_len = 0; + ssize_t name_len = 0; size_t addrinfo_struct_len = ALIGNED_SIZE(sizeof(struct addrinfo)); struct addrinfoW* addrinfow_ptr; struct addrinfo* addrinfo_ptr; char* alloc_ptr = NULL; char* cur_ptr = NULL; + int r; req = container_of(w, uv_getaddrinfo_t, work_req); @@ -131,19 +132,12 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { addrinfo_len += addrinfo_struct_len + ALIGNED_SIZE(addrinfow_ptr->ai_addrlen); if (addrinfow_ptr->ai_canonname != NULL) { - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - NULL, - 0, - NULL, - NULL); - if (name_len == 0) { - req->retcode = uv_translate_sys_error(GetLastError()); + name_len = uv_utf16_length_as_wtf8(addrinfow_ptr->ai_canonname, -1); + if (name_len < 0) { + req->retcode = name_len; goto complete; } - addrinfo_len += ALIGNED_SIZE(name_len); + addrinfo_len += ALIGNED_SIZE(name_len + 1); } addrinfow_ptr = addrinfow_ptr->ai_next; } @@ -182,27 +176,14 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { /* convert canonical name to UTF-8 */ if (addrinfow_ptr->ai_canonname != NULL) { - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - NULL, - 0, - NULL, - NULL); - assert(name_len > 0); - assert(cur_ptr + name_len <= alloc_ptr + addrinfo_len); - name_len = WideCharToMultiByte(CP_UTF8, - 0, - addrinfow_ptr->ai_canonname, - -1, - cur_ptr, - name_len, - NULL, - NULL); - assert(name_len > 0); + name_len = alloc_ptr + addrinfo_len - cur_ptr; + r = uv__copy_utf16_to_utf8(addrinfow_ptr->ai_canonname, + -1, + cur_ptr, + (size_t*)&name_len); + assert(r == 0); addrinfo_ptr->ai_canonname = cur_ptr; - cur_ptr += ALIGNED_SIZE(name_len); + cur_ptr += ALIGNED_SIZE(name_len + 1); } assert(cur_ptr <= alloc_ptr + addrinfo_len); @@ -261,12 +242,11 @@ int uv_getaddrinfo(uv_loop_t* loop, const char* service, const struct addrinfo* hints) { char hostname_ascii[256]; - int nodesize = 0; - int servicesize = 0; - int hintssize = 0; + size_t nodesize = 0; + size_t servicesize = 0; + size_t hintssize = 0; char* alloc_ptr = NULL; - int err; - long rc; + ssize_t rc; if (req == NULL || (node == NULL && service == NULL)) { return UV_EINVAL; @@ -286,56 +266,36 @@ int uv_getaddrinfo(uv_loop_t* loop, hostname_ascii + sizeof(hostname_ascii)); if (rc < 0) return rc; - nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, hostname_ascii, - -1, NULL, 0) * sizeof(WCHAR)); - if (nodesize == 0) { - err = GetLastError(); - goto error; - } + nodesize = strlen(hostname_ascii) + 1; node = hostname_ascii; } if (service != NULL) { - servicesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, - 0, - service, - -1, - NULL, - 0) * - sizeof(WCHAR)); - if (servicesize == 0) { - err = GetLastError(); - goto error; - } + rc = uv_wtf8_length_as_utf16(service); + if (rc < 0) + return rc; + servicesize = rc; } if (hints != NULL) { hintssize = ALIGNED_SIZE(sizeof(struct addrinfoW)); } /* allocate memory for inputs, and partition it as needed */ - alloc_ptr = (char*)uv__malloc(nodesize + servicesize + hintssize); - if (!alloc_ptr) { - err = WSAENOBUFS; - goto error; - } + alloc_ptr = uv__malloc(ALIGNED_SIZE(nodesize * sizeof(WCHAR)) + + ALIGNED_SIZE(servicesize * sizeof(WCHAR)) + + hintssize); + if (!alloc_ptr) + return UV_ENOMEM; /* save alloc_ptr now so we can free if error */ - req->alloc = (void*)alloc_ptr; + req->alloc = (void*) alloc_ptr; /* Convert node string to UTF16 into allocated memory and save pointer in the - * request. */ + * request. The node here has been converted to ascii. */ if (node != NULL) { - req->node = (WCHAR*)alloc_ptr; - if (MultiByteToWideChar(CP_UTF8, - 0, - node, - -1, - (WCHAR*) alloc_ptr, - nodesize / sizeof(WCHAR)) == 0) { - err = GetLastError(); - goto error; - } - alloc_ptr += nodesize; + req->node = (WCHAR*) alloc_ptr; + uv_wtf8_to_utf16(node, (WCHAR*) alloc_ptr, nodesize); + alloc_ptr += ALIGNED_SIZE(nodesize * sizeof(WCHAR)); } else { req->node = NULL; } @@ -343,24 +303,16 @@ int uv_getaddrinfo(uv_loop_t* loop, /* Convert service string to UTF16 into allocated memory and save pointer in * the req. */ if (service != NULL) { - req->service = (WCHAR*)alloc_ptr; - if (MultiByteToWideChar(CP_UTF8, - 0, - service, - -1, - (WCHAR*) alloc_ptr, - servicesize / sizeof(WCHAR)) == 0) { - err = GetLastError(); - goto error; - } - alloc_ptr += servicesize; + req->service = (WCHAR*) alloc_ptr; + uv_wtf8_to_utf16(service, (WCHAR*) alloc_ptr, servicesize); + alloc_ptr += ALIGNED_SIZE(servicesize * sizeof(WCHAR)); } else { req->service = NULL; } /* copy hints to allocated memory and save pointer in req */ if (hints != NULL) { - req->addrinfow = (struct addrinfoW*)alloc_ptr; + req->addrinfow = (struct addrinfoW*) alloc_ptr; req->addrinfow->ai_family = hints->ai_family; req->addrinfow->ai_socktype = hints->ai_socktype; req->addrinfow->ai_protocol = hints->ai_protocol; @@ -387,19 +339,11 @@ int uv_getaddrinfo(uv_loop_t* loop, uv__getaddrinfo_done(&req->work_req, 0); return req->retcode; } - -error: - if (req != NULL) { - uv__free(req->alloc); - req->alloc = NULL; - } - return uv_translate_sys_error(err); } int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) { NET_LUID luid; wchar_t wname[NDIS_IF_MAX_STRING_SIZE + 1]; /* Add one for the NUL. */ - DWORD bufsize; int r; if (buffer == NULL || size == NULL || *size == 0) @@ -415,31 +359,7 @@ int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) { if (r != 0) return uv_translate_sys_error(r); - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, wname, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - wname, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; + return uv__copy_utf16_to_utf8(wname, -1, buffer, size); } int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) { diff --git a/deps/libuv/src/win/getnameinfo.c b/deps/libuv/src/win/getnameinfo.c index b3773380..32863176 100644 --- a/deps/libuv/src/win/getnameinfo.c +++ b/deps/libuv/src/win/getnameinfo.c @@ -42,6 +42,7 @@ static void uv__getnameinfo_work(struct uv__work* w) { uv_getnameinfo_t* req; WCHAR host[NI_MAXHOST]; WCHAR service[NI_MAXSERV]; + size_t size; int ret; req = container_of(w, uv_getnameinfo_t, work_req); @@ -57,29 +58,17 @@ static void uv__getnameinfo_work(struct uv__work* w) { return; } - ret = WideCharToMultiByte(CP_UTF8, - 0, - host, - -1, - req->host, - sizeof(req->host), - NULL, - NULL); - if (ret == 0) { - req->retcode = uv_translate_sys_error(GetLastError()); + size = sizeof(req->host); + ret = uv__copy_utf16_to_utf8(host, -1, req->host, &size); + if (ret < 0) { + req->retcode = ret; return; } - ret = WideCharToMultiByte(CP_UTF8, - 0, - service, - -1, - req->service, - sizeof(req->service), - NULL, - NULL); - if (ret == 0) { - req->retcode = uv_translate_sys_error(GetLastError()); + size = sizeof(req->service); + ret = uv__copy_utf16_to_utf8(service, -1, req->service, &size); + if (ret < 0) { + req->retcode = ret; } } diff --git a/deps/libuv/src/win/internal.h b/deps/libuv/src/win/internal.h index 9672fbc6..867dea5e 100644 --- a/deps/libuv/src/win/internal.h +++ b/deps/libuv/src/win/internal.h @@ -257,8 +257,9 @@ void uv__util_init(void); uint64_t uv__hrtime(unsigned int scale); __declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); -int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8); -int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16); +int uv__convert_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char** utf8); +int uv__copy_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char* utf8, size_t *size); +int uv__convert_utf8_to_utf16(const char* utf8, WCHAR** utf16); typedef int (WINAPI *uv__peersockfunc)(SOCKET, struct sockaddr*, int*); diff --git a/deps/libuv/src/win/pipe.c b/deps/libuv/src/win/pipe.c index f0cac382..cec72ff7 100644 --- a/deps/libuv/src/win/pipe.c +++ b/deps/libuv/src/win/pipe.c @@ -49,7 +49,7 @@ static const int default_pending_pipe_instances = 4; /* Pipe prefix */ static char pipe_prefix[] = "\\\\?\\pipe"; -static const int pipe_prefix_len = sizeof(pipe_prefix) - 1; +static const size_t pipe_prefix_len = sizeof(pipe_prefix) - 1; /* IPC incoming xfer queue item. */ typedef struct { @@ -703,7 +703,7 @@ int uv_pipe_bind2(uv_pipe_t* handle, size_t namelen, unsigned int flags) { uv_loop_t* loop = handle->loop; - int i, err, nameSize; + int i, err; uv_pipe_accept_t* req; if (flags & ~UV_PIPE_NO_TRUNCATE) { @@ -742,9 +742,8 @@ int uv_pipe_bind2(uv_pipe_t* handle, handle->pipe.serv.accept_reqs = (uv_pipe_accept_t*) uv__malloc(sizeof(uv_pipe_accept_t) * handle->pipe.serv.pending_instances); - if (!handle->pipe.serv.accept_reqs) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } + if (!handle->pipe.serv.accept_reqs) + return UV_ENOMEM; for (i = 0; i < handle->pipe.serv.pending_instances; i++) { req = &handle->pipe.serv.accept_reqs[i]; @@ -754,22 +753,9 @@ int uv_pipe_bind2(uv_pipe_t* handle, req->next_pending = NULL; } - /* Convert name to UTF16. */ - nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); - handle->name = uv__malloc(nameSize); - if (!handle->name) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - name, - -1, - handle->name, - nameSize / sizeof(WCHAR))) { - err = GetLastError(); - goto error; - } + err = uv__convert_utf8_to_utf16(name, &handle->name); + if (err) + return err; /* * Attempt to create the first pipe with FILE_FLAG_FIRST_PIPE_INSTANCE. @@ -795,10 +781,8 @@ int uv_pipe_bind2(uv_pipe_t* handle, return 0; error: - if (handle->name) { - uv__free(handle->name); - handle->name = NULL; - } + uv__free(handle->name); + handle->name = NULL; return uv_translate_sys_error(err); } @@ -861,7 +845,8 @@ int uv_pipe_connect2(uv_connect_t* req, unsigned int flags, uv_connect_cb cb) { uv_loop_t* loop = handle->loop; - int err, nameSize; + int err; + size_t nameSize; HANDLE pipeHandle = INVALID_HANDLE_VALUE; DWORD duplex_flags; @@ -904,26 +889,16 @@ int uv_pipe_connect2(uv_connect_t* req, } uv__pipe_connection_init(handle); - /* Convert name to UTF16. */ - nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); - handle->name = uv__malloc(nameSize); - if (!handle->name) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - if (!MultiByteToWideChar(CP_UTF8, - 0, - name, - -1, - handle->name, - nameSize / sizeof(WCHAR))) { - err = GetLastError(); + err = uv__convert_utf8_to_utf16(name, &handle->name); + if (err) { + err = ERROR_NO_UNICODE_TRANSLATION; goto error; } pipeHandle = open_named_pipe(handle->name, &duplex_flags); if (pipeHandle == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_PIPE_BUSY) { + nameSize = (wcslen(handle->name) + 1) * sizeof(WCHAR); req->u.connect.name = uv__malloc(nameSize); if (!req->u.connect.name) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); @@ -2439,7 +2414,6 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) FILE_NAME_INFORMATION tmp_name_info; FILE_NAME_INFORMATION* name_info; WCHAR* name_buf; - unsigned int addrlen; unsigned int name_size; unsigned int name_len; int err; @@ -2450,46 +2424,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) if (handle->name != NULL) { /* The user might try to query the name before we are connected, * and this is just easier to return the cached value if we have it. */ - name_buf = handle->name; - name_len = wcslen(name_buf); - - /* check how much space we need */ - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - NULL, - 0, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - return err; - } else if (addrlen >= *size) { - *size = addrlen + 1; - err = UV_ENOBUFS; - goto error; - } - - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - buffer, - addrlen, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - return err; - } - - *size = addrlen; - buffer[addrlen] = '\0'; - - return 0; + return uv__copy_utf16_to_utf8(handle->name, -1, buffer, size); } if (handle->handle == INVALID_HANDLE_VALUE) { @@ -2517,8 +2452,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) name_info = uv__malloc(name_size); if (!name_info) { *size = 0; - err = UV_ENOMEM; - goto cleanup; + return UV_ENOMEM; } nt_status = pNtQueryInformationFile(handle->handle, @@ -2551,51 +2485,19 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) name_len /= sizeof(WCHAR); - /* check how much space we need */ - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - NULL, - 0, - NULL, - NULL); - if (!addrlen) { + /* "\\\\.\\pipe" + name */ + if (*size < pipe_prefix_len) { *size = 0; - err = uv_translate_sys_error(GetLastError()); - goto error; - } else if (pipe_prefix_len + addrlen >= *size) { - /* "\\\\.\\pipe" + name */ - *size = pipe_prefix_len + addrlen + 1; - err = UV_ENOBUFS; - goto error; } - - memcpy(buffer, pipe_prefix, pipe_prefix_len); - addrlen = WideCharToMultiByte(CP_UTF8, - 0, - name_buf, - name_len, - buffer+pipe_prefix_len, - *size-pipe_prefix_len, - NULL, - NULL); - if (!addrlen) { - *size = 0; - err = uv_translate_sys_error(GetLastError()); - goto error; + else { + memcpy(buffer, pipe_prefix, pipe_prefix_len); + *size -= pipe_prefix_len; } - - addrlen += pipe_prefix_len; - *size = addrlen; - buffer[addrlen] = '\0'; - - err = 0; + err = uv__copy_utf16_to_utf8(name_buf, name_len, buffer+pipe_prefix_len, size); + *size += pipe_prefix_len; error: uv__free(name_info); - -cleanup: return err; } diff --git a/deps/libuv/src/win/process.c b/deps/libuv/src/win/process.c index 3e451e22..43059858 100644 --- a/deps/libuv/src/win/process.c +++ b/deps/libuv/src/win/process.c @@ -105,38 +105,26 @@ static void uv__init_global_job_handle(void) { &info, sizeof info)) uv_fatal_error(GetLastError(), "SetInformationJobObject"); + + + if (!AssignProcessToJobObject(uv_global_job_handle_, GetCurrentProcess())) { + /* Make sure this handle is functional. The Windows kernel has a bug that + * if the first use of AssignProcessToJobObject is for a Windows Store + * program, subsequent attempts to use the handle with fail with + * INVALID_PARAMETER (87). This is possibly because all uses of the handle + * must be for the same Terminal Services session. We can ensure it is tied + * to our current session now by adding ourself to it. We could remove + * ourself afterwards, but there doesn't seem to be a reason to. + */ + DWORD err = GetLastError(); + if (err != ERROR_ACCESS_DENIED) + uv_fatal_error(err, "AssignProcessToJobObject"); + } } static int uv__utf8_to_utf16_alloc(const char* s, WCHAR** ws_ptr) { - int ws_len, r; - WCHAR* ws; - - ws_len = MultiByteToWideChar(CP_UTF8, - 0, - s, - -1, - NULL, - 0); - if (ws_len <= 0) { - return GetLastError(); - } - - ws = (WCHAR*) uv__malloc(ws_len * sizeof(WCHAR)); - if (ws == NULL) { - return ERROR_OUTOFMEMORY; - } - - r = MultiByteToWideChar(CP_UTF8, - 0, - s, - -1, - ws, - ws_len); - assert(r == ws_len); - - *ws_ptr = ws; - return 0; + return uv__convert_utf8_to_utf16(s, ws_ptr); } @@ -396,7 +384,7 @@ static WCHAR* search_path(const WCHAR *file, name_has_ext); while (result == NULL) { - if (*dir_end == L'\0') { + if (dir_end == NULL || *dir_end == L'\0') { break; } @@ -539,21 +527,15 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { /* Count the required size. */ for (arg = args; *arg; arg++) { - DWORD arg_len; + ssize_t arg_len; - arg_len = MultiByteToWideChar(CP_UTF8, - 0, - *arg, - -1, - NULL, - 0); - if (arg_len == 0) { - return GetLastError(); - } + arg_len = uv_wtf8_length_as_utf16(*arg); + if (arg_len < 0) + return arg_len; dst_len += arg_len; - if (arg_len > temp_buffer_len) + if ((size_t) arg_len > temp_buffer_len) temp_buffer_len = arg_len; arg_count++; @@ -564,34 +546,28 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { dst_len = dst_len * 2 + arg_count * 2; /* Allocate buffer for the final command line. */ - dst = (WCHAR*) uv__malloc(dst_len * sizeof(WCHAR)); + dst = uv__malloc(dst_len * sizeof(WCHAR)); if (dst == NULL) { - err = ERROR_OUTOFMEMORY; + err = UV_ENOMEM; goto error; } /* Allocate temporary working buffer. */ - temp_buffer = (WCHAR*) uv__malloc(temp_buffer_len * sizeof(WCHAR)); + temp_buffer = uv__malloc(temp_buffer_len * sizeof(WCHAR)); if (temp_buffer == NULL) { - err = ERROR_OUTOFMEMORY; + err = UV_ENOMEM; goto error; } pos = dst; for (arg = args; *arg; arg++) { - DWORD arg_len; + ssize_t arg_len; /* Convert argument to wide char. */ - arg_len = MultiByteToWideChar(CP_UTF8, - 0, - *arg, - -1, - temp_buffer, - (int) (dst + dst_len - pos)); - if (arg_len == 0) { - err = GetLastError(); - goto error; - } + arg_len = uv_wtf8_length_as_utf16(*arg); + assert(arg_len > 0); + assert(temp_buffer_len >= (size_t) arg_len); + uv_wtf8_to_utf16(*arg, temp_buffer, arg_len); if (verbatim_arguments) { /* Copy verbatim. */ @@ -603,6 +579,7 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) { } *pos++ = *(arg + 1) ? L' ' : L'\0'; + assert(pos <= dst + dst_len); } uv__free(temp_buffer); @@ -688,55 +665,43 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { WCHAR* ptr; char** env; size_t env_len = 0; - int len; + size_t len; size_t i; - DWORD var_size; + size_t var_size; size_t env_block_count = 1; /* 1 for null-terminator */ WCHAR* dst_copy; WCHAR** ptr_copy; WCHAR** env_copy; - DWORD required_vars_value_len[ARRAY_SIZE(required_vars)]; + size_t required_vars_value_len[ARRAY_SIZE(required_vars)]; /* first pass: determine size in UTF-16 */ for (env = env_block; *env; env++) { - int len; + ssize_t len; if (strchr(*env, '=')) { - len = MultiByteToWideChar(CP_UTF8, - 0, - *env, - -1, - NULL, - 0); - if (len <= 0) { - return GetLastError(); - } + len = uv_wtf8_length_as_utf16(*env); + if (len < 0) + return len; env_len += len; env_block_count++; } } /* second pass: copy to UTF-16 environment block */ - dst_copy = (WCHAR*)uv__malloc(env_len * sizeof(WCHAR)); + dst_copy = uv__malloc(env_len * sizeof(WCHAR)); if (dst_copy == NULL && env_len > 0) { - return ERROR_OUTOFMEMORY; + return UV_ENOMEM; } env_copy = alloca(env_block_count * sizeof(WCHAR*)); ptr = dst_copy; ptr_copy = env_copy; for (env = env_block; *env; env++) { + ssize_t len; if (strchr(*env, '=')) { - len = MultiByteToWideChar(CP_UTF8, - 0, - *env, - -1, - ptr, - (int) (env_len - (ptr - dst_copy))); - if (len <= 0) { - DWORD err = GetLastError(); - uv__free(dst_copy); - return err; - } + len = uv_wtf8_length_as_utf16(*env); + assert(len > 0); + assert((size_t) len <= env_len - (ptr - dst_copy)); + uv_wtf8_to_utf16(*env, ptr, len); *ptr_copy++ = ptr; ptr += len; } @@ -754,7 +719,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { cmp = -1; } else { cmp = env_strncmp(required_vars[i].wide_eq, - required_vars[i].len, + required_vars[i].len, *ptr_copy); } if (cmp < 0) { @@ -777,7 +742,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) { dst = uv__malloc((1+env_len) * sizeof(WCHAR)); if (!dst) { uv__free(dst_copy); - return ERROR_OUTOFMEMORY; + return UV_ENOMEM; } for (ptr = dst, ptr_copy = env_copy, i = 0; @@ -975,26 +940,26 @@ int uv_spawn(uv_loop_t* loop, err = uv__utf8_to_utf16_alloc(options->file, &application); if (err) - goto done; + goto done_uv; err = make_program_args( options->args, options->flags & UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS, &arguments); if (err) - goto done; + goto done_uv; if (options->env) { err = make_program_env(options->env, &env); if (err) - goto done; + goto done_uv; } if (options->cwd) { /* Explicit cwd */ err = uv__utf8_to_utf16_alloc(options->cwd, &cwd); if (err) - goto done; + goto done_uv; } else { /* Inherit cwd */ @@ -1025,22 +990,19 @@ int uv_spawn(uv_loop_t* loop, DWORD path_len, r; path_len = GetEnvironmentVariableW(L"PATH", NULL, 0); - if (path_len == 0) { - err = GetLastError(); - goto done; - } + if (path_len != 0) { + alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR)); + if (alloc_path == NULL) { + err = ERROR_OUTOFMEMORY; + goto done; + } + path = alloc_path; - alloc_path = (WCHAR*) uv__malloc(path_len * sizeof(WCHAR)); - if (alloc_path == NULL) { - err = ERROR_OUTOFMEMORY; - goto done; - } - path = alloc_path; - - r = GetEnvironmentVariableW(L"PATH", path, path_len); - if (r == 0 || r >= path_len) { - err = GetLastError(); - goto done; + r = GetEnvironmentVariableW(L"PATH", path, path_len); + if (r == 0 || r >= path_len) { + err = GetLastError(); + goto done; + } } } @@ -1102,6 +1064,7 @@ int uv_spawn(uv_loop_t* loop, * breakaway. */ process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP; + process_flags |= CREATE_SUSPENDED; } if (!CreateProcessW(application_path, @@ -1119,11 +1082,6 @@ int uv_spawn(uv_loop_t* loop, goto done; } - /* Spawn succeeded. Beyond this point, failure is reported asynchronously. */ - - process->process_handle = info.hProcess; - process->pid = info.dwProcessId; - /* If the process isn't spawned as detached, assign to the global job object * so windows will kill it when the parent process dies. */ if (!(options->flags & UV_PROCESS_DETACHED)) { @@ -1146,6 +1104,19 @@ int uv_spawn(uv_loop_t* loop, } } + if (process_flags & CREATE_SUSPENDED) { + if (ResumeThread(info.hThread) == ((DWORD)-1)) { + err = GetLastError(); + TerminateProcess(info.hProcess, 1); + goto done; + } + } + + /* Spawn succeeded. Beyond this point, failure is reported asynchronously. */ + + process->process_handle = info.hProcess; + process->pid = info.dwProcessId; + /* Set IPC pid to all IPC pipes. */ for (i = 0; i < options->stdio_count; i++) { const uv_stdio_container_t* fdopt = &options->stdio[i]; @@ -1173,8 +1144,13 @@ int uv_spawn(uv_loop_t* loop, * made or the handle is closed, whichever happens first. */ uv__handle_start(process); + goto done_uv; + /* Cleanup, whether we succeeded or failed. */ done: + err = uv_translate_sys_error(err); + + done_uv: uv__free(application); uv__free(application_path); uv__free(arguments); @@ -1188,7 +1164,7 @@ int uv_spawn(uv_loop_t* loop, child_stdio_buffer = NULL; } - return uv_translate_sys_error(err); + return err; } diff --git a/deps/libuv/src/win/tty.c b/deps/libuv/src/win/tty.c index 7e1f1554..ac836930 100644 --- a/deps/libuv/src/win/tty.c +++ b/deps/libuv/src/win/tty.c @@ -482,9 +482,11 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { uv_loop_t* loop; uv_tty_t* handle; uv_req_t* req; - DWORD bytes, read_bytes; + DWORD bytes; + size_t read_bytes; WCHAR utf16[MAX_INPUT_BUFFER_LENGTH / 3]; - DWORD chars, read_chars; + DWORD chars; + DWORD read_chars; LONG status; COORD pos; BOOL read_console_success; @@ -525,16 +527,13 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { NULL); if (read_console_success) { - read_bytes = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - read_chars, - handle->tty.rd.read_line_buffer.base, - bytes, - NULL, - NULL); + read_bytes = bytes; + uv_utf16_to_wtf8(utf16, + read_chars, + &handle->tty.rd.read_line_buffer.base, + &read_bytes); SET_REQ_SUCCESS(req); - req->u.io.overlapped.InternalHigh = read_bytes; + req->u.io.overlapped.InternalHigh = (DWORD) read_bytes; } else { SET_REQ_ERROR(req, GetLastError()); } @@ -798,7 +797,9 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, } if (KEV.uChar.UnicodeChar != 0) { - int prefix_len, char_len; + int prefix_len; + size_t char_len; + char* last_key_buf; /* Character key pressed */ if (KEV.uChar.UnicodeChar >= 0xD800 && @@ -819,38 +820,31 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, prefix_len = 0; } - if (KEV.uChar.UnicodeChar >= 0xDC00 && - KEV.uChar.UnicodeChar < 0xE000) { + char_len = sizeof handle->tty.rd.last_key; + last_key_buf = &handle->tty.rd.last_key[prefix_len]; + if (handle->tty.rd.last_utf16_high_surrogate) { /* UTF-16 surrogate pair */ WCHAR utf16_buffer[2]; utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate; utf16_buffer[1] = KEV.uChar.UnicodeChar; - char_len = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - 2, - &handle->tty.rd.last_key[prefix_len], - sizeof handle->tty.rd.last_key, - NULL, - NULL); + if (uv_utf16_to_wtf8(utf16_buffer, + 2, + &last_key_buf, + &char_len)) + char_len = 0; + handle->tty.rd.last_utf16_high_surrogate = 0; } else { /* Single UTF-16 character */ - char_len = WideCharToMultiByte(CP_UTF8, - 0, - &KEV.uChar.UnicodeChar, - 1, - &handle->tty.rd.last_key[prefix_len], - sizeof handle->tty.rd.last_key, - NULL, - NULL); + if (uv_utf16_to_wtf8(&KEV.uChar.UnicodeChar, + 1, + &last_key_buf, + &char_len)) + char_len = 0; } - /* Whatever happened, the last character wasn't a high surrogate. */ - handle->tty.rd.last_utf16_high_surrogate = 0; - /* If the utf16 character(s) couldn't be converted something must be * wrong. */ - if (!char_len) { + if (char_len == 0) { handle->flags &= ~UV_HANDLE_READING; DECREASE_ACTIVE_COUNT(loop, handle); handle->read_cb((uv_stream_t*) handle, diff --git a/deps/libuv/src/win/util.c b/deps/libuv/src/win/util.c index f6ec79cd..91d88a54 100644 --- a/deps/libuv/src/win/util.c +++ b/deps/libuv/src/win/util.c @@ -95,7 +95,7 @@ void uv__util_init(void) { int uv_exepath(char* buffer, size_t* size_ptr) { - int utf8_len, utf16_buffer_len, utf16_len; + size_t utf8_len, utf16_buffer_len, utf16_len; WCHAR* utf16_buffer; int err; @@ -123,25 +123,17 @@ int uv_exepath(char* buffer, size_t* size_ptr) { } /* Convert to UTF-8 */ - utf8_len = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - buffer, - (int) *size_ptr, - NULL, - NULL); - if (utf8_len == 0) { - err = GetLastError(); - goto error; + utf8_len = *size_ptr - 1; /* Reserve space for NUL */ + err = uv_utf16_to_wtf8(utf16_buffer, utf16_len, &buffer, &utf8_len); + if (err == UV_ENOBUFS) { + utf8_len = *size_ptr - 1; + err = 0; } + *size_ptr = utf8_len; uv__free(utf16_buffer); - /* utf8_len *does* include the terminating null at this point, but the - * returned size shouldn't. */ - *size_ptr = utf8_len - 1; - return 0; + return err; error: uv__free(utf16_buffer); @@ -204,45 +196,14 @@ int uv_cwd(char* buffer, size_t* size) { } r = uv__cwd(&utf16_buffer, &utf16_len); - if (r < 0) { + if (r < 0) return r; - } - /* Check how much space we need */ - r = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - NULL, - 0, - NULL, - NULL); - if (r == 0) { - uv__free(utf16_buffer); - return uv_translate_sys_error(GetLastError()); - } else if (r > (int) *size) { - uv__free(utf16_buffer); - *size = r; - return UV_ENOBUFS; - } + r = uv__copy_utf16_to_utf8(utf16_buffer, utf16_len, buffer, size); - /* Convert to UTF-8 */ - r = WideCharToMultiByte(CP_UTF8, - 0, - utf16_buffer, - -1, - buffer, - *size > INT_MAX ? INT_MAX : (int) *size, - NULL, - NULL); uv__free(utf16_buffer); - if (r == 0) { - return uv_translate_sys_error(GetLastError()); - } - - *size = r - 1; - return 0; + return r; } @@ -252,33 +213,10 @@ int uv_chdir(const char* dir) { WCHAR drive_letter, env_var[4]; int r; - if (dir == NULL) { - return UV_EINVAL; - } - - utf16_len = MultiByteToWideChar(CP_UTF8, - 0, - dir, - -1, - NULL, - 0); - if (utf16_len == 0) { - return uv_translate_sys_error(GetLastError()); - } - utf16_buffer = uv__malloc(utf16_len * sizeof(WCHAR)); - if (utf16_buffer == NULL) { - return UV_ENOMEM; - } - - if (MultiByteToWideChar(CP_UTF8, - 0, - dir, - -1, - utf16_buffer, - utf16_len) == 0) { - uv__free(utf16_buffer); - return uv_translate_sys_error(GetLastError()); - } + /* Convert to UTF-16 */ + r = uv__convert_utf8_to_utf16(dir, &utf16_buffer); + if (r) + return r; if (!SetCurrentDirectoryW(utf16_buffer)) { uv__free(utf16_buffer); @@ -416,29 +354,14 @@ int uv_set_process_title(const char* title) { uv__once_init(); - /* Find out how big the buffer for the wide-char title must be */ - length = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0); - if (!length) { - err = GetLastError(); - goto done; - } - - /* Convert to wide-char string */ - title_w = (WCHAR*)uv__malloc(sizeof(WCHAR) * length); - if (!title_w) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - length = MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, length); - if (!length) { - err = GetLastError(); - goto done; - } + err = uv__convert_utf8_to_utf16(title, &title_w); + if (err) + return err; /* If the title must be truncated insert a \0 terminator there */ - if (length > MAX_TITLE_LENGTH) { + length = wcslen(title_w); + if (length >= MAX_TITLE_LENGTH) title_w[MAX_TITLE_LENGTH - 1] = L'\0'; - } if (!SetConsoleTitleW(title_w)) { err = GetLastError(); @@ -460,20 +383,19 @@ done: static int uv__get_process_title(void) { WCHAR title_w[MAX_TITLE_LENGTH]; + DWORD wlen; - if (!GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR))) { - return -1; - } + wlen = GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR)); + if (wlen == 0) + return uv_translate_sys_error(GetLastError()); - if (uv__convert_utf16_to_utf8(title_w, -1, &process_title) != 0) - return -1; - - return 0; + return uv__convert_utf16_to_utf8(title_w, wlen, &process_title); } int uv_get_process_title(char* buffer, size_t size) { size_t len; + int r; if (buffer == NULL || size == 0) return UV_EINVAL; @@ -485,9 +407,12 @@ int uv_get_process_title(char* buffer, size_t size) { * If the process_title was never read before nor explicitly set, * we must query it with getConsoleTitleW */ - if (!process_title && uv__get_process_title() == -1) { - LeaveCriticalSection(&process_title_lock); - return uv_translate_sys_error(GetLastError()); + if (process_title == NULL) { + r = uv__get_process_title(); + if (r) { + LeaveCriticalSection(&process_title_lock); + return r; + } } assert(process_title); @@ -833,19 +758,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, continue; /* Compute the size of the interface name. */ - name_size = WideCharToMultiByte(CP_UTF8, - 0, - adapter->FriendlyName, - -1, - NULL, - 0, - NULL, - FALSE); - if (name_size <= 0) { - uv__free(win_address_buf); - return uv_translate_sys_error(GetLastError()); - } - uv_address_buf_size += name_size; + name_size = uv_utf16_length_as_wtf8(adapter->FriendlyName, -1); + uv_address_buf_size += name_size + 1; /* Count the number of addresses associated with this interface, and * compute the size. */ @@ -875,30 +789,25 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr, adapter != NULL; adapter = adapter->Next) { IP_ADAPTER_UNICAST_ADDRESS* unicast_address; - int name_size; - size_t max_name_size; + size_t name_size; + int r; if (adapter->OperStatus != IfOperStatusUp || adapter->FirstUnicastAddress == NULL) continue; /* Convert the interface name to UTF8. */ - max_name_size = (char*) uv_address_buf + uv_address_buf_size - name_buf; - if (max_name_size > (size_t) INT_MAX) - max_name_size = INT_MAX; - name_size = WideCharToMultiByte(CP_UTF8, - 0, - adapter->FriendlyName, - -1, - name_buf, - (int) max_name_size, - NULL, - FALSE); - if (name_size <= 0) { + name_size = (char*) uv_address_buf + uv_address_buf_size - name_buf; + r = uv__copy_utf16_to_utf8(adapter->FriendlyName, + -1, + name_buf, + &name_size); + if (r) { uv__free(win_address_buf); uv__free(uv_address_buf); - return uv_translate_sys_error(GetLastError()); + return r; } + name_size += 1; /* Add NUL byte. */ /* Add an uv_interface_address_t element for every unicast address. */ for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*) @@ -1061,7 +970,6 @@ int uv_os_homedir(char* buffer, size_t* size) { int uv_os_tmpdir(char* buffer, size_t* size) { wchar_t *path; - DWORD bufsize; size_t len; if (buffer == NULL || size == NULL || *size == 0) @@ -1078,7 +986,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) { if (path == NULL) { return UV_ENOMEM; } - len = GetTempPathW(len, path); + len = GetTempPathW(len, path); if (len == 0) { uv__free(path); @@ -1093,34 +1001,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) { path[len] = L'\0'; } - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - uv__free(path); - return uv_translate_sys_error(GetLastError()); - } else if (bufsize > *size) { - uv__free(path); - *size = bufsize; - return UV_ENOBUFS; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - path, - -1, - buffer, - *size, - NULL, - NULL); - uv__free(path); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - *size = bufsize - 1; - return 0; + return uv__copy_utf16_to_utf8(path, len, buffer, size); } @@ -1131,95 +1012,71 @@ int uv_os_tmpdir(char* buffer, size_t* size) { * If utf16 is null terminated, utf16len can be set to -1, otherwise it must * be specified. */ -int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8) { - DWORD bufsize; +int uv__convert_utf16_to_utf8(const WCHAR* utf16, size_t utf16len, char** utf8) { + size_t utf8_len = 0; if (utf16 == NULL) return UV_EINVAL; - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - utf16len, - NULL, - 0, - NULL, - NULL); - - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - /* Allocate the destination buffer adding an extra byte for the terminating - * NULL. If utf16len is not -1 WideCharToMultiByte will not add it, so - * we do it ourselves always, just in case. */ - *utf8 = uv__malloc(bufsize + 1); - - if (*utf8 == NULL) - return UV_ENOMEM; - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - utf16, - utf16len, - *utf8, - bufsize, - NULL, - NULL); - - if (bufsize == 0) { - uv__free(*utf8); - *utf8 = NULL; - return uv_translate_sys_error(GetLastError()); - } - - (*utf8)[bufsize] = '\0'; - return 0; + *utf8 = NULL; + return uv_utf16_to_wtf8(utf16, utf16len, utf8, &utf8_len); } /* * Converts a UTF-8 string into a UTF-16 one. The resulting string is * null-terminated. - * - * If utf8 is null terminated, utf8len can be set to -1, otherwise it must - * be specified. */ -int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) { +int uv__convert_utf8_to_utf16(const char* utf8, WCHAR** utf16) { int bufsize; if (utf8 == NULL) return UV_EINVAL; - /* Check how much space we need */ - bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, NULL, 0); + /* Check how much space we need (including NUL). */ + bufsize = uv_wtf8_length_as_utf16(utf8); + if (bufsize < 0) + return UV__EINVAL; - if (bufsize == 0) - return uv_translate_sys_error(GetLastError()); - - /* Allocate the destination buffer adding an extra byte for the terminating - * NULL. If utf8len is not -1 MultiByteToWideChar will not add it, so - * we do it ourselves always, just in case. */ - *utf16 = uv__malloc(sizeof(WCHAR) * (bufsize + 1)); + /* Allocate the destination buffer. */ + *utf16 = uv__malloc(sizeof(WCHAR) * bufsize); if (*utf16 == NULL) return UV_ENOMEM; /* Convert to UTF-16 */ - bufsize = MultiByteToWideChar(CP_UTF8, 0, utf8, utf8len, *utf16, bufsize); + uv_wtf8_to_utf16(utf8, *utf16, bufsize); - if (bufsize == 0) { - uv__free(*utf16); - *utf16 = NULL; - return uv_translate_sys_error(GetLastError()); - } - - (*utf16)[bufsize] = L'\0'; return 0; } +/* + * Converts a UTF-16 string into a UTF-8 one in an existing buffer. The + * resulting string is null-terminated. + * + * If utf16 is null terminated, utf16len can be set to -1, otherwise it must + * be specified. + */ +int uv__copy_utf16_to_utf8(const WCHAR* utf16buffer, size_t utf16len, char* utf8, size_t *size) { + int r; + + if (utf8 == NULL || size == NULL) + return UV_EINVAL; + + if (*size == 0) { + *size = uv_utf16_length_as_wtf8(utf16buffer, utf16len); + r = UV_ENOBUFS; + } else { + *size -= 1; /* Reserve space for NUL. */ + r = uv_utf16_to_wtf8(utf16buffer, utf16len, &utf8, size); + } + if (r == UV_ENOBUFS) + *size += 1; /* Add space for NUL. */ + return r; +} + + static int uv__getpwuid_r(uv_passwd_t* pwd) { HANDLE token; wchar_t username[UNLEN + 1]; @@ -1384,14 +1241,13 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) { wchar_t* var; DWORD varlen; wchar_t* name_w; - DWORD bufsize; size_t len; int r; if (name == NULL || buffer == NULL || size == NULL || *size == 0) return UV_EINVAL; - r = uv__convert_utf8_to_utf16(name, -1, &name_w); + r = uv__convert_utf8_to_utf16(name, &name_w); if (r != 0) return r; @@ -1432,35 +1288,7 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) { } } - /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, var, -1, NULL, 0, NULL, NULL); - - if (bufsize == 0) { - r = uv_translate_sys_error(GetLastError()); - goto fail; - } else if (bufsize > *size) { - *size = bufsize; - r = UV_ENOBUFS; - goto fail; - } - - /* Convert to UTF-8 */ - bufsize = WideCharToMultiByte(CP_UTF8, - 0, - var, - -1, - buffer, - *size, - NULL, - NULL); - - if (bufsize == 0) { - r = uv_translate_sys_error(GetLastError()); - goto fail; - } - - *size = bufsize - 1; - r = 0; + r = uv__copy_utf16_to_utf8(var, len, buffer, size); fail: @@ -1482,12 +1310,12 @@ int uv_os_setenv(const char* name, const char* value) { if (name == NULL || value == NULL) return UV_EINVAL; - r = uv__convert_utf8_to_utf16(name, -1, &name_w); + r = uv__convert_utf8_to_utf16(name, &name_w); if (r != 0) return r; - r = uv__convert_utf8_to_utf16(value, -1, &value_w); + r = uv__convert_utf8_to_utf16(value, &value_w); if (r != 0) { uv__free(name_w); @@ -1512,7 +1340,7 @@ int uv_os_unsetenv(const char* name) { if (name == NULL) return UV_EINVAL; - r = uv__convert_utf8_to_utf16(name, -1, &name_w); + r = uv__convert_utf8_to_utf16(name, &name_w); if (r != 0) return r; @@ -1529,9 +1357,6 @@ int uv_os_unsetenv(const char* name) { int uv_os_gethostname(char* buffer, size_t* size) { WCHAR buf[UV_MAXHOSTNAMESIZE]; - size_t len; - char* utf8_str; - int convert_result; if (buffer == NULL || size == NULL || *size == 0) return UV_EINVAL; @@ -1544,22 +1369,7 @@ int uv_os_gethostname(char* buffer, size_t* size) { if (pGetHostNameW(buf, UV_MAXHOSTNAMESIZE) != 0) return uv_translate_sys_error(WSAGetLastError()); - convert_result = uv__convert_utf16_to_utf8(buf, -1, &utf8_str); - - if (convert_result != 0) - return convert_result; - - len = strlen(utf8_str); - if (len >= *size) { - *size = len + 1; - uv__free(utf8_str); - return UV_ENOBUFS; - } - - memcpy(buffer, utf8_str, len + 1); - uv__free(utf8_str); - *size = len; - return 0; + return uv__copy_utf16_to_utf8(buf, -1, buffer, size); } @@ -1665,7 +1475,7 @@ int uv_os_uname(uv_utsname_t* buffer) { HKEY registry_key; WCHAR product_name_w[256]; DWORD product_name_w_size; - int version_size; + size_t version_size; int processor_level; int r; @@ -1696,7 +1506,7 @@ int uv_os_uname(uv_utsname_t* buffer) { r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, - KEY_QUERY_VALUE, + KEY_QUERY_VALUE | KEY_WOW64_64KEY, ®istry_key); if (r == ERROR_SUCCESS) { @@ -1727,37 +1537,29 @@ int uv_os_uname(uv_utsname_t* buffer) { } } - version_size = WideCharToMultiByte(CP_UTF8, - 0, - product_name_w, - -1, - buffer->version, - sizeof(buffer->version), - NULL, - NULL); - if (version_size == 0) { - r = uv_translate_sys_error(GetLastError()); + version_size = sizeof(buffer->version); + r = uv__copy_utf16_to_utf8(product_name_w, + -1, + buffer->version, + &version_size); + if (r) goto error; - } } } /* Append service pack information to the version if present. */ if (os_info.szCSDVersion[0] != L'\0') { if (version_size > 0) - buffer->version[version_size - 1] = ' '; + buffer->version[version_size++] = ' '; - if (WideCharToMultiByte(CP_UTF8, - 0, - os_info.szCSDVersion, - -1, - buffer->version + version_size, - sizeof(buffer->version) - version_size, - NULL, - NULL) == 0) { - r = uv_translate_sys_error(GetLastError()); + version_size = sizeof(buffer->version) - version_size; + r = uv__copy_utf16_to_utf8(os_info.szCSDVersion, + -1, + buffer->version + + sizeof(buffer->version) - version_size, + &version_size); + if (r) goto error; - } } /* Populate the sysname field. */ diff --git a/deps/libuv/test/benchmark-async-pummel.c b/deps/libuv/test/benchmark-async-pummel.c index bec91850..68864c84 100644 --- a/deps/libuv/test/benchmark-async-pummel.c +++ b/deps/libuv/test/benchmark-async-pummel.c @@ -71,21 +71,21 @@ static int test_async_pummel(int nthreads) { tids = calloc(nthreads, sizeof(tids[0])); ASSERT_NOT_NULL(tids); - ASSERT(0 == uv_async_init(uv_default_loop(), &handle, async_cb)); + ASSERT_OK(uv_async_init(uv_default_loop(), &handle, async_cb)); ACCESS_ONCE(const char*, handle.data) = running; for (i = 0; i < nthreads; i++) - ASSERT(0 == uv_thread_create(tids + i, pummel, &handle)); + ASSERT_OK(uv_thread_create(tids + i, pummel, &handle)); time = uv_hrtime(); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); time = uv_hrtime() - time; done = 1; for (i = 0; i < nthreads; i++) - ASSERT(0 == uv_thread_join(tids + i)); + ASSERT_OK(uv_thread_join(tids + i)); printf("async_pummel_%d: %s callbacks in %.2f seconds (%s/sec)\n", nthreads, diff --git a/deps/libuv/test/benchmark-async.c b/deps/libuv/test/benchmark-async.c index d4b7c8bd..5544c46b 100644 --- a/deps/libuv/test/benchmark-async.c +++ b/deps/libuv/test/benchmark-async.c @@ -43,7 +43,7 @@ struct ctx { static void worker_async_cb(uv_async_t* handle) { struct ctx* ctx = container_of(handle, struct ctx, worker_async); - ASSERT(0 == uv_async_send(&ctx->main_async)); + ASSERT_OK(uv_async_send(&ctx->main_async)); ctx->worker_sent++; ctx->worker_seen++; @@ -55,7 +55,7 @@ static void worker_async_cb(uv_async_t* handle) { static void main_async_cb(uv_async_t* handle) { struct ctx* ctx = container_of(handle, struct ctx, main_async); - ASSERT(0 == uv_async_send(&ctx->worker_async)); + ASSERT_OK(uv_async_send(&ctx->worker_async)); ctx->main_sent++; ctx->main_seen++; @@ -66,8 +66,8 @@ static void main_async_cb(uv_async_t* handle) { static void worker(void* arg) { struct ctx* ctx = arg; - ASSERT(0 == uv_async_send(&ctx->main_async)); - ASSERT(0 == uv_run(&ctx->loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_async_send(&ctx->main_async)); + ASSERT_OK(uv_run(&ctx->loop, UV_RUN_DEFAULT)); uv_loop_close(&ctx->loop); } @@ -85,29 +85,29 @@ static int test_async(int nthreads) { for (i = 0; i < nthreads; i++) { ctx = threads + i; ctx->nthreads = nthreads; - ASSERT(0 == uv_loop_init(&ctx->loop)); - ASSERT(0 == uv_async_init(&ctx->loop, &ctx->worker_async, worker_async_cb)); - ASSERT(0 == uv_async_init(uv_default_loop(), - &ctx->main_async, - main_async_cb)); - ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx)); + ASSERT_OK(uv_loop_init(&ctx->loop)); + ASSERT_OK(uv_async_init(&ctx->loop, &ctx->worker_async, worker_async_cb)); + ASSERT_OK(uv_async_init(uv_default_loop(), + &ctx->main_async, + main_async_cb)); + ASSERT_OK(uv_thread_create(&ctx->thread, worker, ctx)); } time = uv_hrtime(); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); for (i = 0; i < nthreads; i++) - ASSERT(0 == uv_thread_join(&threads[i].thread)); + ASSERT_OK(uv_thread_join(&threads[i].thread)); time = uv_hrtime() - time; for (i = 0; i < nthreads; i++) { ctx = threads + i; - ASSERT(ctx->worker_sent == NUM_PINGS); - ASSERT(ctx->worker_seen == NUM_PINGS); - ASSERT(ctx->main_sent == (unsigned int) NUM_PINGS); - ASSERT(ctx->main_seen == (unsigned int) NUM_PINGS); + ASSERT_EQ(ctx->worker_sent, NUM_PINGS); + ASSERT_EQ(ctx->worker_seen, NUM_PINGS); + ASSERT_EQ(ctx->main_sent, (unsigned int) NUM_PINGS); + ASSERT_EQ(ctx->main_seen, (unsigned int) NUM_PINGS); } printf("async%d: %.2f sec (%s/sec)\n", diff --git a/deps/libuv/test/benchmark-getaddrinfo.c b/deps/libuv/test/benchmark-getaddrinfo.c index 1ef7b1ef..cb4d2bc9 100644 --- a/deps/libuv/test/benchmark-getaddrinfo.c +++ b/deps/libuv/test/benchmark-getaddrinfo.c @@ -43,7 +43,7 @@ static void getaddrinfo_initiate(uv_getaddrinfo_t* handle); static void getaddrinfo_cb(uv_getaddrinfo_t* handle, int status, struct addrinfo* res) { - ASSERT(status == 0); + ASSERT_OK(status); calls_completed++; if (calls_initiated < TOTAL_CALLS) { getaddrinfo_initiate(handle); @@ -59,7 +59,7 @@ static void getaddrinfo_initiate(uv_getaddrinfo_t* handle) { calls_initiated++; r = uv_getaddrinfo(loop, handle, &getaddrinfo_cb, name, NULL, NULL); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -80,8 +80,8 @@ BENCHMARK_IMPL(getaddrinfo) { uv_update_time(loop); end_time = uv_now(loop); - ASSERT(calls_initiated == TOTAL_CALLS); - ASSERT(calls_completed == TOTAL_CALLS); + ASSERT_EQ(calls_initiated, TOTAL_CALLS); + ASSERT_EQ(calls_completed, TOTAL_CALLS); fprintf(stderr, "getaddrinfo: %.0f req/s\n", (double) calls_completed / (double) (end_time - start_time) * 1000.0); diff --git a/deps/libuv/test/benchmark-loop-count.c b/deps/libuv/test/benchmark-loop-count.c index 72f25b56..0db4aa56 100644 --- a/deps/libuv/test/benchmark-loop-count.c +++ b/deps/libuv/test/benchmark-loop-count.c @@ -74,7 +74,7 @@ BENCHMARK_IMPL(loop_count) { uv_run(loop, UV_RUN_DEFAULT); ns = uv_hrtime() - ns; - ASSERT(ticks == NUM_TICKS); + ASSERT_UINT64_EQ(ticks, NUM_TICKS); fprintf(stderr, "loop_count: %d ticks in %.2fs (%.0f/s)\n", NUM_TICKS, diff --git a/deps/libuv/test/benchmark-million-async.c b/deps/libuv/test/benchmark-million-async.c index 30c21c38..13b52d48 100644 --- a/deps/libuv/test/benchmark-million-async.c +++ b/deps/libuv/test/benchmark-million-async.c @@ -60,7 +60,7 @@ static void timer_cb(uv_timer_t* handle) { unsigned i; done = 1; - ASSERT(0 == uv_thread_join(&thread_id)); + ASSERT_OK(uv_thread_join(&thread_id)); for (i = 0; i < ARRAY_SIZE(container->async_handles); i++) { uv_async_t* handle = container->async_handles + i; @@ -93,14 +93,14 @@ BENCHMARK_IMPL(million_async) { for (i = 0; i < ARRAY_SIZE(container->async_handles); i++) { handle = container->async_handles + i; - ASSERT(0 == uv_async_init(loop, handle, async_cb)); + ASSERT_OK(uv_async_init(loop, handle, async_cb)); handle->data = NULL; } - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, timeout, 0)); - ASSERT(0 == uv_thread_create(&thread_id, thread_cb, NULL)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, timeout, 0)); + ASSERT_OK(uv_thread_create(&thread_id, thread_cb, NULL)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); printf("%s async events in %.1f seconds (%s/s, %s unique handles seen)\n", fmt(&fmtbuf[0], container->async_events), timeout / 1000., diff --git a/deps/libuv/test/benchmark-million-timers.c b/deps/libuv/test/benchmark-million-timers.c index b35fd5e7..fd999c46 100644 --- a/deps/libuv/test/benchmark-million-timers.c +++ b/deps/libuv/test/benchmark-million-timers.c @@ -57,22 +57,22 @@ BENCHMARK_IMPL(million_timers) { before_all = uv_hrtime(); for (i = 0; i < NUM_TIMERS; i++) { if (i % 1000 == 0) timeout++; - ASSERT(0 == uv_timer_init(loop, timers + i)); - ASSERT(0 == uv_timer_start(timers + i, timer_cb, timeout, 0)); + ASSERT_OK(uv_timer_init(loop, timers + i)); + ASSERT_OK(uv_timer_start(timers + i, timer_cb, timeout, 0)); } before_run = uv_hrtime(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); after_run = uv_hrtime(); for (i = 0; i < NUM_TIMERS; i++) uv_close((uv_handle_t*) (timers + i), close_cb); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); after_all = uv_hrtime(); - ASSERT(timer_cb_called == NUM_TIMERS); - ASSERT(close_cb_called == NUM_TIMERS); + ASSERT_EQ(timer_cb_called, NUM_TIMERS); + ASSERT_EQ(close_cb_called, NUM_TIMERS); free(timers); fprintf(stderr, "%.2f seconds total\n", (after_all - before_all) / 1e9); diff --git a/deps/libuv/test/benchmark-multi-accept.c b/deps/libuv/test/benchmark-multi-accept.c index e2026276..1d19e330 100644 --- a/deps/libuv/test/benchmark-multi-accept.c +++ b/deps/libuv/test/benchmark-multi-accept.c @@ -117,19 +117,19 @@ static void ipc_connection_cb(uv_stream_t* ipc_pipe, int status) { ASSERT_NOT_NULL(pc); if (ipc_pipe->type == UV_TCP) - ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) &pc->peer_handle)); + ASSERT_OK(uv_tcp_init(loop, (uv_tcp_t*) &pc->peer_handle)); else if (ipc_pipe->type == UV_NAMED_PIPE) - ASSERT(0 == uv_pipe_init(loop, (uv_pipe_t*) &pc->peer_handle, 1)); + ASSERT_OK(uv_pipe_init(loop, (uv_pipe_t*) &pc->peer_handle, 1)); else ASSERT(0); - ASSERT(0 == uv_accept(ipc_pipe, (uv_stream_t*) &pc->peer_handle)); - ASSERT(0 == uv_write2(&pc->write_req, - (uv_stream_t*) &pc->peer_handle, - &buf, - 1, - (uv_stream_t*) &sc->server_handle, - ipc_write_cb)); + ASSERT_OK(uv_accept(ipc_pipe, (uv_stream_t*) &pc->peer_handle)); + ASSERT_OK(uv_write2(&pc->write_req, + (uv_stream_t*) &pc->peer_handle, + &buf, + 1, + (uv_stream_t*) &sc->server_handle, + ipc_write_cb)); if (--sc->num_connects == 0) uv_close((uv_handle_t*) ipc_pipe, NULL); @@ -153,10 +153,10 @@ static void ipc_close_cb(uv_handle_t* handle) { static void ipc_connect_cb(uv_connect_t* req, int status) { struct ipc_client_ctx* ctx; ctx = container_of(req, struct ipc_client_ctx, connect_req); - ASSERT(0 == status); - ASSERT(0 == uv_read_start((uv_stream_t*) &ctx->ipc_pipe, - ipc_alloc_cb, - ipc_read_cb)); + ASSERT_OK(status); + ASSERT_OK(uv_read_start((uv_stream_t*) &ctx->ipc_pipe, + ipc_alloc_cb, + ipc_read_cb)); } @@ -182,16 +182,16 @@ static void ipc_read_cb(uv_stream_t* handle, ctx = container_of(ipc_pipe, struct ipc_client_ctx, ipc_pipe); loop = ipc_pipe->loop; - ASSERT(1 == uv_pipe_pending_count(ipc_pipe)); + ASSERT_EQ(1, uv_pipe_pending_count(ipc_pipe)); type = uv_pipe_pending_type(ipc_pipe); if (type == UV_TCP) - ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) ctx->server_handle)); + ASSERT_OK(uv_tcp_init(loop, (uv_tcp_t*) ctx->server_handle)); else if (type == UV_NAMED_PIPE) - ASSERT(0 == uv_pipe_init(loop, (uv_pipe_t*) ctx->server_handle, 0)); + ASSERT_OK(uv_pipe_init(loop, (uv_pipe_t*) ctx->server_handle, 0)); else ASSERT(0); - ASSERT(0 == uv_accept(handle, ctx->server_handle)); + ASSERT_OK(uv_accept(handle, ctx->server_handle)); uv_close((uv_handle_t*) &ctx->ipc_pipe, NULL); } @@ -211,10 +211,10 @@ static void send_listen_handles(uv_handle_type type, ctx.num_connects = num_servers; if (type == UV_TCP) { - ASSERT(0 == uv_tcp_init(loop, (uv_tcp_t*) &ctx.server_handle)); - ASSERT(0 == uv_tcp_bind((uv_tcp_t*) &ctx.server_handle, - (const struct sockaddr*) &listen_addr, - 0)); + ASSERT_OK(uv_tcp_init(loop, (uv_tcp_t*) &ctx.server_handle)); + ASSERT_OK(uv_tcp_bind((uv_tcp_t*) &ctx.server_handle, + (const struct sockaddr*) &listen_addr, + 0)); } else ASSERT(0); @@ -223,16 +223,16 @@ static void send_listen_handles(uv_handle_type type, * If we accept a connection then the connected pipe must be initialized * with ipc=1. */ - ASSERT(0 == uv_pipe_init(loop, &ctx.ipc_pipe, 0)); - ASSERT(0 == uv_pipe_bind(&ctx.ipc_pipe, IPC_PIPE_NAME)); - ASSERT(0 == uv_listen((uv_stream_t*) &ctx.ipc_pipe, 128, ipc_connection_cb)); + ASSERT_OK(uv_pipe_init(loop, &ctx.ipc_pipe, 0)); + ASSERT_OK(uv_pipe_bind(&ctx.ipc_pipe, IPC_PIPE_NAME)); + ASSERT_OK(uv_listen((uv_stream_t*) &ctx.ipc_pipe, 128, ipc_connection_cb)); for (i = 0; i < num_servers; i++) uv_sem_post(&servers[i].semaphore); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); uv_close((uv_handle_t*) &ctx.server_handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); for (i = 0; i < num_servers; i++) uv_sem_wait(&servers[i].semaphore); @@ -245,12 +245,12 @@ static void get_listen_handle(uv_loop_t* loop, uv_stream_t* server_handle) { ctx.server_handle = server_handle; ctx.server_handle->data = "server handle"; - ASSERT(0 == uv_pipe_init(loop, &ctx.ipc_pipe, 1)); + ASSERT_OK(uv_pipe_init(loop, &ctx.ipc_pipe, 1)); uv_pipe_connect(&ctx.connect_req, &ctx.ipc_pipe, IPC_PIPE_NAME, ipc_connect_cb); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); } @@ -259,9 +259,9 @@ static void server_cb(void *arg) { uv_loop_t loop; ctx = arg; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); - ASSERT(0 == uv_async_init(&loop, &ctx->async_handle, sv_async_cb)); + ASSERT_OK(uv_async_init(&loop, &ctx->async_handle, sv_async_cb)); uv_unref((uv_handle_t*) &ctx->async_handle); /* Wait until the main thread is ready. */ @@ -270,10 +270,10 @@ static void server_cb(void *arg) { uv_sem_post(&ctx->semaphore); /* Now start the actual benchmark. */ - ASSERT(0 == uv_listen((uv_stream_t*) &ctx->server_handle, - 128, - sv_connection_cb)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_listen((uv_stream_t*) &ctx->server_handle, + 128, + sv_connection_cb)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); uv_loop_close(&loop); } @@ -292,20 +292,20 @@ static void sv_connection_cb(uv_stream_t* server_handle, int status) { struct server_ctx* ctx; ctx = container_of(server_handle, struct server_ctx, server_handle); - ASSERT(status == 0); + ASSERT_OK(status); storage = malloc(sizeof(*storage)); ASSERT_NOT_NULL(storage); if (server_handle->type == UV_TCP) - ASSERT(0 == uv_tcp_init(server_handle->loop, (uv_tcp_t*) storage)); + ASSERT_OK(uv_tcp_init(server_handle->loop, (uv_tcp_t*) storage)); else if (server_handle->type == UV_NAMED_PIPE) - ASSERT(0 == uv_pipe_init(server_handle->loop, (uv_pipe_t*) storage, 0)); + ASSERT_OK(uv_pipe_init(server_handle->loop, (uv_pipe_t*) storage, 0)); else ASSERT(0); - ASSERT(0 == uv_accept(server_handle, (uv_stream_t*) storage)); - ASSERT(0 == uv_read_start((uv_stream_t*) storage, sv_alloc_cb, sv_read_cb)); + ASSERT_OK(uv_accept(server_handle, (uv_stream_t*) storage)); + ASSERT_OK(uv_read_start((uv_stream_t*) storage, sv_alloc_cb, sv_read_cb)); ctx->num_connects++; } @@ -322,7 +322,7 @@ static void sv_alloc_cb(uv_handle_t* handle, static void sv_read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); uv_close((uv_handle_t*) handle, (uv_close_cb) free); } @@ -330,7 +330,7 @@ static void sv_read_cb(uv_stream_t* handle, static void cl_connect_cb(uv_connect_t* req, int status) { struct client_ctx* ctx = container_of(req, struct client_ctx, connect_req); uv_idle_start(&ctx->idle_handle, cl_idle_cb); - ASSERT(0 == status); + ASSERT_OK(status); } @@ -351,11 +351,11 @@ static void cl_close_cb(uv_handle_t* handle) { return; } - ASSERT(0 == uv_tcp_init(handle->loop, (uv_tcp_t*) &ctx->client_handle)); - ASSERT(0 == uv_tcp_connect(&ctx->connect_req, - (uv_tcp_t*) &ctx->client_handle, - (const struct sockaddr*) &listen_addr, - cl_connect_cb)); + ASSERT_OK(uv_tcp_init(handle->loop, (uv_tcp_t*) &ctx->client_handle)); + ASSERT_OK(uv_tcp_connect(&ctx->connect_req, + (uv_tcp_t*) &ctx->client_handle, + (const struct sockaddr*) &listen_addr, + cl_connect_cb)); } @@ -367,7 +367,7 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) { unsigned int i; double time; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &listen_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &listen_addr)); loop = uv_default_loop(); servers = calloc(num_servers, sizeof(servers[0])); @@ -381,8 +381,8 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) { */ for (i = 0; i < num_servers; i++) { struct server_ctx* ctx = servers + i; - ASSERT(0 == uv_sem_init(&ctx->semaphore, 0)); - ASSERT(0 == uv_thread_create(&ctx->thread_id, server_cb, ctx)); + ASSERT_OK(uv_sem_init(&ctx->semaphore, 0)); + ASSERT_OK(uv_thread_create(&ctx->thread_id, server_cb, ctx)); } send_listen_handles(UV_TCP, num_servers, servers); @@ -392,17 +392,17 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) { ctx->num_connects = NUM_CONNECTS / num_clients; handle = (uv_tcp_t*) &ctx->client_handle; handle->data = "client handle"; - ASSERT(0 == uv_tcp_init(loop, handle)); - ASSERT(0 == uv_tcp_connect(&ctx->connect_req, - handle, - (const struct sockaddr*) &listen_addr, - cl_connect_cb)); - ASSERT(0 == uv_idle_init(loop, &ctx->idle_handle)); + ASSERT_OK(uv_tcp_init(loop, handle)); + ASSERT_OK(uv_tcp_connect(&ctx->connect_req, + handle, + (const struct sockaddr*) &listen_addr, + cl_connect_cb)); + ASSERT_OK(uv_idle_init(loop, &ctx->idle_handle)); } { uint64_t t = uv_hrtime(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); t = uv_hrtime() - t; time = t / 1e9; } @@ -410,7 +410,7 @@ static int test_tcp(unsigned int num_servers, unsigned int num_clients) { for (i = 0; i < num_servers; i++) { struct server_ctx* ctx = servers + i; uv_async_send(&ctx->async_handle); - ASSERT(0 == uv_thread_join(&ctx->thread_id)); + ASSERT_OK(uv_thread_join(&ctx->thread_id)); uv_sem_destroy(&ctx->semaphore); } diff --git a/deps/libuv/test/benchmark-ping-pongs.c b/deps/libuv/test/benchmark-ping-pongs.c index 0357704e..fd5f40b9 100644 --- a/deps/libuv/test/benchmark-ping-pongs.c +++ b/deps/libuv/test/benchmark-ping-pongs.c @@ -90,7 +90,7 @@ static void pinger_close_cb(uv_handle_t* handle) { static void pinger_write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); free(req); } @@ -110,14 +110,14 @@ static void pinger_write_ping(pinger_t* pinger) { static void pinger_shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); pinger_shutdown_cb_called++; /* * The close callback has not been triggered yet. We must wait for EOF * until we close the connection. */ - ASSERT(completed_pingers == 0); + ASSERT_OK(completed_pingers); } @@ -130,13 +130,13 @@ static void pinger_read_cb(uv_stream_t* tcp, pinger = (pinger_t*)tcp->data; if (nread < 0) { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); if (buf->base) { buf_free(buf); } - ASSERT(pinger_shutdown_cb_called == 1); + ASSERT_EQ(1, pinger_shutdown_cb_called); uv_close((uv_handle_t*)tcp, pinger_close_cb); return; @@ -144,7 +144,7 @@ static void pinger_read_cb(uv_stream_t* tcp, /* Now we count the pings */ for (i = 0; i < nread; i++) { - ASSERT(buf->base[i] == PING[pinger->state]); + ASSERT_EQ(buf->base[i], PING[pinger->state]); pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); if (pinger->state == 0) { pinger->pongs++; @@ -166,7 +166,7 @@ static void pinger_read_cb(uv_stream_t* tcp, static void pinger_connect_cb(uv_connect_t* req, int status) { pinger_t *pinger = (pinger_t*)req->handle->data; - ASSERT(status == 0); + ASSERT_OK(status); pinger_write_ping(pinger); @@ -182,8 +182,8 @@ static void pinger_new(void) { pinger_t *pinger; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &client_addr)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", 0, &client_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); pinger = malloc(sizeof(*pinger)); pinger->state = 0; pinger->pongs = 0; @@ -194,9 +194,9 @@ static void pinger_new(void) { pinger->tcp.data = pinger; - ASSERT(0 == uv_tcp_bind(&pinger->tcp, - (const struct sockaddr*) &client_addr, - 0)); + ASSERT_OK(uv_tcp_bind(&pinger->tcp, + (const struct sockaddr*) &client_addr, + 0)); r = uv_tcp_connect(&pinger->connect_req, &pinger->tcp, @@ -214,7 +214,7 @@ BENCHMARK_IMPL(ping_pongs) { pinger_new(); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(completed_pingers == 1); + ASSERT_EQ(1, completed_pingers); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/benchmark-ping-udp.c b/deps/libuv/test/benchmark-ping-udp.c index 3db8765b..2d2fe9c6 100644 --- a/deps/libuv/test/benchmark-ping-udp.c +++ b/deps/libuv/test/benchmark-ping-udp.c @@ -95,11 +95,11 @@ static void pinger_read_cb(uv_udp_t* udp, pinger = (pinger_t*)udp->data; /* No data here means something went wrong */ - ASSERT(nread > 0); + ASSERT_GT(nread, 0); /* Now we count the pings */ for (i = 0; i < nread; i++) { - ASSERT(buf->base[i] == PING[pinger->state]); + ASSERT_EQ(buf->base[i], PING[pinger->state]); pinger->state = (pinger->state + 1) % (sizeof(PING) - 1); if (pinger->state == 0) { pinger->pongs++; @@ -119,15 +119,15 @@ static void udp_pinger_new(void) { pinger_t* pinger = malloc(sizeof(*pinger)); int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &pinger->server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &pinger->server_addr)); pinger->state = 0; pinger->pongs = 0; /* Try to do NUM_PINGS ping-pongs (connection-less). */ r = uv_udp_init(loop, &pinger->udp); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&pinger->udp, (const struct sockaddr*) &pinger->server_addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); pinger->udp.data = pinger; @@ -148,7 +148,7 @@ static int ping_udp(unsigned pingers) { udp_pinger_new(); } uv_run(loop, UV_RUN_DEFAULT); - ASSERT(completed_pingers >= 1); + ASSERT_GE(completed_pingers, 1); fprintf(stderr, "ping_pongs: %d pingers, ~ %lu roundtrips/s\n", completed_pingers, completed_pings / (TIME/1000)); diff --git a/deps/libuv/test/benchmark-pound.c b/deps/libuv/test/benchmark-pound.c index acfe4497..83ce5227 100644 --- a/deps/libuv/test/benchmark-pound.c +++ b/deps/libuv/test/benchmark-pound.c @@ -115,7 +115,7 @@ static void connect_cb(uv_connect_t* req, int status) { } ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); conn = (conn_rec*)req->data; ASSERT_NOT_NULL(conn); @@ -125,13 +125,13 @@ static void connect_cb(uv_connect_t* req, int status) { #endif r = uv_read_start(&conn->stream, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); buf.base = buffer; buf.len = sizeof(buffer) - 1; r = uv_write(&conn->write_req, &conn->stream, &buf, 1, after_write); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -200,9 +200,9 @@ static void tcp_make_connect(conn_rec* p) { tp = (tcp_conn_rec*) p; r = uv_tcp_init(loop, (uv_tcp_t*)&p->stream); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_connect(&tp->conn_req, (uv_tcp_t*) &p->stream, @@ -227,7 +227,7 @@ static void pipe_make_connect(conn_rec* p) { int r; r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_connect(&((pipe_conn_rec*) p)->conn_req, (uv_pipe_t*) &p->stream, diff --git a/deps/libuv/test/benchmark-pump.c b/deps/libuv/test/benchmark-pump.c index 316c6809..8797668e 100644 --- a/deps/libuv/test/benchmark-pump.c +++ b/deps/libuv/test/benchmark-pump.c @@ -159,9 +159,9 @@ static void start_stats_collection(void) { /* Show-stats timer */ stats_left = STATS_COUNT; r = uv_timer_init(loop, &timer_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer_handle, show_stats, STATS_INTERVAL, STATS_INTERVAL); - ASSERT(r == 0); + ASSERT_OK(r); uv_update_time(loop); start_time = uv_now(loop); @@ -170,7 +170,7 @@ static void start_stats_collection(void) { static void read_cb(uv_stream_t* stream, ssize_t bytes, const uv_buf_t* buf) { if (nrecv_total == 0) { - ASSERT(start_time == 0); + ASSERT_OK(start_time); uv_update_time(loop); start_time = uv_now(loop); } @@ -188,7 +188,7 @@ static void read_cb(uv_stream_t* stream, ssize_t bytes, const uv_buf_t* buf) { static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); req_free((uv_req_t*) req); @@ -209,7 +209,7 @@ static void do_write(uv_stream_t* stream) { req = (uv_write_t*) req_alloc(); r = uv_write(req, stream, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -220,7 +220,7 @@ static void connect_cb(uv_connect_t* req, int status) { fprintf(stderr, "%s", uv_strerror(status)); fflush(stderr); } - ASSERT(status == 0); + ASSERT_OK(status); write_sockets++; req_free((uv_req_t*) req); @@ -253,19 +253,19 @@ static void maybe_connect_some(void) { tcp = &tcp_write_handles[max_connect_socket++]; r = uv_tcp_init(loop, tcp); - ASSERT(r == 0); + ASSERT_OK(r); req = (uv_connect_t*) req_alloc(); r = uv_tcp_connect(req, tcp, (const struct sockaddr*) &connect_addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); } else { pipe = &pipe_write_handles[max_connect_socket++]; r = uv_pipe_init(loop, pipe, 0); - ASSERT(r == 0); + ASSERT_OK(r); req = (uv_connect_t*) req_alloc(); uv_pipe_connect(req, pipe, TEST_PIPENAME, connect_cb); @@ -278,24 +278,24 @@ static void connection_cb(uv_stream_t* s, int status) { uv_stream_t* stream; int r; - ASSERT(server == s); - ASSERT(status == 0); + ASSERT_PTR_EQ(server, s); + ASSERT_OK(status); if (type == TCP) { stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t)); r = uv_tcp_init(loop, (uv_tcp_t*)stream); - ASSERT(r == 0); + ASSERT_OK(r); } else { stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t)); r = uv_pipe_init(loop, (uv_pipe_t*)stream, 0); - ASSERT(r == 0); + ASSERT_OK(r); } r = uv_accept(s, stream); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start(stream, buf_alloc, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); read_sockets++; max_read_sockets++; @@ -379,16 +379,16 @@ HELPER_IMPL(tcp_pump_server) { type = TCP; loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &listen_addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &listen_addr)); /* Server */ server = (uv_stream_t*)&tcpServer; r = uv_tcp_init(loop, &tcpServer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcpServer, (const struct sockaddr*) &listen_addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcpServer, MAX_WRITE_HANDLES, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); notify_parent_process(); uv_run(loop, UV_RUN_DEFAULT); @@ -406,11 +406,11 @@ HELPER_IMPL(pipe_pump_server) { /* Server */ server = (uv_stream_t*)&pipeServer; r = uv_pipe_init(loop, &pipeServer, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&pipeServer, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&pipeServer, MAX_WRITE_HANDLES, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); notify_parent_process(); uv_run(loop, UV_RUN_DEFAULT); @@ -421,13 +421,13 @@ HELPER_IMPL(pipe_pump_server) { static void tcp_pump(int n) { - ASSERT(n <= MAX_WRITE_HANDLES); + ASSERT_LE(n, MAX_WRITE_HANDLES); TARGET_CONNECTIONS = n; type = TCP; loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &connect_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &connect_addr)); /* Start making connections */ maybe_connect_some(); @@ -439,7 +439,7 @@ static void tcp_pump(int n) { static void pipe_pump(int n) { - ASSERT(n <= MAX_WRITE_HANDLES); + ASSERT_LE(n, MAX_WRITE_HANDLES); TARGET_CONNECTIONS = n; type = PIPE; diff --git a/deps/libuv/test/benchmark-queue-work.c b/deps/libuv/test/benchmark-queue-work.c index 6e7b74be..5ae08831 100644 --- a/deps/libuv/test/benchmark-queue-work.c +++ b/deps/libuv/test/benchmark-queue-work.c @@ -40,7 +40,7 @@ static void work_cb(uv_work_t* req) { static void after_work_cb(uv_work_t* req, int status) { events++; if (!done) - ASSERT_EQ(0, uv_queue_work(req->loop, req, work_cb, after_work_cb)); + ASSERT_OK(uv_queue_work(req->loop, req, work_cb, after_work_cb)); } static void timer_cb(uv_timer_t* handle) { done = 1; } @@ -55,11 +55,11 @@ BENCHMARK_IMPL(queue_work) { loop = uv_default_loop(); timeout = 5000; - ASSERT_EQ(0, uv_timer_init(loop, &timer_handle)); - ASSERT_EQ(0, uv_timer_start(&timer_handle, timer_cb, timeout, 0)); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, timeout, 0)); - ASSERT_EQ(0, uv_queue_work(loop, &work, work_cb, after_work_cb)); - ASSERT_EQ(0, uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_queue_work(loop, &work, work_cb, after_work_cb)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); printf("%s async jobs in %.1f seconds (%s/s)\n", fmt(&fmtbuf[0], events), diff --git a/deps/libuv/test/benchmark-spawn.c b/deps/libuv/test/benchmark-spawn.c index bdaf6c1a..ef27b385 100644 --- a/deps/libuv/test/benchmark-spawn.c +++ b/deps/libuv/test/benchmark-spawn.c @@ -58,7 +58,7 @@ static void maybe_spawn(void) { static void process_close_cb(uv_handle_t* handle) { - ASSERT(process_open == 1); + ASSERT_EQ(1, process_open); process_open = 0; maybe_spawn(); } @@ -67,8 +67,8 @@ static void process_close_cb(uv_handle_t* handle) { static void exit_cb(uv_process_t* process, int64_t exit_status, int term_signal) { - ASSERT(exit_status == 42); - ASSERT(term_signal == 0); + ASSERT_EQ(42, exit_status); + ASSERT_OK(term_signal); uv_close((uv_handle_t*)process, process_close_cb); } @@ -82,7 +82,7 @@ static void on_alloc(uv_handle_t* handle, static void pipe_close_cb(uv_handle_t* pipe) { - ASSERT(pipe_open == 1); + ASSERT_EQ(1, pipe_open); pipe_open = 0; maybe_spawn(); } @@ -90,7 +90,7 @@ static void pipe_close_cb(uv_handle_t* pipe) { static void on_read(uv_stream_t* pipe, ssize_t nread, const uv_buf_t* buf) { if (nread > 0) { - ASSERT(pipe_open == 1); + ASSERT_EQ(1, pipe_open); output_used += nread; } else if (nread < 0) { if (nread == UV_EOF) { @@ -104,8 +104,8 @@ static void spawn(void) { uv_stdio_container_t stdio[2]; int r; - ASSERT(process_open == 0); - ASSERT(pipe_open == 0); + ASSERT_OK(process_open); + ASSERT_OK(pipe_open); args[0] = exepath; args[1] = "spawn_helper"; @@ -123,14 +123,14 @@ static void spawn(void) { options.stdio[1].data.stream = (uv_stream_t*)&out; r = uv_spawn(loop, &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); process_open = 1; pipe_open = 1; output_used = 0; r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -141,7 +141,7 @@ BENCHMARK_IMPL(spawn) { loop = uv_default_loop(); r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); + ASSERT_OK(r); exepath[exepath_size] = '\0'; uv_update_time(loop); @@ -150,7 +150,7 @@ BENCHMARK_IMPL(spawn) { spawn(); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); uv_update_time(loop); end_time = uv_now(loop); diff --git a/deps/libuv/test/benchmark-tcp-write-batch.c b/deps/libuv/test/benchmark-tcp-write-batch.c index aedefb74..9dfcf14e 100644 --- a/deps/libuv/test/benchmark-tcp-write-batch.c +++ b/deps/libuv/test/benchmark-tcp-write-batch.c @@ -55,16 +55,16 @@ static void connect_cb(uv_connect_t* req, int status) { int i; int r; - ASSERT(req->handle == (uv_stream_t*)&tcp_client); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*)&tcp_client); for (i = 0; i < NUM_WRITE_REQS; i++) { w = &write_reqs[i]; r = uv_write(&w->req, req->handle, &w->buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } r = uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); connect_cb_called++; } @@ -72,14 +72,14 @@ static void connect_cb(uv_connect_t* req, int status) { static void write_cb(uv_write_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); write_cb_called++; } static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*)&tcp_client); - ASSERT(req->handle->write_queue_size == 0); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*)&tcp_client); + ASSERT_OK(req->handle->write_queue_size); uv_close((uv_handle_t*)req->handle, close_cb); free(write_reqs); @@ -89,7 +89,7 @@ static void shutdown_cb(uv_shutdown_t* req, int status) { static void close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*)&tcp_client); + ASSERT_PTR_EQ(handle, (uv_handle_t*)&tcp_client); close_cb_called++; } @@ -112,28 +112,28 @@ BENCHMARK_IMPL(tcp_write_batch) { } loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(loop, &tcp_client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &tcp_client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); start = uv_hrtime(); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); stop = uv_hrtime(); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == NUM_WRITE_REQS); - ASSERT(shutdown_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(write_cb_called, NUM_WRITE_REQS); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, close_cb_called); printf("%ld write requests in %.2fs.\n", (long)NUM_WRITE_REQS, diff --git a/deps/libuv/test/benchmark-thread.c b/deps/libuv/test/benchmark-thread.c index b37a7fd6..b339e7ca 100644 --- a/deps/libuv/test/benchmark-thread.c +++ b/deps/libuv/test/benchmark-thread.c @@ -31,7 +31,7 @@ static volatile int num_threads; static void thread_entry(void* arg) { - ASSERT(arg == (void *) 42); + ASSERT_PTR_EQ(arg, (void *) 42); num_threads++; /* FIXME write barrier? */ } @@ -47,15 +47,15 @@ BENCHMARK_IMPL(thread_create) { for (i = 0; i < NUM_THREADS; i++) { r = uv_thread_create(&tid, thread_entry, (void *) 42); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_thread_join(&tid); - ASSERT(r == 0); + ASSERT_OK(r); } duration = (uv_hrtime() - start_time) / 1e9; - ASSERT(num_threads == NUM_THREADS); + ASSERT_EQ(num_threads, NUM_THREADS); printf("%d threads created in %.2f seconds (%.0f/s)\n", NUM_THREADS, duration, NUM_THREADS / duration); diff --git a/deps/libuv/test/benchmark-udp-pummel.c b/deps/libuv/test/benchmark-udp-pummel.c index f89913b6..7b7e1afa 100644 --- a/deps/libuv/test/benchmark-udp-pummel.c +++ b/deps/libuv/test/benchmark-udp-pummel.c @@ -63,7 +63,7 @@ static void alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { static char slab[65536]; - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -75,7 +75,7 @@ static void send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); if (status != 0) { - ASSERT(status == UV_ECANCELED); + ASSERT_EQ(status, UV_ECANCELED); return; } @@ -83,7 +83,7 @@ static void send_cb(uv_udp_send_t* req, int status) { return; s = container_of(req, struct sender_state, send_req); - ASSERT(req->handle == &s->udp_handle); + ASSERT_PTR_EQ(req->handle, &s->udp_handle); if (timed) goto send; @@ -96,12 +96,12 @@ static void send_cb(uv_udp_send_t* req, int status) { packet_counter--; send: - ASSERT(0 == uv_udp_send(&s->send_req, - &s->udp_handle, - bufs, - ARRAY_SIZE(bufs), - (const struct sockaddr*) &s->addr, - send_cb)); + ASSERT_OK(uv_udp_send(&s->send_req, + &s->udp_handle, + bufs, + ARRAY_SIZE(bufs), + (const struct sockaddr*) &s->addr, + send_cb)); send_cb_called++; } @@ -115,11 +115,11 @@ static void recv_cb(uv_udp_t* handle, return; if (nread < 0) { - ASSERT(nread == UV_ECANCELED); + ASSERT_EQ(nread, UV_ECANCELED); return; } - ASSERT(addr->sa_family == AF_INET); + ASSERT_EQ(addr->sa_family, AF_INET); ASSERT(!memcmp(buf->base, EXPECTED, nread)); recv_cb_called++; @@ -153,8 +153,8 @@ static int pummel(unsigned int n_senders, uv_loop_t* loop; unsigned int i; - ASSERT(n_senders <= ARRAY_SIZE(senders)); - ASSERT(n_receivers <= ARRAY_SIZE(receivers)); + ASSERT_LE(n_senders, ARRAY_SIZE(senders)); + ASSERT_LE(n_receivers, ARRAY_SIZE(receivers)); loop = uv_default_loop(); @@ -162,8 +162,8 @@ static int pummel(unsigned int n_senders, n_receivers_ = n_receivers; if (timeout) { - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timeout_cb, timeout, 0)); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timeout_cb, timeout, 0)); /* Timer should not keep loop alive. */ uv_unref((uv_handle_t*)&timer_handle); timed = 1; @@ -172,10 +172,10 @@ static int pummel(unsigned int n_senders, for (i = 0; i < n_receivers; i++) { struct receiver_state* s = receivers + i; struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", BASE_PORT + i, &addr)); - ASSERT(0 == uv_udp_init(loop, &s->udp_handle)); - ASSERT(0 == uv_udp_bind(&s->udp_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_udp_recv_start(&s->udp_handle, alloc_cb, recv_cb)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", BASE_PORT + i, &addr)); + ASSERT_OK(uv_udp_init(loop, &s->udp_handle)); + ASSERT_OK(uv_udp_bind(&s->udp_handle, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_udp_recv_start(&s->udp_handle, alloc_cb, recv_cb)); uv_unref((uv_handle_t*)&s->udp_handle); } @@ -187,20 +187,20 @@ static int pummel(unsigned int n_senders, for (i = 0; i < n_senders; i++) { struct sender_state* s = senders + i; - ASSERT(0 == uv_ip4_addr("127.0.0.1", - BASE_PORT + (i % n_receivers), - &s->addr)); - ASSERT(0 == uv_udp_init(loop, &s->udp_handle)); - ASSERT(0 == uv_udp_send(&s->send_req, - &s->udp_handle, - bufs, - ARRAY_SIZE(bufs), - (const struct sockaddr*) &s->addr, - send_cb)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", + BASE_PORT + (i % n_receivers), + &s->addr)); + ASSERT_OK(uv_udp_init(loop, &s->udp_handle)); + ASSERT_OK(uv_udp_send(&s->send_req, + &s->udp_handle, + bufs, + ARRAY_SIZE(bufs), + (const struct sockaddr*) &s->addr, + send_cb)); } duration = uv_hrtime(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); duration = uv_hrtime() - duration; /* convert from nanoseconds to milliseconds */ duration = duration / (uint64_t) 1e6; diff --git a/deps/libuv/test/blackhole-server.c b/deps/libuv/test/blackhole-server.c index 0a8758e1..79d6146f 100644 --- a/deps/libuv/test/blackhole-server.c +++ b/deps/libuv/test/blackhole-server.c @@ -43,20 +43,20 @@ static void connection_cb(uv_stream_t* stream, int status) { conn_rec* conn; int r; - ASSERT(status == 0); - ASSERT(stream == (uv_stream_t*)&tcp_server); + ASSERT_OK(status); + ASSERT_PTR_EQ(stream, (uv_stream_t*)&tcp_server); conn = malloc(sizeof *conn); ASSERT_NOT_NULL(conn); r = uv_tcp_init(stream->loop, &conn->handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_accept(stream, (uv_stream_t*)&conn->handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*)&conn->handle, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -76,12 +76,12 @@ static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { if (nread >= 0) return; - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); conn = container_of(stream, conn_rec, handle); r = uv_shutdown(&conn->shutdown_req, stream, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -103,16 +103,16 @@ HELPER_IMPL(tcp4_blackhole_server) { int r; loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(loop, &tcp_server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcp_server, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); notify_parent_process(); r = uv_run(loop, UV_RUN_DEFAULT); diff --git a/deps/libuv/test/echo-server.c b/deps/libuv/test/echo-server.c index 058c9925..572f87df 100644 --- a/deps/libuv/test/echo-server.c +++ b/deps/libuv/test/echo-server.c @@ -65,14 +65,14 @@ static void after_write(uv_write_t* req, int status) { static void after_shutdown(uv_shutdown_t* req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); uv_close((uv_handle_t*) req->handle, on_close); free(req); } static void on_shutdown(uv_shutdown_t* req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); free(req); } @@ -92,7 +92,7 @@ static void after_read(uv_stream_t* handle, free(buf->base); sreq = malloc(sizeof* sreq); if (uv_is_writable(handle)) { - ASSERT_EQ(0, uv_shutdown(sreq, handle, after_shutdown)); + ASSERT_OK(uv_shutdown(sreq, handle, after_shutdown)); } return; } @@ -118,7 +118,7 @@ static void after_read(uv_stream_t* handle, if (i + 2 < nread && buf->base[i + 2] == 'H') reset = 1; if (reset && handle->type == UV_TCP) - ASSERT_EQ(0, uv_tcp_close_reset((uv_tcp_t*) handle, on_close)); + ASSERT_OK(uv_tcp_close_reset((uv_tcp_t*) handle, on_close)); else if (shutdown) break; else @@ -141,7 +141,7 @@ static void after_read(uv_stream_t* handle, } if (shutdown) - ASSERT_EQ(0, uv_shutdown(malloc(sizeof* sreq), handle, on_shutdown)); + ASSERT_OK(uv_shutdown(malloc(sizeof* sreq), handle, on_shutdown)); } @@ -173,21 +173,21 @@ static void on_connection(uv_stream_t* server, int status) { if (status != 0) { fprintf(stderr, "Connect error %s\n", uv_err_name(status)); } - ASSERT(status == 0); + ASSERT_OK(status); switch (serverType) { case TCP: stream = malloc(sizeof(uv_tcp_t)); ASSERT_NOT_NULL(stream); r = uv_tcp_init(loop, (uv_tcp_t*)stream); - ASSERT(r == 0); + ASSERT_OK(r); break; case PIPE: stream = malloc(sizeof(uv_pipe_t)); ASSERT_NOT_NULL(stream); r = uv_pipe_init(loop, (uv_pipe_t*)stream, 0); - ASSERT(r == 0); + ASSERT_OK(r); break; default: @@ -199,15 +199,15 @@ static void on_connection(uv_stream_t* server, int status) { stream->data = server; r = uv_accept(server, stream); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start(stream, echo_alloc, after_read); - ASSERT(r == 0); + ASSERT_OK(r); } static void on_server_close(uv_handle_t* handle) { - ASSERT(handle == server); + ASSERT_PTR_EQ(handle, server); } static uv_udp_send_t* send_alloc(void) { @@ -221,7 +221,7 @@ static uv_udp_send_t* send_alloc(void) { static void on_send(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); req->data = send_freelist; send_freelist = req; } @@ -239,20 +239,20 @@ static void on_recv(uv_udp_t* handle, return; } - ASSERT(nread > 0); - ASSERT(addr->sa_family == AF_INET); + ASSERT_GT(nread, 0); + ASSERT_EQ(addr->sa_family, AF_INET); req = send_alloc(); ASSERT_NOT_NULL(req); sndbuf = uv_buf_init(rcvbuf->base, nread); - ASSERT(0 <= uv_udp_send(req, handle, &sndbuf, 1, addr, on_send)); + ASSERT_LE(0, uv_udp_send(req, handle, &sndbuf, 1, addr, on_send)); } static int tcp4_echo_start(int port) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", port, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", port, &addr)); server = (uv_handle_t*)&tcpServer; serverType = TCP; @@ -286,7 +286,7 @@ static int tcp6_echo_start(int port) { struct sockaddr_in6 addr6; int r; - ASSERT(0 == uv_ip6_addr("::1", port, &addr6)); + ASSERT_OK(uv_ip6_addr("::1", port, &addr6)); server = (uv_handle_t*)&tcpServer; serverType = TCP; @@ -321,7 +321,7 @@ static int udp4_echo_start(int port) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", port, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", port, &addr)); server = (uv_handle_t*)&udpServer; serverType = UDP; diff --git a/deps/libuv/test/run-tests.c b/deps/libuv/test/run-tests.c index d8cfe297..97fec52f 100644 --- a/deps/libuv/test/run-tests.c +++ b/deps/libuv/test/run-tests.c @@ -145,7 +145,7 @@ static int maybe_run_test(int argc, char **argv) { if (strcmp(argv[1], "spawn_helper3") == 0) { char buffer[256]; notify_parent_process(); - ASSERT(buffer == fgets(buffer, sizeof(buffer) - 1, stdin)); + ASSERT_PTR_EQ(buffer, fgets(buffer, sizeof(buffer) - 1, stdin)); buffer[sizeof(buffer) - 1] = '\0'; fputs(buffer, stdout); return 1; @@ -183,10 +183,10 @@ static int maybe_run_test(int argc, char **argv) { notify_parent_process(); r = fprintf(stdout, "hello world\n"); - ASSERT(r > 0); + ASSERT_GT(r, 0); r = fprintf(stderr, "hello errworld\n"); - ASSERT(r > 0); + ASSERT_GT(r, 0); return 1; } @@ -202,7 +202,7 @@ static int maybe_run_test(int argc, char **argv) { ASSERT_NOT_NULL(test); r = fprintf(stdout, "%s", test); - ASSERT(r > 0); + ASSERT_GT(r, 0); return 1; } @@ -216,23 +216,24 @@ static int maybe_run_test(int argc, char **argv) { sCompareObjectHandles pCompareObjectHandles; /* function introduced in Windows 10 */ #endif notify_parent_process(); - ASSERT(sizeof(closed_fd) == read(0, &closed_fd, sizeof(closed_fd))); - ASSERT(sizeof(open_fd) == read(0, &open_fd, sizeof(open_fd))); + ASSERT_EQ(sizeof(closed_fd), read(0, &closed_fd, sizeof(closed_fd))); + ASSERT_EQ(sizeof(open_fd), read(0, &open_fd, sizeof(open_fd))); #ifdef _WIN32 - ASSERT((intptr_t) closed_fd > 0); - ASSERT((intptr_t) open_fd > 0); - ASSERT(0 != GetHandleInformation(open_fd, &flags)); + ASSERT_GT((intptr_t) closed_fd, 0); + ASSERT_GT((intptr_t) open_fd, 0); + ASSERT_NE(0, GetHandleInformation(open_fd, &flags)); kernelbase_module = GetModuleHandleA("kernelbase.dll"); pCompareObjectHandles = (sCompareObjectHandles) GetProcAddress(kernelbase_module, "CompareObjectHandles"); - ASSERT(pCompareObjectHandles == NULL || !pCompareObjectHandles(open_fd, closed_fd)); + ASSERT_NE(pCompareObjectHandles == NULL || \ + !pCompareObjectHandles(open_fd, closed_fd), 0); #else - ASSERT(open_fd > 2); - ASSERT(closed_fd > 2); + ASSERT_GT(open_fd, 2); + ASSERT_GT(closed_fd, 2); # if defined(__PASE__) /* On IBMi PASE, write() returns 1 */ - ASSERT(1 == write(closed_fd, "x", 1)); + ASSERT_EQ(1, write(closed_fd, "x", 1)); # else - ASSERT(-1 == write(closed_fd, "x", 1)); + ASSERT_EQ(-1, write(closed_fd, "x", 1)); # endif /* !__PASE__ */ #endif return 1; @@ -249,8 +250,8 @@ static int maybe_run_test(int argc, char **argv) { uv_uid_t uid = atoi(argv[2]); uv_gid_t gid = atoi(argv[3]); - ASSERT(uid == getuid()); - ASSERT(gid == getgid()); + ASSERT_EQ(uid, getuid()); + ASSERT_EQ(gid, getgid()); notify_parent_process(); return 1; diff --git a/deps/libuv/test/runner-win.c b/deps/libuv/test/runner-win.c index 8c2a00b8..61d6f143 100644 --- a/deps/libuv/test/runner-win.c +++ b/deps/libuv/test/runner-win.c @@ -185,7 +185,7 @@ int process_wait(process_info_t *vec, int n, int timeout) { if (n == 0) return 0; - ASSERT(n <= MAXIMUM_WAIT_OBJECTS); + ASSERT_LE(n, MAXIMUM_WAIT_OBJECTS); for (i = 0; i < n; i++) handles[i] = vec[i].process; @@ -245,7 +245,7 @@ int process_read_last_line(process_info_t *p, DWORD start; OVERLAPPED overlapped; - ASSERT(buffer_len > 0); + ASSERT_GT(buffer_len, 0); size = GetFileSize(p->stdio_out, NULL); if (size == INVALID_FILE_SIZE) diff --git a/deps/libuv/test/task.h b/deps/libuv/test/task.h index fa6cc0ed..8b835326 100644 --- a/deps/libuv/test/task.h +++ b/deps/libuv/test/task.h @@ -244,13 +244,16 @@ typedef enum { #define ASSERT_PTR_NE(a, b) \ ASSERT_BASE(a, !=, b, void*, "p") +#define ASSERT_PTR_LT(a, b) \ + ASSERT_BASE(a, <, b, void*, "p") + /* This macro cleans up the event loop. This is used to avoid valgrind * warnings about memory being "leaked" by the event loop. */ #define MAKE_VALGRIND_HAPPY(loop) \ do { \ close_loop(loop); \ - ASSERT(0 == uv_loop_close(loop)); \ + ASSERT_EQ(0, uv_loop_close(loop)); \ uv_library_shutdown(); \ } while (0) diff --git a/deps/libuv/test/test-active.c b/deps/libuv/test/test-active.c index aaff9708..fadbd10d 100644 --- a/deps/libuv/test/test-active.c +++ b/deps/libuv/test/test-active.c @@ -45,39 +45,39 @@ TEST_IMPL(active) { uv_timer_t timer; r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); /* uv_is_active() and uv_is_closing() should always return either 0 or 1. */ - ASSERT(0 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_active((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &timer)); r = uv_timer_start(&timer, timer_cb, 1000, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(1 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); + ASSERT_EQ(1, uv_is_active((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &timer)); r = uv_timer_stop(&timer); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_active((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &timer)); r = uv_timer_start(&timer, timer_cb, 1000, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(1 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &timer)); + ASSERT_EQ(1, uv_is_active((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &timer)); uv_close((uv_handle_t*) &timer, close_cb); - ASSERT(0 == uv_is_active((uv_handle_t*) &timer)); - ASSERT(1 == uv_is_closing((uv_handle_t*) &timer)); + ASSERT_OK(uv_is_active((uv_handle_t*) &timer)); + ASSERT_EQ(1, uv_is_closing((uv_handle_t*) &timer)); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-async-null-cb.c b/deps/libuv/test/test-async-null-cb.c index 1bdd0e03..ac9fc899 100644 --- a/deps/libuv/test/test-async-null-cb.c +++ b/deps/libuv/test/test-async-null-cb.c @@ -36,7 +36,7 @@ static void thread_cb(void* dummy) { static void check_cb(uv_check_t* handle) { - ASSERT(check_cb_called == 0); + ASSERT_OK(check_cb_called); uv_close((uv_handle_t*) &async_handle, NULL); uv_close((uv_handle_t*) &check_handle, NULL); check_cb_called++; @@ -52,13 +52,13 @@ TEST_IMPL(async_null_cb) { */ memset(&async_handle, 0xff, sizeof(async_handle)); - ASSERT(0 == uv_async_init(uv_default_loop(), &async_handle, NULL)); - ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle)); - ASSERT(0 == uv_check_start(&check_handle, check_cb)); - ASSERT(0 == uv_thread_create(&thread, thread_cb, NULL)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_thread_join(&thread)); - ASSERT(1 == check_cb_called); + ASSERT_OK(uv_async_init(uv_default_loop(), &async_handle, NULL)); + ASSERT_OK(uv_check_init(uv_default_loop(), &check_handle)); + ASSERT_OK(uv_check_start(&check_handle, check_cb)); + ASSERT_OK(uv_thread_create(&thread, thread_cb, NULL)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_thread_join(&thread)); + ASSERT_EQ(1, check_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } diff --git a/deps/libuv/test/test-async.c b/deps/libuv/test/test-async.c index 73664ea5..935436ec 100644 --- a/deps/libuv/test/test-async.c +++ b/deps/libuv/test/test-async.c @@ -49,7 +49,7 @@ static void thread_cb(void *arg) { } r = uv_async_send(&async); - ASSERT(r == 0); + ASSERT_OK(r); /* Work around a bug in Valgrind. * @@ -78,7 +78,7 @@ static void close_cb(uv_handle_t* handle) { static void async_cb(uv_async_t* handle) { int n; - ASSERT(handle == &async); + ASSERT_PTR_EQ(handle, &async); uv_mutex_lock(&mutex); n = ++async_cb_called; @@ -94,13 +94,13 @@ static void async_cb(uv_async_t* handle) { static void prepare_cb(uv_prepare_t* handle) { int r; - ASSERT(handle == &prepare); + ASSERT_PTR_EQ(handle, &prepare); if (prepare_cb_called++) return; r = uv_thread_create(&thread, thread_cb, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_mutex_unlock(&mutex); } @@ -109,25 +109,25 @@ TEST_IMPL(async) { int r; r = uv_mutex_init(&mutex); - ASSERT(r == 0); + ASSERT_OK(r); uv_mutex_lock(&mutex); r = uv_prepare_init(uv_default_loop(), &prepare); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_prepare_start(&prepare, prepare_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_async_init(uv_default_loop(), &async, async_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(prepare_cb_called > 0); - ASSERT(async_cb_called == 3); - ASSERT(close_cb_called == 2); + ASSERT_GT(prepare_cb_called, 0); + ASSERT_EQ(3, async_cb_called); + ASSERT_EQ(2, close_cb_called); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-barrier.c b/deps/libuv/test/test-barrier.c index c780f0cf..5e904c40 100644 --- a/deps/libuv/test/test-barrier.c +++ b/deps/libuv/test/test-barrier.c @@ -53,13 +53,13 @@ TEST_IMPL(barrier_1) { memset(&wc, 0, sizeof(wc)); wc.niter = 1; - ASSERT_EQ(0, uv_barrier_init(&wc.barrier, 2)); - ASSERT_EQ(0, uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_barrier_init(&wc.barrier, 2)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); uv_sleep(100); wc.main_barrier_wait_rval = uv_barrier_wait(&wc.barrier); - ASSERT_EQ(0, uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_barrier_destroy(&wc.barrier); ASSERT_EQ(1, (wc.main_barrier_wait_rval ^ wc.worker_barrier_wait_rval)); @@ -76,12 +76,12 @@ TEST_IMPL(barrier_2) { wc.delay = 100; wc.niter = 1; - ASSERT_EQ(0, uv_barrier_init(&wc.barrier, 2)); - ASSERT_EQ(0, uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_barrier_init(&wc.barrier, 2)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); wc.main_barrier_wait_rval = uv_barrier_wait(&wc.barrier); - ASSERT_EQ(0, uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_barrier_destroy(&wc.barrier); ASSERT_EQ(1, (wc.main_barrier_wait_rval ^ wc.worker_barrier_wait_rval)); @@ -98,13 +98,13 @@ TEST_IMPL(barrier_3) { memset(&wc, 0, sizeof(wc)); wc.niter = 5; - ASSERT_EQ(0, uv_barrier_init(&wc.barrier, 2)); - ASSERT_EQ(0, uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_barrier_init(&wc.barrier, 2)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); for (i = 0; i < wc.niter; i++) wc.main_barrier_wait_rval += uv_barrier_wait(&wc.barrier); - ASSERT_EQ(0, uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_barrier_destroy(&wc.barrier); ASSERT_EQ(wc.niter, wc.main_barrier_wait_rval + wc.worker_barrier_wait_rval); @@ -133,10 +133,10 @@ TEST_IMPL(barrier_serial_thread) { uv_barrier_t barrier; unsigned i; - ASSERT_EQ(0, uv_barrier_init(&barrier, ARRAY_SIZE(threads) + 1)); + ASSERT_OK(uv_barrier_init(&barrier, ARRAY_SIZE(threads) + 1)); for (i = 0; i < ARRAY_SIZE(threads); ++i) - ASSERT_EQ(0, uv_thread_create(&threads[i], serial_worker, &barrier)); + ASSERT_OK(uv_thread_create(&threads[i], serial_worker, &barrier)); for (i = 0; i < 5; i++) uv_barrier_wait(&barrier); @@ -144,7 +144,7 @@ TEST_IMPL(barrier_serial_thread) { uv_barrier_destroy(&barrier); for (i = 0; i < ARRAY_SIZE(threads); ++i) - ASSERT_EQ(0, uv_thread_join(&threads[i])); + ASSERT_OK(uv_thread_join(&threads[i])); return 0; } @@ -153,7 +153,7 @@ TEST_IMPL(barrier_serial_thread) { TEST_IMPL(barrier_serial_thread_single) { uv_barrier_t barrier; - ASSERT_EQ(0, uv_barrier_init(&barrier, 1)); + ASSERT_OK(uv_barrier_init(&barrier, 1)); ASSERT_LT(0, uv_barrier_wait(&barrier)); uv_barrier_destroy(&barrier); return 0; diff --git a/deps/libuv/test/test-callback-stack.c b/deps/libuv/test/test-callback-stack.c index 5dad8d75..dfd102c0 100644 --- a/deps/libuv/test/test-callback-stack.c +++ b/deps/libuv/test/test-callback-stack.c @@ -60,7 +60,7 @@ static void close_cb(uv_handle_t* handle) { static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); ASSERT(nested == 0 && "shutdown_cb must be called from a fresh stack"); shutdown_cb_called++; @@ -77,7 +77,7 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { return; } else if (nread < 0) { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); nested++; uv_close((uv_handle_t*)tcp, close_cb); @@ -105,7 +105,7 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); + ASSERT_PTR_EQ(handle, &timer); ASSERT(nested == 0 && "timer_cb must be called from a fresh stack"); puts("Timeout complete. Now read data..."); @@ -125,7 +125,7 @@ static void timer_cb(uv_timer_t* handle) { static void write_cb(uv_write_t* req, int status) { int r; - ASSERT(status == 0); + ASSERT_OK(status); ASSERT(nested == 0 && "write_cb must be called from a fresh stack"); puts("Data written. 500ms timeout..."); @@ -136,9 +136,9 @@ static void write_cb(uv_write_t* req, int status) { * for the backend to use dirty stack for calling read_cb. */ nested++; r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 500, 0); - ASSERT(r == 0); + ASSERT_OK(r); nested--; write_cb_called++; @@ -150,7 +150,7 @@ static void connect_cb(uv_connect_t* req, int status) { puts("Connected. Write some data to echo server..."); - ASSERT(status == 0); + ASSERT_OK(status); ASSERT(nested == 0 && "connect_cb must be called from a fresh stack"); nested++; @@ -171,7 +171,7 @@ static void connect_cb(uv_connect_t* req, int status) { TEST_IMPL(callback_stack) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); if (uv_tcp_init(uv_default_loop(), &client)) { FATAL("uv_tcp_init failed"); @@ -191,13 +191,18 @@ TEST_IMPL(callback_stack) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(nested == 0); - ASSERT(connect_cb_called == 1 && "connect_cb must be called exactly once"); - ASSERT(write_cb_called == 1 && "write_cb must be called exactly once"); - ASSERT(timer_cb_called == 1 && "timer_cb must be called exactly once"); - ASSERT(bytes_received == sizeof MESSAGE); - ASSERT(shutdown_cb_called == 1 && "shutdown_cb must be called exactly once"); - ASSERT(close_cb_called == 2 && "close_cb must be called exactly twice"); + ASSERT_OK(nested); + ASSERT_NE(connect_cb_called == 1 && \ + "connect_cb must be called exactly once", 0); + ASSERT_NE(write_cb_called == 1 && "write_cb must be called exactly once", + 0); + ASSERT_NE(timer_cb_called == 1 && "timer_cb must be called exactly once", + 0); + ASSERT_EQ(bytes_received, sizeof MESSAGE); + ASSERT_NE(shutdown_cb_called == 1 && \ + "shutdown_cb must be called exactly once", 0); + ASSERT_NE(close_cb_called == 2 && "close_cb must be called exactly twice", + 0); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-close-fd.c b/deps/libuv/test/test-close-fd.c index d8e12653..c072fdbb 100644 --- a/deps/libuv/test/test-close-fd.c +++ b/deps/libuv/test/test-close-fd.c @@ -36,11 +36,11 @@ static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { switch (++read_cb_called) { case 1: - ASSERT(nread == 1); + ASSERT_EQ(1, nread); uv_read_stop(handle); break; case 2: - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); uv_close((uv_handle_t *) handle, NULL); break; default: @@ -55,29 +55,29 @@ TEST_IMPL(close_fd) { uv_file fd[2]; bufs[0] = uv_buf_init("", 1); - ASSERT(0 == uv_pipe(fd, 0, 0)); - ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); - ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); + ASSERT_OK(uv_pipe(fd, 0, 0)); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); + ASSERT_OK(uv_pipe_open(&pipe_handle, fd[0])); /* uv_pipe_open() takes ownership of the file descriptor. */ fd[0] = -1; - ASSERT(1 == uv_fs_write(NULL, &req, fd[1], bufs, 1, -1, NULL)); - ASSERT(1 == req.result); + ASSERT_EQ(1, uv_fs_write(NULL, &req, fd[1], bufs, 1, -1, NULL)); + ASSERT_EQ(1, req.result); uv_fs_req_cleanup(&req); #ifdef _WIN32 - ASSERT(0 == _close(fd[1])); + ASSERT_OK(_close(fd[1])); #else - ASSERT(0 == close(fd[1])); + ASSERT_OK(close(fd[1])); #endif fd[1] = -1; - ASSERT(0 == uv_read_start((uv_stream_t *) &pipe_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == read_cb_called); - ASSERT(0 == uv_is_active((const uv_handle_t *) &pipe_handle)); - ASSERT(0 == uv_read_start((uv_stream_t *) &pipe_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(2 == read_cb_called); - ASSERT(0 != uv_is_closing((const uv_handle_t *) &pipe_handle)); + ASSERT_OK(uv_read_start((uv_stream_t *) &pipe_handle, alloc_cb, read_cb)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, read_cb_called); + ASSERT_OK(uv_is_active((const uv_handle_t *) &pipe_handle)); + ASSERT_OK(uv_read_start((uv_stream_t *) &pipe_handle, alloc_cb, read_cb)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(2, read_cb_called); + ASSERT_NE(0, uv_is_closing((const uv_handle_t *) &pipe_handle)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-close-order.c b/deps/libuv/test/test-close-order.c index 768e1cee..e1aae93b 100644 --- a/deps/libuv/test/test-close-order.c +++ b/deps/libuv/test/test-close-order.c @@ -39,9 +39,9 @@ static void close_cb(uv_handle_t* handle) { /* check_cb should run before any close_cb */ static void check_cb(uv_check_t* handle) { - ASSERT(check_cb_called == 0); - ASSERT(timer_cb_called == 1); - ASSERT(close_cb_called == 0); + ASSERT_OK(check_cb_called); + ASSERT_EQ(1, timer_cb_called); + ASSERT_OK(close_cb_called); uv_close((uv_handle_t*) handle, close_cb); uv_close((uv_handle_t*) &timer_handle2, close_cb); check_cb_called++; @@ -65,15 +65,15 @@ TEST_IMPL(close_order) { uv_timer_init(loop, &timer_handle2); uv_timer_start(&timer_handle2, timer_cb, 100000, 0); - ASSERT(check_cb_called == 0); - ASSERT(close_cb_called == 0); - ASSERT(timer_cb_called == 0); + ASSERT_OK(check_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_OK(timer_cb_called); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(check_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(timer_cb_called == 1); + ASSERT_EQ(1, check_cb_called); + ASSERT_EQ(3, close_cb_called); + ASSERT_EQ(1, timer_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-condvar.c b/deps/libuv/test/test-condvar.c index 61592d0e..2711f8cc 100644 --- a/deps/libuv/test/test-condvar.c +++ b/deps/libuv/test/test-condvar.c @@ -55,10 +55,10 @@ void worker_config_init(worker_config* wc, wc->use_broadcast = use_broadcast; /* Init. */ - ASSERT(0 == uv_sem_init(&wc->sem_waiting, 0)); - ASSERT(0 == uv_sem_init(&wc->sem_signaled, 0)); - ASSERT(0 == uv_cond_init(&wc->cond)); - ASSERT(0 == uv_mutex_init(&wc->mutex)); + ASSERT_OK(uv_sem_init(&wc->sem_waiting, 0)); + ASSERT_OK(uv_sem_init(&wc->sem_signaled, 0)); + ASSERT_OK(uv_cond_init(&wc->cond)); + ASSERT_OK(uv_mutex_init(&wc->mutex)); } void worker_config_destroy(worker_config* wc) { @@ -87,7 +87,7 @@ static void condvar_signal(worker_config* c, int* flag) { uv_mutex_lock(&c->mutex); /* Help waiter differentiate between spurious and legitimate wakeup. */ - ASSERT(*flag == 0); + ASSERT_OK(*flag); *flag = 1; if (c->use_broadcast) @@ -113,7 +113,7 @@ static int condvar_wait(worker_config* c, const int* flag) { do { uv_cond_wait(&c->cond, &c->mutex); } while (*flag == 0); - ASSERT(*flag == 1); + ASSERT_EQ(1, *flag); uv_mutex_unlock(&c->mutex); @@ -130,13 +130,13 @@ TEST_IMPL(condvar_1) { /* Helper signal-then-wait. */ worker_config_init(&wc, 0, condvar_signal, condvar_wait); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); /* We wait-then-signal. */ - ASSERT(0 == wc.wait_cond(&wc, &wc.posted_1)); + ASSERT_OK(wc.wait_cond(&wc, &wc.posted_1)); wc.signal_cond(&wc, &wc.posted_2); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); worker_config_destroy(&wc); return 0; @@ -149,13 +149,13 @@ TEST_IMPL(condvar_2) { /* Helper to signal-then-wait. */ worker_config_init(&wc, 1, condvar_signal, condvar_wait); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); /* We wait-then-signal. */ - ASSERT(0 == wc.wait_cond(&wc, &wc.posted_1)); + ASSERT_OK(wc.wait_cond(&wc, &wc.posted_1)); wc.signal_cond(&wc, &wc.posted_2); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); worker_config_destroy(&wc); return 0; @@ -176,9 +176,9 @@ static int condvar_timedwait(worker_config* c, const int* flag) { /* Wait until I get a non-spurious signal. */ do { r = uv_cond_timedwait(&c->cond, &c->mutex, (uint64_t)(1 * 1e9)); /* 1 s */ - ASSERT(r == 0); /* Should not time out. */ + ASSERT_OK(r); /* Should not time out. */ } while (*flag == 0); - ASSERT(*flag == 1); + ASSERT_EQ(1, *flag); uv_mutex_unlock(&c->mutex); @@ -194,13 +194,13 @@ TEST_IMPL(condvar_3) { /* Helper to signal-then-wait. */ worker_config_init(&wc, 0, condvar_signal, condvar_timedwait); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); /* We wait-then-signal. */ wc.wait_cond(&wc, &wc.posted_1); wc.signal_cond(&wc, &wc.posted_2); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); worker_config_destroy(&wc); return 0; @@ -213,13 +213,13 @@ TEST_IMPL(condvar_4) { /* Helper to signal-then-wait. */ worker_config_init(&wc, 1, condvar_signal, condvar_timedwait); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); /* We wait-then-signal. */ wc.wait_cond(&wc, &wc.posted_1); wc.signal_cond(&wc, &wc.posted_2); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); worker_config_destroy(&wc); return 0; diff --git a/deps/libuv/test/test-connect-unspecified.c b/deps/libuv/test/test-connect-unspecified.c index ecbe9853..73e59a99 100644 --- a/deps/libuv/test/test-connect-unspecified.c +++ b/deps/libuv/test/test-connect-unspecified.c @@ -23,11 +23,11 @@ #include "task.h" static void connect_4(uv_connect_t* req, int status) { - ASSERT(status != UV_EADDRNOTAVAIL); + ASSERT_NE(status, UV_EADDRNOTAVAIL); } static void connect_6(uv_connect_t* req, int status) { - ASSERT(status != UV_EADDRNOTAVAIL); + ASSERT_NE(status, UV_EADDRNOTAVAIL); } TEST_IMPL(connect_unspecified) { @@ -41,23 +41,23 @@ TEST_IMPL(connect_unspecified) { loop = uv_default_loop(); - ASSERT(uv_tcp_init(loop, &socket4) == 0); - ASSERT(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr4) == 0); - ASSERT(uv_tcp_connect(&connect4, - &socket4, - (const struct sockaddr*) &addr4, - connect_4) == 0); + ASSERT_OK(uv_tcp_init(loop, &socket4)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr4)); + ASSERT_OK(uv_tcp_connect(&connect4, + &socket4, + (const struct sockaddr*) &addr4, + connect_4)); if (can_ipv6()) { - ASSERT(uv_tcp_init(loop, &socket6) == 0); - ASSERT(uv_ip6_addr("::", TEST_PORT, &addr6) == 0); - ASSERT(uv_tcp_connect(&connect6, - &socket6, - (const struct sockaddr*) &addr6, - connect_6) == 0); + ASSERT_OK(uv_tcp_init(loop, &socket6)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &addr6)); + ASSERT_OK(uv_tcp_connect(&connect6, + &socket6, + (const struct sockaddr*) &addr6, + connect_6)); } - ASSERT(uv_run(loop, UV_RUN_DEFAULT) == 0); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-connection-fail.c b/deps/libuv/test/test-connection-fail.c index aa7db30d..9efd3ac9 100644 --- a/deps/libuv/test/test-connection-fail.c +++ b/deps/libuv/test/test-connection-fail.c @@ -54,8 +54,8 @@ static void timer_cb(uv_timer_t* handle) { * but libuv hasn't automatically closed the socket. The user must * uv_close the handle manually. */ - ASSERT(close_cb_calls == 0); - ASSERT(connect_cb_calls == 1); + ASSERT_OK(close_cb_calls); + ASSERT_EQ(1, connect_cb_calls); /* Close the tcp handle. */ uv_close((uv_handle_t*)&tcp, on_close); @@ -66,22 +66,22 @@ static void timer_cb(uv_timer_t* handle) { static void on_connect_with_close(uv_connect_t *req, int status) { - ASSERT((uv_stream_t*) &tcp == req->handle); - ASSERT(status == UV_ECONNREFUSED); + ASSERT_PTR_EQ((uv_stream_t*) &tcp, req->handle); + ASSERT_EQ(status, UV_ECONNREFUSED); connect_cb_calls++; - ASSERT(close_cb_calls == 0); + ASSERT_OK(close_cb_calls); uv_close((uv_handle_t*)req->handle, on_close); } static void on_connect_without_close(uv_connect_t *req, int status) { - ASSERT(status == UV_ECONNREFUSED); + ASSERT_EQ(status, UV_ECONNREFUSED); connect_cb_calls++; uv_timer_start(&timer, timer_cb, 100, 0); - ASSERT(close_cb_calls == 0); + ASSERT_OK(close_cb_calls); } @@ -89,10 +89,10 @@ static void connection_fail(uv_connect_cb connect_cb) { struct sockaddr_in client_addr, server_addr; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &client_addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", 0, &client_addr)); /* There should be no servers listening on this port. */ - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); /* Try to connect to the server and do NUM_PINGS ping-pongs. */ r = uv_tcp_init(uv_default_loop(), &tcp); @@ -100,7 +100,7 @@ static void connection_fail(uv_connect_cb connect_cb) { /* We are never doing multiple reads/connects at a time anyway. so these * handles can be pre-initialized. */ - ASSERT(0 == uv_tcp_bind(&tcp, (const struct sockaddr*) &client_addr, 0)); + ASSERT_OK(uv_tcp_bind(&tcp, (const struct sockaddr*) &client_addr, 0)); r = uv_tcp_connect(&req, &tcp, @@ -110,8 +110,8 @@ static void connection_fail(uv_connect_cb connect_cb) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_calls == 1); - ASSERT(close_cb_calls == 1); + ASSERT_EQ(1, connect_cb_calls); + ASSERT_EQ(1, close_cb_calls); } @@ -127,8 +127,8 @@ TEST_IMPL(connection_fail) { connection_fail(on_connect_with_close); - ASSERT(timer_close_cb_calls == 0); - ASSERT(timer_cb_calls == 0); + ASSERT_OK(timer_close_cb_calls); + ASSERT_OK(timer_cb_calls); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -149,12 +149,12 @@ TEST_IMPL(connection_fail_doesnt_auto_close) { int r; r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); connection_fail(on_connect_without_close); - ASSERT(timer_close_cb_calls == 1); - ASSERT(timer_cb_calls == 1); + ASSERT_EQ(1, timer_close_cb_calls); + ASSERT_EQ(1, timer_cb_calls); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-cwd-and-chdir.c b/deps/libuv/test/test-cwd-and-chdir.c index faeed021..e4a0eef0 100644 --- a/deps/libuv/test/test-cwd-and-chdir.c +++ b/deps/libuv/test/test-cwd-and-chdir.c @@ -34,24 +34,24 @@ TEST_IMPL(cwd_and_chdir) { size1 = 1; err = uv_cwd(buffer_orig, &size1); - ASSERT(err == UV_ENOBUFS); - ASSERT(size1 > 1); + ASSERT_EQ(err, UV_ENOBUFS); + ASSERT_GT(size1, 1); size1 = sizeof buffer_orig; err = uv_cwd(buffer_orig, &size1); - ASSERT(err == 0); - ASSERT(size1 > 0); - ASSERT(buffer_orig[size1] != '/'); + ASSERT_OK(err); + ASSERT_GT(size1, 0); + ASSERT_NE(buffer_orig[size1], '/'); err = uv_chdir(buffer_orig); - ASSERT(err == 0); + ASSERT_OK(err); size2 = sizeof buffer_new; err = uv_cwd(buffer_new, &size2); - ASSERT(err == 0); + ASSERT_OK(err); - ASSERT(size1 == size2); - ASSERT(strcmp(buffer_orig, buffer_new) == 0); + ASSERT_EQ(size1, size2); + ASSERT_OK(strcmp(buffer_orig, buffer_new)); return 0; } diff --git a/deps/libuv/test/test-default-loop-close.c b/deps/libuv/test/test-default-loop-close.c index 8d960e11..d08a33ea 100644 --- a/deps/libuv/test/test-default-loop-close.c +++ b/deps/libuv/test/test-default-loop-close.c @@ -39,19 +39,19 @@ TEST_IMPL(default_loop_close) { loop = uv_default_loop(); ASSERT_NOT_NULL(loop); - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - ASSERT(0 == uv_loop_close(loop)); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 1, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, timer_cb_called); + ASSERT_OK(uv_loop_close(loop)); loop = uv_default_loop(); ASSERT_NOT_NULL(loop); - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(2 == timer_cb_called); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 1, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(2, timer_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-delayed-accept.c b/deps/libuv/test/test-delayed-accept.c index c1d6ce0b..f7cf80ab 100644 --- a/deps/libuv/test/test-delayed-accept.c +++ b/deps/libuv/test/test-delayed-accept.c @@ -54,11 +54,11 @@ static void do_accept(uv_timer_t* timer_handle) { ASSERT_NOT_NULL(accepted_handle); r = uv_tcp_init(uv_default_loop(), accepted_handle); - ASSERT(r == 0); + ASSERT_OK(r); server = (uv_tcp_t*)timer_handle->data; r = uv_accept((uv_stream_t*)server, (uv_stream_t*)accepted_handle); - ASSERT(r == 0); + ASSERT_OK(r); do_accept_called++; @@ -79,19 +79,19 @@ static void connection_cb(uv_stream_t* tcp, int status) { int r; uv_timer_t* timer_handle; - ASSERT(status == 0); + ASSERT_OK(status); timer_handle = (uv_timer_t*)malloc(sizeof *timer_handle); ASSERT_NOT_NULL(timer_handle); /* Accept the client after 1 second */ r = uv_timer_init(uv_default_loop(), timer_handle); - ASSERT(r == 0); + ASSERT_OK(r); timer_handle->data = tcp; r = uv_timer_start(timer_handle, do_accept, 1000, 0); - ASSERT(r == 0); + ASSERT_OK(r); connection_cb_called++; } @@ -102,16 +102,16 @@ static void start_server(void) { uv_tcp_t* server = (uv_tcp_t*)malloc(sizeof *server); int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); ASSERT_NOT_NULL(server); r = uv_tcp_init(uv_default_loop(), server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)server, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -123,10 +123,10 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { } if (nread >= 0) { - ASSERT(nread == 0); + ASSERT_OK(nread); } else { ASSERT_NOT_NULL(tcp); - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); uv_close((uv_handle_t*)tcp, close_cb); } } @@ -136,12 +136,12 @@ static void connect_cb(uv_connect_t* req, int status) { int r; ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); /* Not that the server will send anything, but otherwise we'll never know * when the server closes the connection. */ r = uv_read_start((uv_stream_t*)(req->handle), alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); connect_cb_called++; @@ -155,18 +155,18 @@ static void client_connect(void) { uv_connect_t* connect_req = malloc(sizeof *connect_req); int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); ASSERT_NOT_NULL(client); ASSERT_NOT_NULL(connect_req); r = uv_tcp_init(uv_default_loop(), client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(connect_req, client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -179,10 +179,10 @@ TEST_IMPL(delayed_accept) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connection_cb_called == 2); - ASSERT(do_accept_called == 2); - ASSERT(connect_cb_called == 2); - ASSERT(close_cb_called == 7); + ASSERT_EQ(2, connection_cb_called); + ASSERT_EQ(2, do_accept_called); + ASSERT_EQ(2, connect_cb_called); + ASSERT_EQ(7, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-dlerror.c b/deps/libuv/test/test-dlerror.c index 631e67cc..dec0da3a 100644 --- a/deps/libuv/test/test-dlerror.c +++ b/deps/libuv/test/test-dlerror.c @@ -38,7 +38,7 @@ TEST_IMPL(dlerror) { ASSERT_NOT_NULL(strstr(msg, dlerror_no_error)); r = uv_dlopen(path, &lib); - ASSERT(r == -1); + ASSERT_EQ(r, -1); msg = uv_dlerror(&lib); ASSERT_NOT_NULL(msg); diff --git a/deps/libuv/test/test-eintr-handling.c b/deps/libuv/test/test-eintr-handling.c index d37aba4a..1f75e77e 100644 --- a/deps/libuv/test/test-eintr-handling.c +++ b/deps/libuv/test/test-eintr-handling.c @@ -48,13 +48,13 @@ struct thread_ctx { static void thread_main(void* arg) { int nwritten; - ASSERT(0 == kill(getpid(), SIGUSR1)); + ASSERT_OK(kill(getpid(), SIGUSR1)); do nwritten = write(pipe_fds[1], test_buf, sizeof(test_buf)); while (nwritten == -1 && errno == EINTR); - ASSERT(nwritten == sizeof(test_buf)); + ASSERT_EQ(nwritten, sizeof(test_buf)); } static void sig_func(uv_signal_t* handle, int signum) { @@ -70,24 +70,24 @@ TEST_IMPL(eintr_handling) { iov = uv_buf_init(buf, sizeof(buf)); loop = uv_default_loop(); - ASSERT(0 == uv_signal_init(loop, &signal)); - ASSERT(0 == uv_signal_start(&signal, sig_func, SIGUSR1)); + ASSERT_OK(uv_signal_init(loop, &signal)); + ASSERT_OK(uv_signal_start(&signal, sig_func, SIGUSR1)); - ASSERT(0 == pipe(pipe_fds)); - ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); + ASSERT_OK(pipe(pipe_fds)); + ASSERT_OK(uv_thread_create(&thread, thread_main, &ctx)); nread = uv_fs_read(loop, &read_req, pipe_fds[0], &iov, 1, -1, NULL); - ASSERT(nread == sizeof(test_buf)); - ASSERT(0 == strcmp(buf, test_buf)); + ASSERT_EQ(nread, sizeof(test_buf)); + ASSERT_OK(strcmp(buf, test_buf)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(0 == close(pipe_fds[0])); - ASSERT(0 == close(pipe_fds[1])); + ASSERT_OK(close(pipe_fds[0])); + ASSERT_OK(close(pipe_fds[1])); uv_close((uv_handle_t*) &signal, NULL); - ASSERT_EQ(0, uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-embed.c b/deps/libuv/test/test-embed.c index bbe56e17..6e991723 100644 --- a/deps/libuv/test/test-embed.c +++ b/deps/libuv/test/test-embed.c @@ -36,7 +36,7 @@ static uv_barrier_t barrier; static void thread_main(void* arg) { ASSERT_LE(0, uv_barrier_wait(&barrier)); uv_sleep(250); - ASSERT_EQ(0, uv_async_send(&async)); + ASSERT_OK(uv_async_send(&async)); } @@ -50,9 +50,9 @@ TEST_IMPL(embed) { uv_loop_t* loop; loop = uv_default_loop(); - ASSERT_EQ(0, uv_async_init(loop, &async, async_cb)); - ASSERT_EQ(0, uv_barrier_init(&barrier, 2)); - ASSERT_EQ(0, uv_thread_create(&thread, thread_main, NULL)); + ASSERT_OK(uv_async_init(loop, &async, async_cb)); + ASSERT_OK(uv_barrier_init(&barrier, 2)); + ASSERT_OK(uv_thread_create(&thread, thread_main, NULL)); ASSERT_LE(0, uv_barrier_wait(&barrier)); while (uv_loop_alive(loop)) { @@ -71,7 +71,7 @@ TEST_IMPL(embed) { #endif } - ASSERT_EQ(0, uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_barrier_destroy(&barrier); MAKE_VALGRIND_HAPPY(loop); diff --git a/deps/libuv/test/test-emfile.c b/deps/libuv/test/test-emfile.c index 343c9521..ef2338cd 100644 --- a/deps/libuv/test/test-emfile.c +++ b/deps/libuv/test/test-emfile.c @@ -54,37 +54,37 @@ TEST_IMPL(emfile) { /* Lower the file descriptor limit and use up all fds save one. */ limits.rlim_cur = limits.rlim_max = maxfd + 1; if (setrlimit(RLIMIT_NOFILE, &limits)) { - ASSERT(errno == EPERM); /* Valgrind blocks the setrlimit() call. */ + ASSERT_EQ(errno, EPERM); /* Valgrind blocks the setrlimit() call. */ RETURN_SKIP("setrlimit(RLIMIT_NOFILE) failed, running under valgrind?"); } loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 8, connection_cb)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_tcp_init(loop, &server_handle)); + ASSERT_OK(uv_tcp_init(loop, &client_handle)); + ASSERT_OK(uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server_handle, 8, connection_cb)); /* Remember the first one so we can clean up afterwards. */ do first_fd = dup(0); while (first_fd == -1 && errno == EINTR); - ASSERT(first_fd > 0); + ASSERT_GT(first_fd, 0); while (dup(0) != -1 || errno == EINTR); - ASSERT(errno == EMFILE); + ASSERT_EQ(errno, EMFILE); close(maxfd); /* Now connect and use up the last available file descriptor. The EMFILE * handling logic in src/unix/stream.c should ensure that connect_cb() runs * whereas connection_cb() should *not* run. */ - ASSERT(0 == uv_tcp_connect(&connect_req, - &client_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == connect_cb_called); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client_handle, + (const struct sockaddr*) &addr, + connect_cb)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, connect_cb_called); /* Close the dups again. Ignore errors in the unlikely event that the * file descriptors were not contiguous. @@ -108,7 +108,7 @@ static void connect_cb(uv_connect_t* req, int status) { /* |status| should equal 0 because the connection should have been accepted, * it's just that the server immediately closes it again. */ - ASSERT(0 == status); + ASSERT_OK(status); connect_cb_called += 1; uv_close((uv_handle_t*) &server_handle, NULL); uv_close((uv_handle_t*) &client_handle, NULL); diff --git a/deps/libuv/test/test-env-vars.c b/deps/libuv/test/test-env-vars.c index 8118e3da..016f0733 100644 --- a/deps/libuv/test/test-env-vars.c +++ b/deps/libuv/test/test-env-vars.c @@ -35,83 +35,83 @@ TEST_IMPL(env_vars) { /* Reject invalid inputs when setting an environment variable */ r = uv_os_setenv(NULL, "foo"); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_setenv(name, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_setenv(NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Reject invalid inputs when retrieving an environment variable */ size = BUF_SIZE; r = uv_os_getenv(NULL, buf, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_getenv(name, NULL, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_getenv(name, buf, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); size = 0; r = uv_os_getenv(name, buf, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Reject invalid inputs when deleting an environment variable */ r = uv_os_unsetenv(NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Successfully set an environment variable */ r = uv_os_setenv(name, "123456789"); - ASSERT(r == 0); + ASSERT_OK(r); /* Successfully read an environment variable */ size = BUF_SIZE; buf[0] = '\0'; r = uv_os_getenv(name, buf, &size); - ASSERT(r == 0); - ASSERT(strcmp(buf, "123456789") == 0); - ASSERT(size == BUF_SIZE - 1); + ASSERT_OK(r); + ASSERT_OK(strcmp(buf, "123456789")); + ASSERT_EQ(size, BUF_SIZE - 1); /* Return UV_ENOBUFS if the buffer cannot hold the environment variable */ size = BUF_SIZE - 1; buf[0] = '\0'; r = uv_os_getenv(name, buf, &size); - ASSERT(r == UV_ENOBUFS); - ASSERT(size == BUF_SIZE); + ASSERT_EQ(r, UV_ENOBUFS); + ASSERT_EQ(size, BUF_SIZE); /* Successfully delete an environment variable */ r = uv_os_unsetenv(name); - ASSERT(r == 0); + ASSERT_OK(r); /* Return UV_ENOENT retrieving an environment variable that does not exist */ r = uv_os_getenv(name, buf, &size); - ASSERT(r == UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); /* Successfully delete an environment variable that does not exist */ r = uv_os_unsetenv(name); - ASSERT(r == 0); + ASSERT_OK(r); /* Setting an environment variable to the empty string does not delete it. */ r = uv_os_setenv(name, ""); - ASSERT(r == 0); + ASSERT_OK(r); size = BUF_SIZE; r = uv_os_getenv(name, buf, &size); - ASSERT(r == 0); - ASSERT(size == 0); - ASSERT(strlen(buf) == 0); + ASSERT_OK(r); + ASSERT_OK(size); + ASSERT_OK(strlen(buf)); /* Check getting all env variables. */ r = uv_os_setenv(name, "123456789"); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_os_setenv(name2, ""); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 /* Create a special environment variable on Windows in case there are no naturally occurring ones. */ r = uv_os_setenv("=Z:", "\\"); - ASSERT(r == 0); + ASSERT_OK(r); #endif r = uv_os_environ(&envitems, &envcount); - ASSERT(r == 0); - ASSERT(envcount > 0); + ASSERT_OK(r); + ASSERT_GT(envcount, 0); found = 0; found_win_special = 0; @@ -120,16 +120,16 @@ TEST_IMPL(env_vars) { /* printf("Env: %s = %s\n", envitems[i].name, envitems[i].value); */ if (strcmp(envitems[i].name, name) == 0) { found++; - ASSERT(strcmp(envitems[i].value, "123456789") == 0); + ASSERT_OK(strcmp(envitems[i].value, "123456789")); } else if (strcmp(envitems[i].name, name2) == 0) { found++; - ASSERT(strlen(envitems[i].value) == 0); + ASSERT_OK(strlen(envitems[i].value)); } else if (envitems[i].name[0] == '=') { found_win_special++; } } - ASSERT(found == 2); + ASSERT_EQ(2, found); #ifdef _WIN32 ASSERT_GT(found_win_special, 0); #else @@ -140,10 +140,10 @@ TEST_IMPL(env_vars) { uv_os_free_environ(envitems, envcount); r = uv_os_unsetenv(name); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_os_unsetenv(name2); - ASSERT(r == 0); + ASSERT_OK(r); for (i = 1; i <= 4; i++) { size_t n; @@ -158,14 +158,14 @@ TEST_IMPL(env_vars) { memset(p, 'x', n); p[n] = '\0'; - ASSERT_EQ(0, uv_os_setenv(name, p)); - ASSERT_EQ(0, uv_os_getenv(name, p, &size)); + ASSERT_OK(uv_os_setenv(name, p)); + ASSERT_OK(uv_os_getenv(name, p, &size)); ASSERT_EQ(n, size); for (n = 0; n < size; n++) ASSERT_EQ('x', p[n]); - ASSERT_EQ(0, uv_os_unsetenv(name)); + ASSERT_OK(uv_os_unsetenv(name)); free(p); } diff --git a/deps/libuv/test/test-error.c b/deps/libuv/test/test-error.c index f0fb8646..2c6d0ca4 100644 --- a/deps/libuv/test/test-error.c +++ b/deps/libuv/test/test-error.c @@ -51,8 +51,8 @@ TEST_IMPL(error_message) { } ASSERT_NULL(strstr(uv_strerror(UV_EINVAL), "Success")); - ASSERT(strcmp(uv_strerror(1337), "Unknown error") == 0); - ASSERT(strcmp(uv_strerror(-1337), "Unknown error") == 0); + ASSERT_OK(strcmp(uv_strerror(1337), "Unknown error")); + ASSERT_OK(strcmp(uv_strerror(-1337), "Unknown error")); ASSERT_NULL(strstr(uv_strerror_r(UV_EINVAL, buf, sizeof(buf)), "Success")); ASSERT_NOT_NULL(strstr(uv_strerror_r(1337, buf, sizeof(buf)), "1337")); @@ -64,19 +64,19 @@ TEST_IMPL(error_message) { TEST_IMPL(sys_error) { #if defined(_WIN32) - ASSERT(uv_translate_sys_error(ERROR_NOACCESS) == UV_EACCES); - ASSERT(uv_translate_sys_error(ERROR_ELEVATION_REQUIRED) == UV_EACCES); - ASSERT(uv_translate_sys_error(WSAEADDRINUSE) == UV_EADDRINUSE); - ASSERT(uv_translate_sys_error(ERROR_BAD_PIPE) == UV_EPIPE); + ASSERT_EQ(uv_translate_sys_error(ERROR_NOACCESS), UV_EACCES); + ASSERT_EQ(uv_translate_sys_error(ERROR_ELEVATION_REQUIRED), UV_EACCES); + ASSERT_EQ(uv_translate_sys_error(WSAEADDRINUSE), UV_EADDRINUSE); + ASSERT_EQ(uv_translate_sys_error(ERROR_BAD_PIPE), UV_EPIPE); #else - ASSERT(uv_translate_sys_error(EPERM) == UV_EPERM); - ASSERT(uv_translate_sys_error(EPIPE) == UV_EPIPE); - ASSERT(uv_translate_sys_error(EINVAL) == UV_EINVAL); + ASSERT_EQ(uv_translate_sys_error(EPERM), UV_EPERM); + ASSERT_EQ(uv_translate_sys_error(EPIPE), UV_EPIPE); + ASSERT_EQ(uv_translate_sys_error(EINVAL), UV_EINVAL); #endif - ASSERT(uv_translate_sys_error(UV_EINVAL) == UV_EINVAL); - ASSERT(uv_translate_sys_error(UV_ERANGE) == UV_ERANGE); - ASSERT(uv_translate_sys_error(UV_EACCES) == UV_EACCES); - ASSERT(uv_translate_sys_error(0) == 0); + ASSERT_EQ(uv_translate_sys_error(UV_EINVAL), UV_EINVAL); + ASSERT_EQ(uv_translate_sys_error(UV_ERANGE), UV_ERANGE); + ASSERT_EQ(uv_translate_sys_error(UV_EACCES), UV_EACCES); + ASSERT_OK(uv_translate_sys_error(0)); return 0; } diff --git a/deps/libuv/test/test-fork.c b/deps/libuv/test/test-fork.c index 29ed132a..fe42f03d 100644 --- a/deps/libuv/test/test-fork.c +++ b/deps/libuv/test/test-fork.c @@ -51,12 +51,12 @@ static char socket_cb_read_buf[1024]; static void socket_cb(uv_poll_t* poll, int status, int events) { ssize_t cnt; socket_cb_called++; - ASSERT(0 == status); + ASSERT_OK(status); printf("Socket cb got events %d\n", events); - ASSERT(UV_READABLE == (events & UV_READABLE)); + ASSERT_EQ(UV_READABLE, (events & UV_READABLE)); if (socket_cb_read_fd) { cnt = read(socket_cb_read_fd, socket_cb_read_buf, socket_cb_read_size); - ASSERT(cnt == socket_cb_read_size); + ASSERT_EQ(cnt, socket_cb_read_size); } uv_close((uv_handle_t*) poll, NULL); } @@ -66,15 +66,15 @@ static void run_timer_loop_once(void) { uv_loop_t loop; uv_timer_t timer_handle; - ASSERT_EQ(0, uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); timer_cb_called = 0; /* Reset for the child. */ - ASSERT(0 == uv_timer_init(&loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - ASSERT_EQ(0, uv_loop_close(&loop)); + ASSERT_OK(uv_timer_init(&loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 1, 0)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, timer_cb_called); + ASSERT_OK(uv_loop_close(&loop)); } @@ -87,10 +87,10 @@ static void assert_wait_child(pid_t child_pid) { if (waited_pid == -1) { perror("Failed to wait"); } - ASSERT(child_pid == waited_pid); + ASSERT_EQ(child_pid, waited_pid); ASSERT(WIFEXITED(child_stat)); /* Clean exit, not a signal. */ ASSERT(!WIFSIGNALED(child_stat)); - ASSERT(0 == WEXITSTATUS(child_stat)); + ASSERT_OK(WEXITSTATUS(child_stat)); } @@ -109,14 +109,14 @@ TEST_IMPL(fork_timer) { #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ assert_wait_child(child_pid); } else { /* child */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); + ASSERT_OK(uv_loop_fork(uv_default_loop())); run_timer_loop_once(); } @@ -135,30 +135,30 @@ TEST_IMPL(fork_socketpair) { /* Prime the loop. */ run_timer_loop_once(); - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds)); + ASSERT_OK(socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds)); /* Create the server watcher in the parent, use it in the child. */ - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, socket_fds[0])); + ASSERT_OK(uv_poll_init(uv_default_loop(), &poll_handle, socket_fds[0])); #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) child_pid = -1; #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ - ASSERT(3 == send(socket_fds[1], "hi\n", 3, 0)); + ASSERT_EQ(3, send(socket_fds[1], "hi\n", 3, 0)); assert_wait_child(child_pid); } else { /* child */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - ASSERT(0 == socket_cb_called); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, socket_cb)); + ASSERT_OK(uv_loop_fork(uv_default_loop())); + ASSERT_OK(socket_cb_called); + ASSERT_OK(uv_poll_start(&poll_handle, UV_READABLE, socket_cb)); printf("Going to run the loop in the child\n"); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == socket_cb_called); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, socket_cb_called); } MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -176,57 +176,57 @@ TEST_IMPL(fork_socketpair_started) { char sync_buf[1]; uv_poll_t poll_handle; - ASSERT(0 == pipe(sync_pipe)); + ASSERT_OK(pipe(sync_pipe)); /* Prime the loop. */ run_timer_loop_once(); - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds)); + ASSERT_OK(socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds)); /* Create and start the server watcher in the parent, use it in the child. */ - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, socket_fds[0])); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, socket_cb)); + ASSERT_OK(uv_poll_init(uv_default_loop(), &poll_handle, socket_fds[0])); + ASSERT_OK(uv_poll_start(&poll_handle, UV_READABLE, socket_cb)); /* Run the loop AFTER the poll watcher is registered to make sure it gets passed to the kernel. Use NOWAIT and expect a non-zero return to prove the poll watcher is active. */ - ASSERT(1 == uv_run(uv_default_loop(), UV_RUN_NOWAIT)); + ASSERT_EQ(1, uv_run(uv_default_loop(), UV_RUN_NOWAIT)); #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) child_pid = -1; #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ - ASSERT(0 == uv_poll_stop(&poll_handle)); + ASSERT_OK(uv_poll_stop(&poll_handle)); uv_close((uv_handle_t*)&poll_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == socket_cb_called); - ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert child */ - ASSERT(3 == send(socket_fds[1], "hi\n", 3, 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(socket_cb_called); + ASSERT_EQ(1, write(sync_pipe[1], "1", 1)); /* alert child */ + ASSERT_EQ(3, send(socket_fds[1], "hi\n", 3, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == socket_cb_called); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(socket_cb_called); assert_wait_child(child_pid); } else { /* child */ printf("Child is %d\n", getpid()); - ASSERT(1 == read(sync_pipe[0], sync_buf, 1)); /* wait for parent */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - ASSERT(0 == socket_cb_called); + ASSERT_EQ(1, read(sync_pipe[0], sync_buf, 1)); /* wait for parent */ + ASSERT_OK(uv_loop_fork(uv_default_loop())); + ASSERT_OK(socket_cb_called); printf("Going to run the loop in the child\n"); socket_cb_read_fd = socket_fds[0]; socket_cb_read_size = 3; - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == socket_cb_called); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, socket_cb_called); printf("Buf %s\n", socket_cb_read_buf); - ASSERT(0 == strcmp("hi\n", socket_cb_read_buf)); + ASSERT_OK(strcmp("hi\n", socket_cb_read_buf)); } MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -253,41 +253,43 @@ TEST_IMPL(fork_signal_to_child) { fork_signal_cb_called = 0; /* reset */ - ASSERT(0 == pipe(sync_pipe)); + ASSERT_OK(pipe(sync_pipe)); /* Prime the loop. */ run_timer_loop_once(); - ASSERT(0 == uv_signal_init(uv_default_loop(), &signal_handle)); - ASSERT(0 == uv_signal_start(&signal_handle, fork_signal_to_child_cb, SIGUSR1)); + ASSERT_OK(uv_signal_init(uv_default_loop(), &signal_handle)); + ASSERT_OK(uv_signal_start(&signal_handle, + fork_signal_to_child_cb, + SIGUSR1)); #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) child_pid = -1; #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ - ASSERT(1 == read(sync_pipe[0], sync_buf, 1)); /* wait for child */ - ASSERT(0 == kill(child_pid, SIGUSR1)); + ASSERT_EQ(1, read(sync_pipe[0], sync_buf, 1)); /* wait for child */ + ASSERT_OK(kill(child_pid, SIGUSR1)); /* Run the loop, make sure we don't get the signal. */ printf("Running loop in parent\n"); uv_unref((uv_handle_t*)&signal_handle); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_NOWAIT)); - ASSERT(0 == fork_signal_cb_called); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_NOWAIT)); + ASSERT_OK(fork_signal_cb_called); printf("Waiting for child in parent\n"); assert_wait_child(child_pid); } else { /* child */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); - ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert parent */ + ASSERT_OK(uv_loop_fork(uv_default_loop())); + ASSERT_EQ(1, write(sync_pipe[1], "1", 1)); /* alert parent */ /* Get the signal. */ - ASSERT(0 != uv_loop_alive(uv_default_loop())); + ASSERT_NE(0, uv_loop_alive(uv_default_loop())); printf("Running loop in child\n"); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(SIGUSR1 == fork_signal_cb_called); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_EQ(SIGUSR1, fork_signal_cb_called); } MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -308,47 +310,49 @@ TEST_IMPL(fork_signal_to_child_closed) { fork_signal_cb_called = 0; /* reset */ - ASSERT(0 == pipe(sync_pipe)); - ASSERT(0 == pipe(sync_pipe2)); + ASSERT_OK(pipe(sync_pipe)); + ASSERT_OK(pipe(sync_pipe2)); /* Prime the loop. */ run_timer_loop_once(); - ASSERT(0 == uv_signal_init(uv_default_loop(), &signal_handle)); - ASSERT(0 == uv_signal_start(&signal_handle, fork_signal_to_child_cb, SIGUSR1)); + ASSERT_OK(uv_signal_init(uv_default_loop(), &signal_handle)); + ASSERT_OK(uv_signal_start(&signal_handle, + fork_signal_to_child_cb, + SIGUSR1)); #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) child_pid = -1; #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ printf("Wating on child in parent\n"); - ASSERT(1 == read(sync_pipe[0], sync_buf, 1)); /* wait for child */ + ASSERT_EQ(1, read(sync_pipe[0], sync_buf, 1)); /* wait for child */ printf("Parent killing child\n"); - ASSERT(0 == kill(child_pid, SIGUSR1)); + ASSERT_OK(kill(child_pid, SIGUSR1)); /* Run the loop, make sure we don't get the signal. */ printf("Running loop in parent\n"); uv_unref((uv_handle_t*)&signal_handle); /* so the loop can exit; we *shouldn't* get any signals */ run_timer_loop_once(); /* but while we share a pipe, we do, so have something active. */ - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); printf("Signal in parent %d\n", fork_signal_cb_called); - ASSERT(0 == fork_signal_cb_called); - ASSERT(1 == write(sync_pipe2[1], "1", 1)); /* alert child */ + ASSERT_OK(fork_signal_cb_called); + ASSERT_EQ(1, write(sync_pipe2[1], "1", 1)); /* alert child */ printf("Waiting for child in parent\n"); assert_wait_child(child_pid); } else { /* Child. Our signal handler should still be installed. */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); + ASSERT_OK(uv_loop_fork(uv_default_loop())); printf("Checking loop in child\n"); - ASSERT(0 != uv_loop_alive(uv_default_loop())); + ASSERT_NE(0, uv_loop_alive(uv_default_loop())); printf("Alerting parent in child\n"); - ASSERT(1 == write(sync_pipe[1], "1", 1)); /* alert parent */ + ASSERT_EQ(1, write(sync_pipe[1], "1", 1)); /* alert parent */ /* Don't run the loop. Wait for the parent to call us */ printf("Waiting on parent in child\n"); /* Wait for parent. read may fail if the parent tripped an ASSERT @@ -356,7 +360,7 @@ TEST_IMPL(fork_signal_to_child_closed) { */ r = read(sync_pipe2[0], sync_buf, 1); ASSERT(-1 <= r && r <= 1); - ASSERT(0 == fork_signal_cb_called); + ASSERT_OK(fork_signal_cb_called); printf("Exiting child \n"); /* Note that we're deliberately not running the loop * in the child, and also not closing the loop's handles, @@ -371,6 +375,47 @@ TEST_IMPL(fork_signal_to_child_closed) { return 0; } +static void fork_signal_cb(uv_signal_t* h, int s) { + fork_signal_cb_called = s; +} +static void empty_close_cb(uv_handle_t* h){} + +TEST_IMPL(fork_close_signal_in_child) { + uv_loop_t loop; + uv_signal_t signal_handle; + pid_t child_pid; + + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_signal_init(&loop, &signal_handle)); + ASSERT_OK(uv_signal_start(&signal_handle, &fork_signal_cb, SIGHUP)); + + ASSERT_OK(kill(getpid(), SIGHUP)); + child_pid = fork(); + ASSERT_NE(child_pid, -1); + ASSERT_OK(fork_signal_cb_called); + + if (!child_pid) { + uv_loop_fork(&loop); + uv_close((uv_handle_t*)&signal_handle, &empty_close_cb); + uv_run(&loop, UV_RUN_DEFAULT); + /* Child doesn't receive the signal */ + ASSERT_OK(fork_signal_cb_called); + } else { + /* Parent. Runing once to receive the signal */ + uv_run(&loop, UV_RUN_ONCE); + ASSERT_EQ(SIGHUP, fork_signal_cb_called); + + /* loop should stop after closing the only handle */ + uv_close((uv_handle_t*)&signal_handle, &empty_close_cb); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); + + assert_wait_child(child_pid); + } + + MAKE_VALGRIND_HAPPY(&loop); + return 0; +} + static void create_file(const char* name) { int r; @@ -378,11 +423,11 @@ static void create_file(const char* name) { uv_fs_t req; r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); file = r; uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); } @@ -394,17 +439,17 @@ static void touch_file(const char* name) { uv_buf_t buf; r = uv_fs_open(NULL, &req, name, O_RDWR, 0, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); file = r; uv_fs_req_cleanup(&req); buf = uv_buf_init("foo", 4); r = uv_fs_write(NULL, &req, file, &buf, 1, -1, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); } @@ -424,11 +469,11 @@ static void fs_event_cb_file_current_dir(uv_fs_event_t* handle, const char* filename, int events, int status) { - ASSERT(fs_event_cb_called == 0); + ASSERT_OK(fs_event_cb_called); ++fs_event_cb_called; - ASSERT(status == 0); + ASSERT_OK(status); #if defined(__APPLE__) || defined(__linux__) - ASSERT(strcmp(filename, "watch_file") == 0); + ASSERT_OK(strcmp(filename, "watch_file")); #else ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0); #endif @@ -446,28 +491,28 @@ static void assert_watch_file_current_dir(uv_loop_t* const loop, int file_or_dir create_file("watch_file"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); /* watching a dir is the only way to get fsevents involved on apple platforms */ r = uv_fs_event_start(&fs_event, fs_event_cb_file_current_dir, file_or_dir == 1 ? "." : "watch_file", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb_touch, 100, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(timer_cb_touch_called == 0); - ASSERT(fs_event_cb_called == 0); + ASSERT_OK(timer_cb_touch_called); + ASSERT_OK(fs_event_cb_called); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(timer_cb_touch_called == 1); - ASSERT(fs_event_cb_called == 1); + ASSERT_EQ(1, timer_cb_touch_called); + ASSERT_EQ(1, fs_event_cb_called); /* Cleanup */ remove("watch_file"); @@ -492,7 +537,7 @@ static int _do_fork_fs_events_child(int file_or_dir) { #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ @@ -508,10 +553,10 @@ static int _do_fork_fs_events_child(int file_or_dir) { uv_loop_init(&loop); printf("Child first watch\n"); assert_watch_file_current_dir(&loop, file_or_dir); - ASSERT(0 == uv_loop_close(&loop)); + ASSERT_OK(uv_loop_close(&loop)); printf("Child second watch default loop\n"); /* Ee can watch in the default loop. */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); + ASSERT_OK(uv_loop_fork(uv_default_loop())); /* On some platforms (OS X), if we don't update the time now, * the timer cb fires before the event loop enters uv__io_poll, * instead of after, meaning we don't see the change! This may be @@ -524,7 +569,7 @@ static int _do_fork_fs_events_child(int file_or_dir) { especially important on Apple platforms where if we're not careful trying to touch the CFRunLoop, even just to shut it down, that we allocated in the FS_TEST_DIR case would crash. */ - ASSERT(0 == uv_loop_close(uv_default_loop())); + ASSERT_OK(uv_loop_close(uv_default_loop())); printf("Exiting child \n"); } @@ -587,40 +632,40 @@ TEST_IMPL(fork_fs_events_file_parent_child) { create_file("watch_file"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_file_current_dir, "watch_file", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) child_pid = -1; #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* parent */ assert_wait_child(child_pid); } else { /* child */ printf("Running child\n"); - ASSERT(0 == uv_loop_fork(loop)); + ASSERT_OK(uv_loop_fork(loop)); r = uv_timer_start(&timer, timer_cb_touch, 100, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(timer_cb_touch_called == 0); - ASSERT(fs_event_cb_called == 0); + ASSERT_OK(timer_cb_touch_called); + ASSERT_OK(fs_event_cb_called); printf("Running loop in child \n"); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(timer_cb_touch_called == 1); - ASSERT(fs_event_cb_called == 1); + ASSERT_EQ(1, timer_cb_touch_called); + ASSERT_EQ(1, fs_event_cb_called); /* Cleanup */ remove("watch_file"); @@ -646,7 +691,7 @@ static void work_cb(uv_work_t* req) { static void after_work_cb(uv_work_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); after_work_cb_count++; } @@ -655,16 +700,16 @@ static void assert_run_work(uv_loop_t* const loop) { uv_work_t work_req; int r; - ASSERT(work_cb_count == 0); - ASSERT(after_work_cb_count == 0); + ASSERT_OK(work_cb_count); + ASSERT_OK(after_work_cb_count); printf("Queue in %d\n", getpid()); r = uv_queue_work(loop, &work_req, work_cb, after_work_cb); - ASSERT(r == 0); + ASSERT_OK(r); printf("Running in %d\n", getpid()); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(work_cb_count == 1); - ASSERT(after_work_cb_count == 1); + ASSERT_EQ(1, work_cb_count); + ASSERT_EQ(1, after_work_cb_count); /* cleanup */ work_cb_count = 0; @@ -691,7 +736,7 @@ TEST_IMPL(fork_threadpool_queue_work_simple) { #else child_pid = fork(); #endif - ASSERT(child_pid != -1); + ASSERT_NE(child_pid, -1); if (child_pid != 0) { /* Parent. We can still run work. */ @@ -706,7 +751,7 @@ TEST_IMPL(fork_threadpool_queue_work_simple) { uv_loop_close(&loop); printf("Child second watch default loop\n"); /* We can work in the default loop. */ - ASSERT(0 == uv_loop_fork(uv_default_loop())); + ASSERT_OK(uv_loop_fork(uv_default_loop())); assert_run_work(uv_default_loop()); printf("Exiting child \n"); } diff --git a/deps/libuv/test/test-fs-copyfile.c b/deps/libuv/test/test-fs-copyfile.c index d7f04cf4..3f159aeb 100644 --- a/deps/libuv/test/test-fs-copyfile.c +++ b/deps/libuv/test/test-fs-copyfile.c @@ -48,19 +48,19 @@ static void handle_result(uv_fs_t* req) { uint64_t mode; int r; - ASSERT(req->fs_type == UV_FS_COPYFILE); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_COPYFILE); + ASSERT_OK(req->result); /* Verify that the file size and mode are the same. */ r = uv_fs_stat(NULL, &stat_req, req->path, NULL); - ASSERT(r == 0); + ASSERT_OK(r); size = stat_req.statbuf.st_size; mode = stat_req.statbuf.st_mode; uv_fs_req_cleanup(&stat_req); r = uv_fs_stat(NULL, &stat_req, dst, NULL); - ASSERT(r == 0); - ASSERT(stat_req.statbuf.st_size == size); - ASSERT(stat_req.statbuf.st_mode == mode); + ASSERT_OK(r); + ASSERT_EQ(stat_req.statbuf.st_size, size); + ASSERT_EQ(stat_req.statbuf.st_mode, mode); uv_fs_req_cleanup(&stat_req); uv_fs_req_cleanup(req); result_check_count++; @@ -77,7 +77,7 @@ static void touch_file(const char* name, unsigned int size) { r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR, NULL); uv_fs_req_cleanup(&req); - ASSERT(r >= 0); + ASSERT_GE(r, 0); file = r; buf = uv_buf_init("a", 1); @@ -86,12 +86,12 @@ static void touch_file(const char* name, unsigned int size) { for (i = 0; i < size; i++) { r = uv_fs_write(NULL, &req, file, &buf, 1, i, NULL); uv_fs_req_cleanup(&req); - ASSERT(r >= 0); + ASSERT_GE(r, 0); } r = uv_fs_close(NULL, &req, file, NULL); uv_fs_req_cleanup(&req); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -105,102 +105,102 @@ TEST_IMPL(fs_copyfile) { /* Fails with EINVAL if bad flags are passed. */ r = uv_fs_copyfile(NULL, &req, src, dst, -1, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_fs_req_cleanup(&req); /* Fails with ENOENT if source does not exist. */ unlink(src); unlink(dst); r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(req.result == UV_ENOENT); - ASSERT(r == UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); uv_fs_req_cleanup(&req); /* The destination should not exist. */ r = uv_fs_stat(NULL, &req, dst, NULL); - ASSERT(r != 0); + ASSERT(r); uv_fs_req_cleanup(&req); /* Succeeds if src and dst files are identical. */ touch_file(src, 12); r = uv_fs_copyfile(NULL, &req, src, src, 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); /* Verify that the src file did not get truncated. */ r = uv_fs_stat(NULL, &req, src, NULL); - ASSERT_EQ(r, 0); - ASSERT_EQ(req.statbuf.st_size, 12); + ASSERT_OK(r); + ASSERT_EQ(12, req.statbuf.st_size); uv_fs_req_cleanup(&req); unlink(src); /* Copies file synchronously. Creates new file. */ unlink(dst); r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); handle_result(&req); /* Copies a file of size zero. */ unlink(dst); touch_file(src, 0); r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); handle_result(&req); /* Copies file synchronously. Overwrites existing file. */ r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); handle_result(&req); /* Fails to overwrites existing file. */ - ASSERT_EQ(uv_fs_chmod(NULL, &req, dst, 0644, NULL), 0); + ASSERT_OK(uv_fs_chmod(NULL, &req, dst, 0644, NULL)); uv_fs_req_cleanup(&req); r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_EXCL, NULL); - ASSERT(r == UV_EEXIST); + ASSERT_EQ(r, UV_EEXIST); uv_fs_req_cleanup(&req); /* Truncates when an existing destination is larger than the source file. */ - ASSERT_EQ(uv_fs_chmod(NULL, &req, dst, 0644, NULL), 0); + ASSERT_OK(uv_fs_chmod(NULL, &req, dst, 0644, NULL)); uv_fs_req_cleanup(&req); touch_file(src, 1); r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); handle_result(&req); /* Copies a larger file. */ unlink(dst); touch_file(src, 4096 * 2); r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); handle_result(&req); unlink(src); /* Copies file asynchronously */ unlink(dst); r = uv_fs_copyfile(loop, &req, fixture, dst, 0, handle_result); - ASSERT(r == 0); - ASSERT(result_check_count == 5); + ASSERT_OK(r); + ASSERT_EQ(5, result_check_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(result_check_count == 6); + ASSERT_EQ(6, result_check_count); /* Ensure file is user-writable (not copied from src). */ - ASSERT_EQ(uv_fs_chmod(NULL, &req, dst, 0644, NULL), 0); + ASSERT_OK(uv_fs_chmod(NULL, &req, dst, 0644, NULL)); uv_fs_req_cleanup(&req); /* If the flags are invalid, the loop should not be kept open */ unlink(dst); r = uv_fs_copyfile(loop, &req, fixture, dst, -1, fail_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(loop, UV_RUN_DEFAULT); /* Copies file using UV_FS_COPYFILE_FICLONE. */ unlink(dst); r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE, NULL); - ASSERT(r == 0); + ASSERT_OK(r); handle_result(&req); /* Copies file using UV_FS_COPYFILE_FICLONE_FORCE. */ unlink(dst); r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE_FORCE, NULL); - ASSERT(r <= 0); + ASSERT_LE(r, 0); if (r == 0) handle_result(&req); @@ -213,8 +213,8 @@ TEST_IMPL(fs_copyfile) { r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL); /* On IBMi PASE, qsecofr users can overwrite read-only files */ # ifndef __PASE__ - ASSERT(req.result == UV_EACCES); - ASSERT(r == UV_EACCES); + ASSERT_EQ(req.result, UV_EACCES); + ASSERT_EQ(r, UV_EACCES); # endif uv_fs_req_cleanup(&req); #endif diff --git a/deps/libuv/test/test-fs-event.c b/deps/libuv/test/test-fs-event.c index 9f231ebf..7b5c0d8e 100644 --- a/deps/libuv/test/test-fs-event.c +++ b/deps/libuv/test/test-fs-event.c @@ -81,11 +81,11 @@ static void create_file(const char* name) { uv_fs_t req; r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); file = r; uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); } @@ -96,17 +96,17 @@ static void touch_file(const char* name) { uv_buf_t buf; r = uv_fs_open(NULL, &req, name, O_RDWR, 0, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); file = r; uv_fs_req_cleanup(&req); buf = uv_buf_init("foo", 4); r = uv_fs_write(NULL, &req, file, &buf, 1, -1, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); } @@ -125,15 +125,15 @@ static void fail_cb(uv_fs_event_t* handle, static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename, int events, int status) { ++fs_event_cb_called; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE); + ASSERT_PTR_EQ(handle, &fs_event); + ASSERT_OK(status); + ASSERT_EQ(events, UV_CHANGE); #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strcmp(filename, "file1") == 0); + ASSERT_OK(strcmp(filename, "file1")); #else ASSERT(filename == NULL || strcmp(filename, "file1") == 0); #endif - ASSERT(0 == uv_fs_event_stop(handle)); + ASSERT_OK(uv_fs_event_stop(handle)); uv_close((uv_handle_t*)handle, close_cb); } @@ -148,7 +148,7 @@ static const char* fs_event_get_filename(int i) { static void fs_event_create_files(uv_timer_t* handle) { /* Make sure we're not attempting to create files we do not intend */ - ASSERT(fs_event_created < fs_event_file_count); + ASSERT_LT(fs_event_created, fs_event_file_count); /* Create the file */ create_file(fs_event_get_filename(fs_event_created)); @@ -156,7 +156,7 @@ static void fs_event_create_files(uv_timer_t* handle) { if (++fs_event_created < fs_event_file_count) { /* Create another file on a different event loop tick. We do it this way * to avoid fs events coalescing into one fs event. */ - ASSERT_EQ(0, uv_timer_start(&timer, fs_event_create_files, 100, 0)); + ASSERT_OK(uv_timer_start(&timer, fs_event_create_files, 100, 0)); } } @@ -170,19 +170,19 @@ static void fs_event_unlink_files(uv_timer_t* handle) { for (i = 0; i < 16; i++) { r = remove(fs_event_get_filename(i)); if (handle != NULL) - ASSERT(r == 0); + ASSERT_OK(r); } } else { /* Make sure we're not attempting to remove files we do not intend */ - ASSERT(fs_event_removed < fs_event_file_count); + ASSERT_LT(fs_event_removed, fs_event_file_count); /* Remove the file */ - ASSERT(0 == remove(fs_event_get_filename(fs_event_removed))); + ASSERT_OK(remove(fs_event_get_filename(fs_event_removed))); if (++fs_event_removed < fs_event_file_count) { /* Remove another file on a different event loop tick. We do it this way * to avoid fs events coalescing into one fs event. */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); + ASSERT_OK(uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); } } } @@ -192,19 +192,19 @@ static void fs_event_cb_dir_multi_file(uv_fs_event_t* handle, int events, int status) { fs_event_cb_called++; - ASSERT(handle == &fs_event); - ASSERT(status == 0); + ASSERT_PTR_EQ(handle, &fs_event); + ASSERT_OK(status); ASSERT(events == UV_CHANGE || events == UV_RENAME); #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strncmp(filename, file_prefix, sizeof(file_prefix) - 1) == 0); + ASSERT_OK(strncmp(filename, file_prefix, sizeof(file_prefix) - 1)); #else - ASSERT(filename == NULL || - strncmp(filename, file_prefix, sizeof(file_prefix) - 1) == 0); + ASSERT_NE(filename == NULL || + strncmp(filename, file_prefix, sizeof(file_prefix) - 1) == 0, 0); #endif if (fs_event_created + fs_event_removed == fs_event_file_count) { /* Once we've processed all create events, delete all files */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); + ASSERT_OK(uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); } else if (fs_event_cb_called == 2 * fs_event_file_count) { /* Once we've processed all create and delete events, stop watching */ uv_close((uv_handle_t*) &timer, close_cb); @@ -224,7 +224,7 @@ static const char* fs_event_get_filename_in_subdir(int i) { static void fs_event_create_files_in_subdir(uv_timer_t* handle) { /* Make sure we're not attempting to create files we do not intend */ - ASSERT(fs_event_created < fs_event_file_count); + ASSERT_LT(fs_event_created, fs_event_file_count); /* Create the file */ create_file(fs_event_get_filename_in_subdir(fs_event_created)); @@ -232,8 +232,7 @@ static void fs_event_create_files_in_subdir(uv_timer_t* handle) { if (++fs_event_created < fs_event_file_count) { /* Create another file on a different event loop tick. We do it this way * to avoid fs events coalescing into one fs event. */ - ASSERT_EQ(0, - uv_timer_start(&timer, fs_event_create_files_in_subdir, 100, 0)); + ASSERT_OK(uv_timer_start(&timer, fs_event_create_files_in_subdir, 100, 0)); } } @@ -247,19 +246,22 @@ static void fs_event_unlink_files_in_subdir(uv_timer_t* handle) { for (i = 0; i < 16; i++) { r = remove(fs_event_get_filename_in_subdir(i)); if (handle != NULL) - ASSERT(r == 0); + ASSERT_OK(r); } } else { /* Make sure we're not attempting to remove files we do not intend */ - ASSERT(fs_event_removed < fs_event_file_count); + ASSERT_LT(fs_event_removed, fs_event_file_count); /* Remove the file */ - ASSERT(0 == remove(fs_event_get_filename_in_subdir(fs_event_removed))); + ASSERT_OK(remove(fs_event_get_filename_in_subdir(fs_event_removed))); if (++fs_event_removed < fs_event_file_count) { /* Remove another file on a different event loop tick. We do it this way * to avoid fs events coalescing into one fs event. */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files_in_subdir, 1, 0)); + ASSERT_OK(uv_timer_start(&timer, + fs_event_unlink_files_in_subdir, + 1, + 0)); } } } @@ -283,27 +285,30 @@ static void fs_event_cb_dir_multi_file_in_subdir(uv_fs_event_t* handle, return; fs_multievent_cb_called++; - ASSERT(handle == &fs_event); - ASSERT(status == 0); + ASSERT_PTR_EQ(handle, &fs_event); + ASSERT_OK(status); ASSERT(events == UV_CHANGE || events == UV_RENAME); #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strncmp(filename, - file_prefix_in_subdir, - sizeof(file_prefix_in_subdir) - 1) == 0); + ASSERT_OK(strncmp(filename, + file_prefix_in_subdir, + sizeof(file_prefix_in_subdir) - 1)); #else - ASSERT(filename == NULL || - strncmp(filename, - file_prefix_in_subdir, - sizeof(file_prefix_in_subdir) - 1) == 0); + ASSERT_NE(filename == NULL || + strncmp(filename, + file_prefix_in_subdir, + sizeof(file_prefix_in_subdir) - 1) == 0, 0); #endif if (fs_event_created == fs_event_file_count && fs_multievent_cb_called == fs_event_created) { /* Once we've processed all create events, delete all files */ - ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files_in_subdir, 1, 0)); + ASSERT_OK(uv_timer_start(&timer, + fs_event_unlink_files_in_subdir, + 1, + 0)); } else if (fs_multievent_cb_called == 2 * fs_event_file_count) { /* Once we've processed all create and delete events, stop watching */ - ASSERT(fs_event_removed == fs_event_file_count); + ASSERT_EQ(fs_event_removed, fs_event_file_count); uv_close((uv_handle_t*) &timer, close_cb); uv_close((uv_handle_t*) handle, close_cb); } @@ -313,15 +318,15 @@ static void fs_event_cb_dir_multi_file_in_subdir(uv_fs_event_t* handle, static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename, int events, int status) { ++fs_event_cb_called; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE); + ASSERT_PTR_EQ(handle, &fs_event); + ASSERT_OK(status); + ASSERT_EQ(events, UV_CHANGE); #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strcmp(filename, "file2") == 0); + ASSERT_OK(strcmp(filename, "file2")); #else ASSERT(filename == NULL || strcmp(filename, "file2") == 0); #endif - ASSERT(0 == uv_fs_event_stop(handle)); + ASSERT_OK(uv_fs_event_stop(handle)); uv_close((uv_handle_t*)handle, close_cb); } @@ -329,11 +334,11 @@ static void fs_event_cb_file_current_dir(uv_fs_event_t* handle, const char* filename, int events, int status) { ++fs_event_cb_called; - ASSERT(handle == &fs_event); - ASSERT(status == 0); - ASSERT(events == UV_CHANGE); + ASSERT_PTR_EQ(handle, &fs_event); + ASSERT_OK(status); + ASSERT_EQ(events, UV_CHANGE); #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) - ASSERT(strcmp(filename, "watch_file") == 0); + ASSERT_OK(strcmp(filename, "watch_file")); #else ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0); #endif @@ -366,7 +371,7 @@ static void timer_cb_exact(uv_timer_t* handle) { } else { uv_close((uv_handle_t*)handle, NULL); r = uv_fs_event_stop(&fs_event); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &fs_event, NULL); } @@ -384,9 +389,9 @@ static void fs_event_cb_close(uv_fs_event_t* handle, const char* filename, int events, int status) { - ASSERT(status == 0); + ASSERT_OK(status); - ASSERT(fs_event_cb_called < 3); + ASSERT_LT(fs_event_cb_called, 3); ++fs_event_cb_called; if (fs_event_cb_called == 3) { @@ -400,6 +405,8 @@ TEST_IMPL(fs_event_watch_dir) { RETURN_SKIP(NO_FS_EVENTS); #elif defined(__MVS__) RETURN_SKIP("Directory watching not supported on this platform."); +#elif defined(__APPLE__) && defined(__TSAN__) + RETURN_SKIP("Times out under TSAN."); #endif uv_loop_t* loop = uv_default_loop(); @@ -413,18 +420,18 @@ TEST_IMPL(fs_event_watch_dir) { create_dir("watch_dir"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_dir_multi_file, "watch_dir", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, fs_event_create_files, 100, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fs_event_cb_called == fs_event_created + fs_event_removed); - ASSERT(close_cb_called == 2); + ASSERT_EQ(fs_event_cb_called, fs_event_created + fs_event_removed); + ASSERT_EQ(2, close_cb_called); /* Cleanup */ fs_event_unlink_files(NULL); @@ -438,7 +445,9 @@ TEST_IMPL(fs_event_watch_dir) { TEST_IMPL(fs_event_watch_dir_recursive) { -#if defined(__APPLE__) || defined(_WIN32) +#if defined(__APPLE__) && defined(__TSAN__) + RETURN_SKIP("Times out under TSAN."); +#elif defined(__APPLE__) || defined(_WIN32) uv_loop_t* loop; int r; uv_fs_event_t fs_event_root; @@ -454,27 +463,27 @@ TEST_IMPL(fs_event_watch_dir_recursive) { create_dir("watch_dir/subdir"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_dir_multi_file_in_subdir, "watch_dir", UV_FS_EVENT_RECURSIVE); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, fs_event_create_files_in_subdir, 100, 0); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 /* Also try to watch the root directory. * This will be noisier, so we're just checking for any couple events to happen. */ r = uv_fs_event_init(loop, &fs_event_root); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event_root, fs_event_cb_close, "/", UV_FS_EVENT_RECURSIVE); - ASSERT(r == 0); + ASSERT_OK(r); #else fs_event_cb_called += 3; close_cb_called += 1; @@ -483,9 +492,9 @@ TEST_IMPL(fs_event_watch_dir_recursive) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fs_multievent_cb_called == fs_event_created + fs_event_removed); - ASSERT(fs_event_cb_called == 3); - ASSERT(close_cb_called == 3); + ASSERT_EQ(fs_multievent_cb_called, fs_event_created + fs_event_removed); + ASSERT_EQ(3, fs_event_cb_called); + ASSERT_EQ(3, close_cb_called); /* Cleanup */ fs_event_unlink_files_in_subdir(NULL); @@ -522,19 +531,19 @@ TEST_IMPL(fs_event_watch_dir_short_path) { has_shortnames = uv_fs_stat(NULL, &req, "watch_~1", NULL) != UV_ENOENT; if (has_shortnames) { r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_dir, "watch_~1", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb_file, 100, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fs_event_cb_called == 1); - ASSERT(timer_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, fs_event_cb_called); + ASSERT_EQ(1, timer_cb_called); + ASSERT_EQ(1, close_cb_called); } /* Cleanup */ @@ -568,19 +577,19 @@ TEST_IMPL(fs_event_watch_file) { create_file("watch_dir/file2"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_file, "watch_dir/file2", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb_file, 100, 100); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fs_event_cb_called == 1); - ASSERT(timer_cb_called == 2); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, fs_event_cb_called); + ASSERT_EQ(2, timer_cb_called); + ASSERT_EQ(2, close_cb_called); /* Cleanup */ remove("watch_dir/file2"); @@ -624,16 +633,16 @@ TEST_IMPL(fs_event_watch_file_exact_path) { #endif r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_fail, "watch_dir/file.jsx", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb_exact, 100, 100); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(timer_cb_exact_called == 2); + ASSERT_OK(r); + ASSERT_EQ(2, timer_cb_exact_called); /* Cleanup */ remove("watch_dir/file.js"); @@ -656,13 +665,13 @@ TEST_IMPL(fs_event_watch_file_twice) { loop = uv_default_loop(); timer.data = watchers; - ASSERT(0 == uv_fs_event_init(loop, watchers + 0)); - ASSERT(0 == uv_fs_event_start(watchers + 0, fail_cb, path, 0)); - ASSERT(0 == uv_fs_event_init(loop, watchers + 1)); - ASSERT(0 == uv_fs_event_start(watchers + 1, fail_cb, path, 0)); - ASSERT(0 == uv_timer_init(loop, &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_cb_watch_twice, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_fs_event_init(loop, watchers + 0)); + ASSERT_OK(uv_fs_event_start(watchers + 0, fail_cb, path, 0)); + ASSERT_OK(uv_fs_event_init(loop, watchers + 1)); + ASSERT_OK(uv_fs_event_start(watchers + 1, fail_cb, path, 0)); + ASSERT_OK(uv_timer_init(loop, &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_cb_watch_twice, 10, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -690,31 +699,31 @@ TEST_IMPL(fs_event_watch_file_current_dir) { #endif r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_file_current_dir, "watch_file", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); timer.data = "watch_file"; r = uv_timer_start(&timer, timer_cb_touch, 1100, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(timer_cb_touch_called == 0); - ASSERT(fs_event_cb_called == 0); - ASSERT(close_cb_called == 0); + ASSERT_OK(timer_cb_touch_called); + ASSERT_OK(fs_event_cb_called); + ASSERT_OK(close_cb_called); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(timer_cb_touch_called == 1); + ASSERT_EQ(1, timer_cb_touch_called); /* FSEvents on macOS sometimes sends one change event, sometimes two. */ ASSERT_NE(0, fs_event_cb_called); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); /* Cleanup */ remove("watch_file"); @@ -737,11 +746,11 @@ TEST_IMPL(fs_event_watch_file_root_dir) { loop = uv_default_loop(); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fail_cb, path, 0); if (r == UV_ENOENT) RETURN_SKIP("bootsect.bak doesn't exist in system root.\n"); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &fs_event, NULL); @@ -765,20 +774,20 @@ TEST_IMPL(fs_event_no_callback_after_close) { create_file("watch_dir/file1"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_file, "watch_dir/file1", 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&fs_event, close_cb); touch_file("watch_dir/file1"); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fs_event_cb_called == 0); - ASSERT(close_cb_called == 1); + ASSERT_OK(fs_event_cb_called); + ASSERT_EQ(1, close_cb_called); /* Cleanup */ remove("watch_dir/file1"); @@ -803,19 +812,19 @@ TEST_IMPL(fs_event_no_callback_on_close) { create_file("watch_dir/file1"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_file, "watch_dir/file1", 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&fs_event, close_cb); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fs_event_cb_called == 0); - ASSERT(close_cb_called == 1); + ASSERT_OK(fs_event_cb_called); + ASSERT_EQ(1, close_cb_called); /* Cleanup */ remove("watch_dir/file1"); @@ -830,9 +839,9 @@ static void timer_cb(uv_timer_t* handle) { int r; r = uv_fs_event_init(handle->loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_fail, ".", 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&fs_event, close_cb); uv_close((uv_handle_t*)handle, close_cb); @@ -850,14 +859,14 @@ TEST_IMPL(fs_event_immediate_close) { loop = uv_default_loop(); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 1, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -877,9 +886,9 @@ TEST_IMPL(fs_event_close_with_pending_event) { create_file("watch_dir/file"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_fail, "watch_dir", 0); - ASSERT(r == 0); + ASSERT_OK(r); /* Generate an fs event. */ touch_file("watch_dir/file"); @@ -888,7 +897,7 @@ TEST_IMPL(fs_event_close_with_pending_event) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); /* Clean up */ remove("watch_dir/file"); @@ -911,9 +920,9 @@ TEST_IMPL(fs_event_close_with_pending_delete_event) { create_file("watch_dir/file"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_fail, "watch_dir/file", 0); - ASSERT(r == 0); + ASSERT_OK(r); /* Generate an fs event. */ remove("watch_dir/file"); @@ -927,7 +936,7 @@ TEST_IMPL(fs_event_close_with_pending_delete_event) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); /* Clean up */ remove("watch_dir/"); @@ -941,6 +950,8 @@ TEST_IMPL(fs_event_close_in_callback) { RETURN_SKIP(NO_FS_EVENTS); #elif defined(__MVS__) RETURN_SKIP("Directory watching not supported on this platform."); +#elif defined(__APPLE__) && defined(__TSAN__) + RETURN_SKIP("Times out under TSAN."); #endif uv_loop_t* loop; int r; @@ -951,14 +962,14 @@ TEST_IMPL(fs_event_close_in_callback) { create_dir("watch_dir"); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_close, "watch_dir", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, fs_event_create_files, 100, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); @@ -966,8 +977,8 @@ TEST_IMPL(fs_event_close_in_callback) { uv_run(loop, UV_RUN_ONCE); - ASSERT(close_cb_called == 2); - ASSERT(fs_event_cb_called == 3); + ASSERT_EQ(2, close_cb_called); + ASSERT_EQ(3, fs_event_cb_called); /* Clean up */ fs_event_unlink_files(NULL); @@ -991,21 +1002,21 @@ TEST_IMPL(fs_event_start_and_close) { create_dir("watch_dir"); r = uv_fs_event_init(loop, &fs_event1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event1, fs_event_cb_dir, "watch_dir", 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_init(loop, &fs_event2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event2, fs_event_cb_dir, "watch_dir", 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &fs_event2, close_cb); uv_close((uv_handle_t*) &fs_event1, close_cb); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, close_cb_called); remove("watch_dir/"); MAKE_VALGRIND_HAPPY(loop); @@ -1035,28 +1046,28 @@ TEST_IMPL(fs_event_getpath) { for (i = 0; i < ARRAY_SIZE(watch_dir); i++) { r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); len = sizeof buf; r = uv_fs_event_getpath(&fs_event, buf, &len); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_event_start(&fs_event, fail_cb, watch_dir[i], 0); - ASSERT(r == 0); + ASSERT_OK(r); len = 0; r = uv_fs_event_getpath(&fs_event, buf, &len); - ASSERT(r == UV_ENOBUFS); - ASSERT(len < sizeof buf); /* sanity check */ - ASSERT(len == strlen(watch_dir[i]) + 1); + ASSERT_EQ(r, UV_ENOBUFS); + ASSERT_LT(len, sizeof buf); /* sanity check */ + ASSERT_EQ(len, strlen(watch_dir[i]) + 1); r = uv_fs_event_getpath(&fs_event, buf, &len); - ASSERT(r == 0); - ASSERT(len == strlen(watch_dir[i])); + ASSERT_OK(r); + ASSERT_EQ(len, strlen(watch_dir[i])); ASSERT(strcmp(buf, watch_dir[i]) == 0); r = uv_fs_event_stop(&fs_event); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &fs_event, close_cb); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); close_cb_called = 0; } @@ -1108,43 +1119,43 @@ TEST_IMPL(fs_event_error_reporting) { */ for (i = 0; i < ARRAY_SIZE(loops); i++) { loop = &loops[i]; - ASSERT(0 == uv_loop_init(loop)); + ASSERT_OK(uv_loop_init(loop)); event = &events[i]; timer_cb_called = 0; close_cb_called = 0; - ASSERT(0 == uv_fs_event_init(loop, event)); - ASSERT(0 == uv_fs_event_start(event, - fs_event_error_report_cb, - "watch_dir", - 0)); + ASSERT_OK(uv_fs_event_init(loop, event)); + ASSERT_OK(uv_fs_event_start(event, + fs_event_error_report_cb, + "watch_dir", + 0)); uv_unref((uv_handle_t*) event); /* Let loop run for some time */ - ASSERT(0 == uv_timer_init(loop, &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_cb_nop, 2, 0)); + ASSERT_OK(uv_timer_init(loop, &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_cb_nop, 2, 0)); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(1 == timer_cb_called); - ASSERT(1 == close_cb_called); + ASSERT_EQ(1, timer_cb_called); + ASSERT_EQ(1, close_cb_called); if (fs_event_error_reported != 0) break; } /* At least one loop should fail */ - ASSERT(fs_event_error_reported == UV_EMFILE); + ASSERT_EQ(fs_event_error_reported, UV_EMFILE); /* Stop and close all events, and destroy loops */ do { loop = &loops[i]; event = &events[i]; - ASSERT(0 == uv_fs_event_stop(event)); + ASSERT_OK(uv_fs_event_stop(event)); uv_ref((uv_handle_t*) event); uv_close((uv_handle_t*) event, fs_event_error_report_close_cb); close_cb_called = 0; uv_run(loop, UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); uv_loop_close(loop); } while (i-- != 0); @@ -1175,13 +1186,13 @@ TEST_IMPL(fs_event_watch_invalid_path) { loop = uv_default_loop(); r = uv_fs_event_init(loop, &fs_event); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event, fs_event_cb_file, "<:;", 0); - ASSERT(r != 0); - ASSERT(uv_is_active((uv_handle_t*) &fs_event) == 0); + ASSERT(r); + ASSERT_OK(uv_is_active((uv_handle_t*) &fs_event)); r = uv_fs_event_start(&fs_event, fs_event_cb_file, "", 0); - ASSERT(r != 0); - ASSERT(uv_is_active((uv_handle_t*) &fs_event) == 0); + ASSERT(r); + ASSERT_OK(uv_is_active((uv_handle_t*) &fs_event)); MAKE_VALGRIND_HAPPY(loop); return 0; } @@ -1206,24 +1217,24 @@ TEST_IMPL(fs_event_stop_in_cb) { remove(path); create_file(path); - ASSERT_EQ(0, uv_fs_event_init(uv_default_loop(), &fs)); - ASSERT_EQ(0, uv_fs_event_start(&fs, fs_event_cb_stop, path, 0)); + ASSERT_OK(uv_fs_event_init(uv_default_loop(), &fs)); + ASSERT_OK(uv_fs_event_start(&fs, fs_event_cb_stop, path, 0)); /* Note: timer_cb_touch() closes the handle. */ timer.data = path; - ASSERT_EQ(0, uv_timer_init(uv_default_loop(), &timer)); - ASSERT_EQ(0, uv_timer_start(&timer, timer_cb_touch, 100, 0)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_cb_touch, 100, 0)); - ASSERT_EQ(0, fs_event_cb_stop_calls); - ASSERT_EQ(0, timer_cb_touch_called); + ASSERT_OK(fs_event_cb_stop_calls); + ASSERT_OK(timer_cb_touch_called); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT_EQ(1, fs_event_cb_stop_calls); ASSERT_EQ(1, timer_cb_touch_called); uv_close((uv_handle_t*) &fs, NULL); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT_EQ(1, fs_event_cb_stop_calls); remove(path); diff --git a/deps/libuv/test/test-fs-fd-hash.c b/deps/libuv/test/test-fs-fd-hash.c index 8b4bc035..4ed3d548 100644 --- a/deps/libuv/test/test-fs-fd-hash.c +++ b/deps/libuv/test/test-fs-fd-hash.c @@ -43,7 +43,7 @@ void assert_nonexistent(int fd) { void assert_existent(int fd) { struct uv__fd_info_s info = { 0 }; ASSERT(uv__fd_hash_get(fd, &info)); - ASSERT(info.flags == fd + FD_DIFF); + ASSERT_EQ(info.flags, fd + FD_DIFF); } void assert_insertion(int fd) { @@ -58,7 +58,7 @@ void assert_removal(int fd) { struct uv__fd_info_s info = { 0 }; assert_existent(fd); uv__fd_hash_remove(fd, &info); - ASSERT(info.flags == fd + FD_DIFF); + ASSERT_EQ(info.flags, fd + FD_DIFF); assert_nonexistent(fd); } @@ -106,7 +106,7 @@ TEST_IMPL(fs_fd_hash) { { struct uv__fd_info_s info = { 0 }; ASSERT(uv__fd_hash_get(0, &info)); - ASSERT(info.flags == FD_DIFF + FD_DIFF); + ASSERT_EQ(info.flags, FD_DIFF + FD_DIFF); } { /* Leave as it was, will be again tested below */ diff --git a/deps/libuv/test/test-fs-open-flags.c b/deps/libuv/test/test-fs-open-flags.c index ea9be25a..e64ac20d 100644 --- a/deps/libuv/test/test-fs-open-flags.c +++ b/deps/libuv/test/test-fs-open-flags.c @@ -68,8 +68,8 @@ static void setup(void) { uv_fs_req_cleanup(&rmdir_req); r = uv_fs_mkdir(NULL, &mkdir_req, empty_dir, 0755, NULL); - ASSERT(r == 0); - ASSERT(mkdir_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(mkdir_req.result); uv_fs_req_cleanup(&mkdir_req); } @@ -89,13 +89,13 @@ static void refresh(void) { r = uv_fs_open(NULL, &open_req, empty_file, UV_FS_O_TRUNC | UV_FS_O_CREAT | UV_FS_O_WRONLY, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req.result, 0); uv_fs_req_cleanup(&open_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* dummy_file */ @@ -103,19 +103,19 @@ static void refresh(void) { r = uv_fs_open(NULL, &open_req, dummy_file, UV_FS_O_TRUNC | UV_FS_O_CREAT | UV_FS_O_WRONLY, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req.result, 0); uv_fs_req_cleanup(&open_req); iov = uv_buf_init("a", 1); r = uv_fs_write(NULL, &write_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == 1); - ASSERT(write_req.result == 1); + ASSERT_EQ(1, r); + ASSERT_EQ(1, write_req.result); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); } @@ -131,14 +131,14 @@ static void openFail(char *file, int error) { refresh(); r = uv_fs_open(NULL, &open_req, file, flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r == error); - ASSERT(open_req.result == error); + ASSERT_EQ(r, error); + ASSERT_EQ(open_req.result, error); uv_fs_req_cleanup(&open_req); /* Ensure the first call does not create the file */ r = uv_fs_open(NULL, &open_req, file, flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r == error); - ASSERT(open_req.result == error); + ASSERT_EQ(r, error); + ASSERT_EQ(open_req.result, error); uv_fs_req_cleanup(&open_req); cleanup(); @@ -150,8 +150,8 @@ static void refreshOpen(char *file) { refresh(); r = uv_fs_open(NULL, &open_req, file, flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req.result, 0); uv_fs_req_cleanup(&open_req); } @@ -162,37 +162,37 @@ static void writeExpect(char *file, char *expected, int size) { iov = uv_buf_init("b", 1); r = uv_fs_write(NULL, &write_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == 1); - ASSERT(write_req.result == 1); + ASSERT_EQ(1, r); + ASSERT_EQ(1, write_req.result); uv_fs_req_cleanup(&write_req); iov = uv_buf_init("c", 1); r = uv_fs_write(NULL, &write_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == 1); - ASSERT(write_req.result == 1); + ASSERT_EQ(1, r); + ASSERT_EQ(1, write_req.result); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Check contents */ r = uv_fs_open(NULL, &open_req, file, UV_FS_O_RDONLY, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req.result, 0); uv_fs_req_cleanup(&open_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == size); - ASSERT(read_req.result == size); - ASSERT(strncmp(buf, expected, size) == 0); + ASSERT_EQ(r, size); + ASSERT_EQ(read_req.result, size); + ASSERT_OK(strncmp(buf, expected, size)); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); cleanup(); @@ -205,19 +205,19 @@ static void writeFail(char *file, int error) { iov = uv_buf_init("z", 1); r = uv_fs_write(NULL, &write_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == error); - ASSERT(write_req.result == error); + ASSERT_EQ(r, error); + ASSERT_EQ(write_req.result, error); uv_fs_req_cleanup(&write_req); iov = uv_buf_init("z", 1); r = uv_fs_write(NULL, &write_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == error); - ASSERT(write_req.result == error); + ASSERT_EQ(r, error); + ASSERT_EQ(write_req.result, error); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); cleanup(); @@ -230,14 +230,14 @@ static void readExpect(char *file, char *expected, int size) { iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == size); - ASSERT(read_req.result == size); - ASSERT(strncmp(buf, expected, size) == 0); + ASSERT_EQ(r, size); + ASSERT_EQ(read_req.result, size); + ASSERT_OK(strncmp(buf, expected, size)); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); cleanup(); @@ -250,19 +250,19 @@ static void readFail(char *file, int error) { iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == error); - ASSERT(read_req.result == error); + ASSERT_EQ(r, error); + ASSERT_EQ(read_req.result, error); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req.result, &iov, 1, -1, NULL); - ASSERT(r == error); - ASSERT(read_req.result == error); + ASSERT_EQ(r, error); + ASSERT_EQ(read_req.result, error); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); cleanup(); diff --git a/deps/libuv/test/test-fs-poll.c b/deps/libuv/test/test-fs-poll.c index af486023..5f95baf3 100644 --- a/deps/libuv/test/test-fs-poll.c +++ b/deps/libuv/test/test-fs-poll.c @@ -103,44 +103,44 @@ static void poll_cb(uv_fs_poll_t* handle, memset(&zero_statbuf, 0, sizeof(zero_statbuf)); - ASSERT(handle == &poll_handle); - ASSERT(1 == uv_is_active((uv_handle_t*) handle)); + ASSERT_PTR_EQ(handle, &poll_handle); + ASSERT_EQ(1, uv_is_active((uv_handle_t*) handle)); ASSERT_NOT_NULL(prev); ASSERT_NOT_NULL(curr); switch (poll_cb_called++) { case 0: - ASSERT(status == UV_ENOENT); - ASSERT(0 == memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_EQ(status, UV_ENOENT); + ASSERT_OK(memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_OK(memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); touch_file(FIXTURE); break; case 1: - ASSERT(status == 0); - ASSERT(0 == memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 20, 0)); + ASSERT_OK(status); + ASSERT_OK(memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_NE(0, memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 20, 0)); break; case 2: - ASSERT(status == 0); - ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 200, 0)); + ASSERT_OK(status); + ASSERT_NE(0, memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_NE(0, memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 200, 0)); break; case 3: - ASSERT(status == 0); - ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_OK(status); + ASSERT_NE(0, memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_NE(0, memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); remove(FIXTURE); break; case 4: - ASSERT(status == UV_ENOENT); - ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); - ASSERT(0 == memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_EQ(status, UV_ENOENT); + ASSERT_NE(0, memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); + ASSERT_OK(memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); uv_close((uv_handle_t*)handle, close_cb); break; @@ -155,14 +155,14 @@ TEST_IMPL(fs_poll) { remove(FIXTURE); - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_fs_poll_init(loop, &poll_handle)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb, FIXTURE, 100)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_fs_poll_init(loop, &poll_handle)); + ASSERT_OK(uv_fs_poll_start(&poll_handle, poll_cb, FIXTURE, 100)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(poll_cb_called == 5); - ASSERT(timer_cb_called == 2); - ASSERT(close_cb_called == 1); + ASSERT_EQ(5, poll_cb_called); + ASSERT_EQ(2, timer_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -176,21 +176,21 @@ TEST_IMPL(fs_poll_getpath) { remove(FIXTURE); - ASSERT(0 == uv_fs_poll_init(loop, &poll_handle)); + ASSERT_OK(uv_fs_poll_init(loop, &poll_handle)); len = sizeof buf; - ASSERT(UV_EINVAL == uv_fs_poll_getpath(&poll_handle, buf, &len)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); + ASSERT_EQ(UV_EINVAL, uv_fs_poll_getpath(&poll_handle, buf, &len)); + ASSERT_OK(uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); len = sizeof buf; - ASSERT(0 == uv_fs_poll_getpath(&poll_handle, buf, &len)); - ASSERT(buf[len - 1] != 0); - ASSERT(buf[len] == '\0'); - ASSERT(0 == memcmp(buf, FIXTURE, len)); + ASSERT_OK(uv_fs_poll_getpath(&poll_handle, buf, &len)); + ASSERT_NE(0, buf[len - 1]); + ASSERT_EQ(buf[len], '\0'); + ASSERT_OK(memcmp(buf, FIXTURE, len)); uv_close((uv_handle_t*) &poll_handle, close_cb); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -203,14 +203,14 @@ TEST_IMPL(fs_poll_close_request) { remove(FIXTURE); - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); - ASSERT(0 == uv_fs_poll_init(&loop, &poll_handle)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); + ASSERT_OK(uv_fs_poll_init(&loop, &poll_handle)); + ASSERT_OK(uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); uv_close((uv_handle_t*) &poll_handle, close_cb); while (close_cb_called == 0) uv_run(&loop, UV_RUN_ONCE); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; @@ -223,18 +223,18 @@ TEST_IMPL(fs_poll_close_request_multi_start_stop) { remove(FIXTURE); - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); - ASSERT(0 == uv_fs_poll_init(&loop, &poll_handle)); + ASSERT_OK(uv_fs_poll_init(&loop, &poll_handle)); for (i = 0; i < 10; ++i) { - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); - ASSERT(0 == uv_fs_poll_stop(&poll_handle)); + ASSERT_OK(uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); + ASSERT_OK(uv_fs_poll_stop(&poll_handle)); } uv_close((uv_handle_t*) &poll_handle, close_cb); while (close_cb_called == 0) uv_run(&loop, UV_RUN_ONCE); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; @@ -247,18 +247,18 @@ TEST_IMPL(fs_poll_close_request_multi_stop_start) { remove(FIXTURE); - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); - ASSERT(0 == uv_fs_poll_init(&loop, &poll_handle)); + ASSERT_OK(uv_fs_poll_init(&loop, &poll_handle)); for (i = 0; i < 10; ++i) { - ASSERT(0 == uv_fs_poll_stop(&poll_handle)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); + ASSERT_OK(uv_fs_poll_stop(&poll_handle)); + ASSERT_OK(uv_fs_poll_start(&poll_handle, poll_cb_fail, FIXTURE, 100)); } uv_close((uv_handle_t*) &poll_handle, close_cb); while (close_cb_called == 0) uv_run(&loop, UV_RUN_ONCE); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; @@ -271,21 +271,21 @@ TEST_IMPL(fs_poll_close_request_stop_when_active) { remove(FIXTURE); - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); /* Set up all handles. */ - ASSERT(0 == uv_fs_poll_init(&loop, &poll_handle)); - ASSERT(0 == uv_fs_poll_start(&poll_handle, poll_cb_noop, FIXTURE, 100)); + ASSERT_OK(uv_fs_poll_init(&loop, &poll_handle)); + ASSERT_OK(uv_fs_poll_start(&poll_handle, poll_cb_noop, FIXTURE, 100)); uv_run(&loop, UV_RUN_ONCE); /* Close the timer handle, and do not crash. */ - ASSERT(0 == uv_fs_poll_stop(&poll_handle)); + ASSERT_OK(uv_fs_poll_stop(&poll_handle)); uv_run(&loop, UV_RUN_ONCE); /* Clean up after the test. */ uv_close((uv_handle_t*) &poll_handle, close_cb); uv_run(&loop, UV_RUN_ONCE); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; diff --git a/deps/libuv/test/test-fs-readdir.c b/deps/libuv/test/test-fs-readdir.c index 43c9edf1..b6b5b7ff 100644 --- a/deps/libuv/test/test-fs-readdir.c +++ b/deps/libuv/test/test-fs-readdir.c @@ -47,9 +47,9 @@ static void cleanup_test_files(void) { } static void empty_closedir_cb(uv_fs_t* req) { - ASSERT(req == &closedir_req); - ASSERT(req->fs_type == UV_FS_CLOSEDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &closedir_req); + ASSERT_EQ(req->fs_type, UV_FS_CLOSEDIR); + ASSERT_OK(req->result); ++empty_closedir_cb_count; uv_fs_req_cleanup(req); } @@ -58,25 +58,25 @@ static void empty_readdir_cb(uv_fs_t* req) { uv_dir_t* dir; int r; - ASSERT(req == &readdir_req); - ASSERT(req->fs_type == UV_FS_READDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &readdir_req); + ASSERT_EQ(req->fs_type, UV_FS_READDIR); + ASSERT_OK(req->result); dir = req->ptr; uv_fs_req_cleanup(req); r = uv_fs_closedir(uv_default_loop(), &closedir_req, dir, empty_closedir_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void empty_opendir_cb(uv_fs_t* req) { uv_dir_t* dir; int r; - ASSERT(req == &opendir_req); - ASSERT(req->fs_type == UV_FS_OPENDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &opendir_req); + ASSERT_EQ(req->fs_type, UV_FS_OPENDIR); + ASSERT_OK(req->result); ASSERT_NOT_NULL(req->ptr); dir = req->ptr; dir->dirents = dirents; @@ -85,7 +85,7 @@ static void empty_opendir_cb(uv_fs_t* req) { &readdir_req, dir, empty_readdir_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(req); ++empty_opendir_cb_count; } @@ -115,9 +115,9 @@ TEST_IMPL(fs_readdir_empty_dir) { &opendir_req, path, NULL); - ASSERT(r == 0); - ASSERT(opendir_req.fs_type == UV_FS_OPENDIR); - ASSERT(opendir_req.result == 0); + ASSERT_OK(r); + ASSERT_EQ(opendir_req.fs_type, UV_FS_OPENDIR); + ASSERT_OK(opendir_req.result); ASSERT_NOT_NULL(opendir_req.ptr); dir = opendir_req.ptr; uv_fs_req_cleanup(&opendir_req); @@ -130,13 +130,13 @@ TEST_IMPL(fs_readdir_empty_dir) { &readdir_req, dir, NULL); - ASSERT(nb_entries_read == 0); + ASSERT_OK(nb_entries_read); uv_fs_req_cleanup(&readdir_req); /* Fill the req to ensure that required fields are cleaned up. */ memset(&closedir_req, 0xdb, sizeof(closedir_req)); uv_fs_closedir(uv_default_loop(), &closedir_req, dir, NULL); - ASSERT(closedir_req.result == 0); + ASSERT_OK(closedir_req.result); uv_fs_req_cleanup(&closedir_req); /* Testing the asynchronous flavor. */ @@ -147,13 +147,13 @@ TEST_IMPL(fs_readdir_empty_dir) { memset(&closedir_req, 0xdb, sizeof(closedir_req)); r = uv_fs_opendir(uv_default_loop(), &opendir_req, path, empty_opendir_cb); - ASSERT(r == 0); - ASSERT(empty_opendir_cb_count == 0); - ASSERT(empty_closedir_cb_count == 0); + ASSERT_OK(r); + ASSERT_OK(empty_opendir_cb_count); + ASSERT_OK(empty_closedir_cb_count); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(empty_opendir_cb_count == 1); - ASSERT(empty_closedir_cb_count == 1); + ASSERT_OK(r); + ASSERT_EQ(1, empty_opendir_cb_count); + ASSERT_EQ(1, empty_closedir_cb_count); uv_fs_rmdir(uv_default_loop(), &rmdir_req, path, NULL); uv_fs_req_cleanup(&rmdir_req); MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -168,9 +168,9 @@ TEST_IMPL(fs_readdir_empty_dir) { static int non_existing_opendir_cb_count; static void non_existing_opendir_cb(uv_fs_t* req) { - ASSERT(req == &opendir_req); - ASSERT(req->fs_type == UV_FS_OPENDIR); - ASSERT(req->result == UV_ENOENT); + ASSERT_PTR_EQ(req, &opendir_req); + ASSERT_EQ(req->fs_type, UV_FS_OPENDIR); + ASSERT_EQ(req->result, UV_ENOENT); ASSERT_NULL(req->ptr); uv_fs_req_cleanup(req); @@ -188,9 +188,9 @@ TEST_IMPL(fs_readdir_non_existing_dir) { /* Testing the synchronous flavor. */ r = uv_fs_opendir(uv_default_loop(), &opendir_req, path, NULL); - ASSERT(r == UV_ENOENT); - ASSERT(opendir_req.fs_type == UV_FS_OPENDIR); - ASSERT(opendir_req.result == UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); + ASSERT_EQ(opendir_req.fs_type, UV_FS_OPENDIR); + ASSERT_EQ(opendir_req.result, UV_ENOENT); ASSERT_NULL(opendir_req.ptr); uv_fs_req_cleanup(&opendir_req); @@ -202,11 +202,11 @@ TEST_IMPL(fs_readdir_non_existing_dir) { &opendir_req, path, non_existing_opendir_cb); - ASSERT(r == 0); - ASSERT(non_existing_opendir_cb_count == 0); + ASSERT_OK(r); + ASSERT_OK(non_existing_opendir_cb_count); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(non_existing_opendir_cb_count == 1); + ASSERT_OK(r); + ASSERT_EQ(1, non_existing_opendir_cb_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -220,9 +220,9 @@ TEST_IMPL(fs_readdir_non_existing_dir) { static int file_opendir_cb_count; static void file_opendir_cb(uv_fs_t* req) { - ASSERT(req == &opendir_req); - ASSERT(req->fs_type == UV_FS_OPENDIR); - ASSERT(req->result == UV_ENOTDIR); + ASSERT_PTR_EQ(req, &opendir_req); + ASSERT_EQ(req->fs_type, UV_FS_OPENDIR); + ASSERT_EQ(req->result, UV_ENOTDIR); ASSERT_NULL(req->ptr); uv_fs_req_cleanup(req); @@ -241,9 +241,9 @@ TEST_IMPL(fs_readdir_file) { /* Testing the synchronous flavor. */ r = uv_fs_opendir(uv_default_loop(), &opendir_req, path, NULL); - ASSERT(r == UV_ENOTDIR); - ASSERT(opendir_req.fs_type == UV_FS_OPENDIR); - ASSERT(opendir_req.result == UV_ENOTDIR); + ASSERT_EQ(r, UV_ENOTDIR); + ASSERT_EQ(opendir_req.fs_type, UV_FS_OPENDIR); + ASSERT_EQ(opendir_req.result, UV_ENOTDIR); ASSERT_NULL(opendir_req.ptr); uv_fs_req_cleanup(&opendir_req); @@ -253,11 +253,11 @@ TEST_IMPL(fs_readdir_file) { /* Testing the async flavor. */ r = uv_fs_opendir(uv_default_loop(), &opendir_req, path, file_opendir_cb); - ASSERT(r == 0); - ASSERT(file_opendir_cb_count == 0); + ASSERT_OK(r); + ASSERT_OK(file_opendir_cb_count); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(file_opendir_cb_count == 1); + ASSERT_OK(r); + ASSERT_EQ(1, file_opendir_cb_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } @@ -273,8 +273,8 @@ static int non_empty_readdir_cb_count; static int non_empty_closedir_cb_count; static void non_empty_closedir_cb(uv_fs_t* req) { - ASSERT(req == &closedir_req); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &closedir_req); + ASSERT_OK(req->result); uv_fs_req_cleanup(req); ++non_empty_closedir_cb_count; } @@ -282,30 +282,30 @@ static void non_empty_closedir_cb(uv_fs_t* req) { static void non_empty_readdir_cb(uv_fs_t* req) { uv_dir_t* dir; - ASSERT(req == &readdir_req); - ASSERT(req->fs_type == UV_FS_READDIR); + ASSERT_PTR_EQ(req, &readdir_req); + ASSERT_EQ(req->fs_type, UV_FS_READDIR); dir = req->ptr; if (req->result == 0) { uv_fs_req_cleanup(req); - ASSERT(non_empty_readdir_cb_count == 3); + ASSERT_EQ(3, non_empty_readdir_cb_count); uv_fs_closedir(uv_default_loop(), &closedir_req, dir, non_empty_closedir_cb); } else { - ASSERT(req->result == 1); - ASSERT(dir->dirents == dirents); + ASSERT_EQ(1, req->result); + ASSERT_PTR_EQ(dir->dirents, dirents); ASSERT(strcmp(dirents[0].name, "file1") == 0 || strcmp(dirents[0].name, "file2") == 0 || strcmp(dirents[0].name, "test_subdir") == 0); #ifdef HAVE_DIRENT_TYPES if (!strcmp(dirents[0].name, "test_subdir")) - ASSERT(dirents[0].type == UV_DIRENT_DIR); + ASSERT_EQ(dirents[0].type, UV_DIRENT_DIR); else - ASSERT(dirents[0].type == UV_DIRENT_FILE); + ASSERT_EQ(dirents[0].type, UV_DIRENT_FILE); #else - ASSERT(dirents[0].type == UV_DIRENT_UNKNOWN); + ASSERT_EQ(dirents[0].type, UV_DIRENT_UNKNOWN); #endif /* HAVE_DIRENT_TYPES */ ++non_empty_readdir_cb_count; @@ -323,9 +323,9 @@ static void non_empty_opendir_cb(uv_fs_t* req) { uv_dir_t* dir; int r; - ASSERT(req == &opendir_req); - ASSERT(req->fs_type == UV_FS_OPENDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &opendir_req); + ASSERT_EQ(req->fs_type, UV_FS_OPENDIR); + ASSERT_OK(req->result); ASSERT_NOT_NULL(req->ptr); dir = req->ptr; @@ -336,7 +336,7 @@ static void non_empty_opendir_cb(uv_fs_t* req) { &readdir_req, dir, non_empty_readdir_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(req); ++non_empty_opendir_cb_count; } @@ -353,7 +353,7 @@ TEST_IMPL(fs_readdir_non_empty_dir) { cleanup_test_files(); r = uv_fs_mkdir(uv_default_loop(), &mkdir_req, "test_dir", 0755, NULL); - ASSERT(r == 0); + ASSERT_OK(r); /* Create two files synchronously. */ r = uv_fs_open(uv_default_loop(), @@ -361,13 +361,13 @@ TEST_IMPL(fs_readdir_non_empty_dir) { "test_dir/file1", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&create_req); r = uv_fs_close(uv_default_loop(), &close_req, create_req.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_open(uv_default_loop(), @@ -375,13 +375,13 @@ TEST_IMPL(fs_readdir_non_empty_dir) { "test_dir/file2", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&create_req); r = uv_fs_close(uv_default_loop(), &close_req, create_req.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_mkdir(uv_default_loop(), @@ -389,7 +389,7 @@ TEST_IMPL(fs_readdir_non_empty_dir) { "test_dir/test_subdir", 0755, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&mkdir_req); /* Fill the req to ensure that required fields are cleaned up. */ @@ -397,9 +397,9 @@ TEST_IMPL(fs_readdir_non_empty_dir) { /* Testing the synchronous flavor. */ r = uv_fs_opendir(uv_default_loop(), &opendir_req, "test_dir", NULL); - ASSERT(r == 0); - ASSERT(opendir_req.fs_type == UV_FS_OPENDIR); - ASSERT(opendir_req.result == 0); + ASSERT_OK(r); + ASSERT_EQ(opendir_req.fs_type, UV_FS_OPENDIR); + ASSERT_OK(opendir_req.result); ASSERT_NOT_NULL(opendir_req.ptr); entries_count = 0; @@ -417,23 +417,23 @@ TEST_IMPL(fs_readdir_non_empty_dir) { strcmp(dirents[0].name, "test_subdir") == 0); #ifdef HAVE_DIRENT_TYPES if (!strcmp(dirents[0].name, "test_subdir")) - ASSERT(dirents[0].type == UV_DIRENT_DIR); + ASSERT_EQ(dirents[0].type, UV_DIRENT_DIR); else - ASSERT(dirents[0].type == UV_DIRENT_FILE); + ASSERT_EQ(dirents[0].type, UV_DIRENT_FILE); #else - ASSERT(dirents[0].type == UV_DIRENT_UNKNOWN); + ASSERT_EQ(dirents[0].type, UV_DIRENT_UNKNOWN); #endif /* HAVE_DIRENT_TYPES */ uv_fs_req_cleanup(&readdir_req); ++entries_count; } - ASSERT(entries_count == 3); + ASSERT_EQ(3, entries_count); uv_fs_req_cleanup(&readdir_req); /* Fill the req to ensure that required fields are cleaned up. */ memset(&closedir_req, 0xdb, sizeof(closedir_req)); uv_fs_closedir(uv_default_loop(), &closedir_req, dir, NULL); - ASSERT(closedir_req.result == 0); + ASSERT_OK(closedir_req.result); uv_fs_req_cleanup(&closedir_req); /* Testing the asynchronous flavor. */ @@ -445,13 +445,13 @@ TEST_IMPL(fs_readdir_non_empty_dir) { &opendir_req, "test_dir", non_empty_opendir_cb); - ASSERT(r == 0); - ASSERT(non_empty_opendir_cb_count == 0); - ASSERT(non_empty_closedir_cb_count == 0); + ASSERT_OK(r); + ASSERT_OK(non_empty_opendir_cb_count); + ASSERT_OK(non_empty_closedir_cb_count); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(non_empty_opendir_cb_count == 1); - ASSERT(non_empty_closedir_cb_count == 1); + ASSERT_OK(r); + ASSERT_EQ(1, non_empty_opendir_cb_count); + ASSERT_EQ(1, non_empty_closedir_cb_count); uv_fs_rmdir(uv_default_loop(), &rmdir_req, "test_subdir", NULL); uv_fs_req_cleanup(&rmdir_req); diff --git a/deps/libuv/test/test-fs.c b/deps/libuv/test/test-fs.c index e687dde3..1acdc5c6 100644 --- a/deps/libuv/test/test-fs.c +++ b/deps/libuv/test/test-fs.c @@ -170,8 +170,8 @@ static void check_permission(const char* filename, unsigned int mode) { uv_stat_t* s; r = uv_fs_stat(NULL, &req, filename, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); s = &req.statbuf; #if defined(_WIN32) || defined(__CYGWIN__) || defined(__MSYS__) @@ -195,24 +195,24 @@ static void dummy_cb(uv_fs_t* req) { static void link_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_LINK); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_LINK); + ASSERT_OK(req->result); link_cb_count++; uv_fs_req_cleanup(req); } static void symlink_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_SYMLINK); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_SYMLINK); + ASSERT_OK(req->result); symlink_cb_count++; uv_fs_req_cleanup(req); } static void readlink_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_READLINK); - ASSERT(req->result == 0); - ASSERT(strcmp(req->ptr, "test_file_symlink2") == 0); + ASSERT_EQ(req->fs_type, UV_FS_READLINK); + ASSERT_OK(req->result); + ASSERT_OK(strcmp(req->ptr, "test_file_symlink2")); readlink_cb_count++; uv_fs_req_cleanup(req); } @@ -221,16 +221,16 @@ static void readlink_cb(uv_fs_t* req) { static void realpath_cb(uv_fs_t* req) { char test_file_abs_buf[PATHMAX]; size_t test_file_abs_size = sizeof(test_file_abs_buf); - ASSERT(req->fs_type == UV_FS_REALPATH); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_REALPATH); + ASSERT_OK(req->result); uv_cwd(test_file_abs_buf, &test_file_abs_size); #ifdef _WIN32 strcat(test_file_abs_buf, "\\test_file"); - ASSERT(stricmp(req->ptr, test_file_abs_buf) == 0); + ASSERT_OK(stricmp(req->ptr, test_file_abs_buf)); #else strcat(test_file_abs_buf, "/test_file"); - ASSERT(strcmp(req->ptr, test_file_abs_buf) == 0); + ASSERT_OK(strcmp(req->ptr, test_file_abs_buf)); #endif realpath_cb_count++; uv_fs_req_cleanup(req); @@ -238,15 +238,15 @@ static void realpath_cb(uv_fs_t* req) { static void access_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_ACCESS); + ASSERT_EQ(req->fs_type, UV_FS_ACCESS); access_cb_count++; uv_fs_req_cleanup(req); } static void fchmod_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_FCHMOD); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_FCHMOD); + ASSERT_OK(req->result); fchmod_cb_count++; uv_fs_req_cleanup(req); check_permission("test_file", *(int*)req->data); @@ -254,8 +254,8 @@ static void fchmod_cb(uv_fs_t* req) { static void chmod_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_CHMOD); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_CHMOD); + ASSERT_OK(req->result); chmod_cb_count++; uv_fs_req_cleanup(req); check_permission("test_file", *(int*)req->data); @@ -263,42 +263,42 @@ static void chmod_cb(uv_fs_t* req) { static void fchown_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_FCHOWN); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_FCHOWN); + ASSERT_OK(req->result); fchown_cb_count++; uv_fs_req_cleanup(req); } static void chown_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_CHOWN); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_CHOWN); + ASSERT_OK(req->result); chown_cb_count++; uv_fs_req_cleanup(req); } static void lchown_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_LCHOWN); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_LCHOWN); + ASSERT_OK(req->result); lchown_cb_count++; uv_fs_req_cleanup(req); } static void chown_root_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_CHOWN); + ASSERT_EQ(req->fs_type, UV_FS_CHOWN); #if defined(_WIN32) || defined(__MSYS__) /* On windows, chown is a no-op and always succeeds. */ - ASSERT(req->result == 0); + ASSERT_OK(req->result); #else /* On unix, chown'ing the root directory is not allowed - * unless you're root, of course. */ if (geteuid() == 0) - ASSERT(req->result == 0); + ASSERT_OK(req->result); else # if defined(__CYGWIN__) /* On Cygwin, uid 0 is invalid (no root). */ - ASSERT(req->result == UV_EINVAL); + ASSERT_EQ(req->result, UV_EINVAL); # elif defined(__PASE__) /* On IBMi PASE, there is no root user. uid 0 is user qsecofr. * User may grant qsecofr's privileges, including changing @@ -306,7 +306,7 @@ static void chown_root_cb(uv_fs_t* req) { */ ASSERT(req->result == 0 || req->result == UV_EPERM); # else - ASSERT(req->result == UV_EPERM); + ASSERT_EQ(req->result, UV_EPERM); # endif #endif chown_cb_count++; @@ -314,18 +314,18 @@ static void chown_root_cb(uv_fs_t* req) { } static void unlink_cb(uv_fs_t* req) { - ASSERT(req == &unlink_req); - ASSERT(req->fs_type == UV_FS_UNLINK); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &unlink_req); + ASSERT_EQ(req->fs_type, UV_FS_UNLINK); + ASSERT_OK(req->result); unlink_cb_count++; uv_fs_req_cleanup(req); } static void fstat_cb(uv_fs_t* req) { uv_stat_t* s = req->ptr; - ASSERT(req->fs_type == UV_FS_FSTAT); - ASSERT(req->result == 0); - ASSERT(s->st_size == sizeof(test_buf)); + ASSERT_EQ(req->fs_type, UV_FS_FSTAT); + ASSERT_OK(req->result); + ASSERT_EQ(s->st_size, sizeof(test_buf)); uv_fs_req_cleanup(req); fstat_cb_count++; } @@ -334,29 +334,29 @@ static void fstat_cb(uv_fs_t* req) { static void statfs_cb(uv_fs_t* req) { uv_statfs_t* stats; - ASSERT(req->fs_type == UV_FS_STATFS); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_STATFS); + ASSERT_OK(req->result); ASSERT_NOT_NULL(req->ptr); stats = req->ptr; #if defined(_WIN32) || defined(__sun) || defined(_AIX) || defined(__MVS__) || \ defined(__OpenBSD__) || defined(__NetBSD__) - ASSERT(stats->f_type == 0); + ASSERT_OK(stats->f_type); #else - ASSERT(stats->f_type > 0); + ASSERT_GT(stats->f_type, 0); #endif - ASSERT(stats->f_bsize > 0); - ASSERT(stats->f_blocks > 0); - ASSERT(stats->f_bfree <= stats->f_blocks); - ASSERT(stats->f_bavail <= stats->f_bfree); + ASSERT_GT(stats->f_bsize, 0); + ASSERT_GT(stats->f_blocks, 0); + ASSERT_LE(stats->f_bfree, stats->f_blocks); + ASSERT_LE(stats->f_bavail, stats->f_bfree); #ifdef _WIN32 - ASSERT(stats->f_files == 0); - ASSERT(stats->f_ffree == 0); + ASSERT_OK(stats->f_files); + ASSERT_OK(stats->f_ffree); #else /* There is no assertion for stats->f_files that makes sense, so ignore it. */ - ASSERT(stats->f_ffree <= stats->f_files); + ASSERT_LE(stats->f_ffree, stats->f_files); #endif uv_fs_req_cleanup(req); ASSERT_NULL(req->ptr); @@ -366,27 +366,27 @@ static void statfs_cb(uv_fs_t* req) { static void close_cb(uv_fs_t* req) { int r; - ASSERT(req == &close_req); - ASSERT(req->fs_type == UV_FS_CLOSE); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &close_req); + ASSERT_EQ(req->fs_type, UV_FS_CLOSE); + ASSERT_OK(req->result); close_cb_count++; uv_fs_req_cleanup(req); if (close_cb_count == 3) { r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb); - ASSERT(r == 0); + ASSERT_OK(r); } } static void ftruncate_cb(uv_fs_t* req) { int r; - ASSERT(req == &ftruncate_req); - ASSERT(req->fs_type == UV_FS_FTRUNCATE); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &ftruncate_req); + ASSERT_EQ(req->fs_type, UV_FS_FTRUNCATE); + ASSERT_OK(req->result); ftruncate_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void fail_cb(uv_fs_t* req) { @@ -395,45 +395,45 @@ static void fail_cb(uv_fs_t* req) { static void read_cb(uv_fs_t* req) { int r; - ASSERT(req == &read_req); - ASSERT(req->fs_type == UV_FS_READ); - ASSERT(req->result >= 0); /* FIXME(bnoordhuis) Check if requested size? */ + ASSERT_PTR_EQ(req, &read_req); + ASSERT_EQ(req->fs_type, UV_FS_READ); + ASSERT_GE(req->result, 0); /* FIXME(bnoordhuis) Check if requested size? */ read_cb_count++; uv_fs_req_cleanup(req); if (read_cb_count == 1) { - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_OK(strcmp(buf, test_buf)); r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, ftruncate_cb); } else { - ASSERT(strcmp(buf, "test-bu") == 0); + ASSERT_OK(strcmp(buf, "test-bu")); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); } - ASSERT(r == 0); + ASSERT_OK(r); } static void open_cb(uv_fs_t* req) { int r; - ASSERT(req == &open_req1); - ASSERT(req->fs_type == UV_FS_OPEN); + ASSERT_PTR_EQ(req, &open_req1); + ASSERT_EQ(req->fs_type, UV_FS_OPEN); if (req->result < 0) { fprintf(stderr, "async open error: %d\n", (int) req->result); ASSERT(0); } open_cb_count++; ASSERT(req->path); - ASSERT(memcmp(req->path, "test_file2\0", 11) == 0); + ASSERT_OK(memcmp(req->path, "test_file2\0", 11)); uv_fs_req_cleanup(req); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(loop, &read_req, open_req1.result, &iov, 1, -1, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void open_cb_simple(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); + ASSERT_EQ(req->fs_type, UV_FS_OPEN); if (req->result < 0) { fprintf(stderr, "async open error: %d\n", (int) req->result); ASSERT(0); @@ -446,69 +446,69 @@ static void open_cb_simple(uv_fs_t* req) { static void fsync_cb(uv_fs_t* req) { int r; - ASSERT(req == &fsync_req); - ASSERT(req->fs_type == UV_FS_FSYNC); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &fsync_req); + ASSERT_EQ(req->fs_type, UV_FS_FSYNC); + ASSERT_OK(req->result); fsync_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void fdatasync_cb(uv_fs_t* req) { int r; - ASSERT(req == &fdatasync_req); - ASSERT(req->fs_type == UV_FS_FDATASYNC); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &fdatasync_req); + ASSERT_EQ(req->fs_type, UV_FS_FDATASYNC); + ASSERT_OK(req->result); fdatasync_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void write_cb(uv_fs_t* req) { int r; - ASSERT(req == &write_req); - ASSERT(req->fs_type == UV_FS_WRITE); - ASSERT(req->result >= 0); /* FIXME(bnoordhuis) Check if requested size? */ + ASSERT_PTR_EQ(req, &write_req); + ASSERT_EQ(req->fs_type, UV_FS_WRITE); + ASSERT_GE(req->result, 0); /* FIXME(bnoordhuis) Check if requested size? */ write_cb_count++; uv_fs_req_cleanup(req); r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void create_cb(uv_fs_t* req) { int r; - ASSERT(req == &open_req1); - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result >= 0); + ASSERT_PTR_EQ(req, &open_req1); + ASSERT_EQ(req->fs_type, UV_FS_OPEN); + ASSERT_GE(req->result, 0); create_cb_count++; uv_fs_req_cleanup(req); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(loop, &write_req, req->result, &iov, 1, -1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void rename_cb(uv_fs_t* req) { - ASSERT(req == &rename_req); - ASSERT(req->fs_type == UV_FS_RENAME); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &rename_req); + ASSERT_EQ(req->fs_type, UV_FS_RENAME); + ASSERT_OK(req->result); rename_cb_count++; uv_fs_req_cleanup(req); } static void mkdir_cb(uv_fs_t* req) { - ASSERT(req == &mkdir_req); - ASSERT(req->fs_type == UV_FS_MKDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &mkdir_req); + ASSERT_EQ(req->fs_type, UV_FS_MKDIR); + ASSERT_OK(req->result); mkdir_cb_count++; ASSERT(req->path); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); + ASSERT_OK(memcmp(req->path, "test_dir\0", 9)); uv_fs_req_cleanup(req); } @@ -516,24 +516,24 @@ static void mkdir_cb(uv_fs_t* req) { static void check_mkdtemp_result(uv_fs_t* req) { int r; - ASSERT(req->fs_type == UV_FS_MKDTEMP); - ASSERT(req->result == 0); + ASSERT_EQ(req->fs_type, UV_FS_MKDTEMP); + ASSERT_OK(req->result); ASSERT(req->path); - ASSERT(strlen(req->path) == 15); - ASSERT(memcmp(req->path, "test_dir_", 9) == 0); - ASSERT(memcmp(req->path + 9, "XXXXXX", 6) != 0); + ASSERT_EQ(15, strlen(req->path)); + ASSERT_OK(memcmp(req->path, "test_dir_", 9)); + ASSERT_NE(0, memcmp(req->path + 9, "XXXXXX", 6)); check_permission(req->path, 0700); /* Check if req->path is actually a directory */ r = uv_fs_stat(NULL, &stat_req, req->path, NULL); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(((uv_stat_t*)stat_req.ptr)->st_mode & S_IFDIR); uv_fs_req_cleanup(&stat_req); } static void mkdtemp_cb(uv_fs_t* req) { - ASSERT(req == &mkdtemp_req1); + ASSERT_PTR_EQ(req, &mkdtemp_req1); check_mkdtemp_result(req); mkdtemp_cb_count++; } @@ -542,36 +542,36 @@ static void mkdtemp_cb(uv_fs_t* req) { static void check_mkstemp_result(uv_fs_t* req) { int r; - ASSERT(req->fs_type == UV_FS_MKSTEMP); - ASSERT(req->result >= 0); + ASSERT_EQ(req->fs_type, UV_FS_MKSTEMP); + ASSERT_GE(req->result, 0); ASSERT(req->path); - ASSERT(strlen(req->path) == 16); - ASSERT(memcmp(req->path, "test_file_", 10) == 0); - ASSERT(memcmp(req->path + 10, "XXXXXX", 6) != 0); + ASSERT_EQ(16, strlen(req->path)); + ASSERT_OK(memcmp(req->path, "test_file_", 10)); + ASSERT_NE(0, memcmp(req->path + 10, "XXXXXX", 6)); check_permission(req->path, 0600); /* Check if req->path is actually a file */ r = uv_fs_stat(NULL, &stat_req, req->path, NULL); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(stat_req.statbuf.st_mode & S_IFREG); uv_fs_req_cleanup(&stat_req); } static void mkstemp_cb(uv_fs_t* req) { - ASSERT(req == &mkstemp_req1); + ASSERT_PTR_EQ(req, &mkstemp_req1); check_mkstemp_result(req); mkstemp_cb_count++; } static void rmdir_cb(uv_fs_t* req) { - ASSERT(req == &rmdir_req); - ASSERT(req->fs_type == UV_FS_RMDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &rmdir_req); + ASSERT_EQ(req->fs_type, UV_FS_RMDIR); + ASSERT_OK(req->result); rmdir_cb_count++; ASSERT(req->path); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); + ASSERT_OK(memcmp(req->path, "test_dir\0", 9)); uv_fs_req_cleanup(req); } @@ -588,21 +588,21 @@ static void assert_is_file_type(uv_dirent_t dent) { * https://github.com/libuv/libuv/issues/501 */ #if defined(__APPLE__) || defined(_WIN32) - ASSERT(dent.type == UV_DIRENT_FILE); + ASSERT_EQ(dent.type, UV_DIRENT_FILE); #else ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN); #endif #else - ASSERT(dent.type == UV_DIRENT_UNKNOWN); + ASSERT_EQ(dent.type, UV_DIRENT_UNKNOWN); #endif } static void scandir_cb(uv_fs_t* req) { uv_dirent_t dent; - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == 2); + ASSERT_PTR_EQ(req, &scandir_req); + ASSERT_EQ(req->fs_type, UV_FS_SCANDIR); + ASSERT_EQ(2, req->result); ASSERT(req->ptr); while (UV_EOF != uv_fs_scandir_next(req, &dent)) { @@ -611,7 +611,7 @@ static void scandir_cb(uv_fs_t* req) { } scandir_cb_count++; ASSERT(req->path); - ASSERT(memcmp(req->path, "test_dir\0", 9) == 0); + ASSERT_OK(memcmp(req->path, "test_dir\0", 9)); uv_fs_req_cleanup(req); ASSERT(!req->ptr); } @@ -620,11 +620,11 @@ static void scandir_cb(uv_fs_t* req) { static void empty_scandir_cb(uv_fs_t* req) { uv_dirent_t dent; - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &scandir_req); + ASSERT_EQ(req->fs_type, UV_FS_SCANDIR); + ASSERT_OK(req->result); ASSERT_NULL(req->ptr); - ASSERT(UV_EOF == uv_fs_scandir_next(req, &dent)); + ASSERT_EQ(UV_EOF, uv_fs_scandir_next(req, &dent)); uv_fs_req_cleanup(req); scandir_cb_count++; } @@ -632,20 +632,20 @@ static void empty_scandir_cb(uv_fs_t* req) { static void non_existent_scandir_cb(uv_fs_t* req) { uv_dirent_t dent; - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == UV_ENOENT); + ASSERT_PTR_EQ(req, &scandir_req); + ASSERT_EQ(req->fs_type, UV_FS_SCANDIR); + ASSERT_EQ(req->result, UV_ENOENT); ASSERT_NULL(req->ptr); - ASSERT(UV_ENOENT == uv_fs_scandir_next(req, &dent)); + ASSERT_EQ(UV_ENOENT, uv_fs_scandir_next(req, &dent)); uv_fs_req_cleanup(req); scandir_cb_count++; } static void file_scandir_cb(uv_fs_t* req) { - ASSERT(req == &scandir_req); - ASSERT(req->fs_type == UV_FS_SCANDIR); - ASSERT(req->result == UV_ENOTDIR); + ASSERT_PTR_EQ(req, &scandir_req); + ASSERT_EQ(req->fs_type, UV_FS_SCANDIR); + ASSERT_EQ(req->result, UV_ENOTDIR); ASSERT_NULL(req->ptr); uv_fs_req_cleanup(req); scandir_cb_count++; @@ -653,9 +653,9 @@ static void file_scandir_cb(uv_fs_t* req) { static void stat_cb(uv_fs_t* req) { - ASSERT(req == &stat_req); + ASSERT_PTR_EQ(req, &stat_req); ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT); - ASSERT(req->result == 0); + ASSERT_OK(req->result); ASSERT(req->ptr); stat_cb_count++; uv_fs_req_cleanup(req); @@ -664,7 +664,7 @@ static void stat_cb(uv_fs_t* req) { static void stat_batch_cb(uv_fs_t* req) { ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT); - ASSERT(req->result == 0); + ASSERT_OK(req->result); ASSERT(req->ptr); stat_cb_count++; uv_fs_req_cleanup(req); @@ -673,40 +673,40 @@ static void stat_batch_cb(uv_fs_t* req) { static void sendfile_cb(uv_fs_t* req) { - ASSERT(req == &sendfile_req); - ASSERT(req->fs_type == UV_FS_SENDFILE); - ASSERT(req->result == 65545); + ASSERT_PTR_EQ(req, &sendfile_req); + ASSERT_EQ(req->fs_type, UV_FS_SENDFILE); + ASSERT_EQ(65545, req->result); sendfile_cb_count++; uv_fs_req_cleanup(req); } static void sendfile_nodata_cb(uv_fs_t* req) { - ASSERT(req == &sendfile_req); - ASSERT(req->fs_type == UV_FS_SENDFILE); - ASSERT(req->result == 0); + ASSERT_PTR_EQ(req, &sendfile_req); + ASSERT_EQ(req->fs_type, UV_FS_SENDFILE); + ASSERT_OK(req->result); sendfile_cb_count++; uv_fs_req_cleanup(req); } static void open_noent_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result == UV_ENOENT); + ASSERT_EQ(req->fs_type, UV_FS_OPEN); + ASSERT_EQ(req->result, UV_ENOENT); open_cb_count++; uv_fs_req_cleanup(req); } static void open_nametoolong_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result == UV_ENAMETOOLONG); + ASSERT_EQ(req->fs_type, UV_FS_OPEN); + ASSERT_EQ(req->result, UV_ENAMETOOLONG); open_cb_count++; uv_fs_req_cleanup(req); } static void open_loop_cb(uv_fs_t* req) { - ASSERT(req->fs_type == UV_FS_OPEN); - ASSERT(req->result == UV_ELOOP); + ASSERT_EQ(req->fs_type, UV_FS_OPEN); + ASSERT_EQ(req->result, UV_ELOOP); open_cb_count++; uv_fs_req_cleanup(req); } @@ -719,16 +719,16 @@ TEST_IMPL(fs_file_noent) { loop = uv_default_loop(); r = uv_fs_open(NULL, &req, "does_not_exist", O_RDONLY, 0, NULL); - ASSERT(r == UV_ENOENT); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); uv_fs_req_cleanup(&req); r = uv_fs_open(loop, &req, "does_not_exist", O_RDONLY, 0, open_noent_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(open_cb_count == 0); + ASSERT_OK(open_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); + ASSERT_EQ(1, open_cb_count); /* TODO add EACCES test */ @@ -747,16 +747,16 @@ TEST_IMPL(fs_file_nametoolong) { name[TOO_LONG_NAME_LENGTH] = 0; r = uv_fs_open(NULL, &req, name, O_RDONLY, 0, NULL); - ASSERT(r == UV_ENAMETOOLONG); - ASSERT(req.result == UV_ENAMETOOLONG); + ASSERT_EQ(r, UV_ENAMETOOLONG); + ASSERT_EQ(req.result, UV_ENAMETOOLONG); uv_fs_req_cleanup(&req); r = uv_fs_open(loop, &req, name, O_RDONLY, 0, open_nametoolong_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(open_cb_count == 0); + ASSERT_OK(open_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); + ASSERT_EQ(1, open_cb_count); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -783,20 +783,20 @@ TEST_IMPL(fs_file_loop) { if (r == UV_ENOENT) return 0; #endif - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); r = uv_fs_open(NULL, &req, "test_symlink", O_RDONLY, 0, NULL); - ASSERT(r == UV_ELOOP); - ASSERT(req.result == UV_ELOOP); + ASSERT_EQ(r, UV_ELOOP); + ASSERT_EQ(req.result, UV_ELOOP); uv_fs_req_cleanup(&req); r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, open_loop_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(open_cb_count == 0); + ASSERT_OK(open_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); + ASSERT_EQ(1, open_cb_count); unlink("test_symlink"); @@ -817,9 +817,9 @@ static void check_utime(const char* path, else r = uv_fs_stat(loop, &req, path, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(req.result, 0); + ASSERT_OK(req.result); s = &req.statbuf; if (s->st_atim.tv_nsec == 0 && s->st_mtim.tv_nsec == 0) { @@ -868,9 +868,9 @@ static void check_utime(const char* path, static void utime_cb(uv_fs_t* req) { utime_check_t* c; - ASSERT(req == &utime_req); - ASSERT(req->result == 0); - ASSERT(req->fs_type == UV_FS_UTIME); + ASSERT_PTR_EQ(req, &utime_req); + ASSERT_OK(req->result); + ASSERT_EQ(req->fs_type, UV_FS_UTIME); c = req->data; check_utime(c->path, c->atime, c->mtime, /* test_lutime */ 0); @@ -883,9 +883,9 @@ static void utime_cb(uv_fs_t* req) { static void futime_cb(uv_fs_t* req) { utime_check_t* c; - ASSERT(req == &futime_req); - ASSERT(req->result == 0); - ASSERT(req->fs_type == UV_FS_FUTIME); + ASSERT_PTR_EQ(req, &futime_req); + ASSERT_OK(req->result); + ASSERT_EQ(req->fs_type, UV_FS_FUTIME); c = req->data; check_utime(c->path, c->atime, c->mtime, /* test_lutime */ 0); @@ -898,8 +898,8 @@ static void futime_cb(uv_fs_t* req) { static void lutime_cb(uv_fs_t* req) { utime_check_t* c; - ASSERT(req->result == 0); - ASSERT(req->fs_type == UV_FS_LUTIME); + ASSERT_OK(req->result); + ASSERT_EQ(req->fs_type, UV_FS_LUTIME); c = req->data; check_utime(c->path, c->atime, c->mtime, /* test_lutime */ 1); @@ -920,48 +920,48 @@ TEST_IMPL(fs_file_async) { r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR, create_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(fsync_cb_count == 1); - ASSERT(fdatasync_cb_count == 1); - ASSERT(close_cb_count == 1); + ASSERT_EQ(1, create_cb_count); + ASSERT_EQ(1, write_cb_count); + ASSERT_EQ(1, fsync_cb_count); + ASSERT_EQ(1, fdatasync_cb_count); + ASSERT_EQ(1, close_cb_count); r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", rename_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(close_cb_count == 1); - ASSERT(rename_cb_count == 1); + ASSERT_EQ(1, create_cb_count); + ASSERT_EQ(1, write_cb_count); + ASSERT_EQ(1, close_cb_count); + ASSERT_EQ(1, rename_cb_count); r = uv_fs_open(loop, &open_req1, "test_file2", O_RDWR, 0, open_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); - ASSERT(read_cb_count == 1); - ASSERT(close_cb_count == 2); - ASSERT(rename_cb_count == 1); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(ftruncate_cb_count == 1); + ASSERT_EQ(1, open_cb_count); + ASSERT_EQ(1, read_cb_count); + ASSERT_EQ(2, close_cb_count); + ASSERT_EQ(1, rename_cb_count); + ASSERT_EQ(1, create_cb_count); + ASSERT_EQ(1, write_cb_count); + ASSERT_EQ(1, ftruncate_cb_count); r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, open_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 2); - ASSERT(read_cb_count == 2); - ASSERT(close_cb_count == 3); - ASSERT(rename_cb_count == 1); - ASSERT(unlink_cb_count == 1); - ASSERT(create_cb_count == 1); - ASSERT(write_cb_count == 1); - ASSERT(ftruncate_cb_count == 1); + ASSERT_EQ(2, open_cb_count); + ASSERT_EQ(2, read_cb_count); + ASSERT_EQ(3, close_cb_count); + ASSERT_EQ(1, rename_cb_count); + ASSERT_EQ(1, unlink_cb_count); + ASSERT_EQ(1, create_cb_count); + ASSERT_EQ(1, write_cb_count); + ASSERT_EQ(1, ftruncate_cb_count); /* Cleanup. */ unlink("test_file"); @@ -983,70 +983,70 @@ static void fs_file_sync(int add_flags) { r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(write_req.result, 0); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR | add_flags, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(read_req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_req_cleanup(&read_req); r = uv_fs_ftruncate(NULL, &ftruncate_req, open_req1.result, 7, NULL); - ASSERT(r == 0); - ASSERT(ftruncate_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(ftruncate_req.result); uv_fs_req_cleanup(&ftruncate_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_rename(NULL, &rename_req, "test_file", "test_file2", NULL); - ASSERT(r == 0); - ASSERT(rename_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(rename_req.result); uv_fs_req_cleanup(&rename_req); r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDONLY | add_flags, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, "test-bu") == 0); + ASSERT_GE(r, 0); + ASSERT_GE(read_req.result, 0); + ASSERT_OK(strcmp(buf, "test-bu")); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_unlink(NULL, &unlink_req, "test_file2", NULL); - ASSERT(r == 0); - ASSERT(unlink_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(unlink_req.result); uv_fs_req_cleanup(&unlink_req); /* Cleanup */ @@ -1072,19 +1072,19 @@ static void fs_file_write_null_buffer(int add_flags) { r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(NULL, 0); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 0); - ASSERT(write_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(write_req.result); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); unlink("test_file"); @@ -1110,38 +1110,38 @@ TEST_IMPL(fs_async_dir) { loop = uv_default_loop(); r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(mkdir_cb_count == 1); + ASSERT_EQ(1, mkdir_cb_count); /* Create 2 files synchronously. */ r = uv_fs_open(NULL, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_scandir(loop, &scandir_req, "test_dir", 0, scandir_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); + ASSERT_EQ(1, scandir_cb_count); /* sync uv_fs_scandir */ r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT(r == 2); - ASSERT(scandir_req.result == 2); + ASSERT_EQ(2, r); + ASSERT_EQ(2, scandir_req.result); ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); @@ -1151,37 +1151,37 @@ TEST_IMPL(fs_async_dir) { ASSERT(!scandir_req.ptr); r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); r = uv_fs_stat(loop, &stat_req, "test_dir/", stat_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); r = uv_fs_lstat(loop, &stat_req, "test_dir", stat_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); r = uv_fs_lstat(loop, &stat_req, "test_dir/", stat_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(stat_cb_count == 4); + ASSERT_EQ(4, stat_cb_count); r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(unlink_cb_count == 1); + ASSERT_EQ(1, unlink_cb_count); r = uv_fs_unlink(loop, &unlink_req, "test_dir/file2", unlink_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(unlink_cb_count == 2); + ASSERT_EQ(2, unlink_cb_count); r = uv_fs_rmdir(loop, &rmdir_req, "test_dir", rmdir_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(rmdir_cb_count == 1); + ASSERT_EQ(1, rmdir_cb_count); /* Cleanup */ unlink("test_dir/file1"); @@ -1206,58 +1206,58 @@ static int test_sendfile(void (*setup)(int), uv_fs_cb cb, off_t expected_size) { unlink("test_file2"); f = open("test_file", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR); - ASSERT(f != -1); + ASSERT_NE(f, -1); if (setup != NULL) setup(f); r = close(f); - ASSERT(r == 0); + ASSERT_OK(r); /* Test starts here. */ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_open(NULL, &open_req2, "test_file2", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req2.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req2.result, 0); uv_fs_req_cleanup(&open_req2); r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result, 1, 131072, cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(sendfile_cb_count == 1); + ASSERT_EQ(1, sendfile_cb_count); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_close(NULL, &close_req, open_req2.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); memset(&s1, 0, sizeof(s1)); memset(&s2, 0, sizeof(s2)); - ASSERT(0 == stat("test_file", &s1)); - ASSERT(0 == stat("test_file2", &s2)); - ASSERT(s2.st_size == expected_size); + ASSERT_OK(stat("test_file", &s1)); + ASSERT_OK(stat("test_file2", &s2)); + ASSERT_EQ(s2.st_size, expected_size); if (expected_size > 0) { ASSERT_UINT64_EQ(s1.st_size, s2.st_size + 1); r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); memset(buf1, 0, sizeof(buf1)); iov = uv_buf_init(buf1, sizeof(buf1)); r = uv_fs_read(NULL, &req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); ASSERT_EQ(buf1[0], 'e'); /* 'e' from begin */ uv_fs_req_cleanup(&req); } else { @@ -1274,9 +1274,9 @@ static int test_sendfile(void (*setup)(int), uv_fs_cb cb, off_t expected_size) { static void sendfile_setup(int f) { - ASSERT(6 == write(f, "begin\n", 6)); - ASSERT(65542 == lseek(f, 65536, SEEK_CUR)); - ASSERT(4 == write(f, "end\n", 4)); + ASSERT_EQ(6, write(f, "begin\n", 6)); + ASSERT_EQ(65542, lseek(f, 65536, SEEK_CUR)); + ASSERT_EQ(4, write(f, "end\n", 4)); } @@ -1297,18 +1297,18 @@ TEST_IMPL(fs_mkdtemp) { loop = uv_default_loop(); r = uv_fs_mkdtemp(loop, &mkdtemp_req1, path_template, mkdtemp_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(mkdtemp_cb_count == 1); + ASSERT_EQ(1, mkdtemp_cb_count); /* sync mkdtemp */ r = uv_fs_mkdtemp(NULL, &mkdtemp_req2, path_template, NULL); - ASSERT(r == 0); + ASSERT_OK(r); check_mkdtemp_result(&mkdtemp_req2); /* mkdtemp return different values on subsequent calls */ - ASSERT(strcmp(mkdtemp_req1.path, mkdtemp_req2.path) != 0); + ASSERT_NE(0, strcmp(mkdtemp_req1.path, mkdtemp_req2.path)); /* Cleanup */ rmdir(mkdtemp_req1.path); @@ -1330,32 +1330,32 @@ TEST_IMPL(fs_mkstemp) { loop = uv_default_loop(); r = uv_fs_mkstemp(loop, &mkstemp_req1, path_template, mkstemp_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(mkstemp_cb_count == 1); + ASSERT_EQ(1, mkstemp_cb_count); /* sync mkstemp */ r = uv_fs_mkstemp(NULL, &mkstemp_req2, path_template, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); check_mkstemp_result(&mkstemp_req2); /* mkstemp return different values on subsequent calls */ - ASSERT(strcmp(mkstemp_req1.path, mkstemp_req2.path) != 0); + ASSERT_NE(0, strcmp(mkstemp_req1.path, mkstemp_req2.path)); /* invalid template returns EINVAL */ ASSERT_EQ(UV_EINVAL, uv_fs_mkstemp(NULL, &mkstemp_req3, "test_file", NULL)); /* Make sure that path is empty string */ - ASSERT_EQ(0, strlen(mkstemp_req3.path)); + ASSERT_OK(strlen(mkstemp_req3.path)); uv_fs_req_cleanup(&mkstemp_req3); /* We can write to the opened file */ iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, mkstemp_req1.result, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); /* Cleanup */ @@ -1365,15 +1365,15 @@ TEST_IMPL(fs_mkstemp) { uv_fs_req_cleanup(&req); fd = uv_fs_open(NULL, &req, mkstemp_req1.path , O_RDONLY, 0, NULL); - ASSERT(fd >= 0); + ASSERT_GE(fd, 0); uv_fs_req_cleanup(&req); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &req, fd, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_req_cleanup(&req); uv_fs_close(NULL, &req, fd, NULL); @@ -1412,20 +1412,20 @@ TEST_IMPL(fs_fstat) { r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); #ifndef _WIN32 memset(&t, 0, sizeof(t)); - ASSERT(0 == fstat(file, &t)); - ASSERT(0 == uv_fs_fstat(NULL, &req, file, NULL)); - ASSERT(req.result == 0); + ASSERT_OK(fstat(file, &t)); + ASSERT_OK(uv_fs_fstat(NULL, &req, file, NULL)); + ASSERT_OK(req.result); s = req.ptr; # if defined(__APPLE__) - ASSERT(s->st_birthtim.tv_sec == t.st_birthtimespec.tv_sec); - ASSERT(s->st_birthtim.tv_nsec == t.st_birthtimespec.tv_nsec); + ASSERT_EQ(s->st_birthtim.tv_sec, t.st_birthtimespec.tv_sec); + ASSERT_EQ(s->st_birthtim.tv_nsec, t.st_birthtimespec.tv_nsec); # elif defined(__linux__) /* If statx() is supported, the birth time should be equal to the change time * because we just created the file. On older kernels, it's set to zero. @@ -1439,53 +1439,53 @@ TEST_IMPL(fs_fstat) { iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); memset(&req.statbuf, 0xaa, sizeof(req.statbuf)); r = uv_fs_fstat(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); s = req.ptr; - ASSERT(s->st_size == sizeof(test_buf)); + ASSERT_EQ(s->st_size, sizeof(test_buf)); #ifndef _WIN32 r = fstat(file, &t); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(s->st_dev == (uint64_t) t.st_dev); - ASSERT(s->st_mode == (uint64_t) t.st_mode); - ASSERT(s->st_nlink == (uint64_t) t.st_nlink); - ASSERT(s->st_uid == (uint64_t) t.st_uid); - ASSERT(s->st_gid == (uint64_t) t.st_gid); - ASSERT(s->st_rdev == (uint64_t) t.st_rdev); - ASSERT(s->st_ino == (uint64_t) t.st_ino); - ASSERT(s->st_size == (uint64_t) t.st_size); - ASSERT(s->st_blksize == (uint64_t) t.st_blksize); - ASSERT(s->st_blocks == (uint64_t) t.st_blocks); + ASSERT_EQ(s->st_dev, (uint64_t) t.st_dev); + ASSERT_EQ(s->st_mode, (uint64_t) t.st_mode); + ASSERT_EQ(s->st_nlink, (uint64_t) t.st_nlink); + ASSERT_EQ(s->st_uid, (uint64_t) t.st_uid); + ASSERT_EQ(s->st_gid, (uint64_t) t.st_gid); + ASSERT_EQ(s->st_rdev, (uint64_t) t.st_rdev); + ASSERT_EQ(s->st_ino, (uint64_t) t.st_ino); + ASSERT_EQ(s->st_size, (uint64_t) t.st_size); + ASSERT_EQ(s->st_blksize, (uint64_t) t.st_blksize); + ASSERT_EQ(s->st_blocks, (uint64_t) t.st_blocks); #if defined(__APPLE__) - ASSERT(s->st_atim.tv_sec == t.st_atimespec.tv_sec); - ASSERT(s->st_atim.tv_nsec == t.st_atimespec.tv_nsec); - ASSERT(s->st_mtim.tv_sec == t.st_mtimespec.tv_sec); - ASSERT(s->st_mtim.tv_nsec == t.st_mtimespec.tv_nsec); - ASSERT(s->st_ctim.tv_sec == t.st_ctimespec.tv_sec); - ASSERT(s->st_ctim.tv_nsec == t.st_ctimespec.tv_nsec); + ASSERT_EQ(s->st_atim.tv_sec, t.st_atimespec.tv_sec); + ASSERT_EQ(s->st_atim.tv_nsec, t.st_atimespec.tv_nsec); + ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtimespec.tv_sec); + ASSERT_EQ(s->st_mtim.tv_nsec, t.st_mtimespec.tv_nsec); + ASSERT_EQ(s->st_ctim.tv_sec, t.st_ctimespec.tv_sec); + ASSERT_EQ(s->st_ctim.tv_nsec, t.st_ctimespec.tv_nsec); #elif defined(_AIX) || \ defined(__MVS__) - ASSERT(s->st_atim.tv_sec == t.st_atime); - ASSERT(s->st_atim.tv_nsec == 0); - ASSERT(s->st_mtim.tv_sec == t.st_mtime); - ASSERT(s->st_mtim.tv_nsec == 0); - ASSERT(s->st_ctim.tv_sec == t.st_ctime); - ASSERT(s->st_ctim.tv_nsec == 0); + ASSERT_EQ(s->st_atim.tv_sec, t.st_atime); + ASSERT_OK(s->st_atim.tv_nsec); + ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtime); + ASSERT_OK(s->st_mtim.tv_nsec); + ASSERT_EQ(s->st_ctim.tv_sec, t.st_ctime); + ASSERT_OK(s->st_ctim.tv_nsec); #elif defined(__ANDROID__) - ASSERT(s->st_atim.tv_sec == t.st_atime); - ASSERT(s->st_atim.tv_nsec == t.st_atimensec); - ASSERT(s->st_mtim.tv_sec == t.st_mtime); - ASSERT(s->st_mtim.tv_nsec == t.st_mtimensec); - ASSERT(s->st_ctim.tv_sec == t.st_ctime); - ASSERT(s->st_ctim.tv_nsec == t.st_ctimensec); + ASSERT_EQ(s->st_atim.tv_sec, t.st_atime); + ASSERT_EQ(s->st_atim.tv_nsec, t.st_atimensec); + ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtime); + ASSERT_EQ(s->st_mtim.tv_nsec, t.st_mtimensec); + ASSERT_EQ(s->st_ctim.tv_sec, t.st_ctime); + ASSERT_EQ(s->st_ctim.tv_nsec, t.st_ctimensec); #elif defined(__sun) || \ defined(__DragonFly__) || \ defined(__FreeBSD__) || \ @@ -1496,47 +1496,47 @@ TEST_IMPL(fs_fstat) { defined(_SVID_SOURCE) || \ defined(_XOPEN_SOURCE) || \ defined(_DEFAULT_SOURCE) - ASSERT(s->st_atim.tv_sec == t.st_atim.tv_sec); - ASSERT(s->st_atim.tv_nsec == t.st_atim.tv_nsec); - ASSERT(s->st_mtim.tv_sec == t.st_mtim.tv_sec); - ASSERT(s->st_mtim.tv_nsec == t.st_mtim.tv_nsec); - ASSERT(s->st_ctim.tv_sec == t.st_ctim.tv_sec); - ASSERT(s->st_ctim.tv_nsec == t.st_ctim.tv_nsec); + ASSERT_EQ(s->st_atim.tv_sec, t.st_atim.tv_sec); + ASSERT_EQ(s->st_atim.tv_nsec, t.st_atim.tv_nsec); + ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtim.tv_sec); + ASSERT_EQ(s->st_mtim.tv_nsec, t.st_mtim.tv_nsec); + ASSERT_EQ(s->st_ctim.tv_sec, t.st_ctim.tv_sec); + ASSERT_EQ(s->st_ctim.tv_nsec, t.st_ctim.tv_nsec); # if defined(__FreeBSD__) || \ defined(__NetBSD__) - ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec); - ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec); + ASSERT_EQ(s->st_birthtim.tv_sec, t.st_birthtim.tv_sec); + ASSERT_EQ(s->st_birthtim.tv_nsec, t.st_birthtim.tv_nsec); # endif #else - ASSERT(s->st_atim.tv_sec == t.st_atime); - ASSERT(s->st_atim.tv_nsec == 0); - ASSERT(s->st_mtim.tv_sec == t.st_mtime); - ASSERT(s->st_mtim.tv_nsec == 0); - ASSERT(s->st_ctim.tv_sec == t.st_ctime); - ASSERT(s->st_ctim.tv_nsec == 0); + ASSERT_EQ(s->st_atim.tv_sec, t.st_atime); + ASSERT_OK(s->st_atim.tv_nsec); + ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtime); + ASSERT_OK(s->st_mtim.tv_nsec); + ASSERT_EQ(s->st_ctim.tv_sec, t.st_ctime); + ASSERT_OK(s->st_ctim.tv_nsec); #endif #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) - ASSERT(s->st_flags == t.st_flags); - ASSERT(s->st_gen == t.st_gen); + ASSERT_EQ(s->st_flags, t.st_flags); + ASSERT_EQ(s->st_gen, t.st_gen); #else - ASSERT(s->st_flags == 0); - ASSERT(s->st_gen == 0); + ASSERT_OK(s->st_flags); + ASSERT_OK(s->st_gen); #endif uv_fs_req_cleanup(&req); /* Now do the uv_fs_fstat call asynchronously */ r = uv_fs_fstat(loop, &req, file, fstat_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fstat_cb_count == 1); + ASSERT_EQ(1, fstat_cb_count); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* @@ -1564,8 +1564,8 @@ TEST_IMPL(fs_fstat_stdio) { for (fd = 0; fd <= 2; ++fd) { res = uv_fs_fstat(NULL, &req, fd, NULL); - ASSERT(res == 0); - ASSERT(req.result == 0); + ASSERT_OK(res); + ASSERT_OK(req.result); #ifdef _WIN32 st = req.ptr; @@ -1573,9 +1573,11 @@ TEST_IMPL(fs_fstat_stdio) { switch (ft) { case UV_TTY: case UV_NAMED_PIPE: - ASSERT(st->st_mode == (ft == UV_TTY ? S_IFCHR : S_IFIFO)); - ASSERT(st->st_nlink == 1); - ASSERT(st->st_rdev == (ft == UV_TTY ? FILE_DEVICE_CONSOLE : FILE_DEVICE_NAMED_PIPE) << 16); + ASSERT_EQ(st->st_mode, (ft == UV_TTY ? S_IFCHR : S_IFIFO)); + ASSERT_EQ(1, st->st_nlink); + ASSERT_EQ(st->st_rdev, + (ft == UV_TTY ? FILE_DEVICE_CONSOLE : FILE_DEVICE_NAMED_PIPE) + << 16); break; default: break; @@ -1603,52 +1605,52 @@ TEST_IMPL(fs_access) { /* File should not exist */ r = uv_fs_access(NULL, &req, "test_file", F_OK, NULL); - ASSERT(r < 0); - ASSERT(req.result < 0); + ASSERT_LT(r, 0); + ASSERT_LT(req.result, 0); uv_fs_req_cleanup(&req); /* File should not exist */ r = uv_fs_access(loop, &req, "test_file", F_OK, access_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(access_cb_count == 1); + ASSERT_EQ(1, access_cb_count); access_cb_count = 0; /* reset for the next test */ /* Create file */ r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); /* File should exist */ r = uv_fs_access(NULL, &req, "test_file", F_OK, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* File should exist */ r = uv_fs_access(loop, &req, "test_file", F_OK, access_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(access_cb_count == 1); + ASSERT_EQ(1, access_cb_count); access_cb_count = 0; /* reset for the next test */ /* Close file */ r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* Directory access */ r = uv_fs_mkdir(NULL, &req, "test_dir", 0777, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); r = uv_fs_access(NULL, &req, "test_dir", W_OK, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* @@ -1678,22 +1680,22 @@ TEST_IMPL(fs_chmod) { r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); #ifndef _WIN32 /* Make the file write-only */ r = uv_fs_chmod(NULL, &req, "test_file", 0200, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); check_permission("test_file", 0200); @@ -1701,16 +1703,16 @@ TEST_IMPL(fs_chmod) { /* Make the file read-only */ r = uv_fs_chmod(NULL, &req, "test_file", 0400, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); check_permission("test_file", 0400); /* Make the file read+write with sync uv_fs_fchmod */ r = uv_fs_fchmod(NULL, &req, file, 0600, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); check_permission("test_file", 0600); @@ -1722,9 +1724,9 @@ TEST_IMPL(fs_chmod) { req.data = &mode; } r = uv_fs_chmod(loop, &req, "test_file", 0200, chmod_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chmod_cb_count == 1); + ASSERT_EQ(1, chmod_cb_count); chmod_cb_count = 0; /* reset for the next test */ #endif @@ -1734,9 +1736,9 @@ TEST_IMPL(fs_chmod) { req.data = &mode; } r = uv_fs_chmod(loop, &req, "test_file", 0400, chmod_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chmod_cb_count == 1); + ASSERT_EQ(1, chmod_cb_count); /* async fchmod */ { @@ -1744,9 +1746,9 @@ TEST_IMPL(fs_chmod) { req.data = &mode; } r = uv_fs_fchmod(loop, &req, file, 0600, fchmod_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fchmod_cb_count == 1); + ASSERT_EQ(1, fchmod_cb_count); uv_fs_close(loop, &req, file, NULL); @@ -1780,31 +1782,31 @@ TEST_IMPL(fs_unlink_readonly) { O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); uv_fs_close(loop, &req, file, NULL); /* Make the file read-only */ r = uv_fs_chmod(NULL, &req, "test_file", 0400, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); check_permission("test_file", 0400); /* Try to unlink the file */ r = uv_fs_unlink(NULL, &req, "test_file", NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* @@ -1839,30 +1841,30 @@ TEST_IMPL(fs_unlink_archive_readonly) { O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); uv_fs_close(loop, &req, file, NULL); /* Make the file read-only and clear archive flag */ r = SetFileAttributes("test_file", FILE_ATTRIBUTE_READONLY); - ASSERT(r != 0); + ASSERT(r); uv_fs_req_cleanup(&req); check_permission("test_file", 0400); /* Try to unlink the file */ r = uv_fs_unlink(NULL, &req, "test_file", NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* @@ -1894,69 +1896,69 @@ TEST_IMPL(fs_chown) { r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); /* sync chown */ r = uv_fs_chown(NULL, &req, "test_file", -1, -1, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* sync fchown */ r = uv_fs_fchown(NULL, &req, file, -1, -1, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* async chown */ r = uv_fs_chown(loop, &req, "test_file", -1, -1, chown_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chown_cb_count == 1); + ASSERT_EQ(1, chown_cb_count); #ifndef __MVS__ /* chown to root (fail) */ chown_cb_count = 0; r = uv_fs_chown(loop, &req, "test_file", 0, 0, chown_root_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(chown_cb_count == 1); + ASSERT_EQ(1, chown_cb_count); #endif /* async fchown */ r = uv_fs_fchown(loop, &req, file, -1, -1, fchown_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(fchown_cb_count == 1); + ASSERT_EQ(1, fchown_cb_count); #ifndef __HAIKU__ /* Haiku doesn't support hardlink */ /* sync link */ r = uv_fs_link(NULL, &req, "test_file", "test_file_link", NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* sync lchown */ r = uv_fs_lchown(NULL, &req, "test_file_link", -1, -1, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* async lchown */ r = uv_fs_lchown(loop, &req, "test_file_link", -1, -1, lchown_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(lchown_cb_count == 1); + ASSERT_EQ(1, lchown_cb_count); #endif /* Close file */ r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* @@ -1989,58 +1991,58 @@ TEST_IMPL(fs_link) { r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); uv_fs_close(loop, &req, file, NULL); /* sync link */ r = uv_fs_link(NULL, &req, "test_file", "test_file_link", NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); r = uv_fs_open(NULL, &req, "test_file_link", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); link = req.result; uv_fs_req_cleanup(&req); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); close(link); /* async link */ r = uv_fs_link(loop, &req, "test_file", "test_file_link2", link_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(link_cb_count == 1); + ASSERT_EQ(1, link_cb_count); r = uv_fs_open(NULL, &req, "test_file_link2", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); link = req.result; uv_fs_req_cleanup(&req); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_close(loop, &req, link, NULL); @@ -2066,16 +2068,16 @@ TEST_IMPL(fs_readlink) { uv_fs_t req; loop = uv_default_loop(); - ASSERT(0 == uv_fs_readlink(loop, &req, "no_such_file", dummy_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(dummy_cb_count == 1); + ASSERT_OK(uv_fs_readlink(loop, &req, "no_such_file", dummy_cb)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, dummy_cb_count); ASSERT_NULL(req.ptr); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); uv_fs_req_cleanup(&req); - ASSERT(UV_ENOENT == uv_fs_readlink(NULL, &req, "no_such_file", NULL)); + ASSERT_EQ(UV_ENOENT, uv_fs_readlink(NULL, &req, "no_such_file", NULL)); ASSERT_NULL(req.ptr); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); uv_fs_req_cleanup(&req); } @@ -2096,8 +2098,8 @@ TEST_IMPL(fs_readlink) { uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT_EQ(r, 0); - ASSERT_EQ(req.result, 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* Test */ @@ -2118,16 +2120,16 @@ TEST_IMPL(fs_realpath) { uv_fs_t req; loop = uv_default_loop(); - ASSERT(0 == uv_fs_realpath(loop, &req, "no_such_file", dummy_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(dummy_cb_count == 1); + ASSERT_OK(uv_fs_realpath(loop, &req, "no_such_file", dummy_cb)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, dummy_cb_count); ASSERT_NULL(req.ptr); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); uv_fs_req_cleanup(&req); - ASSERT(UV_ENOENT == uv_fs_realpath(NULL, &req, "no_such_file", NULL)); + ASSERT_EQ(UV_ENOENT, uv_fs_realpath(NULL, &req, "no_such_file", NULL)); ASSERT_NULL(req.ptr); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); uv_fs_req_cleanup(&req); MAKE_VALGRIND_HAPPY(loop); @@ -2162,15 +2164,15 @@ TEST_IMPL(fs_symlink) { r = uv_fs_open(NULL, &req, "test_file", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &req, file, &iov, 1, -1, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(req.result == sizeof(test_buf)); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_EQ(req.result, sizeof(test_buf)); uv_fs_req_cleanup(&req); uv_fs_close(loop, &req, file, NULL); @@ -2194,22 +2196,22 @@ TEST_IMPL(fs_symlink) { } } #endif - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); r = uv_fs_open(NULL, &req, "test_file_symlink", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); link = req.result; uv_fs_req_cleanup(&req); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_close(loop, &req, link, NULL); @@ -2219,7 +2221,7 @@ TEST_IMPL(fs_symlink) { "test_file_symlink_symlink", 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); #if defined(__MSYS__) @@ -2227,16 +2229,16 @@ TEST_IMPL(fs_symlink) { #endif r = uv_fs_readlink(NULL, &req, "test_file_symlink_symlink", NULL); - ASSERT(r == 0); - ASSERT(strcmp(req.ptr, "test_file_symlink") == 0); + ASSERT_OK(r); + ASSERT_OK(strcmp(req.ptr, "test_file_symlink")); uv_fs_req_cleanup(&req); r = uv_fs_realpath(NULL, &req, "test_file_symlink_symlink", NULL); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 - ASSERT(stricmp(req.ptr, test_file_abs_buf) == 0); + ASSERT_OK(stricmp(req.ptr, test_file_abs_buf)); #else - ASSERT(strcmp(req.ptr, test_file_abs_buf) == 0); + ASSERT_OK(strcmp(req.ptr, test_file_abs_buf)); #endif uv_fs_req_cleanup(&req); @@ -2247,22 +2249,22 @@ TEST_IMPL(fs_symlink) { "test_file_symlink2", 0, symlink_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(symlink_cb_count == 1); + ASSERT_EQ(1, symlink_cb_count); r = uv_fs_open(NULL, &req, "test_file_symlink2", O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); link = req.result; uv_fs_req_cleanup(&req); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &req, link, &iov, 1, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_close(loop, &req, link, NULL); @@ -2272,18 +2274,18 @@ TEST_IMPL(fs_symlink) { "test_file_symlink2_symlink", 0, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); r = uv_fs_readlink(loop, &req, "test_file_symlink2_symlink", readlink_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(readlink_cb_count == 1); + ASSERT_EQ(1, readlink_cb_count); r = uv_fs_realpath(loop, &req, "test_file", realpath_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(realpath_cb_count == 1); + ASSERT_EQ(1, realpath_cb_count); /* * Run the loop just to check we don't have make any extraneous uv_ref() @@ -2344,71 +2346,71 @@ int test_symlink_dir_impl(int type) { "creation of directory symlinks"); } fprintf(stderr, "r == %i\n", r); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); r = uv_fs_stat(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFDIR); uv_fs_req_cleanup(&req); r = uv_fs_lstat(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); + ASSERT_OK(r); #if defined(__MSYS__) RETURN_SKIP("symlink reading is not supported on MSYS2"); #endif ASSERT(((uv_stat_t*)req.ptr)->st_mode & S_IFLNK); #ifdef _WIN32 - ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir + 4)); + ASSERT_EQ(((uv_stat_t*)req.ptr)->st_size, strlen(test_dir + 4)); #else # ifdef __PASE__ /* On IBMi PASE, st_size returns the length of the symlink itself. */ - ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen("test_dir_symlink")); + ASSERT_EQ(((uv_stat_t*)req.ptr)->st_size, strlen("test_dir_symlink")); # else - ASSERT(((uv_stat_t*)req.ptr)->st_size == strlen(test_dir)); + ASSERT_EQ(((uv_stat_t*)req.ptr)->st_size, strlen(test_dir)); # endif #endif uv_fs_req_cleanup(&req); r = uv_fs_readlink(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 - ASSERT(strcmp(req.ptr, test_dir + 4) == 0); + ASSERT_OK(strcmp(req.ptr, test_dir + 4)); #else - ASSERT(strcmp(req.ptr, test_dir) == 0); + ASSERT_OK(strcmp(req.ptr, test_dir)); #endif uv_fs_req_cleanup(&req); r = uv_fs_realpath(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 - ASSERT(strlen(req.ptr) == test_dir_abs_size - 5); - ASSERT(strnicmp(req.ptr, test_dir + 4, test_dir_abs_size - 5) == 0); + ASSERT_EQ(strlen(req.ptr), test_dir_abs_size - 5); + ASSERT_OK(strnicmp(req.ptr, test_dir + 4, test_dir_abs_size - 5)); #else - ASSERT(strcmp(req.ptr, test_dir_abs_buf) == 0); + ASSERT_OK(strcmp(req.ptr, test_dir_abs_buf)); #endif uv_fs_req_cleanup(&req); r = uv_fs_open(NULL, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); r = uv_fs_scandir(NULL, &scandir_req, "test_dir_symlink", 0, NULL); - ASSERT(r == 2); - ASSERT(scandir_req.result == 2); + ASSERT_EQ(2, r); + ASSERT_EQ(2, scandir_req.result); ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); @@ -2419,16 +2421,16 @@ int test_symlink_dir_impl(int type) { /* unlink will remove the directory symlink */ r = uv_fs_unlink(NULL, &req, "test_dir_symlink", NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); r = uv_fs_scandir(NULL, &scandir_req, "test_dir_symlink", 0, NULL); - ASSERT(r == UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); uv_fs_req_cleanup(&scandir_req); r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT(r == 2); - ASSERT(scandir_req.result == 2); + ASSERT_EQ(2, r); + ASSERT_EQ(2, scandir_req.result); ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0); @@ -2481,7 +2483,7 @@ TEST_IMPL(fs_non_symlink_reparse_point) { FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); - ASSERT(file_handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(file_handle, INVALID_HANDLE_VALUE); memset(&reparse_buffer, 0, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE); reparse_buffer.ReparseTag = REPARSE_TAG; @@ -2496,7 +2498,7 @@ TEST_IMPL(fs_non_symlink_reparse_point) { 0, &bytes_returned, NULL); - ASSERT(r != 0); + ASSERT(r); CloseHandle(file_handle); @@ -2510,11 +2512,11 @@ TEST_IMPL(fs_non_symlink_reparse_point) { shared via SMB as "Macintosh HD". r = uv_fs_stat(NULL, &req, "\\\\\\Macintosh HD\\.DS_Store", NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); r = uv_fs_lstat(NULL, &req, "\\\\\\Macintosh HD\\.DS_Store", NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); */ @@ -2525,25 +2527,25 @@ TEST_IMPL(fs_non_symlink_reparse_point) { the scope of this test. r = uv_fs_stat(NULL, &req, "test_dir/test_file", NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); r = uv_fs_lstat(NULL, &req, "test_dir/test_file", NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); */ r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT(r == 1); - ASSERT(scandir_req.result == 1); + ASSERT_EQ(1, r); + ASSERT_EQ(1, scandir_req.result); ASSERT(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { - ASSERT(strcmp(dent.name, "test_file") == 0); + ASSERT_OK(strcmp(dent.name, "test_file")); /* uv_fs_scandir incorrectly identifies non-symlink reparse points as links because it doesn't open the file and verify the reparse point tag. The PowerShell Get-ChildItem command shares this behavior, so it's reasonable to leave it as is. */ - ASSERT(dent.type == UV_DIRENT_LINK); + ASSERT_EQ(dent.type, UV_DIRENT_LINK); } uv_fs_req_cleanup(&scandir_req); ASSERT(!scandir_req.ptr); @@ -2575,7 +2577,7 @@ TEST_IMPL(fs_lstat_windows_store_apps) { MAKE_VALGRIND_HAPPY(loop); return TEST_SKIP; } - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = snprintf(windowsapps_path, sizeof(localappdata), "%s\\Microsoft\\WindowsApps", @@ -2601,7 +2603,7 @@ TEST_IMPL(fs_lstat_windows_store_apps) { dirent.name) < 0) { continue; } - ASSERT_EQ(uv_fs_lstat(loop, &stat_req, file_path, NULL), 0); + ASSERT_OK(uv_fs_lstat(loop, &stat_req, file_path, NULL)); } MAKE_VALGRIND_HAPPY(loop); return 0; @@ -2621,16 +2623,16 @@ TEST_IMPL(fs_utime) { loop = uv_default_loop(); unlink(path); r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); uv_fs_req_cleanup(&req); uv_fs_close(loop, &req, r, NULL); atime = mtime = 400497753.25; /* 1982-09-10 11:22:33.25 */ r = uv_fs_utime(NULL, &req, path, atime, mtime, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); check_utime(path, atime, mtime, /* test_lutime */ 0); @@ -2643,9 +2645,9 @@ TEST_IMPL(fs_utime) { /* async utime */ utime_req.data = &checkme; r = uv_fs_utime(loop, &utime_req, path, atime, mtime, utime_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(utime_cb_count == 1); + ASSERT_EQ(1, utime_cb_count); /* Cleanup. */ unlink(path); @@ -2668,7 +2670,7 @@ TEST_IMPL(fs_utime_round) { ASSERT_GE(r, 0); ASSERT_GE(req.result, 0); uv_fs_req_cleanup(&req); - ASSERT_EQ(0, uv_fs_close(loop, &req, r, NULL)); + ASSERT_OK(uv_fs_close(loop, &req, r, NULL)); atime = mtime = -14245440.25; /* 1969-07-20T02:56:00.25Z */ @@ -2683,8 +2685,8 @@ TEST_IMPL(fs_utime_round) { RETURN_SKIP("utime on some OS (z/OS, IBM i PASE, AIX) or filesystems may reject pre-epoch timestamps"); } #endif - ASSERT_EQ(0, r); - ASSERT_EQ(0, req.result); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); check_utime(path, atime, mtime, /* test_lutime */ 0); unlink(path); @@ -2699,26 +2701,26 @@ TEST_IMPL(fs_stat_root) { int r; r = uv_fs_stat(NULL, &stat_req, "\\", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_stat(NULL, &stat_req, "..\\..\\..\\..\\..\\..\\..", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_stat(NULL, &stat_req, "..", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_stat(NULL, &stat_req, "..\\", NULL); - ASSERT(r == 0); + ASSERT_OK(r); /* stats the current directory on c: */ r = uv_fs_stat(NULL, &stat_req, "c:", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_stat(NULL, &stat_req, "c:\\", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_stat(NULL, &stat_req, "\\\\?\\C:\\", NULL); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -2742,26 +2744,26 @@ TEST_IMPL(fs_futime) { loop = uv_default_loop(); unlink(path); r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); uv_fs_req_cleanup(&req); uv_fs_close(loop, &req, r, NULL); atime = mtime = 400497753.25; /* 1982-09-10 11:22:33.25 */ r = uv_fs_open(NULL, &req, path, O_RDWR, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; /* FIXME probably not how it's supposed to be used */ uv_fs_req_cleanup(&req); r = uv_fs_futime(NULL, &req, file, atime, mtime, NULL); #if defined(__CYGWIN__) || defined(__MSYS__) - ASSERT(r == UV_ENOSYS); + ASSERT_EQ(r, UV_ENOSYS); RETURN_SKIP("futime not supported on Cygwin"); #else - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); #endif uv_fs_req_cleanup(&req); @@ -2776,9 +2778,9 @@ TEST_IMPL(fs_futime) { /* async futime */ futime_req.data = &checkme; r = uv_fs_futime(loop, &futime_req, file, atime, mtime, futime_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(futime_cb_count == 1); + ASSERT_EQ(1, futime_cb_count); /* Cleanup. */ unlink(path); @@ -2819,8 +2821,8 @@ TEST_IMPL(fs_lutime) { "Symlink creation requires elevated console (with admin rights)"); } #endif - ASSERT_EQ(s, 0); - ASSERT_EQ(req.result, 0); + ASSERT_OK(s); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); /* Test the synchronous version. */ @@ -2837,9 +2839,9 @@ TEST_IMPL(fs_lutime) { ASSERT_EQ(r, UV_ENOSYS); RETURN_SKIP("lutime is not implemented for z/OS and AIX versions below 7.1"); #endif - ASSERT_EQ(r, 0); + ASSERT_OK(r); lutime_cb(&req); - ASSERT_EQ(lutime_cb_count, 1); + ASSERT_EQ(1, lutime_cb_count); /* Test the asynchronous version. */ atime = mtime = 1291404900; /* 2010-12-03 20:35:00 */ @@ -2849,9 +2851,9 @@ TEST_IMPL(fs_lutime) { checkme.path = symlink_path; r = uv_fs_lutime(loop, &req, symlink_path, atime, mtime, lutime_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT_EQ(lutime_cb_count, 2); + ASSERT_EQ(2, lutime_cb_count); /* Cleanup. */ unlink(path); @@ -2869,8 +2871,8 @@ TEST_IMPL(fs_stat_missing_path) { loop = uv_default_loop(); r = uv_fs_stat(NULL, &req, "non_existent_file", NULL); - ASSERT(r == UV_ENOENT); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); uv_fs_req_cleanup(&req); MAKE_VALGRIND_HAPPY(loop); @@ -2894,18 +2896,18 @@ TEST_IMPL(fs_scandir_empty_dir) { memset(&req, 0xdb, sizeof(req)); r = uv_fs_scandir(NULL, &req, path, 0, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); ASSERT_NULL(req.ptr); - ASSERT(UV_EOF == uv_fs_scandir_next(&req, &dent)); + ASSERT_EQ(UV_EOF, uv_fs_scandir_next(&req, &dent)); uv_fs_req_cleanup(&req); r = uv_fs_scandir(loop, &scandir_req, path, 0, empty_scandir_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(scandir_cb_count == 0); + ASSERT_OK(scandir_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); + ASSERT_EQ(1, scandir_cb_count); uv_fs_rmdir(NULL, &req, path, NULL); uv_fs_req_cleanup(&req); @@ -2931,18 +2933,18 @@ TEST_IMPL(fs_scandir_non_existent_dir) { memset(&req, 0xdb, sizeof(req)); r = uv_fs_scandir(NULL, &req, path, 0, NULL); - ASSERT(r == UV_ENOENT); - ASSERT(req.result == UV_ENOENT); + ASSERT_EQ(r, UV_ENOENT); + ASSERT_EQ(req.result, UV_ENOENT); ASSERT_NULL(req.ptr); - ASSERT(UV_ENOENT == uv_fs_scandir_next(&req, &dent)); + ASSERT_EQ(UV_ENOENT, uv_fs_scandir_next(&req, &dent)); uv_fs_req_cleanup(&req); r = uv_fs_scandir(loop, &scandir_req, path, 0, non_existent_scandir_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(scandir_cb_count == 0); + ASSERT_OK(scandir_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); + ASSERT_EQ(1, scandir_cb_count); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -2956,15 +2958,15 @@ TEST_IMPL(fs_scandir_file) { loop = uv_default_loop(); r = uv_fs_scandir(NULL, &scandir_req, path, 0, NULL); - ASSERT(r == UV_ENOTDIR); + ASSERT_EQ(r, UV_ENOTDIR); uv_fs_req_cleanup(&scandir_req); r = uv_fs_scandir(loop, &scandir_req, path, 0, file_scandir_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(scandir_cb_count == 0); + ASSERT_OK(scandir_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(scandir_cb_count == 1); + ASSERT_EQ(1, scandir_cb_count); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -2998,21 +3000,21 @@ TEST_IMPL(fs_open_dir) { loop = uv_default_loop(); r = uv_fs_open(NULL, &req, path, O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); ASSERT_NULL(req.ptr); file = r; uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_open(loop, &req, path, O_RDONLY, 0, open_cb_simple); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(open_cb_count == 0); + ASSERT_OK(open_cb_count); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(open_cb_count == 1); + ASSERT_EQ(1, open_cb_count); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -3029,57 +3031,57 @@ static void fs_file_open_append(int add_flags) { r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(write_req.result, 0); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file", O_RDWR | O_APPEND | add_flags, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(write_req.result, 0); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY | add_flags, S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); printf("read = %d\n", r); - ASSERT(r == 26); - ASSERT(read_req.result == 26); - ASSERT(memcmp(buf, - "test-buffer\n\0test-buffer\n\0", - sizeof("test-buffer\n\0test-buffer\n\0") - 1) == 0); + ASSERT_EQ(26, r); + ASSERT_EQ(26, read_req.result); + ASSERT_OK(memcmp(buf, + "test-buffer\n\0test-buffer\n\0", + sizeof("test-buffer\n\0test-buffer\n\0") - 1)); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3105,53 +3107,53 @@ TEST_IMPL(fs_rename_to_existing_file) { r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(write_req.result, 0); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file2", O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_rename(NULL, &rename_req, "test_file", "test_file2", NULL); - ASSERT(r == 0); - ASSERT(rename_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(rename_req.result); uv_fs_req_cleanup(&rename_req); r = uv_fs_open(NULL, &open_req1, "test_file2", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(read_req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3167,49 +3169,49 @@ static void fs_read_bufs(int add_flags) { char scratch[768]; uv_buf_t bufs[4]; - ASSERT(0 <= uv_fs_open(NULL, &open_req1, - "test/fixtures/lorem_ipsum.txt", - O_RDONLY | add_flags, 0, NULL)); - ASSERT(open_req1.result >= 0); + ASSERT_LE(0, uv_fs_open(NULL, &open_req1, + "test/fixtures/lorem_ipsum.txt", + O_RDONLY | add_flags, 0, NULL)); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); - ASSERT(UV_EINVAL == uv_fs_read(NULL, &read_req, open_req1.result, - NULL, 0, 0, NULL)); - ASSERT(UV_EINVAL == uv_fs_read(NULL, &read_req, open_req1.result, - NULL, 1, 0, NULL)); - ASSERT(UV_EINVAL == uv_fs_read(NULL, &read_req, open_req1.result, - bufs, 0, 0, NULL)); + ASSERT_EQ(UV_EINVAL, uv_fs_read(NULL, &read_req, open_req1.result, + NULL, 0, 0, NULL)); + ASSERT_EQ(UV_EINVAL, uv_fs_read(NULL, &read_req, open_req1.result, + NULL, 1, 0, NULL)); + ASSERT_EQ(UV_EINVAL, uv_fs_read(NULL, &read_req, open_req1.result, + bufs, 0, 0, NULL)); bufs[0] = uv_buf_init(scratch + 0, 256); bufs[1] = uv_buf_init(scratch + 256, 256); bufs[2] = uv_buf_init(scratch + 512, 128); bufs[3] = uv_buf_init(scratch + 640, 128); - ASSERT(446 == uv_fs_read(NULL, - &read_req, - open_req1.result, - bufs + 0, - 2, /* 2x 256 bytes. */ - 0, /* Positional read. */ - NULL)); - ASSERT(read_req.result == 446); + ASSERT_EQ(446, uv_fs_read(NULL, + &read_req, + open_req1.result, + bufs + 0, + 2, /* 2x 256 bytes. */ + 0, /* Positional read. */ + NULL)); + ASSERT_EQ(446, read_req.result); uv_fs_req_cleanup(&read_req); - ASSERT(190 == uv_fs_read(NULL, - &read_req, - open_req1.result, - bufs + 2, - 2, /* 2x 128 bytes. */ - 256, /* Positional read. */ - NULL)); - ASSERT(read_req.result == /* 446 - 256 */ 190); + ASSERT_EQ(190, uv_fs_read(NULL, + &read_req, + open_req1.result, + bufs + 2, + 2, /* 2x 128 bytes. */ + 256, /* Positional read. */ + NULL)); + ASSERT_EQ(read_req.result, /* 446 - 256 */ 190); uv_fs_req_cleanup(&read_req); - ASSERT(0 == memcmp(bufs[1].base + 0, bufs[2].base, 128)); - ASSERT(0 == memcmp(bufs[1].base + 128, bufs[3].base, 190 - 128)); + ASSERT_OK(memcmp(bufs[1].base + 0, bufs[2].base, 128)); + ASSERT_OK(memcmp(bufs[1].base + 128, bufs[3].base, 190 - 128)); - ASSERT(0 == uv_fs_close(NULL, &close_req, open_req1.result, NULL)); - ASSERT(close_req.result == 0); + ASSERT_OK(uv_fs_close(NULL, &close_req, open_req1.result, NULL)); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); } TEST_IMPL(fs_read_bufs) { @@ -3234,45 +3236,45 @@ static void fs_read_file_eof(int add_flags) { r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(write_req.result, 0); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY | add_flags, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); memset(buf, 0, sizeof(buf)); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result >= 0); - ASSERT(strcmp(buf, test_buf) == 0); + ASSERT_GE(r, 0); + ASSERT_GE(read_req.result, 0); + ASSERT_OK(strcmp(buf, test_buf)); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, read_req.result, NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(read_req.result); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3298,26 +3300,26 @@ static void fs_write_multiple_bufs(int add_flags) { r = uv_fs_open(NULL, &open_req1, "test_file", O_WRONLY | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iovs[0] = uv_buf_init(test_buf, sizeof(test_buf)); iovs[1] = uv_buf_init(test_buf2, sizeof(test_buf2)); r = uv_fs_write(NULL, &write_req, open_req1.result, iovs, 2, 0, NULL); - ASSERT(r >= 0); - ASSERT(write_req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(write_req.result, 0); uv_fs_req_cleanup(&write_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY | add_flags, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); memset(buf, 0, sizeof(buf)); @@ -3325,48 +3327,48 @@ static void fs_write_multiple_bufs(int add_flags) { /* Read the strings back to separate buffers. */ iovs[0] = uv_buf_init(buf, sizeof(test_buf)); iovs[1] = uv_buf_init(buf2, sizeof(test_buf2)); - ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); + ASSERT_OK(lseek(open_req1.result, 0, SEEK_CUR)); r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, 2, -1, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result == sizeof(test_buf) + sizeof(test_buf2)); - ASSERT(strcmp(buf, test_buf) == 0); - ASSERT(strcmp(buf2, test_buf2) == 0); + ASSERT_GE(r, 0); + ASSERT_EQ(read_req.result, sizeof(test_buf) + sizeof(test_buf2)); + ASSERT_OK(strcmp(buf, test_buf)); + ASSERT_OK(strcmp(buf2, test_buf2)); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(read_req.result); uv_fs_req_cleanup(&read_req); /* Read the strings back to separate buffers. */ iovs[0] = uv_buf_init(buf, sizeof(test_buf)); iovs[1] = uv_buf_init(buf2, sizeof(test_buf2)); r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, 2, 0, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); if (read_req.result == sizeof(test_buf)) { /* Infer that preadv is not available. */ uv_fs_req_cleanup(&read_req); r = uv_fs_read(NULL, &read_req, open_req1.result, &iovs[1], 1, read_req.result, NULL); - ASSERT(r >= 0); - ASSERT(read_req.result == sizeof(test_buf2)); + ASSERT_GE(r, 0); + ASSERT_EQ(read_req.result, sizeof(test_buf2)); } else { - ASSERT(read_req.result == sizeof(test_buf) + sizeof(test_buf2)); + ASSERT_EQ(read_req.result, sizeof(test_buf) + sizeof(test_buf2)); } - ASSERT(strcmp(buf, test_buf) == 0); - ASSERT(strcmp(buf2, test_buf2) == 0); + ASSERT_OK(strcmp(buf, test_buf)); + ASSERT_OK(strcmp(buf2, test_buf2)); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, sizeof(test_buf) + sizeof(test_buf2), NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(read_req.result); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3406,8 +3408,8 @@ static void fs_write_alotof_bufs(int add_flags) { O_RDWR | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); for (index = 0; index < iovcount; ++index) @@ -3420,8 +3422,8 @@ static void fs_write_alotof_bufs(int add_flags) { iovcount, -1, NULL); - ASSERT(r >= 0); - ASSERT((size_t)write_req.result == sizeof(test_buf) * iovcount); + ASSERT_GE(r, 0); + ASSERT_EQ((size_t)write_req.result, sizeof(test_buf) * iovcount); uv_fs_req_cleanup(&write_req); /* Read the strings back to separate buffers. */ @@ -3433,31 +3435,32 @@ static void fs_write_alotof_bufs(int add_flags) { sizeof(test_buf)); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY | add_flags, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, iovcount, -1, NULL); if (iovcount > iovmax) iovcount = iovmax; - ASSERT(r >= 0); - ASSERT((size_t)read_req.result == sizeof(test_buf) * iovcount); + ASSERT_GE(r, 0); + ASSERT_EQ((size_t)read_req.result, sizeof(test_buf) * iovcount); for (index = 0; index < iovcount; ++index) - ASSERT(strncmp(buffer + index * sizeof(test_buf), - test_buf, - sizeof(test_buf)) == 0); + ASSERT_OK(strncmp(buffer + index * sizeof(test_buf), + test_buf, + sizeof(test_buf))); uv_fs_req_cleanup(&read_req); free(buffer); - ASSERT(lseek(open_req1.result, write_req.result, SEEK_SET) == write_req.result); + ASSERT_EQ(lseek(open_req1.result, write_req.result, SEEK_SET), + write_req.result); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, @@ -3466,13 +3469,13 @@ static void fs_write_alotof_bufs(int add_flags) { 1, -1, NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(read_req.result); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3518,14 +3521,14 @@ static void fs_write_alotof_bufs_with_offset(int add_flags) { O_RDWR | O_CREAT | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(filler, filler_len); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == filler_len); - ASSERT(write_req.result == filler_len); + ASSERT_EQ(r, filler_len); + ASSERT_EQ(write_req.result, filler_len); uv_fs_req_cleanup(&write_req); offset = (int64_t)r; @@ -3539,8 +3542,8 @@ static void fs_write_alotof_bufs_with_offset(int add_flags) { iovcount, offset, NULL); - ASSERT(r >= 0); - ASSERT((size_t)write_req.result == sizeof(test_buf) * iovcount); + ASSERT_GE(r, 0); + ASSERT_EQ((size_t)write_req.result, sizeof(test_buf) * iovcount); uv_fs_req_cleanup(&write_req); /* Read the strings back to separate buffers. */ @@ -3553,25 +3556,25 @@ static void fs_write_alotof_bufs_with_offset(int add_flags) { r = uv_fs_read(NULL, &read_req, open_req1.result, iovs, iovcount, offset, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); if (r == sizeof(test_buf)) iovcount = 1; /* Infer that preadv is not available. */ else if (iovcount > iovmax) iovcount = iovmax; - ASSERT((size_t)read_req.result == sizeof(test_buf) * iovcount); + ASSERT_EQ((size_t)read_req.result, sizeof(test_buf) * iovcount); for (index = 0; index < iovcount; ++index) - ASSERT(strncmp(buffer + index * sizeof(test_buf), - test_buf, - sizeof(test_buf)) == 0); + ASSERT_OK(strncmp(buffer + index * sizeof(test_buf), + test_buf, + sizeof(test_buf))); uv_fs_req_cleanup(&read_req); free(buffer); r = uv_fs_stat(NULL, &stat_req, "test_file", NULL); - ASSERT(r == 0); - ASSERT((int64_t)((uv_stat_t*)stat_req.ptr)->st_size == - offset + (int64_t)write_req.result); + ASSERT_OK(r); + ASSERT_EQ((int64_t)((uv_stat_t*)stat_req.ptr)->st_size, + offset + (int64_t)write_req.result); uv_fs_req_cleanup(&stat_req); iov = uv_buf_init(buf, sizeof(buf)); @@ -3582,13 +3585,13 @@ static void fs_write_alotof_bufs_with_offset(int add_flags) { 1, offset + write_req.result, NULL); - ASSERT(r == 0); - ASSERT(read_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(read_req.result); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3611,9 +3614,9 @@ TEST_IMPL(fs_read_dir) { /* Setup */ rmdir("test_dir"); r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(mkdir_cb_count == 1); + ASSERT_EQ(1, mkdir_cb_count); /* Setup Done Here */ /* Get a file descriptor for the directory */ @@ -3623,7 +3626,7 @@ TEST_IMPL(fs_read_dir) { UV_FS_O_RDONLY | UV_FS_O_DIRECTORY, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); + ASSERT_GE(r, 0); uv_fs_req_cleanup(&open_req1); /* Try to read data from the directory */ @@ -3643,12 +3646,12 @@ TEST_IMPL(fs_read_dir) { */ ASSERT((r >= 0) || (r == UV_EISDIR)); #else - ASSERT(r == UV_EISDIR); + ASSERT_EQ(r, UV_EISDIR); #endif uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -3695,7 +3698,7 @@ static void thread_main(void* arg) { if (ctx->doread) { result = write(ctx->fd, data, nbytes); /* Should not see EINTR (or other errors) */ - ASSERT(result == nbytes); + ASSERT_EQ(result, nbytes); } else { result = read(ctx->fd, data, nbytes); /* Should not see EINTR (or other errors), @@ -3757,13 +3760,13 @@ static void test_fs_partial(int doread) { loop = uv_default_loop(); - ASSERT(0 == uv_signal_init(loop, &signal)); - ASSERT(0 == uv_signal_start(&signal, sig_func, SIGUSR1)); + ASSERT_OK(uv_signal_init(loop, &signal)); + ASSERT_OK(uv_signal_start(&signal, sig_func, SIGUSR1)); - ASSERT(0 == pipe(pipe_fds)); + ASSERT_OK(pipe(pipe_fds)); ctx.fd = pipe_fds[doread]; - ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); + ASSERT_OK(uv_thread_create(&thread, thread_main, &ctx)); if (doread) { uv_buf_t* read_iovs; @@ -3780,34 +3783,34 @@ static void test_fs_partial(int doread) { iovcount -= read_iovcount; nread += result; } else { - ASSERT(result == UV_EINTR); + ASSERT_EQ(result, UV_EINTR); } uv_fs_req_cleanup(&read_req); } } else { int result; result = uv_fs_write(loop, &write_req, pipe_fds[1], iovs, iovcount, -1, NULL); - ASSERT(write_req.result == result); - ASSERT(result == ctx.size); + ASSERT_EQ(write_req.result, result); + ASSERT_EQ(result, ctx.size); uv_fs_req_cleanup(&write_req); } - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); ASSERT_MEM_EQ(buffer, ctx.data, ctx.size); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(0 == close(pipe_fds[1])); + ASSERT_OK(close(pipe_fds[1])); uv_close((uv_handle_t*) &signal, NULL); { /* Make sure we read everything that we wrote. */ int result; result = uv_fs_read(loop, &read_req, pipe_fds[0], iovs, 1, -1, NULL); - ASSERT(result == 0); + ASSERT_OK(result); uv_fs_req_cleanup(&read_req); } - ASSERT(0 == close(pipe_fds[0])); + ASSERT_OK(close(pipe_fds[0])); free(iovs); free(buffer); @@ -3832,13 +3835,13 @@ TEST_IMPL(fs_read_write_null_arguments) { int r; r = uv_fs_read(NULL, &read_req, 0, NULL, 0, -1, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_fs_req_cleanup(&read_req); r = uv_fs_write(NULL, &write_req, 0, NULL, 0, -1, NULL); /* Validate some memory management on failed input validation before sending fs work to the thread pool. */ - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); ASSERT_NULL(write_req.path); ASSERT_NULL(write_req.ptr); #ifdef _WIN32 @@ -3853,36 +3856,36 @@ TEST_IMPL(fs_read_write_null_arguments) { iov = uv_buf_init(NULL, 0); r = uv_fs_read(NULL, &read_req, 0, &iov, 0, -1, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(NULL, 0); r = uv_fs_write(NULL, &write_req, 0, &iov, 0, -1, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_fs_req_cleanup(&write_req); /* If the arguments are invalid, the loop should not be kept open */ loop = uv_default_loop(); r = uv_fs_read(loop, &read_req, 0, NULL, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(loop, UV_RUN_DEFAULT); uv_fs_req_cleanup(&read_req); r = uv_fs_write(loop, &write_req, 0, NULL, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(loop, UV_RUN_DEFAULT); uv_fs_req_cleanup(&write_req); iov = uv_buf_init(NULL, 0); r = uv_fs_read(loop, &read_req, 0, &iov, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(loop, UV_RUN_DEFAULT); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(NULL, 0); r = uv_fs_write(loop, &write_req, 0, &iov, 0, -1, fail_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(loop, UV_RUN_DEFAULT); uv_fs_req_cleanup(&write_req); @@ -3906,20 +3909,20 @@ TEST_IMPL(get_osfhandle_valid_handle) { O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); fd = uv_get_osfhandle(open_req1.result); #ifdef _WIN32 - ASSERT(fd != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(fd, INVALID_HANDLE_VALUE); #else - ASSERT(fd >= 0); + ASSERT_GE(fd, 0); #endif r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup. */ @@ -3945,27 +3948,27 @@ TEST_IMPL(open_osfhandle_valid_handle) { O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); handle = uv_get_osfhandle(open_req1.result); #ifdef _WIN32 - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); #else - ASSERT(handle >= 0); + ASSERT_GE(handle, 0); #endif fd = uv_open_osfhandle(handle); #ifdef _WIN32 - ASSERT(fd > 0); + ASSERT_GT(fd, 0); #else - ASSERT(fd == open_req1.result); + ASSERT_EQ(fd, open_req1.result); #endif r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup. */ @@ -3988,24 +3991,24 @@ TEST_IMPL(fs_file_pos_after_op_with_offset) { O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r > 0); + ASSERT_GT(r, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(test_buf, sizeof(test_buf)); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, 0, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_OK(lseek(open_req1.result, 0, SEEK_CUR)); uv_fs_req_cleanup(&write_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, 0, NULL); - ASSERT(r == sizeof(test_buf)); - ASSERT(strcmp(buf, test_buf) == 0); - ASSERT(lseek(open_req1.result, 0, SEEK_CUR) == 0); + ASSERT_EQ(r, sizeof(test_buf)); + ASSERT_OK(strcmp(buf, test_buf)); + ASSERT_OK(lseek(open_req1.result, 0, SEEK_CUR)); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -4021,30 +4024,30 @@ static void fs_file_pos_common(void) { iov = uv_buf_init("abc", 3); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 3); + ASSERT_EQ(3, r); uv_fs_req_cleanup(&write_req); /* Read with offset should not change the position */ iov = uv_buf_init(buf, 1); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, 1, NULL); - ASSERT(r == 1); - ASSERT(buf[0] == 'b'); + ASSERT_EQ(1, r); + ASSERT_EQ(buf[0], 'b'); uv_fs_req_cleanup(&read_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&read_req); /* Write without offset should change the position */ iov = uv_buf_init("d", 1); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 1); + ASSERT_EQ(1, r); uv_fs_req_cleanup(&write_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&read_req); } @@ -4053,23 +4056,23 @@ static void fs_file_pos_close_check(const char *contents, int size) { /* Close */ r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); /* Confirm file contents */ r = uv_fs_open(NULL, &open_req1, "test_file", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == size); - ASSERT(strncmp(buf, contents, size) == 0); + ASSERT_EQ(r, size); + ASSERT_OK(strncmp(buf, contents, size)); uv_fs_req_cleanup(&read_req); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -4088,7 +4091,7 @@ static void fs_file_pos_write(int add_flags) { O_TRUNC | O_CREAT | O_RDWR | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r > 0); + ASSERT_GT(r, 0); uv_fs_req_cleanup(&open_req1); fs_file_pos_common(); @@ -4096,12 +4099,12 @@ static void fs_file_pos_write(int add_flags) { /* Write with offset should not change the position */ iov = uv_buf_init("e", 1); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, 1, NULL); - ASSERT(r == 1); + ASSERT_EQ(1, r); uv_fs_req_cleanup(&write_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&read_req); fs_file_pos_close_check("aecd", 4); @@ -4126,7 +4129,7 @@ static void fs_file_pos_append(int add_flags) { O_APPEND | O_CREAT | O_RDWR | add_flags, S_IWUSR | S_IRUSR, NULL); - ASSERT(r > 0); + ASSERT_GT(r, 0); uv_fs_req_cleanup(&open_req1); fs_file_pos_common(); @@ -4135,13 +4138,13 @@ static void fs_file_pos_append(int add_flags) { * but does not change the position */ iov = uv_buf_init("e", 1); r = uv_fs_write(NULL, &write_req, open_req1.result, &iov, 1, 1, NULL); - ASSERT(r == 1); + ASSERT_EQ(1, r); uv_fs_req_cleanup(&write_req); iov = uv_buf_init(buf, sizeof(buf)); r = uv_fs_read(NULL, &read_req, open_req1.result, &iov, 1, -1, NULL); - ASSERT(r == 1); - ASSERT(buf[0] == 'e'); + ASSERT_EQ(1, r); + ASSERT_EQ(buf[0], 'e'); uv_fs_req_cleanup(&read_req); fs_file_pos_close_check("abcde", 5); @@ -4160,97 +4163,97 @@ TEST_IMPL(fs_null_req) { int r; r = uv_fs_open(NULL, NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_close(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_read(NULL, NULL, 0, NULL, 0, -1, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_write(NULL, NULL, 0, NULL, 0, -1, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_unlink(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_mkdir(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_mkdtemp(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_mkstemp(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_rmdir(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_scandir(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_link(NULL, NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_symlink(NULL, NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_readlink(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_realpath(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_chown(NULL, NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_fchown(NULL, NULL, 0, 0, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_stat(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_lstat(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_fstat(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_rename(NULL, NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_fsync(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_fdatasync(NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_ftruncate(NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_copyfile(NULL, NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_sendfile(NULL, NULL, 0, 0, 0, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_access(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_chmod(NULL, NULL, NULL, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_fchmod(NULL, NULL, 0, 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_utime(NULL, NULL, NULL, 0.0, 0.0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_futime(NULL, NULL, 0, 0.0, 0.0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_fs_statfs(NULL, NULL, NULL, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* This should be a no-op. */ uv_fs_req_cleanup(NULL); @@ -4265,7 +4268,7 @@ TEST_IMPL(fs_exclusive_sharing_mode) { /* Setup. */ unlink("test_file"); - ASSERT(UV_FS_O_EXLOCK > 0); + ASSERT_GT(UV_FS_O_EXLOCK, 0); r = uv_fs_open(NULL, &open_req1, @@ -4273,8 +4276,8 @@ TEST_IMPL(fs_exclusive_sharing_mode) { O_RDWR | O_CREAT | UV_FS_O_EXLOCK, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_open(NULL, @@ -4283,13 +4286,13 @@ TEST_IMPL(fs_exclusive_sharing_mode) { O_RDONLY | UV_FS_O_EXLOCK, S_IWUSR | S_IRUSR, NULL); - ASSERT(r < 0); - ASSERT(open_req2.result < 0); + ASSERT_LT(r, 0); + ASSERT_LT(open_req2.result, 0); uv_fs_req_cleanup(&open_req2); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); r = uv_fs_open(NULL, @@ -4298,13 +4301,13 @@ TEST_IMPL(fs_exclusive_sharing_mode) { O_RDONLY | UV_FS_O_EXLOCK, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req2.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req2.result, 0); uv_fs_req_cleanup(&open_req2); r = uv_fs_close(NULL, &close_req, open_req2.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Cleanup */ @@ -4322,10 +4325,10 @@ TEST_IMPL(fs_file_flag_no_buffering) { /* Setup. */ unlink("test_file"); - ASSERT(UV_FS_O_APPEND > 0); - ASSERT(UV_FS_O_CREAT > 0); - ASSERT(UV_FS_O_DIRECT > 0); - ASSERT(UV_FS_O_RDWR > 0); + ASSERT_GT(UV_FS_O_APPEND, 0); + ASSERT_GT(UV_FS_O_CREAT, 0); + ASSERT_GT(UV_FS_O_DIRECT, 0); + ASSERT_GT(UV_FS_O_RDWR, 0); /* FILE_APPEND_DATA must be excluded from FILE_GENERIC_WRITE: */ r = uv_fs_open(NULL, @@ -4334,13 +4337,13 @@ TEST_IMPL(fs_file_flag_no_buffering) { UV_FS_O_RDWR | UV_FS_O_CREAT | UV_FS_O_DIRECT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* FILE_APPEND_DATA and FILE_FLAG_NO_BUFFERING are mutually exclusive: */ @@ -4350,8 +4353,8 @@ TEST_IMPL(fs_file_flag_no_buffering) { UV_FS_O_APPEND | UV_FS_O_DIRECT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r == UV_EINVAL); - ASSERT(open_req2.result == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); + ASSERT_EQ(open_req2.result, UV_EINVAL); uv_fs_req_cleanup(&open_req2); /* Cleanup */ @@ -4392,7 +4395,7 @@ TEST_IMPL(fs_open_readonly_acl) { /* Setup - clear the ACL and remove the file */ loop = uv_default_loop(); r = uv_os_get_passwd(&pwd); - ASSERT(r == 0); + ASSERT_OK(r); call_icacls("icacls test_file_icacls /remove \"%s\" /inheritance:e", pwd.username); uv_fs_chmod(loop, &req, "test_file_icacls", S_IWUSR, NULL); @@ -4405,12 +4408,12 @@ TEST_IMPL(fs_open_readonly_acl) { O_RDONLY | O_CREAT, S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(open_req1.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(open_req1.result, 0); uv_fs_req_cleanup(&open_req1); r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); - ASSERT(r == 0); - ASSERT(close_req.result == 0); + ASSERT_OK(r); + ASSERT_OK(close_req.result); uv_fs_req_cleanup(&close_req); /* Set up ACL */ @@ -4442,7 +4445,7 @@ TEST_IMPL(fs_open_readonly_acl) { pwd.username); unlink("test_file_icacls"); uv_os_free_passwd(&pwd); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; } @@ -4463,35 +4466,35 @@ TEST_IMPL(fs_fchmod_archive_readonly) { O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); /* Make the file read-only and clear archive flag */ r = SetFileAttributes("test_file", FILE_ATTRIBUTE_READONLY); - ASSERT(r != 0); + ASSERT(r); check_permission("test_file", 0400); /* Try fchmod */ r = uv_fs_open(NULL, &req, "test_file", O_RDONLY, 0, NULL); - ASSERT(r >= 0); - ASSERT(req.result >= 0); + ASSERT_GE(r, 0); + ASSERT_GE(req.result, 0); file = req.result; uv_fs_req_cleanup(&req); r = uv_fs_fchmod(NULL, &req, file, S_IWUSR, NULL); - ASSERT(r == 0); - ASSERT(req.result == 0); + ASSERT_OK(r); + ASSERT_OK(req.result); uv_fs_req_cleanup(&req); r = uv_fs_close(NULL, &req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&req); check_permission("test_file", S_IWUSR); /* Restore Archive flag for rest of the tests */ r = SetFileAttributes("test_file", FILE_ATTRIBUTE_ARCHIVE); - ASSERT(r != 0); + ASSERT(r); return 0; } @@ -4503,7 +4506,7 @@ TEST_IMPL(fs_invalid_mkdir_name) { loop = uv_default_loop(); r = uv_fs_mkdir(loop, &req, "invalid>", 0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); ASSERT_EQ(UV_EINVAL, uv_fs_mkdir(loop, &req, "test:lol", 0, NULL)); return 0; @@ -4518,15 +4521,15 @@ TEST_IMPL(fs_statfs) { /* Test the synchronous version. */ r = uv_fs_statfs(NULL, &req, ".", NULL); - ASSERT(r == 0); + ASSERT_OK(r); statfs_cb(&req); - ASSERT(statfs_cb_count == 1); + ASSERT_EQ(1, statfs_cb_count); /* Test the asynchronous version. */ r = uv_fs_statfs(loop, &req, ".", statfs_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(statfs_cb_count == 2); + ASSERT_EQ(2, statfs_cb_count); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -4538,13 +4541,13 @@ TEST_IMPL(fs_get_system_error) { int system_error; r = uv_fs_statfs(NULL, &req, "non_existing_file", NULL); - ASSERT(r != 0); + ASSERT(r); system_error = uv_fs_get_system_error(&req); #ifdef _WIN32 - ASSERT(system_error == ERROR_FILE_NOT_FOUND); + ASSERT_EQ(system_error, ERROR_FILE_NOT_FOUND); #else - ASSERT(system_error == ENOENT); + ASSERT_EQ(system_error, ENOENT); #endif return 0; @@ -4559,13 +4562,13 @@ TEST_IMPL(fs_stat_batch_multiple) { rmdir("test_dir"); r = uv_fs_mkdir(NULL, &mkdir_req, "test_dir", 0755, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); loop = uv_default_loop(); for (i = 0; i < (int) ARRAY_SIZE(req); ++i) { r = uv_fs_stat(loop, &req[i], "test_dir", stat_batch_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } uv_run(loop, UV_RUN_DEFAULT); @@ -4590,7 +4593,7 @@ TEST_IMPL(fs_wtf) { loop = uv_default_loop(); r = uv_fs_mkdir(NULL, &mkdir_req, "test_dir", 0777, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_fs_req_cleanup(&mkdir_req); file_handle = CreateFileW(L"test_dir/hi\xD801\x0037", @@ -4601,19 +4604,19 @@ TEST_IMPL(fs_wtf) { FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); - ASSERT(file_handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(file_handle, INVALID_HANDLE_VALUE); CloseHandle(file_handle); r = uv_fs_scandir(NULL, &scandir_req, "test_dir", 0, NULL); - ASSERT_EQ(r, 1); - ASSERT_EQ(scandir_req.result, 1); + ASSERT_EQ(1, r); + ASSERT_EQ(1, scandir_req.result); ASSERT_NOT_NULL(scandir_req.ptr); while (UV_EOF != uv_fs_scandir_next(&scandir_req, &dent)) { snprintf(test_file_buf, sizeof(test_file_buf), "test_dir\\%s", dent.name); printf("stat %s\n", test_file_buf); r = uv_fs_stat(NULL, &stat_req, test_file_buf, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } uv_fs_req_cleanup(&scandir_req); ASSERT_NULL(scandir_req.ptr); diff --git a/deps/libuv/test/test-get-currentexe.c b/deps/libuv/test/test-get-currentexe.c index becaf5c1..c813d3a5 100644 --- a/deps/libuv/test/test-get-currentexe.c +++ b/deps/libuv/test/test-get-currentexe.c @@ -60,43 +60,43 @@ TEST_IMPL(get_currentexe) { * executable_path. */ ASSERT(match && !strcmp(match, path)); - ASSERT(size == strlen(buffer)); + ASSERT_EQ(size, strlen(buffer)); /* Negative tests */ size = sizeof(buffer) / sizeof(buffer[0]); r = uv_exepath(NULL, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_exepath(buffer, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); size = 0; r = uv_exepath(buffer, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); memset(buffer, -1, sizeof(buffer)); size = 1; r = uv_exepath(buffer, &size); - ASSERT(r == 0); - ASSERT(size == 0); - ASSERT(buffer[0] == '\0'); + ASSERT_OK(r); + ASSERT_OK(size); + ASSERT_EQ(buffer[0], '\0'); memset(buffer, -1, sizeof(buffer)); size = 2; r = uv_exepath(buffer, &size); - ASSERT(r == 0); - ASSERT(size == 1); - ASSERT(buffer[0] != '\0'); - ASSERT(buffer[1] == '\0'); + ASSERT_OK(r); + ASSERT_EQ(1, size); + ASSERT_NE(buffer[0], '\0'); + ASSERT_EQ(buffer[1], '\0'); /* Verify uv_exepath is not affected by uv_set_process_title(). */ r = uv_set_process_title("foobar"); - ASSERT_EQ(r, 0); + ASSERT_OK(r); size = sizeof(buffer); r = uv_exepath(buffer, &size); - ASSERT_EQ(r, 0); + ASSERT_OK(r); match = strstr(buffer, path); /* Verify that the path returned from uv_exepath is a subdirectory of diff --git a/deps/libuv/test/test-get-loadavg.c b/deps/libuv/test/test-get-loadavg.c index 4762e475..ef1719c0 100644 --- a/deps/libuv/test/test-get-loadavg.c +++ b/deps/libuv/test/test-get-loadavg.c @@ -27,9 +27,9 @@ TEST_IMPL(get_loadavg) { double avg[3] = {-1, -1, -1}; uv_loadavg(avg); - ASSERT(avg[0] >= 0); - ASSERT(avg[1] >= 0); - ASSERT(avg[2] >= 0); + ASSERT_GE(avg[0], 0); + ASSERT_GE(avg[1], 0); + ASSERT_GE(avg[2], 0); return 0; } diff --git a/deps/libuv/test/test-get-memory.c b/deps/libuv/test/test-get-memory.c index 9ac42c38..2a23f794 100644 --- a/deps/libuv/test/test-get-memory.c +++ b/deps/libuv/test/test-get-memory.c @@ -35,13 +35,13 @@ TEST_IMPL(get_memory) { (unsigned long long) constrained_mem, (unsigned long long) available_mem); - ASSERT(free_mem > 0); - ASSERT(total_mem > 0); + ASSERT_GT(free_mem, 0); + ASSERT_GT(total_mem, 0); /* On IBMi PASE, the amount of memory in use is always zero. */ #ifdef __PASE__ - ASSERT(total_mem == free_mem); + ASSERT_EQ(total_mem, free_mem); #else - ASSERT(total_mem > free_mem); + ASSERT_GT(total_mem, free_mem); #endif ASSERT_LE(available_mem, total_mem); /* we'd really want to test if available <= free, but that is fragile: diff --git a/deps/libuv/test/test-get-passwd.c b/deps/libuv/test/test-get-passwd.c index 29a2bd12..b1e76200 100644 --- a/deps/libuv/test/test-get-passwd.c +++ b/deps/libuv/test/test-get-passwd.c @@ -39,7 +39,7 @@ TEST_IMPL(get_passwd) { /* Test the normal case */ r = uv_os_get_passwd(&pwd); - ASSERT_EQ(r, 0); + ASSERT_OK(r); len = strlen(pwd.username); ASSERT_GT(len, 0); @@ -114,7 +114,7 @@ TEST_IMPL(get_passwd2) { /* Test the normal case */ r = uv_os_get_passwd(&pwd); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_os_get_passwd2(&pwd2, pwd.uid); @@ -123,7 +123,7 @@ TEST_IMPL(get_passwd2) { (void) &len; #else - ASSERT_EQ(r, 0); + ASSERT_OK(r); ASSERT_EQ(pwd.uid, pwd2.uid); ASSERT_STR_EQ(pwd.username, pwd2.username); ASSERT_STR_EQ(pwd.shell, pwd2.shell); @@ -131,15 +131,20 @@ TEST_IMPL(get_passwd2) { uv_os_free_passwd(&pwd2); r = uv_os_get_passwd2(&pwd2, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); len = strlen(pwd2.username); ASSERT_GT(len, 0); +#if defined(__PASE__) + // uid 0 is qsecofr on IBM i + ASSERT_STR_EQ(pwd2.username, "qsecofr"); +#else ASSERT_STR_EQ(pwd2.username, "root"); - +#endif len = strlen(pwd2.homedir); +# ifndef __PASE__ ASSERT_GT(len, 0); - +#endif len = strlen(pwd2.shell); # ifndef __PASE__ ASSERT_GT(len, 0); @@ -174,7 +179,7 @@ TEST_IMPL(get_group) { int r; r = uv_os_get_passwd(&pwd); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_os_get_group(&grp, pwd.gid); @@ -183,7 +188,7 @@ TEST_IMPL(get_group) { (void) &len; #else - ASSERT_EQ(r, 0); + ASSERT_OK(r); ASSERT_EQ(pwd.gid, grp.gid); len = strlen(grp.groupname); diff --git a/deps/libuv/test/test-getaddrinfo.c b/deps/libuv/test/test-getaddrinfo.c index 1032537a..76137f06 100644 --- a/deps/libuv/test/test-getaddrinfo.c +++ b/deps/libuv/test/test-getaddrinfo.c @@ -40,8 +40,8 @@ static void getaddrinfo_fail_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { - ASSERT(fail_cb_called == 0); - ASSERT(status < 0); + ASSERT_OK(fail_cb_called); + ASSERT_LT(status, 0); ASSERT_NULL(res); uv_freeaddrinfo(res); /* Should not crash. */ fail_cb_called++; @@ -51,7 +51,7 @@ static void getaddrinfo_fail_cb(uv_getaddrinfo_t* req, static void getaddrinfo_basic_cb(uv_getaddrinfo_t* handle, int status, struct addrinfo* res) { - ASSERT(handle == getaddrinfo_handle); + ASSERT_PTR_EQ(handle, getaddrinfo_handle); getaddrinfo_cbs++; free(handle); uv_freeaddrinfo(res); @@ -66,7 +66,7 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle, for (i = 0; i < CONCURRENT_COUNT; i++) { if (&getaddrinfo_handles[i] == handle) { - ASSERT(i == *data); + ASSERT_EQ(i, *data); callback_counts[i]++; break; @@ -89,22 +89,22 @@ TEST_IMPL(getaddrinfo_fail) { uv_getaddrinfo_t req; - ASSERT(UV_EINVAL == uv_getaddrinfo(uv_default_loop(), - &req, - (uv_getaddrinfo_cb) abort, - NULL, - NULL, - NULL)); + ASSERT_EQ(UV_EINVAL, uv_getaddrinfo(uv_default_loop(), + &req, + (uv_getaddrinfo_cb) abort, + NULL, + NULL, + NULL)); /* Use a FQDN by ending in a period */ - ASSERT(0 == uv_getaddrinfo(uv_default_loop(), - &req, - getaddrinfo_fail_cb, - "example.invalid.", - NULL, - NULL)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(fail_cb_called == 1); + ASSERT_OK(uv_getaddrinfo(uv_default_loop(), + &req, + getaddrinfo_fail_cb, + "example.invalid.", + NULL, + NULL)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, fail_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -119,12 +119,12 @@ TEST_IMPL(getaddrinfo_fail_sync) { uv_getaddrinfo_t req; /* Use a FQDN by ending in a period */ - ASSERT(0 > uv_getaddrinfo(uv_default_loop(), - &req, - NULL, - "example.invalid.", - NULL, - NULL)); + ASSERT_GT(0, uv_getaddrinfo(uv_default_loop(), + &req, + NULL, + "example.invalid.", + NULL, + NULL)); uv_freeaddrinfo(req.addrinfo); MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -147,11 +147,11 @@ TEST_IMPL(getaddrinfo_basic) { name, NULL, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(getaddrinfo_cbs == 1); + ASSERT_EQ(1, getaddrinfo_cbs); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -165,12 +165,12 @@ TEST_IMPL(getaddrinfo_basic_sync) { #endif uv_getaddrinfo_t req; - ASSERT(0 == uv_getaddrinfo(uv_default_loop(), - &req, - NULL, - name, - NULL, - NULL)); + ASSERT_OK(uv_getaddrinfo(uv_default_loop(), + &req, + NULL, + name, + NULL, + NULL)); uv_freeaddrinfo(req.addrinfo); MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -201,13 +201,13 @@ TEST_IMPL(getaddrinfo_concurrent) { name, NULL, NULL); - ASSERT(r == 0); + ASSERT_OK(r); } uv_run(uv_default_loop(), UV_RUN_DEFAULT); for (i = 0; i < CONCURRENT_COUNT; i++) { - ASSERT(callback_counts[i] == 1); + ASSERT_EQ(1, callback_counts[i]); } MAKE_VALGRIND_HAPPY(uv_default_loop()); diff --git a/deps/libuv/test/test-gethostname.c b/deps/libuv/test/test-gethostname.c index dc29cd69..cc15a825 100644 --- a/deps/libuv/test/test-gethostname.c +++ b/deps/libuv/test/test-gethostname.c @@ -32,27 +32,27 @@ TEST_IMPL(gethostname) { /* Reject invalid inputs */ size = 1; r = uv_os_gethostname(NULL, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_gethostname(buf, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); size = 0; r = uv_os_gethostname(buf, &size); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Return UV_ENOBUFS if the buffer cannot hold the hostname */ enobufs_size = 1; buf[0] = '\0'; r = uv_os_gethostname(buf, &enobufs_size); ASSERT_EQ(r, UV_ENOBUFS); - ASSERT(buf[0] == '\0'); - ASSERT(enobufs_size > 1); + ASSERT_EQ(buf[0], '\0'); + ASSERT_GT(enobufs_size, 1); /* Successfully get the hostname */ size = UV_MAXHOSTNAMESIZE; r = uv_os_gethostname(buf, &size); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(size > 0 && size == strlen(buf)); - ASSERT(size + 1 == enobufs_size); + ASSERT_EQ(size + 1, enobufs_size); return 0; } diff --git a/deps/libuv/test/test-getnameinfo.c b/deps/libuv/test/test-getnameinfo.c index cea57b01..415e48a4 100644 --- a/deps/libuv/test/test-getnameinfo.c +++ b/deps/libuv/test/test-getnameinfo.c @@ -39,7 +39,7 @@ static void getnameinfo_req(uv_getnameinfo_t* handle, const char* hostname, const char* service) { ASSERT_NOT_NULL(handle); - ASSERT(status == 0); + ASSERT_OK(status); ASSERT_NOT_NULL(hostname); ASSERT_NOT_NULL(service); } @@ -54,14 +54,14 @@ TEST_IMPL(getnameinfo_basic_ip4) { int r; r = uv_ip4_addr(address_ip4, port, &addr4); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getnameinfo(uv_default_loop(), &req, &getnameinfo_req, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); @@ -76,15 +76,15 @@ TEST_IMPL(getnameinfo_basic_ip4_sync) { RETURN_SKIP("Test does not currently work in QEMU"); #endif - ASSERT(0 == uv_ip4_addr(address_ip4, port, &addr4)); + ASSERT_OK(uv_ip4_addr(address_ip4, port, &addr4)); - ASSERT(0 == uv_getnameinfo(uv_default_loop(), - &req, - NULL, - (const struct sockaddr*)&addr4, - 0)); - ASSERT(req.host[0] != '\0'); - ASSERT(req.service[0] != '\0'); + ASSERT_OK(uv_getnameinfo(uv_default_loop(), + &req, + NULL, + (const struct sockaddr*)&addr4, + 0)); + ASSERT_NE(req.host[0], '\0'); + ASSERT_NE(req.service[0], '\0'); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -100,14 +100,14 @@ TEST_IMPL(getnameinfo_basic_ip6) { int r; r = uv_ip6_addr(address_ip6, port, &addr6); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getnameinfo(uv_default_loop(), &req, &getnameinfo_req, (const struct sockaddr*)&addr6, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); diff --git a/deps/libuv/test/test-getsockname.c b/deps/libuv/test/test-getsockname.c index 1d4d9f12..7bc0ba2e 100644 --- a/deps/libuv/test/test-getsockname.c +++ b/deps/libuv/test/test-getsockname.c @@ -73,7 +73,7 @@ static void after_read(uv_stream_t* handle, req = (uv_shutdown_t*) malloc(sizeof *req); r = uv_shutdown(req, handle, after_shutdown); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -84,22 +84,22 @@ static void check_sockname(struct sockaddr* addr, const char* compare_ip, char check_ip[17]; int r; - ASSERT(0 == uv_ip4_addr(compare_ip, compare_port, &compare_addr)); + ASSERT_OK(uv_ip4_addr(compare_ip, compare_port, &compare_addr)); /* Both addresses should be ipv4 */ - ASSERT(check_addr.sin_family == AF_INET); - ASSERT(compare_addr.sin_family == AF_INET); + ASSERT_EQ(check_addr.sin_family, AF_INET); + ASSERT_EQ(compare_addr.sin_family, AF_INET); /* Check if the ip matches */ - ASSERT(memcmp(&check_addr.sin_addr, - &compare_addr.sin_addr, - sizeof compare_addr.sin_addr) == 0); + ASSERT_OK(memcmp(&check_addr.sin_addr, + &compare_addr.sin_addr, + sizeof compare_addr.sin_addr)); /* Check if the port matches. If port == 0 anything goes. */ ASSERT(compare_port == 0 || check_addr.sin_port == compare_addr.sin_port); r = uv_ip4_name(&check_addr, (char*) check_ip, sizeof check_ip); - ASSERT(r == 0); + ASSERT_OK(r); printf("%s: %s:%d\n", context, check_ip, ntohs(check_addr.sin_port)); } @@ -114,34 +114,34 @@ static void on_connection(uv_stream_t* server, int status) { if (status != 0) { fprintf(stderr, "Connect error %s\n", uv_err_name(status)); } - ASSERT(status == 0); + ASSERT_OK(status); handle = malloc(sizeof(*handle)); ASSERT_NOT_NULL(handle); r = uv_tcp_init(loop, handle); - ASSERT(r == 0); + ASSERT_OK(r); /* associate server with stream */ handle->data = server; r = uv_accept(server, (uv_stream_t*)handle); - ASSERT(r == 0); + ASSERT_OK(r); namelen = sizeof sockname; r = uv_tcp_getsockname(handle, &sockname, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&sockname, "127.0.0.1", server_port, "accepted socket"); getsocknamecount_tcp++; namelen = sizeof peername; r = uv_tcp_getpeername(handle, &peername, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&peername, "127.0.0.1", connect_port, "accepted socket peer"); getpeernamecount++; r = uv_read_start((uv_stream_t*)handle, alloc, after_read); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -149,17 +149,17 @@ static void on_connect(uv_connect_t* req, int status) { struct sockaddr sockname, peername; int r, namelen; - ASSERT(status == 0); + ASSERT_OK(status); namelen = sizeof sockname; r = uv_tcp_getsockname((uv_tcp_t*) req->handle, &sockname, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&sockname, "127.0.0.1", 0, "connected socket"); getsocknamecount_tcp++; namelen = sizeof peername; r = uv_tcp_getpeername((uv_tcp_t*) req->handle, &peername, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&peername, "127.0.0.1", server_port, "connected socket peer"); getpeernamecount++; @@ -173,7 +173,7 @@ static int tcp_listener(void) { int namelen; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", server_port, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", server_port, &addr)); r = uv_tcp_init(loop, &tcpServer); if (r) { @@ -196,13 +196,13 @@ static int tcp_listener(void) { memset(&sockname, -1, sizeof sockname); namelen = sizeof sockname; r = uv_tcp_getsockname(&tcpServer, &sockname, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&sockname, "0.0.0.0", server_port, "server socket"); getsocknamecount_tcp++; namelen = sizeof sockname; r = uv_tcp_getpeername(&tcpServer, &peername, &namelen); - ASSERT(r == UV_ENOTCONN); + ASSERT_EQ(r, UV_ENOTCONN); getpeernamecount++; return 0; @@ -214,7 +214,7 @@ static void tcp_connector(void) { struct sockaddr sockname; int r, namelen; - ASSERT(0 == uv_ip4_addr("127.0.0.1", server_port, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", server_port, &server_addr)); r = uv_tcp_init(loop, &tcp); tcp.data = &connect_req; @@ -230,9 +230,9 @@ static void tcp_connector(void) { namelen = sizeof sockname; r = uv_tcp_getsockname(&tcp, &sockname, &namelen); ASSERT(!r); - ASSERT(sockname.sa_family == AF_INET); + ASSERT_EQ(sockname.sa_family, AF_INET); connect_port = ntohs(((struct sockaddr_in*) &sockname)->sin_port); - ASSERT(connect_port > 0); + ASSERT_GT(connect_port, 0); } @@ -245,7 +245,7 @@ static void udp_recv(uv_udp_t* handle, int namelen; int r; - ASSERT(nread >= 0); + ASSERT_GE(nread, 0); free(buf->base); if (nread == 0) { @@ -255,7 +255,7 @@ static void udp_recv(uv_udp_t* handle, memset(&sockname, -1, sizeof sockname); namelen = sizeof(sockname); r = uv_udp_getsockname(&udp, &sockname, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&sockname, "0.0.0.0", 0, "udp receiving socket"); getsocknamecount_udp++; @@ -275,7 +275,7 @@ static int udp_listener(void) { int namelen; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", server_port, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", server_port, &addr)); r = uv_udp_init(loop, &udpServer); if (r) { @@ -292,12 +292,12 @@ static int udp_listener(void) { memset(&sockname, -1, sizeof sockname); namelen = sizeof sockname; r = uv_udp_getsockname(&udpServer, &sockname, &namelen); - ASSERT(r == 0); + ASSERT_OK(r); check_sockname(&sockname, "0.0.0.0", server_port, "udp listener socket"); getsocknamecount_udp++; r = uv_udp_recv_start(&udpServer, alloc, udp_recv); - ASSERT(r == 0); + ASSERT_OK(r); return 0; } @@ -312,7 +312,7 @@ static void udp_sender(void) { ASSERT(!r); buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr("127.0.0.1", server_port, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", server_port, &server_addr)); r = uv_udp_send(&send_req, &udp, @@ -334,8 +334,8 @@ TEST_IMPL(getsockname_tcp) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(getsocknamecount_tcp == 3); - ASSERT(getpeernamecount == 3); + ASSERT_EQ(3, getsocknamecount_tcp); + ASSERT_EQ(3, getpeernamecount); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -352,10 +352,10 @@ TEST_IMPL(getsockname_udp) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(getsocknamecount_udp == 2); + ASSERT_EQ(2, getsocknamecount_udp); - ASSERT(udp.send_queue_size == 0); - ASSERT(udpServer.send_queue_size == 0); + ASSERT_OK(udp.send_queue_size); + ASSERT_OK(udpServer.send_queue_size); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-getters-setters.c b/deps/libuv/test/test-getters-setters.c index 9869f7b9..e4c6717d 100644 --- a/deps/libuv/test/test-getters-setters.c +++ b/deps/libuv/test/test-getters-setters.c @@ -30,9 +30,9 @@ int cookie3; TEST_IMPL(handle_type_name) { - ASSERT(strcmp(uv_handle_type_name(UV_NAMED_PIPE), "pipe") == 0); - ASSERT(strcmp(uv_handle_type_name(UV_UDP), "udp") == 0); - ASSERT(strcmp(uv_handle_type_name(UV_FILE), "file") == 0); + ASSERT_OK(strcmp(uv_handle_type_name(UV_NAMED_PIPE), "pipe")); + ASSERT_OK(strcmp(uv_handle_type_name(UV_UDP), "udp")); + ASSERT_OK(strcmp(uv_handle_type_name(UV_FILE), "file")); ASSERT_NULL(uv_handle_type_name(UV_HANDLE_TYPE_MAX)); ASSERT_NULL(uv_handle_type_name(UV_HANDLE_TYPE_MAX + 1)); ASSERT_NULL(uv_handle_type_name(UV_UNKNOWN_HANDLE)); @@ -41,9 +41,9 @@ TEST_IMPL(handle_type_name) { TEST_IMPL(req_type_name) { - ASSERT(strcmp(uv_req_type_name(UV_REQ), "req") == 0); - ASSERT(strcmp(uv_req_type_name(UV_UDP_SEND), "udp_send") == 0); - ASSERT(strcmp(uv_req_type_name(UV_WORK), "work") == 0); + ASSERT_OK(strcmp(uv_req_type_name(UV_REQ), "req")); + ASSERT_OK(strcmp(uv_req_type_name(UV_UDP_SEND), "udp_send")); + ASSERT_OK(strcmp(uv_req_type_name(UV_WORK), "work")); ASSERT_NULL(uv_req_type_name(UV_REQ_TYPE_MAX)); ASSERT_NULL(uv_req_type_name(UV_REQ_TYPE_MAX + 1)); ASSERT_NULL(uv_req_type_name(UV_UNKNOWN_REQ)); @@ -60,48 +60,48 @@ TEST_IMPL(getters_setters) { loop = malloc(uv_loop_size()); ASSERT_NOT_NULL(loop); r = uv_loop_init(loop); - ASSERT(r == 0); + ASSERT_OK(r); uv_loop_set_data(loop, &cookie1); - ASSERT(loop->data == &cookie1); - ASSERT(uv_loop_get_data(loop) == &cookie1); + ASSERT_PTR_EQ(loop->data, &cookie1); + ASSERT_PTR_EQ(uv_loop_get_data(loop), &cookie1); pipe = malloc(uv_handle_size(UV_NAMED_PIPE)); r = uv_pipe_init(loop, pipe, 0); - ASSERT(r == 0); - ASSERT(uv_handle_get_type((uv_handle_t*)pipe) == UV_NAMED_PIPE); + ASSERT_OK(r); + ASSERT_EQ(uv_handle_get_type((uv_handle_t*)pipe), UV_NAMED_PIPE); - ASSERT(uv_handle_get_loop((uv_handle_t*)pipe) == loop); + ASSERT_PTR_EQ(uv_handle_get_loop((uv_handle_t*)pipe), loop); pipe->data = &cookie2; - ASSERT(uv_handle_get_data((uv_handle_t*)pipe) == &cookie2); + ASSERT_PTR_EQ(uv_handle_get_data((uv_handle_t*)pipe), &cookie2); uv_handle_set_data((uv_handle_t*)pipe, &cookie1); - ASSERT(uv_handle_get_data((uv_handle_t*)pipe) == &cookie1); - ASSERT(pipe->data == &cookie1); + ASSERT_PTR_EQ(uv_handle_get_data((uv_handle_t*)pipe), &cookie1); + ASSERT_PTR_EQ(pipe->data, &cookie1); - ASSERT(uv_stream_get_write_queue_size((uv_stream_t*)pipe) == 0); + ASSERT_OK(uv_stream_get_write_queue_size((uv_stream_t*)pipe)); pipe->write_queue_size++; - ASSERT(uv_stream_get_write_queue_size((uv_stream_t*)pipe) == 1); + ASSERT_EQ(1, uv_stream_get_write_queue_size((uv_stream_t*)pipe)); pipe->write_queue_size--; uv_close((uv_handle_t*)pipe, NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); fs = malloc(uv_req_size(UV_FS)); uv_fs_stat(loop, fs, ".", NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(uv_fs_get_type(fs) == UV_FS_STAT); - ASSERT(uv_fs_get_result(fs) == 0); - ASSERT(uv_fs_get_ptr(fs) == uv_fs_get_statbuf(fs)); + ASSERT_EQ(uv_fs_get_type(fs), UV_FS_STAT); + ASSERT_OK(uv_fs_get_result(fs)); + ASSERT_PTR_EQ(uv_fs_get_ptr(fs), uv_fs_get_statbuf(fs)); ASSERT(uv_fs_get_statbuf(fs)->st_mode & S_IFDIR); - ASSERT(strcmp(uv_fs_get_path(fs), ".") == 0); + ASSERT_OK(strcmp(uv_fs_get_path(fs), ".")); uv_fs_req_cleanup(fs); r = uv_loop_close(loop); - ASSERT(r == 0); + ASSERT_OK(r); free(pipe); free(fs); diff --git a/deps/libuv/test/test-gettimeofday.c b/deps/libuv/test/test-gettimeofday.c index 4ebc11f9..7d901281 100644 --- a/deps/libuv/test/test-gettimeofday.c +++ b/deps/libuv/test/test-gettimeofday.c @@ -28,12 +28,12 @@ TEST_IMPL(gettimeofday) { tv.tv_sec = 0; r = uv_gettimeofday(&tv); - ASSERT(r == 0); - ASSERT(tv.tv_sec != 0); + ASSERT_OK(r); + ASSERT_NE(0, tv.tv_sec); /* Test invalid input. */ r = uv_gettimeofday(NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); return 0; } diff --git a/deps/libuv/test/test-handle-fileno.c b/deps/libuv/test/test-handle-fileno.c index 6c4c2b66..be53152c 100644 --- a/deps/libuv/test/test-handle-fileno.c +++ b/deps/libuv/test/test-handle-fileno.c @@ -56,49 +56,49 @@ TEST_IMPL(handle_fileno) { uv_loop_t* loop; loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_idle_init(loop, &idle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &idle, &fd); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*) &idle, NULL); r = uv_tcp_init(loop, &tcp); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &tcp, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_tcp_bind(&tcp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &tcp, &fd); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &tcp, NULL); r = uv_fileno((uv_handle_t*) &tcp, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_udp_init(loop, &udp); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &udp, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_udp_bind(&udp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &udp, &fd); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &udp, NULL); r = uv_fileno((uv_handle_t*) &udp, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_pipe_init(loop, &pipe, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &pipe, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_pipe_bind(&pipe, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((uv_handle_t*) &pipe, &fd); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &pipe, NULL); r = uv_fileno((uv_handle_t*) &pipe, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); tty_fd = get_tty_fd(); if (tty_fd < 0) { @@ -106,14 +106,14 @@ TEST_IMPL(handle_fileno) { fflush(stderr); } else { r = uv_tty_init(loop, &tty, tty_fd, 0); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_is_readable((uv_stream_t*) &tty)); ASSERT(!uv_is_writable((uv_stream_t*) &tty)); r = uv_fileno((uv_handle_t*) &tty, &fd); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &tty, NULL); r = uv_fileno((uv_handle_t*) &tty, &fd); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); ASSERT(!uv_is_readable((uv_stream_t*) &tty)); ASSERT(!uv_is_writable((uv_stream_t*) &tty)); } diff --git a/deps/libuv/test/test-homedir.c b/deps/libuv/test/test-homedir.c index 508351f7..769d5c81 100644 --- a/deps/libuv/test/test-homedir.c +++ b/deps/libuv/test/test-homedir.c @@ -34,39 +34,39 @@ TEST_IMPL(homedir) { /* Test the normal case */ len = sizeof homedir; homedir[0] = '\0'; - ASSERT(strlen(homedir) == 0); + ASSERT_OK(strlen(homedir)); r = uv_os_homedir(homedir, &len); - ASSERT(r == 0); - ASSERT(strlen(homedir) == len); - ASSERT(len > 0); - ASSERT(homedir[len] == '\0'); + ASSERT_OK(r); + ASSERT_EQ(strlen(homedir), len); + ASSERT_GT(len, 0); + ASSERT_EQ(homedir[len], '\0'); #ifdef _WIN32 if (len == 3 && homedir[1] == ':') - ASSERT(homedir[2] == '\\'); + ASSERT_EQ(homedir[2], '\\'); else - ASSERT(homedir[len - 1] != '\\'); + ASSERT_NE(homedir[len - 1], '\\'); #else if (len == 1) - ASSERT(homedir[0] == '/'); + ASSERT_EQ(homedir[0], '/'); else - ASSERT(homedir[len - 1] != '/'); + ASSERT_NE(homedir[len - 1], '/'); #endif /* Test the case where the buffer is too small */ len = SMALLPATH; r = uv_os_homedir(homedir, &len); - ASSERT(r == UV_ENOBUFS); - ASSERT(len > SMALLPATH); + ASSERT_EQ(r, UV_ENOBUFS); + ASSERT_GT(len, SMALLPATH); /* Test invalid inputs */ r = uv_os_homedir(NULL, &len); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_homedir(homedir, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); len = 0; r = uv_os_homedir(homedir, &len); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); return 0; } diff --git a/deps/libuv/test/test-hrtime.c b/deps/libuv/test/test-hrtime.c index 854a482f..c0b88c67 100644 --- a/deps/libuv/test/test-hrtime.c +++ b/deps/libuv/test/test-hrtime.c @@ -45,7 +45,7 @@ TEST_IMPL(hrtime) { * that the difference between the two hrtime values has a reasonable * lower bound. */ - ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC); + ASSERT_UINT64_GT(diff, (uint64_t) 25 * NANOSEC / MILLISEC); --i; } return 0; @@ -57,8 +57,8 @@ TEST_IMPL(clock_gettime) { ASSERT_EQ(UV_EINVAL, uv_clock_gettime(1337, &t)); ASSERT_EQ(UV_EFAULT, uv_clock_gettime(1337, NULL)); - ASSERT_EQ(0, uv_clock_gettime(UV_CLOCK_MONOTONIC, &t)); - ASSERT_EQ(0, uv_clock_gettime(UV_CLOCK_REALTIME, &t)); + ASSERT_OK(uv_clock_gettime(UV_CLOCK_MONOTONIC, &t)); + ASSERT_OK(uv_clock_gettime(UV_CLOCK_REALTIME, &t)); ASSERT_GT(1682500000000ll, t.tv_sec); /* 2023-04-26T09:06:40.000Z */ return 0; diff --git a/deps/libuv/test/test-idle.c b/deps/libuv/test/test-idle.c index e3f4c2bc..069e3483 100644 --- a/deps/libuv/test/test-idle.c +++ b/deps/libuv/test/test-idle.c @@ -39,7 +39,7 @@ static void close_cb(uv_handle_t* handle) { static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); + ASSERT_PTR_EQ(handle, &timer_handle); uv_close((uv_handle_t*) &idle_handle, close_cb); uv_close((uv_handle_t*) &check_handle, close_cb); @@ -52,7 +52,7 @@ static void timer_cb(uv_timer_t* handle) { static void idle_cb(uv_idle_t* handle) { - ASSERT(handle == &idle_handle); + ASSERT_PTR_EQ(handle, &idle_handle); idle_cb_called++; fprintf(stderr, "idle_cb %d\n", idle_cb_called); @@ -61,7 +61,7 @@ static void idle_cb(uv_idle_t* handle) { static void check_cb(uv_check_t* handle) { - ASSERT(handle == &check_handle); + ASSERT_PTR_EQ(handle, &check_handle); check_cb_called++; fprintf(stderr, "check_cb %d\n", check_cb_called); @@ -73,26 +73,26 @@ TEST_IMPL(idle_starvation) { int r; r = uv_idle_init(uv_default_loop(), &idle_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_idle_start(&idle_handle, idle_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_check_init(uv_default_loop(), &check_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_check_start(&check_handle, check_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(uv_default_loop(), &timer_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer_handle, timer_cb, 50, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(idle_cb_called > 0); - ASSERT(timer_cb_called == 1); - ASSERT(close_cb_called == 3); + ASSERT_GT(idle_cb_called, 0); + ASSERT_EQ(1, timer_cb_called); + ASSERT_EQ(3, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -105,19 +105,19 @@ static void idle_stop(uv_idle_t* handle) { TEST_IMPL(idle_check) { - ASSERT_EQ(0, uv_idle_init(uv_default_loop(), &idle_handle)); - ASSERT_EQ(0, uv_idle_start(&idle_handle, idle_stop)); + ASSERT_OK(uv_idle_init(uv_default_loop(), &idle_handle)); + ASSERT_OK(uv_idle_start(&idle_handle, idle_stop)); - ASSERT_EQ(0, uv_check_init(uv_default_loop(), &check_handle)); - ASSERT_EQ(0, uv_check_start(&check_handle, check_cb)); + ASSERT_OK(uv_check_init(uv_default_loop(), &check_handle)); + ASSERT_OK(uv_check_start(&check_handle, check_cb)); ASSERT_EQ(1, uv_run(uv_default_loop(), UV_RUN_ONCE)); ASSERT_EQ(1, check_cb_called); - ASSERT_EQ(0, close_cb_called); + ASSERT_OK(close_cb_called); uv_close((uv_handle_t*) &idle_handle, close_cb); uv_close((uv_handle_t*) &check_handle, close_cb); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); diff --git a/deps/libuv/test/test-idna.c b/deps/libuv/test/test-idna.c index 9b700281..bcacfc8a 100644 --- a/deps/libuv/test/test-idna.c +++ b/deps/libuv/test/test-idna.c @@ -20,6 +20,7 @@ */ #include "task.h" +#define uv__malloc malloc #include "../src/idna.c" #include @@ -31,66 +32,66 @@ TEST_IMPL(utf8_decode1) { /* ASCII. */ p = b; snprintf(b, sizeof(b), "%c\x7F", 0x00); - ASSERT(0 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 1); - ASSERT(127 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 2); + ASSERT_OK(uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 1); + ASSERT_EQ(127, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 2); /* Two-byte sequences. */ p = b; snprintf(b, sizeof(b), "\xC2\x80\xDF\xBF"); - ASSERT(128 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 2); - ASSERT(0x7FF == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 4); + ASSERT_EQ(128, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 2); + ASSERT_EQ(0x7FF, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 4); /* Three-byte sequences. */ p = b; snprintf(b, sizeof(b), "\xE0\xA0\x80\xEF\xBF\xBF"); - ASSERT(0x800 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 3); - ASSERT(0xFFFF == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 6); + ASSERT_EQ(0x800, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 3); + ASSERT_EQ(0xFFFF, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 6); /* Four-byte sequences. */ p = b; snprintf(b, sizeof(b), "\xF0\x90\x80\x80\xF4\x8F\xBF\xBF"); - ASSERT(0x10000 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 4); - ASSERT(0x10FFFF == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 8); + ASSERT_EQ(0x10000, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 4); + ASSERT_EQ(0x10FFFF, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 8); /* Four-byte sequences > U+10FFFF; disallowed. */ p = b; snprintf(b, sizeof(b), "\xF4\x90\xC0\xC0\xF7\xBF\xBF\xBF"); - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 4); - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 8); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 4); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 8); /* Overlong; disallowed. */ p = b; snprintf(b, sizeof(b), "\xC0\x80\xC1\x80"); - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 2); - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 4); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 2); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 4); /* Surrogate pairs; disallowed. */ p = b; snprintf(b, sizeof(b), "\xED\xA0\x80\xED\xA3\xBF"); - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 3); - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + 6); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 3); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + 6); /* Simply illegal. */ p = b; snprintf(b, sizeof(b), "\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); for (i = 1; i <= 8; i++) { - ASSERT((unsigned) -1 == uv__utf8_decode1(&p, b + sizeof(b))); - ASSERT(p == b + i); + ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + sizeof(b))); + ASSERT_PTR_EQ(p, b + i); } return 0; @@ -122,7 +123,7 @@ TEST_IMPL(utf8_decode1_overrun) { do { \ char d[256] = {0}; \ static const char s[] = "" input ""; \ - ASSERT(err == uv__idna_toascii(s, s + sizeof(s) - 1, d, d + sizeof(d))); \ + ASSERT_EQ(err, uv__idna_toascii(s, s + sizeof(s) - 1, d, d + sizeof(d))); \ } while (0) #define T(input, expected) \ @@ -132,13 +133,13 @@ TEST_IMPL(utf8_decode1_overrun) { char d2[256] = {0}; \ static const char s[] = "" input ""; \ n = uv__idna_toascii(s, s + sizeof(s) - 1, d1, d1 + sizeof(d1)); \ - ASSERT(n == sizeof(expected)); \ - ASSERT(0 == memcmp(d1, expected, n)); \ + ASSERT_EQ(n, sizeof(expected)); \ + ASSERT_OK(memcmp(d1, expected, n)); \ /* Sanity check: encoding twice should not change the output. */ \ n = uv__idna_toascii(d1, d1 + strlen(d1), d2, d2 + sizeof(d2)); \ - ASSERT(n == sizeof(expected)); \ - ASSERT(0 == memcmp(d2, expected, n)); \ - ASSERT(0 == memcmp(d1, d2, sizeof(d2))); \ + ASSERT_EQ(n, sizeof(expected)); \ + ASSERT_OK(memcmp(d2, expected, n)); \ + ASSERT_OK(memcmp(d1, d2, sizeof(d2))); \ } while (0) TEST_IMPL(idna_toascii) { diff --git a/deps/libuv/test/test-ip-name.c b/deps/libuv/test/test-ip-name.c index 006095f5..cdc0c563 100644 --- a/deps/libuv/test/test-ip-name.c +++ b/deps/libuv/test/test-ip-name.c @@ -40,20 +40,20 @@ TEST_IMPL(ip_name) { struct sockaddr_in6* addr6 = &test_addr.addr6; /* test ip4_name */ - ASSERT_EQ(0, uv_ip4_addr("192.168.0.1", TEST_PORT, addr4)); - ASSERT_EQ(0, uv_ip4_name(addr4, dst, INET_ADDRSTRLEN)); - ASSERT_EQ(0, strcmp("192.168.0.1", dst)); + ASSERT_OK(uv_ip4_addr("192.168.0.1", TEST_PORT, addr4)); + ASSERT_OK(uv_ip4_name(addr4, dst, INET_ADDRSTRLEN)); + ASSERT_OK(strcmp("192.168.0.1", dst)); - ASSERT_EQ(0, uv_ip_name(addr, dst, INET_ADDRSTRLEN)); - ASSERT_EQ(0, strcmp("192.168.0.1", dst)); + ASSERT_OK(uv_ip_name(addr, dst, INET_ADDRSTRLEN)); + ASSERT_OK(strcmp("192.168.0.1", dst)); /* test ip6_name */ - ASSERT_EQ(0, uv_ip6_addr("fe80::2acf:daff:fedd:342a", TEST_PORT, addr6)); - ASSERT_EQ(0, uv_ip6_name(addr6, dst, INET6_ADDRSTRLEN)); - ASSERT_EQ(0, strcmp("fe80::2acf:daff:fedd:342a", dst)); + ASSERT_OK(uv_ip6_addr("fe80::2acf:daff:fedd:342a", TEST_PORT, addr6)); + ASSERT_OK(uv_ip6_name(addr6, dst, INET6_ADDRSTRLEN)); + ASSERT_OK(strcmp("fe80::2acf:daff:fedd:342a", dst)); - ASSERT_EQ(0, uv_ip_name(addr, dst, INET6_ADDRSTRLEN)); - ASSERT_EQ(0, strcmp("fe80::2acf:daff:fedd:342a", dst)); + ASSERT_OK(uv_ip_name(addr, dst, INET6_ADDRSTRLEN)); + ASSERT_OK(strcmp("fe80::2acf:daff:fedd:342a", dst)); /* test other sa_family */ addr->sa_family = AF_UNIX; diff --git a/deps/libuv/test/test-ip4-addr.c b/deps/libuv/test/test-ip4-addr.c index 722ffb39..4a16c832 100644 --- a/deps/libuv/test/test-ip4-addr.c +++ b/deps/libuv/test/test-ip4-addr.c @@ -30,25 +30,25 @@ TEST_IMPL(ip4_addr) { struct sockaddr_in addr; char dst[16]; - ASSERT(0 == uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", dst, sizeof(dst))); - ASSERT(0 == strcmp(dst, "255.255.255.255")); - ASSERT(UV_ENOSPC == uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", - dst, sizeof(dst) - 1)); + ASSERT_OK(uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", dst, sizeof(dst))); + ASSERT_OK(strcmp(dst, "255.255.255.255")); + ASSERT_EQ(UV_ENOSPC, uv_inet_ntop(AF_INET, "\xFF\xFF\xFF\xFF", + dst, sizeof(dst) - 1)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_ip4_addr("255.255.255.255", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("255.255.255*000", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("255.255.255.256", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("2555.0.0.0", TEST_PORT, &addr)); - ASSERT(UV_EINVAL == uv_ip4_addr("255", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("255.255.255.255", TEST_PORT, &addr)); + ASSERT_EQ(UV_EINVAL, uv_ip4_addr("255.255.255*000", TEST_PORT, &addr)); + ASSERT_EQ(UV_EINVAL, uv_ip4_addr("255.255.255.256", TEST_PORT, &addr)); + ASSERT_EQ(UV_EINVAL, uv_ip4_addr("2555.0.0.0", TEST_PORT, &addr)); + ASSERT_EQ(UV_EINVAL, uv_ip4_addr("255", TEST_PORT, &addr)); #ifdef SIN6_LEN - ASSERT(addr.sin_len == sizeof(addr)); + ASSERT_EQ(addr.sin_len, sizeof(addr)); #endif /* for broken address family */ - ASSERT(UV_EAFNOSUPPORT == uv_inet_pton(42, "127.0.0.1", - &addr.sin_addr.s_addr)); + ASSERT_EQ(UV_EAFNOSUPPORT, uv_inet_pton(42, "127.0.0.1", + &addr.sin_addr.s_addr)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-ip6-addr.c b/deps/libuv/test/test-ip6-addr.c index 8f0c1860..632b7928 100644 --- a/deps/libuv/test/test-ip6-addr.c +++ b/deps/libuv/test/test-ip6-addr.c @@ -51,7 +51,7 @@ TEST_IMPL(ip6_addr_link_local) { int ix; int r; - ASSERT(0 == uv_interface_addresses(&addresses, &count)); + ASSERT_OK(uv_interface_addresses(&addresses, &count)); for (ix = 0; ix < count; ix++) { address = addresses + ix; @@ -59,10 +59,10 @@ TEST_IMPL(ip6_addr_link_local) { if (address->address.address6.sin6_family != AF_INET6) continue; - ASSERT(0 == uv_inet_ntop(AF_INET6, - &address->address.address6.sin6_addr, - string_address, - sizeof(string_address))); + ASSERT_OK(uv_inet_ntop(AF_INET6, + &address->address.address6.sin6_addr, + string_address, + sizeof(string_address))); /* Skip addresses that are not link-local. */ if (strncmp(string_address, "fe80::", 6) != 0) @@ -72,21 +72,23 @@ TEST_IMPL(ip6_addr_link_local) { device_name = address->name; scoped_addr_len = sizeof(scoped_addr); - ASSERT(0 == uv_if_indextoname(iface_index, scoped_addr, &scoped_addr_len)); + ASSERT_OK(uv_if_indextoname(iface_index, + scoped_addr, + &scoped_addr_len)); #ifndef _WIN32 /* This assert fails on Windows, as Windows semantics are different. */ - ASSERT(0 == strcmp(device_name, scoped_addr)); + ASSERT_OK(strcmp(device_name, scoped_addr)); #endif interface_id_len = sizeof(interface_id); r = uv_if_indextoiid(iface_index, interface_id, &interface_id_len); - ASSERT(0 == r); + ASSERT_OK(r); #ifdef _WIN32 /* On Windows, the interface identifier is the numeric string of the index. */ - ASSERT(strtoul(interface_id, NULL, 10) == iface_index); + ASSERT_EQ(strtoul(interface_id, NULL, 10), iface_index); #else /* On Unix/Linux, the interface identifier is the interface device name. */ - ASSERT(0 == strcmp(device_name, interface_id)); + ASSERT_OK(strcmp(device_name, interface_id)); #endif snprintf(scoped_addr, @@ -102,16 +104,18 @@ TEST_IMPL(ip6_addr_link_local) { device_name); fflush(stderr); - ASSERT(0 == uv_ip6_addr(scoped_addr, TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr(scoped_addr, TEST_PORT, &addr)); fprintf(stderr, "Got scope_id 0x%2x\n", (unsigned)addr.sin6_scope_id); fflush(stderr); - ASSERT(iface_index == addr.sin6_scope_id); + ASSERT_EQ(iface_index, addr.sin6_scope_id); } uv_free_interface_addresses(addresses, count); scoped_addr_len = sizeof(scoped_addr); - ASSERT(0 != uv_if_indextoname((unsigned int)-1, scoped_addr, &scoped_addr_len)); + ASSERT_NE(0, uv_if_indextoname((unsigned int)-1, + scoped_addr, + &scoped_addr_len)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -137,16 +141,16 @@ TEST_IMPL(ip6_addr_link_local) { X("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255.255") \ #define TEST_GOOD(ADDR) \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR, &addr)); \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR "%en1", &addr)); \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR "%%%%", &addr)); \ - ASSERT(0 == uv_inet_pton(AF_INET6, ADDR "%en1:1.2.3.4", &addr)); \ + ASSERT_OK(uv_inet_pton(AF_INET6, ADDR, &addr)); \ + ASSERT_OK(uv_inet_pton(AF_INET6, ADDR "%en1", &addr)); \ + ASSERT_OK(uv_inet_pton(AF_INET6, ADDR "%%%%", &addr)); \ + ASSERT_OK(uv_inet_pton(AF_INET6, ADDR "%en1:1.2.3.4", &addr)); \ #define TEST_BAD(ADDR) \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR, &addr)); \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR "%en1", &addr)); \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR "%%%%", &addr)); \ - ASSERT(0 != uv_inet_pton(AF_INET6, ADDR "%en1:1.2.3.4", &addr)); \ + ASSERT_NE(0, uv_inet_pton(AF_INET6, ADDR, &addr)); \ + ASSERT_NE(0, uv_inet_pton(AF_INET6, ADDR "%en1", &addr)); \ + ASSERT_NE(0, uv_inet_pton(AF_INET6, ADDR "%%%%", &addr)); \ + ASSERT_NE(0, uv_inet_pton(AF_INET6, ADDR "%en1:1.2.3.4", &addr)); \ TEST_IMPL(ip6_pton) { struct in6_addr addr; @@ -163,9 +167,9 @@ TEST_IMPL(ip6_pton) { TEST_IMPL(ip6_sin6_len) { struct sockaddr_in6 s; - ASSERT_EQ(0, uv_ip6_addr("::", 0, &s)); + ASSERT_OK(uv_ip6_addr("::", 0, &s)); #ifdef SIN6_LEN - ASSERT(s.sin6_len == sizeof(s)); + ASSERT_EQ(s.sin6_len, sizeof(s)); #endif return 0; } diff --git a/deps/libuv/test/test-ipc-heavy-traffic-deadlock-bug.c b/deps/libuv/test/test-ipc-heavy-traffic-deadlock-bug.c index f239d1fc..0305500a 100644 --- a/deps/libuv/test/test-ipc-heavy-traffic-deadlock-bug.c +++ b/deps/libuv/test/test-ipc-heavy-traffic-deadlock-bug.c @@ -49,7 +49,7 @@ static size_t bytes_read; static void write_cb(uv_write_t* req, int status) { struct write_info* write_info = container_of(req, struct write_info, write_req); - ASSERT(status == 0); + ASSERT_OK(status); bytes_written += BUFFERS_PER_WRITE * BUFFER_SIZE; free(write_info); } @@ -75,7 +75,7 @@ static void do_write(uv_stream_t* handle) { r = uv_write( &write_info->write_req, handle, bufs, BUFFERS_PER_WRITE, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void alloc_cb(uv_handle_t* handle, @@ -94,18 +94,18 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { ssize_t i; int r; - ASSERT(nread >= 0); + ASSERT_GE(nread, 0); bytes_read += nread; for (i = 0; i < nread; i++) - ASSERT(buf->base[i] == BUFFER_CONTENT); + ASSERT_EQ(buf->base[i], BUFFER_CONTENT); free(buf->base); if (bytes_read >= XFER_SIZE) { r = uv_read_stop(handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_shutdown(&shutdown_req, handle, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -121,13 +121,13 @@ static void do_writes_and_reads(uv_stream_t* handle) { } r = uv_read_start(handle, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(handle->loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(bytes_written == XFER_SIZE); - ASSERT(bytes_read == XFER_SIZE); + ASSERT_EQ(bytes_written, XFER_SIZE); + ASSERT_EQ(bytes_read, XFER_SIZE); } TEST_IMPL(ipc_heavy_traffic_deadlock_bug) { @@ -146,9 +146,9 @@ int ipc_helper_heavy_traffic_deadlock_bug(void) { int r; r = uv_pipe_init(uv_default_loop(), &pipe, 1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_open(&pipe, 0); - ASSERT(r == 0); + ASSERT_OK(r); notify_parent_process(); do_writes_and_reads((uv_stream_t*) &pipe); diff --git a/deps/libuv/test/test-ipc-send-recv.c b/deps/libuv/test/test-ipc-send-recv.c index 48eea728..0cdd881b 100644 --- a/deps/libuv/test/test-ipc-send-recv.c +++ b/deps/libuv/test/test-ipc-send-recv.c @@ -96,7 +96,7 @@ static void recv_cb(uv_stream_t* handle, free(buf->base); pipe = (uv_pipe_t*) handle; - ASSERT(pipe == &ctx.channel); + ASSERT_PTR_EQ(pipe, &ctx.channel); do { if (++recv_cb_count == 1) { @@ -112,13 +112,13 @@ static void recv_cb(uv_stream_t* handle, * acceptable value. */ if (nread == UV_EOF) { /* UV_EOF is only acceptable for the final recv_cb call */ - ASSERT(recv_cb_count == 2); + ASSERT_EQ(2, recv_cb_count); } else { - ASSERT(nread >= 0); - ASSERT(uv_pipe_pending_count(pipe) > 0); + ASSERT_GE(nread, 0); + ASSERT_GT(uv_pipe_pending_count(pipe), 0); pending = uv_pipe_pending_type(pipe); - ASSERT(pending == ctx.expected_type); + ASSERT_EQ(pending, ctx.expected_type); if (pending == UV_NAMED_PIPE) r = uv_pipe_init(ctx.channel.loop, &recv->pipe, 0); @@ -126,10 +126,10 @@ static void recv_cb(uv_stream_t* handle, r = uv_tcp_init(ctx.channel.loop, &recv->tcp); else abort(); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_accept(handle, &recv->stream); - ASSERT(r == 0); + ASSERT_OK(r); } } while (uv_pipe_pending_count(pipe) > 0); @@ -143,8 +143,8 @@ static void connect_cb(uv_connect_t* req, int status) { int r; uv_buf_t buf; - ASSERT(req == &ctx.connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &ctx.connect_req); + ASSERT_OK(status); buf = uv_buf_init(".", 1); r = uv_write2(&ctx.write_req, @@ -152,7 +152,7 @@ static void connect_cb(uv_connect_t* req, int status) { &buf, 1, &ctx.send.stream, NULL); - ASSERT(r == 0); + ASSERT_OK(r); /* Perform two writes to the same pipe to make sure that on Windows we are * not running into issue 505: @@ -163,10 +163,10 @@ static void connect_cb(uv_connect_t* req, int status) { &buf, 1, &ctx.send2.stream, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*)&ctx.channel, alloc_cb, recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static int run_test(int inprocess) { @@ -176,12 +176,12 @@ static int run_test(int inprocess) { if (inprocess) { r = uv_thread_create(&tid, ipc_send_recv_helper_threadproc, (void *) 42); - ASSERT(r == 0); + ASSERT_OK(r); uv_sleep(1000); r = uv_pipe_init(uv_default_loop(), &ctx.channel, 1); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_connect(&ctx.connect_req, &ctx.channel, TEST_PIPENAME_3, connect_cb); } else { @@ -191,13 +191,13 @@ static int run_test(int inprocess) { } r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(recv_cb_count == 2); + ASSERT_EQ(2, recv_cb_count); if (inprocess) { r = uv_thread_join(&tid); - ASSERT(r == 0); + ASSERT_OK(r); } return 0; @@ -209,19 +209,19 @@ static int run_ipc_send_recv_pipe(int inprocess) { ctx.expected_type = UV_NAMED_PIPE; r = uv_pipe_init(uv_default_loop(), &ctx.send.pipe, 1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&ctx.send.pipe, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(uv_default_loop(), &ctx.send2.pipe, 1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&ctx.send2.pipe, TEST_PIPENAME_2); - ASSERT(r == 0); + ASSERT_OK(r); r = run_test(inprocess); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -245,24 +245,24 @@ static int run_ipc_send_recv_tcp(int inprocess) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); ctx.expected_type = UV_TCP; r = uv_tcp_init(uv_default_loop(), &ctx.send.tcp); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &ctx.send2.tcp); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&ctx.send.tcp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&ctx.send2.tcp, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = run_test(inprocess); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -286,7 +286,7 @@ TEST_IMPL(ipc_send_recv_tcp_inprocess) { /* Everything here runs in a child process or second thread. */ static void write2_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); /* After two successful writes in the child process, allow the child * process to be closed. */ @@ -317,7 +317,7 @@ static void read_cb(uv_stream_t* handle, ASSERT_GE(nread, 0); pipe = (uv_pipe_t*) handle; - ASSERT_EQ(pipe, &ctx2.channel); + ASSERT_PTR_EQ(pipe, &ctx2.channel); while (uv_pipe_pending_count(pipe) > 0) { if (++read_cb_count == 2) { @@ -337,10 +337,10 @@ static void read_cb(uv_stream_t* handle, r = uv_tcp_init(ctx2.channel.loop, &recv->tcp); else abort(); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_accept(handle, &recv->stream); - ASSERT(r == 0); + ASSERT_OK(r); wrbuf = uv_buf_init(".", 1); r = uv_write2(write_req, @@ -349,27 +349,27 @@ static void read_cb(uv_stream_t* handle, 1, &recv->stream, write2_cb); - ASSERT(r == 0); + ASSERT_OK(r); } } static void send_recv_start(void) { int r; - ASSERT(1 == uv_is_readable((uv_stream_t*)&ctx2.channel)); - ASSERT(1 == uv_is_writable((uv_stream_t*)&ctx2.channel)); - ASSERT(0 == uv_is_closing((uv_handle_t*)&ctx2.channel)); + ASSERT_EQ(1, uv_is_readable((uv_stream_t*)&ctx2.channel)); + ASSERT_EQ(1, uv_is_writable((uv_stream_t*)&ctx2.channel)); + ASSERT_OK(uv_is_closing((uv_handle_t*)&ctx2.channel)); r = uv_read_start((uv_stream_t*)&ctx2.channel, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void listen_cb(uv_stream_t* handle, int status) { int r; - ASSERT(handle == (uv_stream_t*)&ctx2.listen); - ASSERT(status == 0); + ASSERT_PTR_EQ(handle, (uv_stream_t*)&ctx2.listen); + ASSERT_OK(status); r = uv_accept((uv_stream_t*)&ctx2.listen, (uv_stream_t*)&ctx2.channel); - ASSERT(r == 0); + ASSERT_OK(r); send_recv_start(); } @@ -382,27 +382,27 @@ int run_ipc_send_recv_helper(uv_loop_t* loop, int inprocess) { memset(&ctx2, 0, sizeof(ctx2)); r = uv_pipe_init(loop, &ctx2.listen, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(loop, &ctx2.channel, 1); - ASSERT(r == 0); + ASSERT_OK(r); if (inprocess) { r = uv_pipe_bind(&ctx2.listen, TEST_PIPENAME_3); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&ctx2.listen, SOMAXCONN, listen_cb); - ASSERT(r == 0); + ASSERT_OK(r); } else { r = uv_pipe_open(&ctx2.channel, 0); - ASSERT(r == 0); + ASSERT_OK(r); send_recv_start(); } notify_parent_process(); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); return 0; } @@ -414,7 +414,7 @@ int ipc_send_recv_helper(void) { int r; r = run_ipc_send_recv_helper(uv_default_loop(), 0); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -425,11 +425,11 @@ void ipc_send_recv_helper_threadproc(void* arg) { uv_loop_t loop; r = uv_loop_init(&loop); - ASSERT(r == 0); + ASSERT_OK(r); r = run_ipc_send_recv_helper(&loop, 1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_loop_close(&loop); - ASSERT(r == 0); + ASSERT_OK(r); } diff --git a/deps/libuv/test/test-ipc.c b/deps/libuv/test/test-ipc.c index 7ec6ec9c..49975d9b 100644 --- a/deps/libuv/test/test-ipc.c +++ b/deps/libuv/test/test-ipc.c @@ -68,16 +68,16 @@ static void on_connection(uv_stream_t* server, int status) { if (!local_conn_accepted) { /* Accept the connection and close it. Also and close the server. */ - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_PTR_EQ(&tcp_server, server); conn = malloc(sizeof(*conn)); ASSERT_NOT_NULL(conn); r = uv_tcp_init(server->loop, conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_close((uv_handle_t*)conn, close_server_conn_cb); uv_close((uv_handle_t*)server, NULL); @@ -91,8 +91,8 @@ static void exit_cb(uv_process_t* process, int term_signal) { printf("exit_cb\n"); exit_cb_called++; - ASSERT_EQ(exit_status, 0); - ASSERT_EQ(term_signal, 0); + ASSERT_OK(exit_status); + ASSERT_OK(term_signal); uv_close((uv_handle_t*)process, NULL); } @@ -126,14 +126,14 @@ static void make_many_connections(void) { ASSERT_NOT_NULL(conn); r = uv_tcp_init(uv_default_loop(), &conn->conn); - ASSERT_EQ(r, 0); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(r); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_connect(&conn->conn_req, (uv_tcp_t*) &conn->conn, (const struct sockaddr*) &addr, connect_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); conn->conn.data = conn; } @@ -179,13 +179,13 @@ static void on_read(uv_stream_t* handle, /* Accept the pending TCP server, and start listening on it. */ ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, on_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); tcp_server_listening = 1; @@ -194,13 +194,13 @@ static void on_read(uv_stream_t* handle, outbuf = uv_buf_init("foobar\n", 7); r = uv_write(&write_req, (uv_stream_t*)pipe, &outbuf, 1, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* Create a bunch of connections to get both servers to accept. */ make_many_connections(); } else if (memcmp("accepted_connection\n", buf->base, nread) == 0) { /* Remote server has accepted a connection. Close the channel. */ - ASSERT_EQ(0, uv_pipe_pending_count(pipe)); + ASSERT_OK(uv_pipe_pending_count(pipe)); ASSERT_EQ(pending, UV_UNKNOWN_HANDLE); remote_conn_accepted = 1; uv_close((uv_handle_t*)&channel, NULL); @@ -248,28 +248,28 @@ static void on_read_listen_after_bound_twice(uv_stream_t* handle, /* Accept the first TCP server, and start listening on it. */ ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, on_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } else if (read_cb_called == 2) { /* Accept the second TCP server, and start listening on it. */ ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_server2); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept((uv_stream_t*)pipe, (uv_stream_t*)&tcp_server2); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcp_server2, BACKLOG, on_connection); ASSERT_EQ(r, UV_EADDRINUSE); uv_close((uv_handle_t*)&tcp_server, NULL); uv_close((uv_handle_t*)&tcp_server2, NULL); - ASSERT_EQ(0, uv_pipe_pending_count(pipe)); + ASSERT_OK(uv_pipe_pending_count(pipe)); uv_close((uv_handle_t*)&channel, NULL); } @@ -288,12 +288,12 @@ void spawn_helper(uv_pipe_t* channel, uv_stdio_container_t stdio[3]; r = uv_pipe_init(uv_default_loop(), channel, 1); - ASSERT_EQ(r, 0); - ASSERT_NE(channel->ipc, 0); + ASSERT_OK(r); + ASSERT_NE(0, channel->ipc); exepath_size = sizeof(exepath); r = uv_exepath(exepath, &exepath_size); - ASSERT_EQ(r, 0); + ASSERT_OK(r); exepath[exepath_size] = '\0'; args[0] = exepath; @@ -315,12 +315,12 @@ void spawn_helper(uv_pipe_t* channel, stdio[2].data.fd = 2; r = uv_spawn(uv_default_loop(), process, &options); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } static void on_tcp_write(uv_write_t* req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_PTR_EQ(req->handle, &tcp_connection); tcp_write_cb_called++; } @@ -385,10 +385,10 @@ static void on_read_connection(uv_stream_t* handle, /* Accept the pending TCP connection */ ASSERT_EQ(pending, UV_TCP); r = uv_tcp_init(uv_default_loop(), &tcp_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept(handle, (uv_stream_t*)&tcp_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* Make sure that the expected data is correctly multiplexed. */ ASSERT_MEM_EQ("hello\n", buf->base, nread); @@ -397,10 +397,10 @@ static void on_read_connection(uv_stream_t* handle, outbuf = uv_buf_init("world\n", 6); r = uv_write(&write_req, (uv_stream_t*)&tcp_connection, &outbuf, 1, on_tcp_write); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*)&tcp_connection, on_read_alloc, on_tcp_read); - ASSERT_EQ(r, 0); + ASSERT_OK(r); free(buf->base); } @@ -422,7 +422,7 @@ static int run_ipc_test(const char* helper, uv_read_cb read_cb) { uv_read_start((uv_stream_t*)&channel, on_alloc, read_cb); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -434,10 +434,10 @@ TEST_IMPL(ipc_listen_before_write) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_listen_before_write", on_read); - ASSERT_EQ(local_conn_accepted, 1); - ASSERT_EQ(remote_conn_accepted, 1); - ASSERT_EQ(read_cb_called, 1); - ASSERT_EQ(exit_cb_called, 1); + ASSERT_EQ(1, local_conn_accepted); + ASSERT_EQ(1, remote_conn_accepted); + ASSERT_EQ(1, read_cb_called); + ASSERT_EQ(1, exit_cb_called); return r; } @@ -447,10 +447,10 @@ TEST_IMPL(ipc_listen_after_write) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_listen_after_write", on_read); - ASSERT_EQ(local_conn_accepted, 1); - ASSERT_EQ(remote_conn_accepted, 1); - ASSERT_EQ(read_cb_called, 1); - ASSERT_EQ(exit_cb_called, 1); + ASSERT_EQ(1, local_conn_accepted); + ASSERT_EQ(1, remote_conn_accepted); + ASSERT_EQ(1, read_cb_called); + ASSERT_EQ(1, exit_cb_called); return r; } @@ -460,10 +460,10 @@ TEST_IMPL(ipc_tcp_connection) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_tcp_connection", on_read_connection); - ASSERT_EQ(read_cb_called, 1); - ASSERT_EQ(tcp_write_cb_called, 1); - ASSERT_EQ(tcp_read_cb_called, 1); - ASSERT_EQ(exit_cb_called, 1); + ASSERT_EQ(1, read_cb_called); + ASSERT_EQ(1, tcp_write_cb_called); + ASSERT_EQ(1, tcp_read_cb_called); + ASSERT_EQ(1, exit_cb_called); return r; } @@ -474,20 +474,20 @@ TEST_IMPL(listen_with_simultaneous_accepts) { int r; struct sockaddr_in addr; - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_simultaneous_accepts(&server, 1); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT_EQ(r, 0); - ASSERT_EQ(server.reqs_pending, 32); + ASSERT_OK(r); + ASSERT_EQ(32, server.reqs_pending); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -499,20 +499,20 @@ TEST_IMPL(listen_no_simultaneous_accepts) { int r; struct sockaddr_in addr; - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_simultaneous_accepts(&server, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT_EQ(r, 0); - ASSERT_EQ(server.reqs_pending, 1); + ASSERT_OK(r); + ASSERT_EQ(1, server.reqs_pending); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -523,8 +523,8 @@ TEST_IMPL(ipc_listen_after_bind_twice) { RETURN_SKIP(NO_SEND_HANDLE_ON_PIPE); #endif int r = run_ipc_test("ipc_helper_bind_twice", on_read_listen_after_bound_twice); - ASSERT_EQ(read_cb_called, 2); - ASSERT_EQ(exit_cb_called, 1); + ASSERT_EQ(2, read_cb_called); + ASSERT_EQ(1, exit_cb_called); return r; } #endif @@ -532,7 +532,7 @@ TEST_IMPL(ipc_listen_after_bind_twice) { TEST_IMPL(ipc_send_zero) { int r; r = run_ipc_test("ipc_helper_send_zero", on_read_send_zero); - ASSERT_EQ(r, 0); + ASSERT_OK(r); return 0; } @@ -563,7 +563,7 @@ static void tcp_connection_write_cb(uv_write_t* req, int status) { static void send_zero_write_cb(uv_write_t* req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); send_zero_write++; } @@ -591,7 +591,7 @@ static void on_tcp_child_process_read(uv_stream_t* tcp, /* Write to the socket */ outbuf = uv_buf_init("hello again\n", 12); r = uv_write(&conn.tcp_write_req, tcp, &outbuf, 1, tcp_connection_write_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); tcp_conn_read_cb_called++; } @@ -600,9 +600,9 @@ static void on_tcp_child_process_read(uv_stream_t* tcp, static void connect_child_process_cb(uv_connect_t* req, int status) { int r; - ASSERT_EQ(status, 0); + ASSERT_OK(status); r = uv_read_start(req->handle, on_read_alloc, on_tcp_child_process_read); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } @@ -615,21 +615,21 @@ static void ipc_on_connection(uv_stream_t* server, int status) { * Accept the connection and close it. Also let the other * side know. */ - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_PTR_EQ(&tcp_server, server); r = uv_tcp_init(server->loop, &conn.conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)&conn.conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&conn.conn, close_cb); buf = uv_buf_init("accepted_connection\n", 20); r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, NULL, conn_notify_write_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); connection_accepted = 1; } @@ -646,28 +646,28 @@ static void ipc_on_connection_tcp_conn(uv_stream_t* server, int status) { uv_buf_t buf; uv_tcp_t* conn; - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_PTR_EQ(&tcp_server, server); conn = malloc(sizeof(*conn)); ASSERT_NOT_NULL(conn); r = uv_tcp_init(server->loop, conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* Send the accepted connection to the other process */ buf = uv_buf_init("hello\n", 6); r = uv_write2(&conn_notify_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)conn, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) conn, on_read_alloc, on_tcp_child_process_read); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_close((uv_handle_t*)conn, close_and_free_cb); } @@ -682,44 +682,44 @@ int ipc_helper(int listen_after_write) { int r; uv_buf_t buf; - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_open(&channel, 0); ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); - ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &channel)); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); if (!listen_after_write) { r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } buf = uv_buf_init("hello\n", 6); r = uv_write2(&write_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)&tcp_server, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); if (listen_after_write) { r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } notify_parent_process(); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(connection_accepted, 1); - ASSERT_EQ(close_cb_called, 3); + ASSERT_EQ(1, connection_accepted); + ASSERT_EQ(3, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -736,43 +736,43 @@ int ipc_helper_tcp_connection(void) { struct sockaddr_in addr; r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_open(&channel, 0); ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); - ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &channel)); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcp_server, BACKLOG, ipc_on_connection_tcp_conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* Make a connection to the server */ r = uv_tcp_init(uv_default_loop(), &conn.conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_connect(&conn.conn_req, (uv_tcp_t*) &conn.conn, (const struct sockaddr*) &addr, connect_child_process_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(tcp_conn_read_cb_called, 1); - ASSERT_EQ(tcp_conn_write_cb_called, 1); - ASSERT_EQ(close_cb_called, 4); + ASSERT_EQ(1, tcp_conn_read_cb_called); + ASSERT_EQ(1, tcp_conn_write_cb_called); + ASSERT_EQ(4, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -787,38 +787,38 @@ int ipc_helper_bind_twice(void) { int r; uv_buf_t buf; - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_pipe_init(uv_default_loop(), &channel, 1); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_open(&channel, 0); ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); - ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &channel)); buf = uv_buf_init("hello\n", 6); r = uv_tcp_init(uv_default_loop(), &tcp_server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &tcp_server2); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcp_server2, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_write2(&write_req, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)&tcp_server, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_write2(&write_req2, (uv_stream_t*)&channel, &buf, 1, (uv_stream_t*)&tcp_server2, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -831,13 +831,13 @@ int ipc_helper_send_zero(void) { zero_buf = uv_buf_init(0, 0); r = uv_pipe_init(uv_default_loop(), &channel, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_open(&channel, 0); ASSERT_EQ(1, uv_is_readable((uv_stream_t*) &channel)); ASSERT_EQ(1, uv_is_writable((uv_stream_t*) &channel)); - ASSERT_EQ(0, uv_is_closing((uv_handle_t*) &channel)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &channel)); r = uv_write(&write_req, (uv_stream_t*)&channel, @@ -845,12 +845,12 @@ int ipc_helper_send_zero(void) { 1, send_zero_write_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(send_zero_write, 1); + ASSERT_EQ(1, send_zero_write); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-list.h b/deps/libuv/test/test-list.h index 78ff9c2d..d112d07a 100644 --- a/deps/libuv/test/test-list.h +++ b/deps/libuv/test/test-list.h @@ -127,6 +127,8 @@ TEST_DECLARE (tcp_bind_writable_flags) TEST_DECLARE (tcp_bind_or_listen_error_after_close) TEST_DECLARE (tcp_listen_without_bind) TEST_DECLARE (tcp_connect_error_fault) +TEST_DECLARE (tcp_connect6_error_fault) +TEST_DECLARE (tcp_connect6_link_local) TEST_DECLARE (tcp_connect_timeout) TEST_DECLARE (tcp_local_connect_timeout) TEST_DECLARE (tcp6_local_connect_timeout) @@ -321,6 +323,7 @@ TEST_DECLARE (spawn_detached) TEST_DECLARE (spawn_and_kill_with_std) TEST_DECLARE (spawn_and_ping) TEST_DECLARE (spawn_preserve_env) +TEST_DECLARE (spawn_same_stdout_stderr) TEST_DECLARE (spawn_setuid_fails) TEST_DECLARE (spawn_setgid_fails) TEST_DECLARE (spawn_stdout_to_file) @@ -501,6 +504,7 @@ TEST_DECLARE (listen_with_simultaneous_accepts) TEST_DECLARE (listen_no_simultaneous_accepts) TEST_DECLARE (fs_stat_root) TEST_DECLARE (spawn_with_an_odd_path) +TEST_DECLARE (spawn_no_path) TEST_DECLARE (ipc_listen_after_bind_twice) TEST_DECLARE (win32_signum_number) #else @@ -542,6 +546,7 @@ TEST_DECLARE (fork_socketpair) TEST_DECLARE (fork_socketpair_started) TEST_DECLARE (fork_signal_to_child) TEST_DECLARE (fork_signal_to_child_closed) +TEST_DECLARE (fork_close_signal_in_child) #ifndef __APPLE__ /* This is forbidden in a fork child: The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). */ @@ -724,6 +729,8 @@ TASK_LIST_START TEST_ENTRY (tcp_bind_or_listen_error_after_close) TEST_ENTRY (tcp_listen_without_bind) TEST_ENTRY (tcp_connect_error_fault) + TEST_ENTRY (tcp_connect6_error_fault) + TEST_ENTRY (tcp_connect6_link_local) TEST_ENTRY (tcp_connect_timeout) TEST_ENTRY (tcp_local_connect_timeout) TEST_ENTRY (tcp6_local_connect_timeout) @@ -977,6 +984,7 @@ TASK_LIST_START TEST_ENTRY (spawn_and_kill_with_std) TEST_ENTRY (spawn_and_ping) TEST_ENTRY (spawn_preserve_env) + TEST_ENTRY (spawn_same_stdout_stderr) TEST_ENTRY (spawn_setuid_fails) TEST_ENTRY (spawn_setgid_fails) TEST_ENTRY (spawn_stdout_to_file) @@ -1015,6 +1023,7 @@ TASK_LIST_START TEST_ENTRY (listen_no_simultaneous_accepts) TEST_ENTRY (fs_stat_root) TEST_ENTRY (spawn_with_an_odd_path) + TEST_ENTRY (spawn_no_path) TEST_ENTRY (ipc_listen_after_bind_twice) TEST_ENTRY (win32_signum_number) #else @@ -1055,6 +1064,7 @@ TASK_LIST_START TEST_ENTRY (fs_unlink_archive_readonly) #endif TEST_ENTRY (fs_chown) + TEST_ENTRY (fs_link) TEST_ENTRY (fs_utime) TEST_ENTRY (fs_utime_round) TEST_ENTRY (fs_futime) @@ -1175,6 +1185,7 @@ TASK_LIST_START TEST_ENTRY (fork_socketpair_started) TEST_ENTRY (fork_signal_to_child) TEST_ENTRY (fork_signal_to_child_closed) + TEST_ENTRY (fork_close_signal_in_child) #ifndef __APPLE__ TEST_ENTRY (fork_fs_events_child) TEST_ENTRY (fork_fs_events_child_dir) diff --git a/deps/libuv/test/test-loop-alive.c b/deps/libuv/test/test-loop-alive.c index 76a2b04c..279cfc32 100644 --- a/deps/libuv/test/test-loop-alive.c +++ b/deps/libuv/test/test-loop-alive.c @@ -37,7 +37,7 @@ static void work_cb(uv_work_t* req) { static void after_work_cb(uv_work_t* req, int status) { ASSERT(req); - ASSERT(status == 0); + ASSERT_OK(status); } @@ -51,16 +51,16 @@ TEST_IMPL(loop_alive) { ASSERT(uv_loop_alive(uv_default_loop())); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(!uv_loop_alive(uv_default_loop())); /* loops with requests are alive */ r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_loop_alive(uv_default_loop())); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(!uv_loop_alive(uv_default_loop())); MAKE_VALGRIND_HAPPY(uv_default_loop()); diff --git a/deps/libuv/test/test-loop-close.c b/deps/libuv/test/test-loop-close.c index f5814796..cd1b76ce 100644 --- a/deps/libuv/test/test-loop-close.c +++ b/deps/libuv/test/test-loop-close.c @@ -35,23 +35,23 @@ TEST_IMPL(loop_close) { uv_loop_t loop; loop.data = &loop; - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(loop.data == (void*) &loop); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_PTR_EQ(loop.data, (void*) &loop); uv_timer_init(&loop, &timer_handle); uv_timer_start(&timer_handle, timer_cb, 100, 100); - ASSERT(UV_EBUSY == uv_loop_close(&loop)); + ASSERT_EQ(UV_EBUSY, uv_loop_close(&loop)); uv_run(&loop, UV_RUN_DEFAULT); uv_close((uv_handle_t*) &timer_handle, NULL); r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(loop.data == (void*) &loop); - ASSERT(0 == uv_loop_close(&loop)); - ASSERT(loop.data == (void*) &loop); + ASSERT_PTR_EQ(loop.data, (void*) &loop); + ASSERT_OK(uv_loop_close(&loop)); + ASSERT_PTR_EQ(loop.data, (void*) &loop); return 0; } @@ -67,11 +67,11 @@ static void loop_instant_close_after_work_cb(uv_work_t* req, int status) { TEST_IMPL(loop_instant_close) { static uv_loop_t loop; static uv_work_t req; - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_queue_work(&loop, - &req, - loop_instant_close_work_cb, - loop_instant_close_after_work_cb)); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_queue_work(&loop, + &req, + loop_instant_close_work_cb, + loop_instant_close_after_work_cb)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } diff --git a/deps/libuv/test/test-loop-configure.c b/deps/libuv/test/test-loop-configure.c index d057c1ed..1bc32843 100644 --- a/deps/libuv/test/test-loop-configure.c +++ b/deps/libuv/test/test-loop-configure.c @@ -24,15 +24,15 @@ static void timer_cb(uv_timer_t* handle) { TEST_IMPL(loop_configure) { uv_timer_t timer_handle; uv_loop_t loop; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); #ifdef _WIN32 - ASSERT(UV_ENOSYS == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, 0)); + ASSERT_EQ(UV_ENOSYS, uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, 0)); #else - ASSERT(0 == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF)); + ASSERT_OK(uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF)); #endif - ASSERT(0 == uv_timer_init(&loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(0 == uv_loop_close(&loop)); + ASSERT_OK(uv_timer_init(&loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 10, 0)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_loop_close(&loop)); return 0; } diff --git a/deps/libuv/test/test-loop-handles.c b/deps/libuv/test/test-loop-handles.c index 5d3df024..58368bf7 100644 --- a/deps/libuv/test/test-loop-handles.c +++ b/deps/libuv/test/test-loop-handles.c @@ -108,7 +108,7 @@ static int idle_2_is_active = 0; static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); + ASSERT_PTR_EQ(handle, &timer_handle); } @@ -116,7 +116,7 @@ static void idle_2_close_cb(uv_handle_t* handle) { fprintf(stderr, "%s", "IDLE_2_CLOSE_CB\n"); fflush(stderr); - ASSERT(handle == (uv_handle_t*)&idle_2_handle); + ASSERT_PTR_EQ(handle, (uv_handle_t*)&idle_2_handle); ASSERT(idle_2_is_active); @@ -129,7 +129,7 @@ static void idle_2_cb(uv_idle_t* handle) { fprintf(stderr, "%s", "IDLE_2_CB\n"); fflush(stderr); - ASSERT(handle == &idle_2_handle); + ASSERT_PTR_EQ(handle, &idle_2_handle); idle_2_cb_called++; @@ -144,14 +144,14 @@ static void idle_1_cb(uv_idle_t* handle) { fflush(stderr); ASSERT_NOT_NULL(handle); - ASSERT(idles_1_active > 0); + ASSERT_GT(idles_1_active, 0); /* Init idle_2 and make it active */ if (!idle_2_is_active && !uv_is_closing((uv_handle_t*)&idle_2_handle)) { r = uv_idle_init(uv_default_loop(), &idle_2_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_idle_start(&idle_2_handle, idle_2_cb); - ASSERT(r == 0); + ASSERT_OK(r); idle_2_is_active = 1; idle_2_cb_started++; } @@ -160,7 +160,7 @@ static void idle_1_cb(uv_idle_t* handle) { if (idle_1_cb_called % 5 == 0) { r = uv_idle_stop((uv_idle_t*)handle); - ASSERT(r == 0); + ASSERT_OK(r); idles_1_active--; } } @@ -179,7 +179,7 @@ static void idle_1_close_cb(uv_handle_t* handle) { static void prepare_1_close_cb(uv_handle_t* handle) { fprintf(stderr, "%s", "PREPARE_1_CLOSE_CB"); fflush(stderr); - ASSERT(handle == (uv_handle_t*)&prepare_1_handle); + ASSERT_PTR_EQ(handle, (uv_handle_t*)&prepare_1_handle); prepare_1_close_cb_called++; } @@ -188,7 +188,7 @@ static void prepare_1_close_cb(uv_handle_t* handle) { static void check_close_cb(uv_handle_t* handle) { fprintf(stderr, "%s", "CHECK_CLOSE_CB\n"); fflush(stderr); - ASSERT(handle == (uv_handle_t*)&check_handle); + ASSERT_PTR_EQ(handle, (uv_handle_t*)&check_handle); check_close_cb_called++; } @@ -197,7 +197,7 @@ static void check_close_cb(uv_handle_t* handle) { static void prepare_2_close_cb(uv_handle_t* handle) { fprintf(stderr, "%s", "PREPARE_2_CLOSE_CB\n"); fflush(stderr); - ASSERT(handle == (uv_handle_t*)&prepare_2_handle); + ASSERT_PTR_EQ(handle, (uv_handle_t*)&prepare_2_handle); prepare_2_close_cb_called++; } @@ -208,13 +208,13 @@ static void check_cb(uv_check_t* handle) { fprintf(stderr, "%s", "CHECK_CB\n"); fflush(stderr); - ASSERT(handle == &check_handle); + ASSERT_PTR_EQ(handle, &check_handle); if (loop_iteration < ITERATIONS) { /* Make some idle watchers active */ for (i = 0; i < 1 + (loop_iteration % IDLE_COUNT); i++) { r = uv_idle_start(&idle_1_handles[i], idle_1_cb); - ASSERT(r == 0); + ASSERT_OK(r); idles_1_active++; } @@ -244,16 +244,16 @@ static void prepare_2_cb(uv_prepare_t* handle) { fprintf(stderr, "%s", "PREPARE_2_CB\n"); fflush(stderr); - ASSERT(handle == &prepare_2_handle); + ASSERT_PTR_EQ(handle, &prepare_2_handle); /* Prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), and it * stops itself immediately. A started watcher is not queued until the next * round, so when this callback is made (loop_iteration % 2 == 0) cannot be * true. */ - ASSERT(loop_iteration % 2 != 0); + ASSERT_NE(0, loop_iteration % 2); r = uv_prepare_stop((uv_prepare_t*)handle); - ASSERT(r == 0); + ASSERT_OK(r); prepare_2_cb_called++; } @@ -264,11 +264,11 @@ static void prepare_1_cb(uv_prepare_t* handle) { fprintf(stderr, "%s", "PREPARE_1_CB\n"); fflush(stderr); - ASSERT(handle == &prepare_1_handle); + ASSERT_PTR_EQ(handle, &prepare_1_handle); if (loop_iteration % 2 == 0) { r = uv_prepare_start(&prepare_2_handle, prepare_2_cb); - ASSERT(r == 0); + ASSERT_OK(r); } prepare_1_cb_called++; @@ -283,23 +283,23 @@ TEST_IMPL(loop_handles) { int r; r = uv_prepare_init(uv_default_loop(), &prepare_1_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_prepare_start(&prepare_1_handle, prepare_1_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_check_init(uv_default_loop(), &check_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_check_start(&check_handle, check_cb); - ASSERT(r == 0); + ASSERT_OK(r); /* initialize only, prepare_2 is started by prepare_1_cb */ r = uv_prepare_init(uv_default_loop(), &prepare_2_handle); - ASSERT(r == 0); + ASSERT_OK(r); for (i = 0; i < IDLE_COUNT; i++) { /* initialize only, idle_1 handles are started by check_cb */ r = uv_idle_init(uv_default_loop(), &idle_1_handles[i]); - ASSERT(r == 0); + ASSERT_OK(r); } /* don't init or start idle_2, both is done by idle_1_cb */ @@ -307,30 +307,30 @@ TEST_IMPL(loop_handles) { /* The timer callback is there to keep the event loop polling unref it as it * is not supposed to keep the loop alive */ r = uv_timer_init(uv_default_loop(), &timer_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*)&timer_handle); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(loop_iteration == ITERATIONS); + ASSERT_EQ(loop_iteration, ITERATIONS); - ASSERT(prepare_1_cb_called == ITERATIONS); - ASSERT(prepare_1_close_cb_called == 1); + ASSERT_EQ(prepare_1_cb_called, ITERATIONS); + ASSERT_EQ(1, prepare_1_close_cb_called); - ASSERT(prepare_2_cb_called == ITERATIONS / 2); - ASSERT(prepare_2_close_cb_called == 1); + ASSERT_EQ(prepare_2_cb_called, ITERATIONS / 2); + ASSERT_EQ(1, prepare_2_close_cb_called); - ASSERT(check_cb_called == ITERATIONS); - ASSERT(check_close_cb_called == 1); + ASSERT_EQ(check_cb_called, ITERATIONS); + ASSERT_EQ(1, check_close_cb_called); /* idle_1_cb should be called a lot */ - ASSERT(idle_1_close_cb_called == IDLE_COUNT); + ASSERT_EQ(idle_1_close_cb_called, IDLE_COUNT); - ASSERT(idle_2_close_cb_called == idle_2_cb_started); - ASSERT(idle_2_is_active == 0); + ASSERT_EQ(idle_2_close_cb_called, idle_2_cb_started); + ASSERT_OK(idle_2_is_active); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-loop-stop.c b/deps/libuv/test/test-loop-stop.c index 981d20d1..a00a5b81 100644 --- a/deps/libuv/test/test-loop-stop.c +++ b/deps/libuv/test/test-loop-stop.c @@ -30,7 +30,7 @@ static int num_ticks = 10; static void prepare_cb(uv_prepare_t* handle) { - ASSERT(handle == &prepare_handle); + ASSERT_PTR_EQ(handle, &prepare_handle); prepare_called++; if (prepare_called == num_ticks) uv_prepare_stop(handle); @@ -38,7 +38,7 @@ static void prepare_cb(uv_prepare_t* handle) { static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); + ASSERT_PTR_EQ(handle, &timer_handle); timer_called++; if (timer_called == 1) uv_stop(uv_default_loop()); @@ -55,17 +55,17 @@ TEST_IMPL(loop_stop) { uv_timer_start(&timer_handle, timer_cb, 100, 100); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r != 0); - ASSERT(timer_called == 1); + ASSERT(r); + ASSERT_EQ(1, timer_called); r = uv_run(uv_default_loop(), UV_RUN_NOWAIT); - ASSERT(r != 0); - ASSERT(prepare_called > 1); + ASSERT(r); + ASSERT_GT(prepare_called, 1); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(timer_called == 10); - ASSERT(prepare_called == 10); + ASSERT_OK(r); + ASSERT_EQ(10, timer_called); + ASSERT_EQ(10, prepare_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -76,7 +76,7 @@ TEST_IMPL(loop_stop_before_run) { ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); ASSERT_OK(uv_timer_start(&timer_handle, (uv_timer_cb) abort, 0, 0)); uv_stop(uv_default_loop()); - ASSERT_NE(uv_run(uv_default_loop(), UV_RUN_DEFAULT), 0); + ASSERT_NE(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-loop-time.c b/deps/libuv/test/test-loop-time.c index 5d083064..01e44ffb 100644 --- a/deps/libuv/test/test-loop-time.c +++ b/deps/libuv/test/test-loop-time.c @@ -28,7 +28,7 @@ TEST_IMPL(loop_update_time) { start = uv_now(uv_default_loop()); while (uv_now(uv_default_loop()) - start < 1000) - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_NOWAIT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_NOWAIT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -46,23 +46,23 @@ TEST_IMPL(loop_backend_timeout) { /* The default loop has some internal watchers to initialize. */ loop->active_handles++; r = uv_run(loop, UV_RUN_NOWAIT); - ASSERT_EQ(r, 1); + ASSERT_EQ(1, r); loop->active_handles--; - ASSERT_EQ(uv_loop_alive(loop), 0); + ASSERT_OK(uv_loop_alive(loop)); r = uv_timer_init(loop, &timer); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(uv_loop_alive(loop), 0); - ASSERT_EQ(uv_backend_timeout(loop), 0); + ASSERT_OK(uv_loop_alive(loop)); + ASSERT_OK(uv_backend_timeout(loop)); r = uv_timer_start(&timer, cb, 1000, 0); /* 1 sec */ - ASSERT_EQ(r, 0); - ASSERT_EQ(uv_backend_timeout(loop), 1000); + ASSERT_OK(r); + ASSERT_EQ(1000, uv_backend_timeout(loop)); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); - ASSERT_EQ(uv_backend_timeout(loop), 0); + ASSERT_OK(r); + ASSERT_OK(uv_backend_timeout(loop)); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-metrics.c b/deps/libuv/test/test-metrics.c index d532f4ef..c7c73aa5 100644 --- a/deps/libuv/test/test-metrics.c +++ b/deps/libuv/test/test-metrics.c @@ -59,11 +59,11 @@ TEST_IMPL(metrics_idle_time) { cntr = 0; timer.data = &cntr; - ASSERT_EQ(0, uv_loop_configure(uv_default_loop(), UV_METRICS_IDLE_TIME)); - ASSERT_EQ(0, uv_timer_init(uv_default_loop(), &timer)); - ASSERT_EQ(0, uv_timer_start(&timer, timer_spin_cb, timeout, 0)); + ASSERT_OK(uv_loop_configure(uv_default_loop(), UV_METRICS_IDLE_TIME)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_spin_cb, timeout, 0)); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT_GT(cntr, 0); idle_time = uv_metrics_idle_time(uv_default_loop()); @@ -87,12 +87,12 @@ static void metrics_routine_cb(void* arg) { cntr = 0; timer.data = &cntr; - ASSERT_EQ(0, uv_loop_init(&loop)); - ASSERT_EQ(0, uv_loop_configure(&loop, UV_METRICS_IDLE_TIME)); - ASSERT_EQ(0, uv_timer_init(&loop, &timer)); - ASSERT_EQ(0, uv_timer_start(&timer, timer_spin_cb, timeout, 0)); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_loop_configure(&loop, UV_METRICS_IDLE_TIME)); + ASSERT_OK(uv_timer_init(&loop, &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_spin_cb, timeout, 0)); - ASSERT_EQ(0, uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); ASSERT_GT(cntr, 0); idle_time = uv_metrics_idle_time(&loop); @@ -104,7 +104,7 @@ static void metrics_routine_cb(void* arg) { ASSERT_GE(idle_time, (timeout - 500) * UV_NS_TO_MS); close_loop(&loop); - ASSERT_EQ(0, uv_loop_close(&loop)); + ASSERT_OK(uv_loop_close(&loop)); } @@ -113,7 +113,7 @@ TEST_IMPL(metrics_idle_time_thread) { int i; for (i = 0; i < 5; i++) { - ASSERT_EQ(0, uv_thread_create(&threads[i], metrics_routine_cb, NULL)); + ASSERT_OK(uv_thread_create(&threads[i], metrics_routine_cb, NULL)); } for (i = 0; i < 5; i++) { @@ -136,16 +136,16 @@ TEST_IMPL(metrics_idle_time_zero) { cntr = 0; timer.data = &cntr; - ASSERT_EQ(0, uv_loop_configure(uv_default_loop(), UV_METRICS_IDLE_TIME)); - ASSERT_EQ(0, uv_timer_init(uv_default_loop(), &timer)); - ASSERT_EQ(0, uv_timer_start(&timer, timer_noop_cb, 0, 0)); + ASSERT_OK(uv_loop_configure(uv_default_loop(), UV_METRICS_IDLE_TIME)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_noop_cb, 0, 0)); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT_GT(cntr, 0); - ASSERT_EQ(0, uv_metrics_idle_time(uv_default_loop())); + ASSERT_OK(uv_metrics_idle_time(uv_default_loop())); - ASSERT_EQ(0, uv_metrics_info(uv_default_loop(), &metrics)); + ASSERT_OK(uv_metrics_info(uv_default_loop(), &metrics)); ASSERT_UINT64_EQ(cntr, metrics.loop_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -156,7 +156,7 @@ TEST_IMPL(metrics_idle_time_zero) { static void close_cb(uv_fs_t* req) { uv_metrics_t metrics; - ASSERT_EQ(0, uv_metrics_info(uv_default_loop(), &metrics)); + ASSERT_OK(uv_metrics_info(uv_default_loop(), &metrics)); ASSERT_UINT64_EQ(3, metrics.loop_count); ASSERT_UINT64_GT(metrics.events, last_events_count); @@ -168,7 +168,7 @@ static void close_cb(uv_fs_t* req) { static void write_cb(uv_fs_t* req) { uv_metrics_t metrics; - ASSERT_EQ(0, uv_metrics_info(uv_default_loop(), &metrics)); + ASSERT_OK(uv_metrics_info(uv_default_loop(), &metrics)); ASSERT_UINT64_EQ(2, metrics.loop_count); ASSERT_UINT64_GT(metrics.events, last_events_count); ASSERT_EQ(req->result, sizeof(test_buf)); @@ -176,17 +176,17 @@ static void write_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); last_events_count = metrics.events; - ASSERT_EQ(0, uv_fs_close(uv_default_loop(), - &fs_reqs.close_req, - fs_reqs.open_req.result, - close_cb)); + ASSERT_OK(uv_fs_close(uv_default_loop(), + &fs_reqs.close_req, + fs_reqs.open_req.result, + close_cb)); } static void create_cb(uv_fs_t* req) { uv_metrics_t metrics; - ASSERT_EQ(0, uv_metrics_info(uv_default_loop(), &metrics)); + ASSERT_OK(uv_metrics_info(uv_default_loop(), &metrics)); /* Event count here is still 0 so not going to check. */ ASSERT_UINT64_EQ(1, metrics.loop_count); ASSERT_GE(req->result, 0); @@ -195,13 +195,13 @@ static void create_cb(uv_fs_t* req) { last_events_count = metrics.events; uv_buf_t iov = uv_buf_init(test_buf, sizeof(test_buf)); - ASSERT_EQ(0, uv_fs_write(uv_default_loop(), - &fs_reqs.write_req, - req->result, - &iov, - 1, - 0, - write_cb)); + ASSERT_OK(uv_fs_write(uv_default_loop(), + &fs_reqs.write_req, + req->result, + &iov, + 1, + 0, + write_cb)); } @@ -210,15 +210,15 @@ static void prepare_cb(uv_prepare_t* handle) { uv_prepare_stop(handle); - ASSERT_EQ(0, uv_metrics_info(uv_default_loop(), &metrics)); + ASSERT_OK(uv_metrics_info(uv_default_loop(), &metrics)); ASSERT_UINT64_EQ(0, metrics.loop_count); ASSERT_UINT64_EQ(0, metrics.events); - ASSERT_EQ(0, uv_fs_open(uv_default_loop(), - &fs_reqs.open_req, - "test_file", - O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR, - create_cb)); + ASSERT_OK(uv_fs_open(uv_default_loop(), + &fs_reqs.open_req, + "test_file", + O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR, + create_cb)); } @@ -229,10 +229,10 @@ TEST_IMPL(metrics_info_check) { uv_fs_unlink(NULL, &unlink_req, "test_file", NULL); uv_fs_req_cleanup(&unlink_req); - ASSERT_EQ(0, uv_prepare_init(uv_default_loop(), &prepare)); - ASSERT_EQ(0, uv_prepare_start(&prepare, prepare_cb)); + ASSERT_OK(uv_prepare_init(uv_default_loop(), &prepare)); + ASSERT_OK(uv_prepare_start(&prepare, prepare_cb)); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); uv_fs_unlink(NULL, &unlink_req, "test_file", NULL); uv_fs_req_cleanup(&unlink_req); diff --git a/deps/libuv/test/test-multiple-listen.c b/deps/libuv/test/test-multiple-listen.c index bbaa9bc1..47f35f6c 100644 --- a/deps/libuv/test/test-multiple-listen.c +++ b/deps/libuv/test/test-multiple-listen.c @@ -38,7 +38,7 @@ static void close_cb(uv_handle_t* handle) { static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); + ASSERT_OK(status); uv_close((uv_handle_t*)&server, close_cb); connection_cb_called++; } @@ -48,25 +48,25 @@ static void start_server(void) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void connect_cb(uv_connect_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); free(req); uv_close((uv_handle_t*)&client, close_cb); connect_cb_called++; @@ -78,17 +78,17 @@ static void client_connect(void) { uv_connect_t* connect_req = malloc(sizeof *connect_req); int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); ASSERT_NOT_NULL(connect_req); r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(connect_req, &client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -100,9 +100,9 @@ TEST_IMPL(multiple_listen) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connection_cb_called == 1); - ASSERT(connect_cb_called == 1); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, connection_cb_called); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-mutexes.c b/deps/libuv/test/test-mutexes.c index 975222ca..ca337732 100644 --- a/deps/libuv/test/test-mutexes.c +++ b/deps/libuv/test/test-mutexes.c @@ -40,7 +40,7 @@ TEST_IMPL(thread_mutex) { int r; r = uv_mutex_init(&mutex); - ASSERT(r == 0); + ASSERT_OK(r); uv_mutex_lock(&mutex); uv_mutex_unlock(&mutex); @@ -55,11 +55,11 @@ TEST_IMPL(thread_mutex_recursive) { int r; r = uv_mutex_init_recursive(&mutex); - ASSERT(r == 0); + ASSERT_OK(r); uv_mutex_lock(&mutex); uv_mutex_lock(&mutex); - ASSERT(0 == uv_mutex_trylock(&mutex)); + ASSERT_OK(uv_mutex_trylock(&mutex)); uv_mutex_unlock(&mutex); uv_mutex_unlock(&mutex); @@ -75,7 +75,7 @@ TEST_IMPL(thread_rwlock) { int r; r = uv_rwlock_init(&rwlock); - ASSERT(r == 0); + ASSERT_OK(r); uv_rwlock_rdlock(&rwlock); uv_rwlock_rdunlock(&rwlock); @@ -101,7 +101,7 @@ static void synchronize(void) { synchronize_nowait(); /* Wait for the other thread. Guard against spurious wakeups. */ for (current = step; current == step; uv_cond_wait(&condvar, &mutex)); - ASSERT(step == current + 1); + ASSERT_EQ(step, current + 1); } @@ -111,23 +111,23 @@ static void thread_rwlock_trylock_peer(void* unused) { uv_mutex_lock(&mutex); /* Write lock held by other thread. */ - ASSERT(UV_EBUSY == uv_rwlock_tryrdlock(&rwlock)); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); + ASSERT_EQ(UV_EBUSY, uv_rwlock_tryrdlock(&rwlock)); + ASSERT_EQ(UV_EBUSY, uv_rwlock_trywrlock(&rwlock)); synchronize(); /* Read lock held by other thread. */ - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); + ASSERT_OK(uv_rwlock_tryrdlock(&rwlock)); uv_rwlock_rdunlock(&rwlock); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); + ASSERT_EQ(UV_EBUSY, uv_rwlock_trywrlock(&rwlock)); synchronize(); /* Acquire write lock. */ - ASSERT(0 == uv_rwlock_trywrlock(&rwlock)); + ASSERT_OK(uv_rwlock_trywrlock(&rwlock)); synchronize(); /* Release write lock and acquire read lock. */ uv_rwlock_wrunlock(&rwlock); - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); + ASSERT_OK(uv_rwlock_tryrdlock(&rwlock)); synchronize(); uv_rwlock_rdunlock(&rwlock); @@ -139,22 +139,22 @@ static void thread_rwlock_trylock_peer(void* unused) { TEST_IMPL(thread_rwlock_trylock) { uv_thread_t thread; - ASSERT(0 == uv_cond_init(&condvar)); - ASSERT(0 == uv_mutex_init(&mutex)); - ASSERT(0 == uv_rwlock_init(&rwlock)); + ASSERT_OK(uv_cond_init(&condvar)); + ASSERT_OK(uv_mutex_init(&mutex)); + ASSERT_OK(uv_rwlock_init(&rwlock)); uv_mutex_lock(&mutex); - ASSERT(0 == uv_thread_create(&thread, thread_rwlock_trylock_peer, NULL)); + ASSERT_OK(uv_thread_create(&thread, thread_rwlock_trylock_peer, NULL)); /* Hold write lock. */ - ASSERT(0 == uv_rwlock_trywrlock(&rwlock)); + ASSERT_OK(uv_rwlock_trywrlock(&rwlock)); synchronize(); /* Releases the mutex to the other thread. */ /* Release write lock and acquire read lock. Pthreads doesn't support * the notion of upgrading or downgrading rwlocks, so neither do we. */ uv_rwlock_wrunlock(&rwlock); - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); + ASSERT_OK(uv_rwlock_tryrdlock(&rwlock)); synchronize(); /* Release read lock. */ @@ -162,17 +162,17 @@ TEST_IMPL(thread_rwlock_trylock) { synchronize(); /* Write lock held by other thread. */ - ASSERT(UV_EBUSY == uv_rwlock_tryrdlock(&rwlock)); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); + ASSERT_EQ(UV_EBUSY, uv_rwlock_tryrdlock(&rwlock)); + ASSERT_EQ(UV_EBUSY, uv_rwlock_trywrlock(&rwlock)); synchronize(); /* Read lock held by other thread. */ - ASSERT(0 == uv_rwlock_tryrdlock(&rwlock)); + ASSERT_OK(uv_rwlock_tryrdlock(&rwlock)); uv_rwlock_rdunlock(&rwlock); - ASSERT(UV_EBUSY == uv_rwlock_trywrlock(&rwlock)); + ASSERT_EQ(UV_EBUSY, uv_rwlock_trywrlock(&rwlock)); synchronize(); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_rwlock_destroy(&rwlock); uv_mutex_unlock(&mutex); uv_mutex_destroy(&mutex); diff --git a/deps/libuv/test/test-not-readable-nor-writable-on-read-error.c b/deps/libuv/test/test-not-readable-nor-writable-on-read-error.c index 823a4e91..2c45a2da 100644 --- a/deps/libuv/test/test-not-readable-nor-writable-on-read-error.c +++ b/deps/libuv/test/test-not-readable-nor-writable-on-read-error.c @@ -35,7 +35,7 @@ static int close_cb_called; static void write_cb(uv_write_t* req, int status) { write_cb_called++; - ASSERT(status == 0); + ASSERT_OK(status); } static void alloc_cb(uv_handle_t* handle, @@ -54,8 +54,8 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { read_cb_called++; ASSERT((nread < 0) && (nread != UV_EOF)); - ASSERT(0 == uv_is_writable(handle)); - ASSERT(0 == uv_is_readable(handle)); + ASSERT_OK(uv_is_writable(handle)); + ASSERT_OK(uv_is_readable(handle)); uv_close((uv_handle_t*) handle, close_cb); } @@ -65,10 +65,10 @@ static void connect_cb(uv_connect_t* req, int status) { uv_buf_t reset_me; connect_cb_called++; - ASSERT(status == 0); + ASSERT_OK(status); r = uv_read_start((uv_stream_t*) &tcp_client, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); reset_me = uv_buf_init(reset_me_cmd, sizeof(reset_me_cmd)); @@ -78,26 +78,26 @@ static void connect_cb(uv_connect_t* req, int status) { 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } TEST_IMPL(not_readable_nor_writable_on_read_error) { struct sockaddr_in sa; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &sa)); - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_tcp_init(&loop, &tcp_client)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &sa)); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_tcp_init(&loop, &tcp_client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &tcp_client, - (const struct sockaddr*) &sa, - connect_cb)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &tcp_client, + (const struct sockaddr*) &sa, + connect_cb)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(read_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, read_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; diff --git a/deps/libuv/test/test-not-writable-after-shutdown.c b/deps/libuv/test/test-not-writable-after-shutdown.c index 84e09177..066f8bba 100644 --- a/deps/libuv/test/test-not-writable-after-shutdown.c +++ b/deps/libuv/test/test-not-writable-after-shutdown.c @@ -34,12 +34,12 @@ static void shutdown_cb(uv_shutdown_t* req, int status) { static void connect_cb(uv_connect_t* req, int status) { int r; - ASSERT(status == 0); + ASSERT_OK(status); r = uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_is_writable(req->handle)); + ASSERT_OK(uv_is_writable(req->handle)); } TEST_IMPL(not_writable_after_shutdown) { @@ -49,20 +49,20 @@ TEST_IMPL(not_writable_after_shutdown) { uv_tcp_t socket; uv_connect_t connect_req; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); r = uv_tcp_init(loop, &socket); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &socket, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-osx-select.c b/deps/libuv/test/test-osx-select.c index 00ae540b..44e2c6d8 100644 --- a/deps/libuv/test/test-osx-select.c +++ b/deps/libuv/test/test-osx-select.c @@ -62,7 +62,7 @@ TEST_IMPL(osx_select) { } r = uv_tty_init(uv_default_loop(), &tty, fd, 1); - ASSERT(r == 0); + ASSERT_OK(r); uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb); @@ -72,12 +72,12 @@ TEST_IMPL(osx_select) { "feel pretty happy\n"; for (i = 0, len = strlen(str); i < len; i++) { r = ioctl(fd, TIOCSTI, str + i); - ASSERT(r == 0); + ASSERT_OK(r); } uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(read_count == 3); + ASSERT_EQ(3, read_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -97,13 +97,13 @@ TEST_IMPL(osx_select_many_fds) { TEST_FILE_LIMIT(ARRAY_SIZE(tcps) + 100); r = uv_ip4_addr("127.0.0.1", 0, &addr); - ASSERT(r == 0); + ASSERT_OK(r); for (i = 0; i < ARRAY_SIZE(tcps); i++) { r = uv_tcp_init(uv_default_loop(), &tcps[i]); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcps[i], (const struct sockaddr *) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*) &tcps[i]); } @@ -115,10 +115,10 @@ TEST_IMPL(osx_select_many_fds) { } r = uv_tty_init(uv_default_loop(), &tty, fd, 1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); /* Emulate user-input */ str = "got some input\n" @@ -126,12 +126,12 @@ TEST_IMPL(osx_select_many_fds) { "feel pretty happy\n"; for (i = 0, len = strlen(str); i < len; i++) { r = ioctl(fd, TIOCSTI, str + i); - ASSERT(r == 0); + ASSERT_OK(r); } uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(read_count == 3); + ASSERT_EQ(3, read_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-ping-pong.c b/deps/libuv/test/test-ping-pong.c index f54f2ad2..cd9fbf62 100644 --- a/deps/libuv/test/test-ping-pong.c +++ b/deps/libuv/test/test-ping-pong.c @@ -83,7 +83,7 @@ static void pinger_on_close(uv_handle_t* handle) { static void pinger_after_write(uv_write_t* req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); free(req->data); free(req); } @@ -112,7 +112,7 @@ static void pinger_write_ping(pinger_t* pinger) { req = malloc(sizeof(*req)); ASSERT_NOT_NULL(req); req->data = NULL; - ASSERT_EQ(0, uv_write(req, stream, bufs, nbufs, pinger_after_write)); + ASSERT_OK(uv_write(req, stream, bufs, nbufs, pinger_after_write)); puts("PING"); } @@ -188,7 +188,7 @@ static void ponger_read_cb(uv_stream_t* stream, req = malloc(sizeof(*req)); ASSERT_NOT_NULL(req); req->data = buf->base; - ASSERT_EQ(0, uv_write(req, stream, &writebuf, 1, pinger_after_write)); + ASSERT_OK(uv_write(req, stream, &writebuf, 1, pinger_after_write)); } @@ -197,17 +197,17 @@ static void pinger_on_connect(uv_connect_t* req, int status) { pinger_on_connect_count++; - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_EQ(1, uv_is_readable(req->handle)); ASSERT_EQ(1, uv_is_writable(req->handle)); - ASSERT_EQ(0, uv_is_closing((uv_handle_t *) req->handle)); + ASSERT_OK(uv_is_closing((uv_handle_t *) req->handle)); pinger_write_ping(pinger); - ASSERT_EQ(0, uv_read_start((uv_stream_t*) req->handle, - alloc_cb, - pinger_read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) req->handle, + alloc_cb, + pinger_read_cb)); } @@ -218,7 +218,7 @@ static void tcp_pinger_v6_new(int vectored_writes) { pinger_t* pinger; - ASSERT_EQ(0, uv_ip6_addr("::1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip6_addr("::1", TEST_PORT, &server_addr)); pinger = malloc(sizeof(*pinger)); ASSERT_NOT_NULL(pinger); pinger->vectored_writes = vectored_writes; @@ -229,7 +229,7 @@ static void tcp_pinger_v6_new(int vectored_writes) { /* Try to connect to the server and do NUM_PINGS ping-pongs. */ r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp); pinger->stream.tcp.data = pinger; - ASSERT_EQ(0, r); + ASSERT_OK(r); /* We are never doing multiple reads/connects at a time anyway, so these * handles can be pre-initialized. */ @@ -237,10 +237,10 @@ static void tcp_pinger_v6_new(int vectored_writes) { &pinger->stream.tcp, (const struct sockaddr*) &server_addr, pinger_on_connect); - ASSERT_EQ(0, r); + ASSERT_OK(r); /* Synchronous connect callbacks are not allowed. */ - ASSERT_EQ(pinger_on_connect_count, 0); + ASSERT_OK(pinger_on_connect_count); } @@ -249,7 +249,7 @@ static void tcp_pinger_new(int vectored_writes) { struct sockaddr_in server_addr; pinger_t* pinger; - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); pinger = malloc(sizeof(*pinger)); ASSERT_NOT_NULL(pinger); pinger->vectored_writes = vectored_writes; @@ -260,7 +260,7 @@ static void tcp_pinger_new(int vectored_writes) { /* Try to connect to the server and do NUM_PINGS ping-pongs. */ r = uv_tcp_init(uv_default_loop(), &pinger->stream.tcp); pinger->stream.tcp.data = pinger; - ASSERT_EQ(0, r); + ASSERT_OK(r); /* We are never doing multiple reads/connects at a time anyway, so these * handles can be pre-initialized. */ @@ -268,10 +268,10 @@ static void tcp_pinger_new(int vectored_writes) { &pinger->stream.tcp, (const struct sockaddr*) &server_addr, pinger_on_connect); - ASSERT_EQ(0, r); + ASSERT_OK(r); /* Synchronous connect callbacks are not allowed. */ - ASSERT_EQ(pinger_on_connect_count, 0); + ASSERT_OK(pinger_on_connect_count); } @@ -289,7 +289,7 @@ static void pipe_pinger_new(int vectored_writes) { /* Try to connect to the server and do NUM_PINGS ping-pongs. */ r = uv_pipe_init(uv_default_loop(), &pinger->stream.pipe, 0); pinger->stream.pipe.data = pinger; - ASSERT_EQ(0, r); + ASSERT_OK(r); /* We are never doing multiple reads/connects at a time anyway, so these * handles can be pre-initialized. */ @@ -297,7 +297,7 @@ static void pipe_pinger_new(int vectored_writes) { pinger_on_connect); /* Synchronous connect callbacks are not allowed. */ - ASSERT_EQ(pinger_on_connect_count, 0); + ASSERT_OK(pinger_on_connect_count); } @@ -315,31 +315,31 @@ static void socketpair_pinger_new(int vectored_writes) { /* Try to make a socketpair and do NUM_PINGS ping-pongs. */ (void)uv_default_loop(); /* ensure WSAStartup has been performed */ - ASSERT_EQ(0, uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)); + ASSERT_OK(uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)); #ifndef _WIN32 /* On Windows, this is actually a UV_TCP, but libuv doesn't detect that. */ ASSERT_EQ(uv_guess_handle((uv_file) fds[0]), UV_NAMED_PIPE); ASSERT_EQ(uv_guess_handle((uv_file) fds[1]), UV_NAMED_PIPE); #endif - ASSERT_EQ(0, uv_tcp_init(uv_default_loop(), &pinger->stream.tcp)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &pinger->stream.tcp)); pinger->stream.pipe.data = pinger; - ASSERT_EQ(0, uv_tcp_open(&pinger->stream.tcp, fds[1])); + ASSERT_OK(uv_tcp_open(&pinger->stream.tcp, fds[1])); ponger = malloc(sizeof(*ponger)); ASSERT_NOT_NULL(ponger); ponger->data = NULL; - ASSERT_EQ(0, uv_tcp_init(uv_default_loop(), ponger)); - ASSERT_EQ(0, uv_tcp_open(ponger, fds[0])); + ASSERT_OK(uv_tcp_init(uv_default_loop(), ponger)); + ASSERT_OK(uv_tcp_open(ponger, fds[0])); pinger_write_ping(pinger); - ASSERT_EQ(0, uv_read_start((uv_stream_t*) &pinger->stream.tcp, - alloc_cb, - pinger_read_cb)); - ASSERT_EQ(0, uv_read_start((uv_stream_t*) ponger, - alloc_cb, - ponger_read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) &pinger->stream.tcp, + alloc_cb, + pinger_read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) ponger, + alloc_cb, + ponger_read_cb)); } @@ -349,14 +349,14 @@ static void pipe2_pinger_new(int vectored_writes) { uv_pipe_t* ponger; /* Try to make a pipe and do NUM_PINGS pings. */ - ASSERT_EQ(0, uv_pipe(fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)); + ASSERT_OK(uv_pipe(fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)); ASSERT_EQ(uv_guess_handle(fds[0]), UV_NAMED_PIPE); ASSERT_EQ(uv_guess_handle(fds[1]), UV_NAMED_PIPE); ponger = malloc(sizeof(*ponger)); ASSERT_NOT_NULL(ponger); - ASSERT_EQ(0, uv_pipe_init(uv_default_loop(), ponger, 0)); - ASSERT_EQ(0, uv_pipe_open(ponger, fds[0])); + ASSERT_OK(uv_pipe_init(uv_default_loop(), ponger, 0)); + ASSERT_OK(uv_pipe_open(ponger, fds[0])); pinger = malloc(sizeof(*pinger)); ASSERT_NOT_NULL(pinger); @@ -364,19 +364,19 @@ static void pipe2_pinger_new(int vectored_writes) { pinger->state = 0; pinger->pongs = 0; pinger->pong = PING; - ASSERT_EQ(0, uv_pipe_init(uv_default_loop(), &pinger->stream.pipe, 0)); - ASSERT_EQ(0, uv_pipe_open(&pinger->stream.pipe, fds[1])); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &pinger->stream.pipe, 0)); + ASSERT_OK(uv_pipe_open(&pinger->stream.pipe, fds[1])); pinger->stream.pipe.data = pinger; /* record for close_cb */ ponger->data = pinger; /* record for read_cb */ pinger_write_ping(pinger); - ASSERT_EQ(0, uv_read_start((uv_stream_t*) ponger, alloc_cb, pinger_read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) ponger, alloc_cb, pinger_read_cb)); } static int run_ping_pong_test(void) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(completed_pingers, 1); + ASSERT_EQ(1, completed_pingers); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-pipe-bind-error.c b/deps/libuv/test/test-pipe-bind-error.c index f8626302..381a0084 100644 --- a/deps/libuv/test/test-pipe-bind-error.c +++ b/deps/libuv/test/test-pipe-bind-error.c @@ -46,26 +46,26 @@ TEST_IMPL(pipe_bind_error_addrinuse) { int r; r = uv_pipe_init(uv_default_loop(), &server1, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&server1, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(uv_default_loop(), &server2, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&server2, TEST_PIPENAME); - ASSERT(r == UV_EADDRINUSE); + ASSERT_EQ(r, UV_EADDRINUSE); r = uv_listen((uv_stream_t*)&server1, SOMAXCONN, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server2, SOMAXCONN, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server1, close_cb); uv_close((uv_handle_t*)&server2, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -77,16 +77,16 @@ TEST_IMPL(pipe_bind_error_addrnotavail) { int r; r = uv_pipe_init(uv_default_loop(), &server, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&server, BAD_PIPENAME); - ASSERT(r == UV_EACCES); + ASSERT_EQ(r, UV_EACCES); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -98,17 +98,17 @@ TEST_IMPL(pipe_bind_error_inval) { int r; r = uv_pipe_init(uv_default_loop(), &server, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&server, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&server, TEST_PIPENAME_2); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -123,16 +123,16 @@ TEST_IMPL(pipe_listen_without_bind) { int r; r = uv_pipe_init(uv_default_loop(), &server, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -141,14 +141,14 @@ TEST_IMPL(pipe_listen_without_bind) { TEST_IMPL(pipe_bind_or_listen_error_after_close) { uv_pipe_t server; - ASSERT_EQ(uv_pipe_init(uv_default_loop(), &server, 0), 0); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &server, 0)); uv_close((uv_handle_t*) &server, NULL); ASSERT_EQ(uv_pipe_bind(&server, TEST_PIPENAME), UV_EINVAL); ASSERT_EQ(uv_listen((uv_stream_t*) &server, SOMAXCONN, NULL), UV_EINVAL); - ASSERT_EQ(uv_run(uv_default_loop(), UV_RUN_DEFAULT), 0); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-pipe-close-stdout-read-stdin.c b/deps/libuv/test/test-pipe-close-stdout-read-stdin.c index a9295f0a..51bbf0f5 100644 --- a/deps/libuv/test/test-pipe-close-stdout-read-stdin.c +++ b/deps/libuv/test/test-pipe-close-stdout-read-stdin.c @@ -61,7 +61,7 @@ TEST_IMPL(pipe_close_stdout_read_stdin) { uv_pipe_t stdin_pipe; r = pipe(fd); - ASSERT(r == 0); + ASSERT_OK(r); #if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) pid = -1; @@ -80,24 +80,24 @@ TEST_IMPL(pipe_close_stdout_read_stdin) { ASSERT(-1 <= r && r <= 1); close(0); r = dup(fd[0]); - ASSERT(r != -1); + ASSERT_NE(r, -1); /* Create a stream that reads from the pipe. */ r = uv_pipe_init(uv_default_loop(), (uv_pipe_t *)&stdin_pipe, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_open((uv_pipe_t *)&stdin_pipe, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t *)&stdin_pipe, alloc_buffer, read_stdin); - ASSERT(r == 0); + ASSERT_OK(r); /* * Because the other end of the pipe was closed, there should * be no event left to process after one run of the event loop. * Otherwise, it means that events were not processed correctly. */ - ASSERT(uv_run(uv_default_loop(), UV_RUN_NOWAIT) == 0); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_NOWAIT)); } else { /* * Close both ends of the pipe so that the child diff --git a/deps/libuv/test/test-pipe-connect-error.c b/deps/libuv/test/test-pipe-connect-error.c index 140e7d32..ee6e0776 100644 --- a/deps/libuv/test/test-pipe-connect-error.c +++ b/deps/libuv/test/test-pipe-connect-error.c @@ -64,13 +64,13 @@ TEST_IMPL(pipe_connect_bad_name) { int r; r = uv_pipe_init(uv_default_loop(), &client, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_connect(&req, &client, BAD_PIPENAME, connect_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(close_cb_called, 1); - ASSERT_EQ(connect_cb_called, 1); + ASSERT_EQ(1, close_cb_called); + ASSERT_EQ(1, connect_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -84,13 +84,13 @@ TEST_IMPL(pipe_connect_to_file) { int r; r = uv_pipe_init(uv_default_loop(), &client, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_connect(&req, &client, path, connect_cb_file); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(close_cb_called, 1); - ASSERT_EQ(connect_cb_called, 1); + ASSERT_EQ(1, close_cb_called); + ASSERT_EQ(1, connect_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-pipe-connect-multiple.c b/deps/libuv/test/test-pipe-connect-multiple.c index b8f417e8..69a09ec6 100644 --- a/deps/libuv/test/test-pipe-connect-multiple.c +++ b/deps/libuv/test/test-pipe-connect-multiple.c @@ -44,14 +44,14 @@ static uv_pipe_t connections[NUM_CLIENTS]; static void connection_cb(uv_stream_t* server, int status) { int r; uv_pipe_t* conn; - ASSERT(status == 0); + ASSERT_OK(status); conn = &connections[connection_cb_called]; r = uv_pipe_init(server->loop, conn, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)conn); - ASSERT(r == 0); + ASSERT_OK(r); if (++connection_cb_called == NUM_CLIENTS && connect_cb_called == NUM_CLIENTS) { @@ -61,7 +61,7 @@ static void connection_cb(uv_stream_t* server, int status) { static void connect_cb(uv_connect_t* connect_req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); if (++connect_cb_called == NUM_CLIENTS && connection_cb_called == NUM_CLIENTS) { uv_stop(connect_req->handle->loop); @@ -80,17 +80,17 @@ TEST_IMPL(pipe_connect_multiple) { loop = uv_default_loop(); r = uv_pipe_init(loop, &server_handle, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&server_handle, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server_handle, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); for (i = 0; i < NUM_CLIENTS; i++) { r = uv_pipe_init(loop, &clients[i].pipe_handle, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_connect(&clients[i].conn_req, &clients[i].pipe_handle, TEST_PIPENAME, @@ -99,8 +99,8 @@ TEST_IMPL(pipe_connect_multiple) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(connection_cb_called == NUM_CLIENTS); - ASSERT(connect_cb_called == NUM_CLIENTS); + ASSERT_EQ(connection_cb_called, NUM_CLIENTS); + ASSERT_EQ(connect_cb_called, NUM_CLIENTS); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -110,14 +110,14 @@ TEST_IMPL(pipe_connect_multiple) { static void connection_cb2(uv_stream_t* server, int status) { int r; uv_pipe_t* conn; - ASSERT_EQ(status, 0); + ASSERT_OK(status); conn = &connections[connection_cb_called]; r = uv_pipe_init(server->loop, conn, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_close((uv_handle_t*)conn, NULL); if (++connection_cb_called == NUM_CLIENTS && @@ -146,17 +146,17 @@ TEST_IMPL(pipe_connect_close_multiple) { loop = uv_default_loop(); r = uv_pipe_init(loop, &server_handle, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_pipe_bind(&server_handle, TEST_PIPENAME); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server_handle, 128, connection_cb2); - ASSERT_EQ(r, 0); + ASSERT_OK(r); for (i = 0; i < NUM_CLIENTS; i++) { r = uv_pipe_init(loop, &clients[i].pipe_handle, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_pipe_connect(&clients[i].conn_req, &clients[i].pipe_handle, TEST_PIPENAME, diff --git a/deps/libuv/test/test-pipe-connect-prepare.c b/deps/libuv/test/test-pipe-connect-prepare.c index f7a79404..93d15a47 100644 --- a/deps/libuv/test/test-pipe-connect-prepare.c +++ b/deps/libuv/test/test-pipe-connect-prepare.c @@ -48,7 +48,7 @@ static void close_cb(uv_handle_t* handle) { static void connect_cb(uv_connect_t* connect_req, int status) { - ASSERT(status == UV_ENOENT); + ASSERT_EQ(status, UV_ENOENT); connect_cb_called++; uv_close((uv_handle_t*)&prepare_handle, close_cb); uv_close((uv_handle_t*)&pipe_handle, close_cb); @@ -56,7 +56,7 @@ static void connect_cb(uv_connect_t* connect_req, int status) { static void prepare_cb(uv_prepare_t* handle) { - ASSERT(handle == &prepare_handle); + ASSERT_PTR_EQ(handle, &prepare_handle); uv_pipe_connect(&conn_req, &pipe_handle, BAD_PIPENAME, connect_cb); } @@ -65,18 +65,18 @@ TEST_IMPL(pipe_connect_on_prepare) { int r; r = uv_pipe_init(uv_default_loop(), &pipe_handle, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_prepare_init(uv_default_loop(), &prepare_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_prepare_start(&prepare_handle, prepare_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 2); - ASSERT(connect_cb_called == 1); + ASSERT_EQ(2, close_cb_called); + ASSERT_EQ(1, connect_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-pipe-getsockname.c b/deps/libuv/test/test-pipe-getsockname.c index d749933d..eb09d88f 100644 --- a/deps/libuv/test/test-pipe-getsockname.c +++ b/deps/libuv/test/test-pipe-getsockname.c @@ -40,8 +40,8 @@ static int pipe_client_connect_cb_called = 0; static void pipe_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &pipe_client || - handle == (uv_handle_t*) &pipe_server); + ASSERT_NE(handle == (uv_handle_t*) &pipe_client || + handle == (uv_handle_t*) &pipe_server, 0); pipe_close_cb_called++; } @@ -51,12 +51,12 @@ static void pipe_client_connect_cb(uv_connect_t* req, int status) { size_t len; int r; - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); len = sizeof buf; r = uv_pipe_getpeername(&pipe_client, buf, &len); - ASSERT(r == 0); + ASSERT_OK(r); if (*buf == '\0') { /* Linux abstract socket. */ const char expected[] = "\0" TEST_PIPENAME; @@ -82,7 +82,7 @@ static void pipe_server_connection_cb(uv_stream_t* handle, int status) { /* This function *may* be called, depending on whether accept or the * connection callback is called first. */ - ASSERT(status == 0); + ASSERT_OK(status); } @@ -99,44 +99,44 @@ TEST_IMPL(pipe_getsockname) { ASSERT_NOT_NULL(loop); r = uv_pipe_init(loop, &pipe_server, 0); - ASSERT(r == 0); + ASSERT_OK(r); len = sizeof buf; r = uv_pipe_getsockname(&pipe_server, buf, &len); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); len = sizeof buf; r = uv_pipe_getpeername(&pipe_server, buf, &len); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_pipe_bind(&pipe_server, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); len = sizeof buf; r = uv_pipe_getsockname(&pipe_server, buf, &len); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(buf[len - 1] != 0); - ASSERT(buf[len] == '\0'); - ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0); + ASSERT_NE(0, buf[len - 1]); + ASSERT_EQ(buf[len], '\0'); + ASSERT_OK(memcmp(buf, TEST_PIPENAME, len)); len = sizeof buf; r = uv_pipe_getpeername(&pipe_server, buf, &len); - ASSERT(r == UV_ENOTCONN); + ASSERT_EQ(r, UV_ENOTCONN); r = uv_listen((uv_stream_t*) &pipe_server, 0, pipe_server_connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(loop, &pipe_client, 0); - ASSERT(r == 0); + ASSERT_OK(r); len = sizeof buf; r = uv_pipe_getsockname(&pipe_client, buf, &len); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); len = sizeof buf; r = uv_pipe_getpeername(&pipe_client, buf, &len); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); uv_pipe_connect(&connect_req, &pipe_client, TEST_PIPENAME, pipe_client_connect_cb); @@ -146,15 +146,15 @@ TEST_IMPL(pipe_getsockname) { len = sizeof buf; r = uv_pipe_getpeername(&pipe_client, buf, &len); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(buf[len - 1] != 0); - ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0); + ASSERT_NE(0, buf[len - 1]); + ASSERT_OK(memcmp(buf, TEST_PIPENAME, len)); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(pipe_client_connect_cb_called == 1); - ASSERT(pipe_close_cb_called == 2); + ASSERT_OK(r); + ASSERT_EQ(1, pipe_client_connect_cb_called); + ASSERT_EQ(2, pipe_close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -218,50 +218,50 @@ TEST_IMPL(pipe_getsockname_blocking) { int r; r = CreatePipe(&readh, &writeh, NULL, 65536); - ASSERT(r != 0); + ASSERT(r); r = uv_pipe_init(uv_default_loop(), &pipe_client, 0); - ASSERT(r == 0); + ASSERT_OK(r); readfd = _open_osfhandle((intptr_t)readh, _O_RDONLY); - ASSERT(r != -1); + ASSERT_NE(r, -1); r = uv_pipe_open(&pipe_client, readfd); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &pipe_client, (uv_alloc_cb) abort, (uv_read_cb) abort); - ASSERT(r == 0); + ASSERT_OK(r); Sleep(100); r = uv_read_stop((uv_stream_t*)&pipe_client); - ASSERT(r == 0); + ASSERT_OK(r); len1 = sizeof buf1; r = uv_pipe_getsockname(&pipe_client, buf1, &len1); - ASSERT(r == 0); - ASSERT(len1 == 0); /* It's an annonymous pipe. */ + ASSERT_OK(r); + ASSERT_OK(len1); /* It's an annonymous pipe. */ r = uv_read_start((uv_stream_t*)&pipe_client, (uv_alloc_cb) abort, (uv_read_cb) abort); - ASSERT(r == 0); + ASSERT_OK(r); Sleep(100); len2 = sizeof buf2; r = uv_pipe_getsockname(&pipe_client, buf2, &len2); - ASSERT(r == 0); - ASSERT(len2 == 0); /* It's an annonymous pipe. */ + ASSERT_OK(r); + ASSERT_OK(len2); /* It's an annonymous pipe. */ r = uv_read_stop((uv_stream_t*)&pipe_client); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(len1 == len2); - ASSERT(memcmp(buf1, buf2, len1) == 0); + ASSERT_EQ(len1, len2); + ASSERT_OK(memcmp(buf1, buf2, len1)); pipe_close_cb_called = 0; uv_close((uv_handle_t*)&pipe_client, pipe_close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(pipe_close_cb_called == 1); + ASSERT_EQ(1, pipe_close_cb_called); CloseHandle(writeh); #endif diff --git a/deps/libuv/test/test-pipe-pending-instances.c b/deps/libuv/test/test-pipe-pending-instances.c index 9b1bfbc9..570ecd69 100644 --- a/deps/libuv/test/test-pipe-pending-instances.c +++ b/deps/libuv/test/test-pipe-pending-instances.c @@ -37,22 +37,22 @@ TEST_IMPL(pipe_pending_instances) { loop = uv_default_loop(); r = uv_pipe_init(loop, &pipe_handle, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_pending_instances(&pipe_handle, 8); r = uv_pipe_bind(&pipe_handle, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_pending_instances(&pipe_handle, 16); r = uv_listen((uv_stream_t*)&pipe_handle, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&pipe_handle, NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-pipe-sendmsg.c b/deps/libuv/test/test-pipe-sendmsg.c index 7758b65b..3958b053 100644 --- a/deps/libuv/test/test-pipe-sendmsg.c +++ b/deps/libuv/test/test-pipe-sendmsg.c @@ -45,12 +45,12 @@ static void set_nonblocking(uv_os_sock_t sock) { #ifdef _WIN32 unsigned long on = 1; r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); + ASSERT_OK(r); #else int flags = fcntl(sock, F_GETFL, 0); - ASSERT(flags >= 0); + ASSERT_GE(flags, 0); r = fcntl(sock, F_SETFL, flags | O_NONBLOCK); - ASSERT(r >= 0); + ASSERT_GE(r, 0); #endif } @@ -79,22 +79,22 @@ static void read_cb(uv_stream_t* handle, unsigned int i; p = (uv_pipe_t*) handle; - ASSERT(nread >= 0); + ASSERT_GE(nread, 0); while (uv_pipe_pending_count(p) != 0) { pending = uv_pipe_pending_type(p); - ASSERT(pending == UV_NAMED_PIPE); + ASSERT_EQ(pending, UV_NAMED_PIPE); - ASSERT(incoming_count < ARRAY_SIZE(incoming)); + ASSERT_LT(incoming_count, ARRAY_SIZE(incoming)); inc = &incoming[incoming_count++]; - ASSERT(0 == uv_pipe_init(p->loop, inc, 0)); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) inc)); + ASSERT_OK(uv_pipe_init(p->loop, inc, 0)); + ASSERT_OK(uv_accept(handle, (uv_stream_t*) inc)); } if (incoming_count != ARRAY_SIZE(incoming)) return; - ASSERT(0 == uv_read_stop((uv_stream_t*) p)); + ASSERT_OK(uv_read_stop((uv_stream_t*) p)); uv_close((uv_handle_t*) p, close_cb); for (i = 0; i < ARRAY_SIZE(incoming); i++) uv_close((uv_handle_t*) &incoming[i], close_cb); @@ -115,12 +115,12 @@ TEST_IMPL(pipe_sendmsg) { unsigned int i; uv_buf_t buf; - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); + ASSERT_OK(socketpair(AF_UNIX, SOCK_STREAM, 0, fds)); for (i = 0; i < ARRAY_SIZE(send_fds); i += 2) - ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, send_fds + i)); - ASSERT(i == ARRAY_SIZE(send_fds)); - ASSERT(0 == uv_pipe_init(uv_default_loop(), &p, 1)); - ASSERT(0 == uv_pipe_open(&p, fds[1])); + ASSERT_OK(socketpair(AF_UNIX, SOCK_STREAM, 0, send_fds + i)); + ASSERT_EQ(i, ARRAY_SIZE(send_fds)); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &p, 1)); + ASSERT_OK(uv_pipe_open(&p, fds[1])); buf = uv_buf_init("X", 1); memset(&msg, 0, sizeof(msg)); @@ -130,7 +130,7 @@ TEST_IMPL(pipe_sendmsg) { msg.msg_control = (void*) scratch; msg.msg_controllen = CMSG_LEN(sizeof(send_fds)); - ASSERT(sizeof(scratch) >= msg.msg_controllen); + ASSERT_GE(sizeof(scratch), msg.msg_controllen); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_SOCKET; @@ -146,16 +146,16 @@ TEST_IMPL(pipe_sendmsg) { } set_nonblocking(fds[1]); - ASSERT(0 == uv_read_start((uv_stream_t*) &p, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) &p, alloc_cb, read_cb)); do r = sendmsg(fds[0], &msg, 0); while (r == -1 && errno == EINTR); - ASSERT(r == 1); + ASSERT_EQ(1, r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(ARRAY_SIZE(incoming) == incoming_count); - ASSERT(ARRAY_SIZE(incoming) + 1 == close_called); + ASSERT_EQ(ARRAY_SIZE(incoming), incoming_count); + ASSERT_EQ(ARRAY_SIZE(incoming) + 1, close_called); close(fds[0]); MAKE_VALGRIND_HAPPY(uv_default_loop()); diff --git a/deps/libuv/test/test-pipe-server-close.c b/deps/libuv/test/test-pipe-server-close.c index dc206619..ad7d792a 100644 --- a/deps/libuv/test/test-pipe-server-close.c +++ b/deps/libuv/test/test-pipe-server-close.c @@ -35,15 +35,15 @@ static int pipe_client_connect_cb_called = 0; static void pipe_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &pipe_client || - handle == (uv_handle_t*) &pipe_server); + ASSERT_NE(handle == (uv_handle_t*) &pipe_client || + handle == (uv_handle_t*) &pipe_server, 0); pipe_close_cb_called++; } static void pipe_client_connect_cb(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); pipe_client_connect_cb_called++; @@ -56,7 +56,7 @@ static void pipe_server_connection_cb(uv_stream_t* handle, int status) { /* This function *may* be called, depending on whether accept or the * connection callback is called first. */ - ASSERT(status == 0); + ASSERT_OK(status); } @@ -71,23 +71,23 @@ TEST_IMPL(pipe_server_close) { ASSERT_NOT_NULL(loop); r = uv_pipe_init(loop, &pipe_server, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&pipe_server, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*) &pipe_server, 0, pipe_server_connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(loop, &pipe_client, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_connect(&connect_req, &pipe_client, TEST_PIPENAME, pipe_client_connect_cb); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(pipe_client_connect_cb_called == 1); - ASSERT(pipe_close_cb_called == 2); + ASSERT_OK(r); + ASSERT_EQ(1, pipe_client_connect_cb_called); + ASSERT_EQ(2, pipe_close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-pipe-set-fchmod.c b/deps/libuv/test/test-pipe-set-fchmod.c index 402970e3..9563e4fd 100644 --- a/deps/libuv/test/test-pipe-set-fchmod.c +++ b/deps/libuv/test/test-pipe-set-fchmod.c @@ -35,10 +35,10 @@ TEST_IMPL(pipe_set_chmod) { loop = uv_default_loop(); r = uv_pipe_init(loop, &pipe_handle, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_bind(&pipe_handle, TEST_PIPENAME); - ASSERT(r == 0); + ASSERT_OK(r); /* No easy way to test if this works, we will only make sure that the call is * successful. */ @@ -47,17 +47,17 @@ TEST_IMPL(pipe_set_chmod) { MAKE_VALGRIND_HAPPY(loop); RETURN_SKIP("Insufficient privileges to alter pipe fmode"); } - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 memset(&stat_buf, 0, sizeof(stat_buf)); - ASSERT_EQ(0, stat(TEST_PIPENAME, &stat_buf)); + ASSERT_OK(stat(TEST_PIPENAME, &stat_buf)); ASSERT(stat_buf.st_mode & S_IRUSR); ASSERT(stat_buf.st_mode & S_IRGRP); ASSERT(stat_buf.st_mode & S_IROTH); #endif r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 stat(TEST_PIPENAME, &stat_buf); ASSERT(stat_buf.st_mode & S_IWUSR); @@ -66,7 +66,7 @@ TEST_IMPL(pipe_set_chmod) { #endif r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE | UV_READABLE); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 stat(TEST_PIPENAME, &stat_buf); ASSERT(stat_buf.st_mode & S_IRUSR); @@ -78,14 +78,14 @@ TEST_IMPL(pipe_set_chmod) { #endif r = uv_pipe_chmod(NULL, UV_WRITABLE | UV_READABLE); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_pipe_chmod(&pipe_handle, 12345678); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&pipe_handle, NULL); r = uv_pipe_chmod(&pipe_handle, UV_WRITABLE | UV_READABLE); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-pipe-set-non-blocking.c b/deps/libuv/test/test-pipe-set-non-blocking.c index 1b90bca3..bf1c2841 100644 --- a/deps/libuv/test/test-pipe-set-non-blocking.c +++ b/deps/libuv/test/test-pipe-set-non-blocking.c @@ -46,13 +46,13 @@ static void thread_main(void* arg) { uv_fs_req_cleanup(&req); } while (n > 0 || (n == -1 && uv_errno == UV_EINTR)); - ASSERT(n == 0); + ASSERT_OK(n); } #ifdef _WIN32 static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); req->handle = NULL; /* signal completion of write_cb */ } #endif @@ -77,15 +77,15 @@ TEST_IMPL(pipe_set_non_blocking) { uv_write_t write_req; #endif - ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); - ASSERT(0 == uv_pipe(fd, 0, 0)); - ASSERT(0 == uv_pipe_open(&pipe_handle, fd[1])); - ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1)); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); + ASSERT_OK(uv_pipe(fd, 0, 0)); + ASSERT_OK(uv_pipe_open(&pipe_handle, fd[1])); + ASSERT_OK(uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1)); fd[1] = -1; /* fd[1] is owned by pipe_handle now. */ ctx.fd = fd[0]; - ASSERT(0 == uv_barrier_init(&ctx.barrier, 2)); - ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); + ASSERT_OK(uv_barrier_init(&ctx.barrier, 2)); + ASSERT_OK(uv_thread_create(&thread, thread_main, &ctx)); uv_barrier_wait(&ctx.barrier); buf.len = sizeof(data); @@ -99,25 +99,29 @@ TEST_IMPL(pipe_set_non_blocking) { */ n = uv_try_write((uv_stream_t*) &pipe_handle, &buf, 1); #ifdef _WIN32 - ASSERT(n == UV_EAGAIN); /* E_NOTIMPL */ - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &pipe_handle, &buf, 1, write_cb)); + ASSERT_EQ(n, UV_EAGAIN); /* E_NOTIMPL */ + ASSERT_OK(uv_write(&write_req, + (uv_stream_t*) &pipe_handle, + &buf, + 1, + write_cb)); ASSERT_NOT_NULL(write_req.handle); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); ASSERT_NULL(write_req.handle); /* check for signaled completion of write_cb */ n = buf.len; #endif - ASSERT(n == sizeof(data)); + ASSERT_EQ(n, sizeof(data)); nwritten += n; } uv_close((uv_handle_t*) &pipe_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); #ifdef _WIN32 - ASSERT(0 == _close(fd[0])); /* fd[1] is closed by uv_close(). */ + ASSERT_OK(_close(fd[0])); /* fd[1] is closed by uv_close(). */ #else - ASSERT(0 == close(fd[0])); /* fd[1] is closed by uv_close(). */ + ASSERT_OK(close(fd[0])); /* fd[1] is closed by uv_close(). */ #endif fd[0] = -1; uv_barrier_destroy(&ctx.barrier); diff --git a/deps/libuv/test/test-platform-output.c b/deps/libuv/test/test-platform-output.c index 5839f52d..f18e097f 100644 --- a/deps/libuv/test/test-platform-output.c +++ b/deps/libuv/test/test-platform-output.c @@ -44,37 +44,37 @@ TEST_IMPL(platform_output) { int err; err = uv_get_process_title(buffer, sizeof(buffer)); - ASSERT(err == 0); + ASSERT_OK(err); printf("uv_get_process_title: %s\n", buffer); size = sizeof(buffer); err = uv_cwd(buffer, &size); - ASSERT(err == 0); + ASSERT_OK(err); printf("uv_cwd: %s\n", buffer); err = uv_resident_set_memory(&rss); #if defined(__MSYS__) - ASSERT(err == UV_ENOSYS); + ASSERT_EQ(err, UV_ENOSYS); #else - ASSERT(err == 0); + ASSERT_OK(err); printf("uv_resident_set_memory: %llu\n", (unsigned long long) rss); #endif err = uv_uptime(&uptime); #if defined(__PASE__) - ASSERT(err == UV_ENOSYS); + ASSERT_EQ(err, UV_ENOSYS); #else - ASSERT(err == 0); - ASSERT(uptime > 0); + ASSERT_OK(err); + ASSERT_GT(uptime, 0); printf("uv_uptime: %f\n", uptime); #endif err = uv_getrusage(&rusage); - ASSERT(err == 0); - ASSERT(rusage.ru_utime.tv_sec >= 0); - ASSERT(rusage.ru_utime.tv_usec >= 0); - ASSERT(rusage.ru_stime.tv_sec >= 0); - ASSERT(rusage.ru_stime.tv_usec >= 0); + ASSERT_OK(err); + ASSERT_GE(rusage.ru_utime.tv_sec, 0); + ASSERT_GE(rusage.ru_utime.tv_usec, 0); + ASSERT_GE(rusage.ru_stime.tv_sec, 0); + ASSERT_GE(rusage.ru_stime.tv_usec, 0); printf("uv_getrusage:\n"); printf(" user: %llu sec %llu microsec\n", (unsigned long long) rusage.ru_utime.tv_sec, @@ -92,9 +92,9 @@ TEST_IMPL(platform_output) { err = uv_cpu_info(&cpus, &count); #if defined(__CYGWIN__) || defined(__MSYS__) - ASSERT(err == UV_ENOSYS); + ASSERT_EQ(err, UV_ENOSYS); #else - ASSERT(err == 0); + ASSERT_OK(err); printf("uv_cpu_info:\n"); for (i = 0; i < count; i++) { @@ -113,7 +113,7 @@ TEST_IMPL(platform_output) { uv_free_cpu_info(cpus, count); err = uv_interface_addresses(&interfaces, &count); - ASSERT(err == 0); + ASSERT_OK(err); printf("uv_interface_addresses:\n"); for (i = 0; i < count; i++) { @@ -149,7 +149,7 @@ TEST_IMPL(platform_output) { uv_free_interface_addresses(interfaces, count); err = uv_os_get_passwd(&pwd); - ASSERT_EQ(err, 0); + ASSERT_OK(err); err = uv_os_get_group(&grp, pwd.gid); #if defined(_WIN32) @@ -159,7 +159,7 @@ TEST_IMPL(platform_output) { (void) member; grp.groupname = "ENOTSUP"; #else - ASSERT_EQ(err, 0); + ASSERT_OK(err); ASSERT_EQ(pwd.gid, grp.gid); #endif @@ -183,14 +183,14 @@ TEST_IMPL(platform_output) { #endif pid = uv_os_getpid(); - ASSERT(pid > 0); + ASSERT_GT(pid, 0); printf("uv_os_getpid: %d\n", (int) pid); ppid = uv_os_getppid(); - ASSERT(ppid > 0); + ASSERT_GT(ppid, 0); printf("uv_os_getppid: %d\n", (int) ppid); err = uv_os_uname(&uname); - ASSERT(err == 0); + ASSERT_OK(err); printf("uv_os_uname:\n"); printf(" sysname: %s\n", uname.sysname); printf(" release: %s\n", uname.release); diff --git a/deps/libuv/test/test-poll-close-doesnt-corrupt-stack.c b/deps/libuv/test/test-poll-close-doesnt-corrupt-stack.c index a19f4276..0acb452a 100644 --- a/deps/libuv/test/test-poll-close-doesnt-corrupt-stack.c +++ b/deps/libuv/test/test-poll-close-doesnt-corrupt-stack.c @@ -59,12 +59,12 @@ static void NO_INLINE close_socket_and_verify_stack(void) { data[i] = MARKER; r = closesocket(sock); - ASSERT(r == 0); + ASSERT_OK(r); uv_sleep(VERIFY_AFTER); for (i = 0; i < ARRAY_SIZE(data); i++) - ASSERT(data[i] == MARKER); + ASSERT_EQ(data[i], MARKER); } #endif @@ -79,34 +79,34 @@ TEST_IMPL(poll_close_doesnt_corrupt_stack) { struct sockaddr_in addr; r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); sock = socket(AF_INET, SOCK_STREAM, 0); - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); on = 1; r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr); - ASSERT(r == 0); + ASSERT_OK(r); r = connect(sock, (const struct sockaddr*) &addr, sizeof addr); - ASSERT(r != 0); - ASSERT(WSAGetLastError() == WSAEWOULDBLOCK); + ASSERT(r); + ASSERT_EQ(WSAGetLastError(), WSAEWOULDBLOCK); r = uv_poll_init_socket(uv_default_loop(), &handle, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_poll_start(&handle, UV_READABLE | UV_WRITABLE, poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &handle, close_cb); close_socket_and_verify_stack(); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-poll-close.c b/deps/libuv/test/test-poll-close.c index b4ad4c78..5843bf45 100644 --- a/deps/libuv/test/test-poll-close.c +++ b/deps/libuv/test/test-poll-close.c @@ -50,7 +50,7 @@ TEST_IMPL(poll_close) { { struct WSAData wsa_data; int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); } #endif @@ -66,7 +66,7 @@ TEST_IMPL(poll_close) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == NUM_SOCKETS); + ASSERT_EQ(close_cb_called, NUM_SOCKETS); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-poll-closesocket.c b/deps/libuv/test/test-poll-closesocket.c index a81d0b09..01f8f741 100644 --- a/deps/libuv/test/test-poll-closesocket.c +++ b/deps/libuv/test/test-poll-closesocket.c @@ -39,11 +39,11 @@ static void close_cb(uv_handle_t* h) { static void poll_cb(uv_poll_t* h, int status, int events) { int r; - ASSERT(status == 0); - ASSERT(h == &handle); + ASSERT_OK(status); + ASSERT_PTR_EQ(h, &handle); r = uv_poll_start(&handle, UV_READABLE, poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); closesocket(sock); uv_close((uv_handle_t*) &handle, close_cb); @@ -62,29 +62,29 @@ TEST_IMPL(poll_closesocket) { struct sockaddr_in addr; r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); sock = socket(AF_INET, SOCK_STREAM, 0); - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); on = 1; r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr); - ASSERT(r == 0); + ASSERT_OK(r); r = connect(sock, (const struct sockaddr*) &addr, sizeof addr); - ASSERT(r != 0); - ASSERT(WSAGetLastError() == WSAEWOULDBLOCK); + ASSERT(r); + ASSERT_EQ(WSAGetLastError(), WSAEWOULDBLOCK); r = uv_poll_init_socket(uv_default_loop(), &handle, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_poll_start(&handle, UV_WRITABLE, poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-poll-multiple-handles.c b/deps/libuv/test/test-poll-multiple-handles.c index 1aad1ef2..d9c4924d 100644 --- a/deps/libuv/test/test-poll-multiple-handles.c +++ b/deps/libuv/test/test-poll-multiple-handles.c @@ -40,7 +40,7 @@ static void close_cb(uv_handle_t* handle) { static void poll_cb(uv_poll_t* handle, int status, int events) { /* Not a bound socket, linux immediately reports UV_READABLE, other OS do not */ - ASSERT(events == UV_READABLE); + ASSERT_EQ(events, UV_READABLE); } TEST_IMPL(poll_multiple_handles) { @@ -51,20 +51,24 @@ TEST_IMPL(poll_multiple_handles) { { struct WSAData wsa_data; int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); } #endif sock = socket(AF_INET, SOCK_STREAM, 0); #ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); #else - ASSERT(sock != -1); + ASSERT_NE(sock, -1); #endif - ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &first_poll_handle, sock)); - ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &second_poll_handle, sock)); + ASSERT_OK(uv_poll_init_socket(uv_default_loop(), + &first_poll_handle, + sock)); + ASSERT_OK(uv_poll_init_socket(uv_default_loop(), + &second_poll_handle, + sock)); - ASSERT(0 == uv_poll_start(&first_poll_handle, UV_READABLE, poll_cb)); + ASSERT_OK(uv_poll_start(&first_poll_handle, UV_READABLE, poll_cb)); /* We may not start polling while another polling handle is active * on that fd. @@ -73,26 +77,27 @@ TEST_IMPL(poll_multiple_handles) { /* We do not track handles in an O(1) lookupable way on Windows, * so not checking that here. */ - ASSERT(uv_poll_start(&second_poll_handle, UV_READABLE, poll_cb) == UV_EEXIST); + ASSERT_EQ(uv_poll_start(&second_poll_handle, UV_READABLE, poll_cb), + UV_EEXIST); #endif /* After stopping the other polling handle, we now should be able to poll */ - ASSERT(0 == uv_poll_stop(&first_poll_handle)); - ASSERT(0 == uv_poll_start(&second_poll_handle, UV_READABLE, poll_cb)); + ASSERT_OK(uv_poll_stop(&first_poll_handle)); + ASSERT_OK(uv_poll_start(&second_poll_handle, UV_READABLE, poll_cb)); /* Closing an already stopped polling handle is safe in any case */ uv_close((uv_handle_t*) &first_poll_handle, close_cb); uv_unref((uv_handle_t*) &second_poll_handle); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(close_cb_called == 1); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, close_cb_called); uv_ref((uv_handle_t*) &second_poll_handle); ASSERT(uv_is_active((uv_handle_t*) &second_poll_handle)); uv_close((uv_handle_t*) &second_poll_handle, close_cb); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(close_cb_called == 2); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-poll-oob.c b/deps/libuv/test/test-poll-oob.c index b1ff41f5..b40c93c3 100644 --- a/deps/libuv/test/test-poll-oob.c +++ b/deps/libuv/test/test-poll-oob.c @@ -70,7 +70,7 @@ static void poll_cb(uv_poll_t* handle, int status, int events) { int n; int fd; - ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd)); + ASSERT_OK(uv_fileno((uv_handle_t*)handle, &fd)); memset(buffer, 0, 5); if (events & UV_PRIORITIZED) { @@ -79,10 +79,10 @@ static void poll_cb(uv_poll_t* handle, int status, int events) { while (n == -1 && errno == EINTR); ASSERT(n >= 0 || errno != EINVAL); cli_pr_check = 1; - ASSERT(0 == uv_poll_stop(&poll_req[0])); - ASSERT(0 == uv_poll_start(&poll_req[0], - UV_READABLE | UV_WRITABLE, - poll_cb)); + ASSERT_OK(uv_poll_stop(&poll_req[0])); + ASSERT_OK(uv_poll_start(&poll_req[0], + UV_READABLE | UV_WRITABLE, + poll_cb)); } if (events & UV_READABLE) { if (fd == client_fd) { @@ -91,21 +91,21 @@ static void poll_cb(uv_poll_t* handle, int status, int events) { while (n == -1 && errno == EINTR); ASSERT(n >= 0 || errno != EINVAL); if (cli_rd_check == 1) { - ASSERT(strncmp(buffer, "world", n) == 0); - ASSERT(5 == n); + ASSERT_OK(strncmp(buffer, "world", n)); + ASSERT_EQ(5, n); cli_rd_check = 2; } if (cli_rd_check == 0) { - ASSERT(n == 4); - ASSERT(strncmp(buffer, "hello", n) == 0); + ASSERT_EQ(4, n); + ASSERT_OK(strncmp(buffer, "hello", n)); cli_rd_check = 1; do { do n = recv(server_fd, &buffer, 5, 0); while (n == -1 && errno == EINTR); if (n > 0) { - ASSERT(n == 5); - ASSERT(strncmp(buffer, "world", n) == 0); + ASSERT_EQ(5, n); + ASSERT_OK(strncmp(buffer, "world", n)); cli_rd_check = 2; } } while (n > 0); @@ -118,8 +118,8 @@ static void poll_cb(uv_poll_t* handle, int status, int events) { n = recv(server_fd, &buffer, 3, 0); while (n == -1 && errno == EINTR); ASSERT(n >= 0 || errno != EINVAL); - ASSERT(3 == n); - ASSERT(strncmp(buffer, "foo", n) == 0); + ASSERT_EQ(3, n); + ASSERT_OK(strncmp(buffer, "foo", n)); srv_rd_check = 1; uv_poll_stop(&poll_req[1]); } @@ -128,35 +128,39 @@ static void poll_cb(uv_poll_t* handle, int status, int events) { do { n = send(client_fd, "foo", 3, 0); } while (n < 0 && errno == EINTR); - ASSERT(3 == n); + ASSERT_EQ(3, n); } } static void connection_cb(uv_stream_t* handle, int status) { int r; - ASSERT(0 == status); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_fileno((uv_handle_t*) &peer_handle, &server_fd)); - ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &poll_req[0], client_fd)); - ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &poll_req[1], server_fd)); - ASSERT(0 == uv_poll_start(&poll_req[0], - UV_PRIORITIZED | UV_READABLE | UV_WRITABLE, - poll_cb)); - ASSERT(0 == uv_poll_start(&poll_req[1], - UV_READABLE, - poll_cb)); + ASSERT_OK(status); + ASSERT_OK(uv_accept(handle, (uv_stream_t*) &peer_handle)); + ASSERT_OK(uv_fileno((uv_handle_t*) &peer_handle, &server_fd)); + ASSERT_OK(uv_poll_init_socket(uv_default_loop(), + &poll_req[0], + client_fd)); + ASSERT_OK(uv_poll_init_socket(uv_default_loop(), + &poll_req[1], + server_fd)); + ASSERT_OK(uv_poll_start(&poll_req[0], + UV_PRIORITIZED | UV_READABLE | UV_WRITABLE, + poll_cb)); + ASSERT_OK(uv_poll_start(&poll_req[1], + UV_READABLE, + poll_cb)); do { r = send(server_fd, "hello", 5, MSG_OOB); } while (r < 0 && errno == EINTR); - ASSERT(5 == r); + ASSERT_EQ(5, r); do { r = send(server_fd, "world", 5, 0); } while (r < 0 && errno == EINTR); - ASSERT(5 == r); + ASSERT_EQ(5, r); - ASSERT(0 == uv_idle_start(&idle, idle_cb)); + ASSERT_OK(uv_idle_start(&idle, idle_cb)); } @@ -165,39 +169,39 @@ TEST_IMPL(poll_oob) { int r = 0; uv_loop_t* loop; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_init(loop, &peer_handle)); - ASSERT(0 == uv_idle_init(loop, &idle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); + ASSERT_OK(uv_tcp_init(loop, &server_handle)); + ASSERT_OK(uv_tcp_init(loop, &client_handle)); + ASSERT_OK(uv_tcp_init(loop, &peer_handle)); + ASSERT_OK(uv_idle_init(loop, &idle)); + ASSERT_OK(uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); /* Ensure two separate packets */ - ASSERT(0 == uv_tcp_nodelay(&client_handle, 1)); + ASSERT_OK(uv_tcp_nodelay(&client_handle, 1)); client_fd = socket(PF_INET, SOCK_STREAM, 0); - ASSERT(client_fd >= 0); + ASSERT_GE(client_fd, 0); do { errno = 0; r = connect(client_fd, (const struct sockaddr*)&addr, sizeof(addr)); } while (r == -1 && errno == EINTR); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(ticks == kMaxTicks); + ASSERT_EQ(ticks, kMaxTicks); /* Did client receive the POLLPRI message */ - ASSERT(cli_pr_check == 1); + ASSERT_EQ(1, cli_pr_check); /* Did client receive the POLLIN message */ - ASSERT(cli_rd_check == 2); + ASSERT_EQ(2, cli_rd_check); /* Could we write with POLLOUT and did the server receive our POLLOUT message * through POLLIN. */ - ASSERT(srv_rd_check == 1); + ASSERT_EQ(1, srv_rd_check); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-poll.c b/deps/libuv/test/test-poll.c index a0f28324..f5a30e9a 100644 --- a/deps/libuv/test/test-poll.c +++ b/deps/libuv/test/test-poll.c @@ -106,9 +106,9 @@ static uv_os_sock_t create_bound_socket (struct sockaddr_in bind_addr) { sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); #ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); #else - ASSERT(sock >= 0); + ASSERT_GE(sock, 0); #endif #ifndef _WIN32 @@ -116,12 +116,12 @@ static uv_os_sock_t create_bound_socket (struct sockaddr_in bind_addr) { /* Allow reuse of the port. */ int yes = 1; r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); - ASSERT(r == 0); + ASSERT_OK(r); } #endif r = bind(sock, (const struct sockaddr*) &bind_addr, sizeof bind_addr); - ASSERT(r == 0); + ASSERT_OK(r); return sock; } @@ -163,12 +163,12 @@ static connection_context_t* create_connection_context( r = uv_poll_init_socket(uv_default_loop(), &context->poll_handle, sock); context->open_handles++; context->poll_handle.data = context; - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(uv_default_loop(), &context->timer_handle); context->open_handles++; context->timer_handle.data = context; - ASSERT(r == 0); + ASSERT_OK(r); return context; } @@ -179,15 +179,15 @@ static void connection_close_cb(uv_handle_t* handle) { if (--context->open_handles == 0) { if (test_mode == DUPLEX || context->is_server_connection) { - ASSERT(context->read == TRANSFER_BYTES); + ASSERT_EQ(context->read, TRANSFER_BYTES); } else { - ASSERT(context->read == 0); + ASSERT_OK(context->read); } if (test_mode == DUPLEX || !context->is_server_connection) { - ASSERT(context->sent == TRANSFER_BYTES); + ASSERT_EQ(context->sent, TRANSFER_BYTES); } else { - ASSERT(context->sent == 0); + ASSERT_OK(context->sent); } closed_connections++; @@ -208,7 +208,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { unsigned int new_events; int r; - ASSERT(status == 0); + ASSERT_OK(status); ASSERT(events & context->events); ASSERT(!(events & ~context->events)); @@ -226,7 +226,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { do r = recv(context->sock, buffer, sizeof buffer, 0); while (r == -1 && errno == EINTR); - ASSERT(r >= 0); + ASSERT_GE(r, 0); if (r > 0) { context->read += r; @@ -306,7 +306,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { static char buffer[103]; int send_bytes = MIN(TRANSFER_BYTES - context->sent, sizeof buffer); - ASSERT(send_bytes > 0); + ASSERT_GT(send_bytes, 0); do r = send(context->sock, buffer, send_bytes, 0); @@ -318,7 +318,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { break; } - ASSERT(r > 0); + ASSERT_GT(r, 0); context->sent += r; valid_writable_wakeups++; break; @@ -330,7 +330,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { static char buffer[1234]; int send_bytes = MIN(TRANSFER_BYTES - context->sent, sizeof buffer); - ASSERT(send_bytes > 0); + ASSERT_GT(send_bytes, 0); do r = send(context->sock, buffer, send_bytes, 0); @@ -342,18 +342,18 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { break; } - ASSERT(r > 0); + ASSERT_GT(r, 0); valid_writable_wakeups++; context->sent += r; while (context->sent < TRANSFER_BYTES) { send_bytes = MIN(TRANSFER_BYTES - context->sent, sizeof buffer); - ASSERT(send_bytes > 0); + ASSERT_GT(send_bytes, 0); do r = send(context->sock, buffer, send_bytes, 0); while (r == -1 && errno == EINTR); - ASSERT(r != 0); + ASSERT(r); if (r < 0) { ASSERT(got_eagain()); @@ -403,7 +403,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { #else r = shutdown(context->sock, SHUT_WR); #endif - ASSERT(r == 0); + ASSERT_OK(r); context->sent_fin = 1; new_events &= ~UV_WRITABLE; } @@ -432,9 +432,9 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { /* Assert that uv_is_active works correctly for poll handles. */ if (context->events != 0) { - ASSERT(1 == uv_is_active((uv_handle_t*) handle)); + ASSERT_EQ(1, uv_is_active((uv_handle_t*) handle)); } else { - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); + ASSERT_OK(uv_is_active((uv_handle_t*) handle)); } } @@ -444,7 +444,7 @@ static void delay_timer_cb(uv_timer_t* timer) { int r; /* Timer should auto stop. */ - ASSERT(0 == uv_is_active((uv_handle_t*) timer)); + ASSERT_OK(uv_is_active((uv_handle_t*) timer)); /* Add the requested events to the poll mask. */ ASSERT(context->delayed_events != 0); @@ -454,7 +454,7 @@ static void delay_timer_cb(uv_timer_t* timer) { r = uv_poll_start(&context->poll_handle, context->events, connection_poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -471,7 +471,7 @@ static server_context_t* create_server_context( r = uv_poll_init_socket(uv_default_loop(), &context->poll_handle, sock); context->poll_handle.data = context; - ASSERT(r == 0); + ASSERT_OK(r); return context; } @@ -500,9 +500,9 @@ static void server_poll_cb(uv_poll_t* handle, int status, int events) { addr_len = sizeof addr; sock = accept(server_context->sock, (struct sockaddr*) &addr, &addr_len); #ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); #else - ASSERT(sock >= 0); + ASSERT_GE(sock, 0); #endif connection_context = create_connection_context(sock, 1); @@ -510,7 +510,7 @@ static void server_poll_cb(uv_poll_t* handle, int status, int events) { r = uv_poll_start(&connection_context->poll_handle, UV_READABLE | UV_WRITABLE | UV_DISCONNECT, connection_poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); if (++server_context->connections == NUM_CLIENTS) { close_socket(server_context->sock); @@ -525,15 +525,15 @@ static void start_server(void) { uv_os_sock_t sock; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); sock = create_bound_socket(addr); context = create_server_context(sock); r = listen(sock, 100); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_poll_start(&context->poll_handle, UV_READABLE, server_poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -544,8 +544,8 @@ static void start_client(void) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", 0, &addr)); sock = create_bound_socket(addr); context = create_connection_context(sock, 0); @@ -554,7 +554,7 @@ static void start_client(void) { r = uv_poll_start(&context->poll_handle, UV_READABLE | UV_WRITABLE | UV_DISCONNECT, connection_poll_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = connect(sock, (struct sockaddr*) &server_addr, sizeof server_addr); ASSERT(r == 0 || got_eagain()); @@ -568,7 +568,7 @@ static void start_poll_test(void) { { struct WSAData wsa_data; int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); } #endif @@ -578,16 +578,16 @@ static void start_poll_test(void) { start_client(); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); /* Assert that at most five percent of the writable wakeups was spurious. */ - ASSERT(spurious_writable_wakeups == 0 || - (valid_writable_wakeups + spurious_writable_wakeups) / - spurious_writable_wakeups > 20); + ASSERT_NE(spurious_writable_wakeups == 0 || + (valid_writable_wakeups + spurious_writable_wakeups) / + spurious_writable_wakeups > 20, 0); - ASSERT(closed_connections == NUM_CLIENTS * 2); + ASSERT_EQ(closed_connections, NUM_CLIENTS * 2); #if !defined(__sun) && !defined(_AIX) && !defined(__MVS__) - ASSERT(disconnects == NUM_CLIENTS * 2); + ASSERT_EQ(disconnects, NUM_CLIENTS * 2); #endif MAKE_VALGRIND_HAPPY(uv_default_loop()); } @@ -642,9 +642,9 @@ TEST_IMPL(poll_bad_fdtype) { #else fd = open(".", O_RDONLY); #endif - ASSERT(fd != -1); - ASSERT(0 != uv_poll_init(uv_default_loop(), &poll_handle, fd)); - ASSERT(0 == close(fd)); + ASSERT_NE(fd, -1); + ASSERT_NE(0, uv_poll_init(uv_default_loop(), &poll_handle, fd)); + ASSERT_OK(close(fd)); #endif MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -658,15 +658,15 @@ TEST_IMPL(poll_nested_epoll) { int fd; fd = epoll_create(1); - ASSERT(fd != -1); + ASSERT_NE(fd, -1); - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, fd)); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, (uv_poll_cb) abort)); - ASSERT(0 != uv_run(uv_default_loop(), UV_RUN_NOWAIT)); + ASSERT_OK(uv_poll_init(uv_default_loop(), &poll_handle, fd)); + ASSERT_OK(uv_poll_start(&poll_handle, UV_READABLE, (uv_poll_cb) abort)); + ASSERT_NE(0, uv_run(uv_default_loop(), UV_RUN_NOWAIT)); uv_close((uv_handle_t*) &poll_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == close(fd)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(close(fd)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -680,15 +680,15 @@ TEST_IMPL(poll_nested_kqueue) { int fd; fd = kqueue(); - ASSERT(fd != -1); + ASSERT_NE(fd, -1); - ASSERT(0 == uv_poll_init(uv_default_loop(), &poll_handle, fd)); - ASSERT(0 == uv_poll_start(&poll_handle, UV_READABLE, (uv_poll_cb) abort)); - ASSERT(0 != uv_run(uv_default_loop(), UV_RUN_NOWAIT)); + ASSERT_OK(uv_poll_init(uv_default_loop(), &poll_handle, fd)); + ASSERT_OK(uv_poll_start(&poll_handle, UV_READABLE, (uv_poll_cb) abort)); + ASSERT_NE(0, uv_run(uv_default_loop(), UV_RUN_NOWAIT)); uv_close((uv_handle_t*) &poll_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == close(fd)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(close(fd)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-process-priority.c b/deps/libuv/test/test-process-priority.c index b3d0a85b..941e4b36 100644 --- a/deps/libuv/test/test-process-priority.c +++ b/deps/libuv/test/test-process-priority.c @@ -35,7 +35,7 @@ TEST_IMPL(process_priority) { /* Verify that passing a NULL pointer returns UV_EINVAL. */ r = uv_os_getpriority(0, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Verify that all valid values work. */ for (i = UV_PRIORITY_HIGHEST; i <= UV_PRIORITY_LOW; i++) { @@ -46,38 +46,38 @@ TEST_IMPL(process_priority) { if (r == UV_EACCES) continue; - ASSERT(r == 0); - ASSERT(uv_os_getpriority(0, &priority) == 0); + ASSERT_OK(r); + ASSERT_OK(uv_os_getpriority(0, &priority)); /* Verify that the priority values match on Unix, and are range mapped on Windows. */ #ifndef _WIN32 - ASSERT(priority == i); + ASSERT_EQ(priority, i); #else /* On Windows, only elevated users can set UV_PRIORITY_HIGHEST. Other users will silently be set to UV_PRIORITY_HIGH. */ if (i < UV_PRIORITY_HIGH) ASSERT(priority == UV_PRIORITY_HIGHEST || priority == UV_PRIORITY_HIGH); else if (i < UV_PRIORITY_ABOVE_NORMAL) - ASSERT(priority == UV_PRIORITY_HIGH); + ASSERT_EQ(priority, UV_PRIORITY_HIGH); else if (i < UV_PRIORITY_NORMAL) - ASSERT(priority == UV_PRIORITY_ABOVE_NORMAL); + ASSERT_EQ(priority, UV_PRIORITY_ABOVE_NORMAL); else if (i < UV_PRIORITY_BELOW_NORMAL) - ASSERT(priority == UV_PRIORITY_NORMAL); + ASSERT_EQ(priority, UV_PRIORITY_NORMAL); else if (i < UV_PRIORITY_LOW) - ASSERT(priority == UV_PRIORITY_BELOW_NORMAL); + ASSERT_EQ(priority, UV_PRIORITY_BELOW_NORMAL); else - ASSERT(priority == UV_PRIORITY_LOW); + ASSERT_EQ(priority, UV_PRIORITY_LOW); #endif /* Verify that the current PID and 0 are equivalent. */ - ASSERT(uv_os_getpriority(uv_os_getpid(), &r) == 0); - ASSERT(priority == r); + ASSERT_OK(uv_os_getpriority(uv_os_getpid(), &r)); + ASSERT_EQ(priority, r); } /* Verify that invalid priorities return UV_EINVAL. */ - ASSERT(uv_os_setpriority(0, UV_PRIORITY_HIGHEST - 1) == UV_EINVAL); - ASSERT(uv_os_setpriority(0, UV_PRIORITY_LOW + 1) == UV_EINVAL); + ASSERT_EQ(uv_os_setpriority(0, UV_PRIORITY_HIGHEST - 1), UV_EINVAL); + ASSERT_EQ(uv_os_setpriority(0, UV_PRIORITY_LOW + 1), UV_EINVAL); return 0; } diff --git a/deps/libuv/test/test-process-title-threadsafe.c b/deps/libuv/test/test-process-title-threadsafe.c index 927643cc..05baaf44 100644 --- a/deps/libuv/test/test-process-title-threadsafe.c +++ b/deps/libuv/test/test-process-title-threadsafe.c @@ -46,7 +46,7 @@ static void getter_thread_body(void* arg) { getter_sem = arg; while (UV_EAGAIN == uv_sem_trywait(getter_sem)) { - ASSERT(0 == uv_get_process_title(buffer, sizeof(buffer))); + ASSERT_OK(uv_get_process_title(buffer, sizeof(buffer))); /* The maximum size of the process title on some platforms depends on * the total size of the argv vector. It's therefore possible to read @@ -70,10 +70,10 @@ static void setter_thread_body(void* arg) { int i; for (i = 0; i < NUM_ITERATIONS; i++) { - ASSERT(0 == uv_set_process_title(titles[0])); - ASSERT(0 == uv_set_process_title(titles[1])); - ASSERT(0 == uv_set_process_title(titles[2])); - ASSERT(0 == uv_set_process_title(titles[3])); + ASSERT_OK(uv_set_process_title(titles[0])); + ASSERT_OK(uv_set_process_title(titles[1])); + ASSERT_OK(uv_set_process_title(titles[2])); + ASSERT_OK(uv_set_process_title(titles[3])); } } @@ -89,20 +89,19 @@ TEST_IMPL(process_title_threadsafe) { RETURN_SKIP("uv_(get|set)_process_title is not implemented."); #endif - ASSERT(0 == uv_set_process_title(titles[0])); + ASSERT_OK(uv_set_process_title(titles[0])); - ASSERT_EQ(0, uv_sem_init(&getter_sem, 0)); - ASSERT_EQ(0, - uv_thread_create(&getter_thread, getter_thread_body, &getter_sem)); + ASSERT_OK(uv_sem_init(&getter_sem, 0)); + ASSERT_OK(uv_thread_create(&getter_thread, getter_thread_body, &getter_sem)); for (i = 0; i < (int) ARRAY_SIZE(setter_threads); i++) - ASSERT(0 == uv_thread_create(&setter_threads[i], setter_thread_body, NULL)); + ASSERT_OK(uv_thread_create(&setter_threads[i], setter_thread_body, NULL)); for (i = 0; i < (int) ARRAY_SIZE(setter_threads); i++) - ASSERT(0 == uv_thread_join(&setter_threads[i])); + ASSERT_OK(uv_thread_join(&setter_threads[i])); uv_sem_post(&getter_sem); - ASSERT_EQ(0, uv_thread_join(&getter_thread)); + ASSERT_OK(uv_thread_join(&getter_thread)); uv_sem_destroy(&getter_sem); return 0; diff --git a/deps/libuv/test/test-process-title.c b/deps/libuv/test/test-process-title.c index c5cff972..7178cf87 100644 --- a/deps/libuv/test/test-process-title.c +++ b/deps/libuv/test/test-process-title.c @@ -29,15 +29,15 @@ static void set_title(const char* title) { int err; err = uv_get_process_title(buffer, sizeof(buffer)); - ASSERT(err == 0); + ASSERT_OK(err); err = uv_set_process_title(title); - ASSERT(err == 0); + ASSERT_OK(err); err = uv_get_process_title(buffer, sizeof(buffer)); - ASSERT(err == 0); + ASSERT_OK(err); - ASSERT(strcmp(buffer, title) == 0); + ASSERT_OK(strcmp(buffer, title)); } @@ -47,15 +47,15 @@ static void uv_get_process_title_edge_cases(void) { /* Test a NULL buffer */ r = uv_get_process_title(NULL, 100); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Test size of zero */ r = uv_get_process_title(buffer, 0); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Test for insufficient buffer size */ r = uv_get_process_title(buffer, 1); - ASSERT(r == UV_ENOBUFS); + ASSERT_EQ(r, UV_ENOBUFS); } @@ -77,8 +77,8 @@ TEST_IMPL(process_title) { static void exit_cb(uv_process_t* process, int64_t status, int signo) { - ASSERT(status == 0); - ASSERT(signo == 0); + ASSERT_OK(status); + ASSERT_OK(signo); uv_close((uv_handle_t*) process, NULL); } @@ -97,7 +97,7 @@ TEST_IMPL(process_title_big_argv) { #endif exepath_size = sizeof(exepath) - 1; - ASSERT(0 == uv_exepath(exepath, &exepath_size)); + ASSERT_OK(uv_exepath(exepath, &exepath_size)); exepath[exepath_size] = '\0'; memset(jumbo, 'x', sizeof(jumbo) - 1); @@ -117,8 +117,8 @@ TEST_IMPL(process_title_big_argv) { options.args = args; options.exit_cb = exit_cb; - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -131,5 +131,5 @@ void process_title_big_argv(void) { /* Return value deliberately ignored. */ uv_get_process_title(buf, sizeof(buf)); - ASSERT(0 != strcmp(buf, "fail")); + ASSERT_NE(0, strcmp(buf, "fail")); } diff --git a/deps/libuv/test/test-queue-foreach-delete.c b/deps/libuv/test/test-queue-foreach-delete.c index 4fe8aece..b3a2d19c 100644 --- a/deps/libuv/test/test-queue-foreach-delete.c +++ b/deps/libuv/test/test-queue-foreach-delete.c @@ -71,7 +71,7 @@ static const unsigned first_handle_number_fs_event = 0; static unsigned name##_cb_calls[3]; \ \ static void name##2_cb(__VA_ARGS__) { \ - ASSERT(handle == &(name)[2]); \ + ASSERT_PTR_EQ(handle, &(name)[2]); \ if (first_handle_number_##name == 2) { \ uv_close((uv_handle_t*)&(name)[2], NULL); \ uv_close((uv_handle_t*)&(name)[1], NULL); \ @@ -80,12 +80,12 @@ static const unsigned first_handle_number_fs_event = 0; } \ \ static void name##1_cb(__VA_ARGS__) { \ - ASSERT(handle == &(name)[1]); \ + ASSERT_PTR_EQ(handle, &(name)[1]); \ ASSERT(0 && "Shouldn't be called" && (&name[0])); \ } \ \ static void name##0_cb(__VA_ARGS__) { \ - ASSERT(handle == &(name)[0]); \ + ASSERT_PTR_EQ(handle, &(name)[0]); \ if (first_handle_number_##name == 0) { \ uv_close((uv_handle_t*)&(name)[0], NULL); \ uv_close((uv_handle_t*)&(name)[1], NULL); \ @@ -105,18 +105,18 @@ static const unsigned first_handle_number_fs_event = 0; for (i = 0; i < ARRAY_SIZE(name); i++) { \ int r; \ r = uv_##name##_init((loop), &(name)[i]); \ - ASSERT(r == 0); \ + ASSERT_OK(r); \ \ r = uv_##name##_start(&(name)[i], name##_cbs[i]); \ - ASSERT(r == 0); \ + ASSERT_OK(r); \ } \ } while (0) #define END_ASSERTS(name) \ do { \ - ASSERT(name##_cb_calls[0] == 1); \ - ASSERT(name##_cb_calls[1] == 0); \ - ASSERT(name##_cb_calls[2] == 1); \ + ASSERT_EQ(1, name##_cb_calls[0]); \ + ASSERT_OK(name##_cb_calls[1]); \ + ASSERT_EQ(1, name##_cb_calls[2]); \ } while (0) DEFINE_GLOBALS_AND_CBS(idle, uv_idle_t* handle) @@ -140,13 +140,13 @@ static void init_and_start_fs_events(uv_loop_t* loop) { for (i = 0; i < ARRAY_SIZE(fs_event); i++) { int r; r = uv_fs_event_init(loop, &fs_event[i]); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fs_event_start(&fs_event[i], (uv_fs_event_cb)fs_event_cbs[i], watched_dir, 0); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -156,10 +156,10 @@ static void helper_timer_cb(uv_timer_t* thandle) { /* fire all fs_events */ r = uv_fs_utime(thandle->loop, &fs_req, watched_dir, 0, 0, NULL); - ASSERT(r == 0); - ASSERT(fs_req.result == 0); - ASSERT(fs_req.fs_type == UV_FS_UTIME); - ASSERT(strcmp(fs_req.path, watched_dir) == 0); + ASSERT_OK(r); + ASSERT_OK(fs_req.result); + ASSERT_EQ(fs_req.fs_type, UV_FS_UTIME); + ASSERT_OK(strcmp(fs_req.path, watched_dir)); uv_fs_req_cleanup(&fs_req); helper_timer_cb_calls++; @@ -182,21 +182,21 @@ TEST_IMPL(queue_foreach_delete) { /* helper timer to trigger async and fs_event callbacks */ r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, helper_timer_cb, 0, 0); - ASSERT(r == 0); + ASSERT_OK(r); #endif r = uv_run(loop, UV_RUN_NOWAIT); - ASSERT(r == 1); + ASSERT_EQ(1, r); END_ASSERTS(idle); END_ASSERTS(prepare); END_ASSERTS(check); #ifdef __linux__ - ASSERT(helper_timer_cb_calls == 1); + ASSERT_EQ(1, helper_timer_cb_calls); #endif MAKE_VALGRIND_HAPPY(loop); diff --git a/deps/libuv/test/test-random.c b/deps/libuv/test/test-random.c index 3ff3fa8b..d82d0578 100644 --- a/deps/libuv/test/test-random.c +++ b/deps/libuv/test/test-random.c @@ -33,16 +33,16 @@ static void random_cb(uv_random_t* req, int status, void* buf, size_t buflen) { memset(zero, 0, sizeof(zero)); - ASSERT(0 == status); - ASSERT(buf == (void*) scratch); + ASSERT_OK(status); + ASSERT_PTR_EQ(buf, (void*) scratch); if (random_cb_called == 0) { - ASSERT(buflen == 0); - ASSERT(0 == memcmp(scratch, zero, sizeof(zero))); + ASSERT_OK(buflen); + ASSERT_OK(memcmp(scratch, zero, sizeof(zero))); } else { - ASSERT(buflen == sizeof(scratch)); + ASSERT_EQ(buflen, sizeof(scratch)); /* Buy a lottery ticket if you manage to trip this assertion. */ - ASSERT(0 != memcmp(scratch, zero, sizeof(zero))); + ASSERT_NE(0, memcmp(scratch, zero, sizeof(zero))); } random_cb_called++; @@ -54,21 +54,21 @@ TEST_IMPL(random_async) { uv_loop_t* loop; loop = uv_default_loop(); - ASSERT(UV_EINVAL == uv_random(loop, &req, scratch, sizeof(scratch), -1, - random_cb)); - ASSERT(UV_E2BIG == uv_random(loop, &req, scratch, -1, -1, random_cb)); + ASSERT_EQ(UV_EINVAL, uv_random(loop, &req, scratch, sizeof(scratch), -1, + random_cb)); + ASSERT_EQ(UV_E2BIG, uv_random(loop, &req, scratch, -1, -1, random_cb)); - ASSERT(0 == uv_random(loop, &req, scratch, 0, 0, random_cb)); - ASSERT(0 == random_cb_called); + ASSERT_OK(uv_random(loop, &req, scratch, 0, 0, random_cb)); + ASSERT_OK(random_cb_called); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == random_cb_called); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, random_cb_called); - ASSERT(0 == uv_random(loop, &req, scratch, sizeof(scratch), 0, random_cb)); - ASSERT(1 == random_cb_called); + ASSERT_OK(uv_random(loop, &req, scratch, sizeof(scratch), 0, random_cb)); + ASSERT_EQ(1, random_cb_called); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(2 == random_cb_called); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(2, random_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -79,15 +79,15 @@ TEST_IMPL(random_sync) { char zero[256]; char buf[256]; - ASSERT(UV_EINVAL == uv_random(NULL, NULL, buf, sizeof(buf), -1, NULL)); - ASSERT(UV_E2BIG == uv_random(NULL, NULL, buf, -1, -1, NULL)); + ASSERT_EQ(UV_EINVAL, uv_random(NULL, NULL, buf, sizeof(buf), -1, NULL)); + ASSERT_EQ(UV_E2BIG, uv_random(NULL, NULL, buf, -1, -1, NULL)); memset(buf, 0, sizeof(buf)); - ASSERT(0 == uv_random(NULL, NULL, buf, sizeof(buf), 0, NULL)); + ASSERT_OK(uv_random(NULL, NULL, buf, sizeof(buf), 0, NULL)); /* Buy a lottery ticket if you manage to trip this assertion. */ memset(zero, 0, sizeof(zero)); - ASSERT(0 != memcmp(buf, zero, sizeof(zero))); + ASSERT_NE(0, memcmp(buf, zero, sizeof(zero))); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-readable-on-eof.c b/deps/libuv/test/test-readable-on-eof.c index 1162f8db..2137ac59 100644 --- a/deps/libuv/test/test-readable-on-eof.c +++ b/deps/libuv/test/test-readable-on-eof.c @@ -35,7 +35,7 @@ static int close_cb_called; static void write_cb(uv_write_t* req, int status) { write_cb_called++; - ASSERT_EQ(status, 0); + ASSERT_OK(status); } static void alloc_cb(uv_handle_t* handle, @@ -54,16 +54,16 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { int r; ASSERT_EQ(nread, UV_EOF); - ASSERT_EQ(uv_is_readable(handle), 1); - ASSERT_EQ(uv_is_writable(handle), 1); + ASSERT_EQ(1, uv_is_readable(handle)); + ASSERT_EQ(1, uv_is_writable(handle)); if (++read_cb_called == 3) { uv_close((uv_handle_t*) handle, close_cb); - ASSERT_EQ(uv_is_readable(handle), 0); - ASSERT_EQ(uv_is_writable(handle), 0); + ASSERT_OK(uv_is_readable(handle)); + ASSERT_OK(uv_is_writable(handle)); } else { r = uv_read_start((uv_stream_t*) &tcp_client, alloc_cb, read_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } } @@ -72,7 +72,7 @@ static void connect_cb(uv_connect_t* req, int status) { uv_buf_t close_me; connect_cb_called++; - ASSERT_EQ(status, 0); + ASSERT_OK(status); read_cb((uv_stream_t*) &tcp_client, UV_EOF, NULL); @@ -84,27 +84,26 @@ static void connect_cb(uv_connect_t* req, int status) { 1, write_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } TEST_IMPL(readable_on_eof) { struct sockaddr_in sa; - ASSERT_EQ(uv_ip4_addr("127.0.0.1", TEST_PORT, &sa), 0); - ASSERT_EQ(uv_loop_init(&loop), 0); - ASSERT_EQ(uv_tcp_init(&loop, &tcp_client), 0); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &sa)); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_tcp_init(&loop, &tcp_client)); - ASSERT_EQ(uv_tcp_connect(&connect_req, + ASSERT_OK(uv_tcp_connect(&connect_req, &tcp_client, (const struct sockaddr*) &sa, - connect_cb), - 0); + connect_cb)); - ASSERT_EQ(uv_run(&loop, UV_RUN_DEFAULT), 0); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT_EQ(connect_cb_called, 1); - ASSERT_EQ(read_cb_called, 3); - ASSERT_EQ(write_cb_called, 1); - ASSERT_EQ(close_cb_called, 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(3, read_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; diff --git a/deps/libuv/test/test-ref.c b/deps/libuv/test/test-ref.c index 7a9a0b93..dbe94f71 100644 --- a/deps/libuv/test/test-ref.c +++ b/deps/libuv/test/test-ref.c @@ -47,9 +47,9 @@ static void close_cb(uv_handle_t* handle) { static void do_close(void* handle) { close_cb_called = 0; uv_close((uv_handle_t*)handle, close_cb); - ASSERT(close_cb_called == 0); + ASSERT_OK(close_cb_called); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); } @@ -69,13 +69,13 @@ static void req_cb(uv_handle_t* req, int status) { static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &shutdown_req); + ASSERT_PTR_EQ(req, &shutdown_req); shutdown_cb_called++; } static void write_cb(uv_write_t* req, int status) { - ASSERT(req == &write_req); + ASSERT_PTR_EQ(req, &write_req); uv_shutdown(&shutdown_req, req->handle, shutdown_cb); write_cb_called++; } @@ -83,8 +83,8 @@ static void write_cb(uv_write_t* req, int status) { static void connect_and_write(uv_connect_t* req, int status) { uv_buf_t buf = uv_buf_init(buffer, sizeof buffer); - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); uv_write(&write_req, req->handle, &buf, 1, write_cb); connect_cb_called++; } @@ -92,8 +92,8 @@ static void connect_and_write(uv_connect_t* req, int status) { static void connect_and_shutdown(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); uv_shutdown(&shutdown_req, req->handle, shutdown_cb); connect_cb_called++; } @@ -250,7 +250,7 @@ TEST_IMPL(tcp_ref2b) { uv_unref((uv_handle_t*)&h); uv_close((uv_handle_t*)&h, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } @@ -259,7 +259,7 @@ TEST_IMPL(tcp_ref2b) { TEST_IMPL(tcp_ref3) { struct sockaddr_in addr; uv_tcp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); uv_tcp_init(uv_default_loop(), &h); uv_tcp_connect(&connect_req, &h, @@ -267,8 +267,8 @@ TEST_IMPL(tcp_ref3) { connect_and_shutdown); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, shutdown_cb_called); do_close(&h); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -278,7 +278,7 @@ TEST_IMPL(tcp_ref3) { TEST_IMPL(tcp_ref4) { struct sockaddr_in addr; uv_tcp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); uv_tcp_init(uv_default_loop(), &h); uv_tcp_connect(&connect_req, &h, @@ -286,9 +286,9 @@ TEST_IMPL(tcp_ref4) { connect_and_write); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, shutdown_cb_called); do_close(&h); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -309,7 +309,7 @@ TEST_IMPL(udp_ref) { TEST_IMPL(udp_ref2) { struct sockaddr_in addr; uv_udp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); uv_udp_init(uv_default_loop(), &h); uv_udp_bind(&h, (const struct sockaddr*) &addr, 0); uv_udp_recv_start(&h, (uv_alloc_cb)fail_cb, (uv_udp_recv_cb)fail_cb); @@ -327,7 +327,7 @@ TEST_IMPL(udp_ref3) { uv_udp_send_t req; uv_udp_t h; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); uv_udp_init(uv_default_loop(), &h); uv_udp_send(&req, &h, @@ -337,7 +337,7 @@ TEST_IMPL(udp_ref3) { (uv_udp_send_cb) req_cb); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(req_cb_called == 1); + ASSERT_EQ(1, req_cb_called); do_close(&h); MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -374,8 +374,8 @@ TEST_IMPL(pipe_ref3) { uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_and_shutdown); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, shutdown_cb_called); do_close(&h); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -388,9 +388,9 @@ TEST_IMPL(pipe_ref4) { uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_and_write); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, shutdown_cb_called); do_close(&h); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -410,7 +410,7 @@ TEST_IMPL(process_ref) { exepath_size = sizeof(exepath); r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); + ASSERT_OK(r); argv[0] = exepath; options.file = exepath; @@ -418,13 +418,13 @@ TEST_IMPL(process_ref) { options.exit_cb = NULL; r = uv_spawn(uv_default_loop(), &h, &options); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*)&h); uv_run(uv_default_loop(), UV_RUN_DEFAULT); r = uv_process_kill(&h, /* SIGTERM */ 15); - ASSERT(r == 0); + ASSERT_OK(r); do_close(&h); @@ -437,9 +437,9 @@ TEST_IMPL(has_ref) { uv_idle_t h; uv_idle_init(uv_default_loop(), &h); uv_ref((uv_handle_t*)&h); - ASSERT(uv_has_ref((uv_handle_t*)&h) == 1); + ASSERT_EQ(1, uv_has_ref((uv_handle_t*)&h)); uv_unref((uv_handle_t*)&h); - ASSERT(uv_has_ref((uv_handle_t*)&h) == 0); + ASSERT_OK(uv_has_ref((uv_handle_t*)&h)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } diff --git a/deps/libuv/test/test-run-nowait.c b/deps/libuv/test/test-run-nowait.c index 70410537..89f5f55b 100644 --- a/deps/libuv/test/test-run-nowait.c +++ b/deps/libuv/test/test-run-nowait.c @@ -27,7 +27,7 @@ static int timer_called = 0; static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer_handle); + ASSERT_PTR_EQ(handle, &timer_handle); timer_called = 1; } @@ -38,8 +38,8 @@ TEST_IMPL(run_nowait) { uv_timer_start(&timer_handle, timer_cb, 100, 100); r = uv_run(uv_default_loop(), UV_RUN_NOWAIT); - ASSERT(r != 0); - ASSERT(timer_called == 0); + ASSERT(r); + ASSERT_OK(timer_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-run-once.c b/deps/libuv/test/test-run-once.c index ee332fa1..0ae0082c 100644 --- a/deps/libuv/test/test-run-once.c +++ b/deps/libuv/test/test-run-once.c @@ -29,7 +29,7 @@ static int idle_counter; static void idle_cb(uv_idle_t* handle) { - ASSERT(handle == &idle_handle); + ASSERT_PTR_EQ(handle, &idle_handle); if (++idle_counter == NUM_TICKS) uv_idle_stop(handle); @@ -41,7 +41,7 @@ TEST_IMPL(run_once) { uv_idle_start(&idle_handle, idle_cb); while (uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(idle_counter == NUM_TICKS); + ASSERT_EQ(idle_counter, NUM_TICKS); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-semaphore.c b/deps/libuv/test/test-semaphore.c index ac03bb08..ad54808d 100644 --- a/deps/libuv/test/test-semaphore.c +++ b/deps/libuv/test/test-semaphore.c @@ -40,7 +40,7 @@ static void worker(void* arg) { uv_sleep(c->delay); uv_mutex_lock(&c->mutex); - ASSERT(c->posted == 0); + ASSERT_OK(c->posted); uv_sem_post(&c->sem); c->posted = 1; uv_mutex_unlock(&c->mutex); @@ -53,17 +53,17 @@ TEST_IMPL(semaphore_1) { memset(&wc, 0, sizeof(wc)); - ASSERT(0 == uv_sem_init(&wc.sem, 0)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_sem_init(&wc.sem, 0)); + ASSERT_OK(uv_mutex_init(&wc.mutex)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); uv_sleep(100); uv_mutex_lock(&wc.mutex); - ASSERT(wc.posted == 1); + ASSERT_EQ(1, wc.posted); uv_sem_wait(&wc.sem); /* should not block */ uv_mutex_unlock(&wc.mutex); /* ergo, it should be ok to unlock after wait */ - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); uv_sem_destroy(&wc.sem); @@ -78,13 +78,13 @@ TEST_IMPL(semaphore_2) { memset(&wc, 0, sizeof(wc)); wc.delay = 100; - ASSERT(0 == uv_sem_init(&wc.sem, 0)); - ASSERT(0 == uv_mutex_init(&wc.mutex)); - ASSERT(0 == uv_thread_create(&thread, worker, &wc)); + ASSERT_OK(uv_sem_init(&wc.sem, 0)); + ASSERT_OK(uv_mutex_init(&wc.mutex)); + ASSERT_OK(uv_thread_create(&thread, worker, &wc)); uv_sem_wait(&wc.sem); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); uv_sem_destroy(&wc.sem); @@ -95,15 +95,15 @@ TEST_IMPL(semaphore_2) { TEST_IMPL(semaphore_3) { uv_sem_t sem; - ASSERT(0 == uv_sem_init(&sem, 3)); + ASSERT_OK(uv_sem_init(&sem, 3)); uv_sem_wait(&sem); /* should not block */ uv_sem_wait(&sem); /* should not block */ - ASSERT(0 == uv_sem_trywait(&sem)); - ASSERT(UV_EAGAIN == uv_sem_trywait(&sem)); + ASSERT_OK(uv_sem_trywait(&sem)); + ASSERT_EQ(UV_EAGAIN, uv_sem_trywait(&sem)); uv_sem_post(&sem); - ASSERT(0 == uv_sem_trywait(&sem)); - ASSERT(UV_EAGAIN == uv_sem_trywait(&sem)); + ASSERT_OK(uv_sem_trywait(&sem)); + ASSERT_EQ(UV_EAGAIN, uv_sem_trywait(&sem)); uv_sem_destroy(&sem); diff --git a/deps/libuv/test/test-shutdown-close.c b/deps/libuv/test/test-shutdown-close.c index cb478b5f..306404af 100644 --- a/deps/libuv/test/test-shutdown-close.c +++ b/deps/libuv/test/test-shutdown-close.c @@ -37,7 +37,7 @@ static int close_cb_called = 0; static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &shutdown_req); + ASSERT_PTR_EQ(req, &shutdown_req); ASSERT(status == 0 || status == UV_ECANCELED); shutdown_cb_called++; } @@ -51,14 +51,14 @@ static void close_cb(uv_handle_t* handle) { static void connect_cb(uv_connect_t* req, int status) { int r; - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); r = uv_shutdown(&shutdown_req, req->handle, shutdown_cb); - ASSERT(r == 0); - ASSERT(0 == uv_is_closing((uv_handle_t*) req->handle)); + ASSERT_OK(r); + ASSERT_OK(uv_is_closing((uv_handle_t*) req->handle)); uv_close((uv_handle_t*) req->handle, close_cb); - ASSERT(1 == uv_is_closing((uv_handle_t*) req->handle)); + ASSERT_EQ(1, uv_is_closing((uv_handle_t*) req->handle)); connect_cb_called++; } @@ -69,20 +69,20 @@ TEST_IMPL(shutdown_close_tcp) { uv_tcp_t h; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &h); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &h, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -94,14 +94,14 @@ TEST_IMPL(shutdown_close_pipe) { int r; r = uv_pipe_init(uv_default_loop(), &h, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_connect(&connect_req, &h, TEST_PIPENAME, connect_cb); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(connect_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-shutdown-eof.c b/deps/libuv/test/test-shutdown-eof.c index 9c0b8565..6669c297 100644 --- a/deps/libuv/test/test-shutdown-eof.c +++ b/deps/libuv/test/test-shutdown-eof.c @@ -46,7 +46,7 @@ static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { - ASSERT((uv_tcp_t*)t == &tcp); + ASSERT_PTR_EQ((uv_tcp_t*)t, &tcp); if (nread == 0) { free(buf->base); @@ -54,14 +54,14 @@ static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { } if (!got_q) { - ASSERT(nread == 1); + ASSERT_EQ(1, nread); ASSERT(!got_eof); - ASSERT(buf->base[0] == 'Q'); + ASSERT_EQ(buf->base[0], 'Q'); free(buf->base); got_q = 1; puts("got Q"); } else { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); if (buf->base) { free(buf->base); } @@ -72,24 +72,24 @@ static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { static void shutdown_cb(uv_shutdown_t *req, int status) { - ASSERT(req == &shutdown_req); + ASSERT_PTR_EQ(req, &shutdown_req); - ASSERT(called_connect_cb == 1); + ASSERT_EQ(1, called_connect_cb); ASSERT(!got_eof); - ASSERT(called_tcp_close_cb == 0); - ASSERT(called_timer_close_cb == 0); - ASSERT(called_timer_cb == 0); + ASSERT_OK(called_tcp_close_cb); + ASSERT_OK(called_timer_close_cb); + ASSERT_OK(called_timer_cb); called_shutdown_cb++; } static void connect_cb(uv_connect_t *req, int status) { - ASSERT(status == 0); - ASSERT(req == &connect_req); + ASSERT_OK(status); + ASSERT_PTR_EQ(req, &connect_req); /* Start reading from our connection so we can receive the EOF. */ - ASSERT_EQ(0, uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb)); /* Check error handling. */ ASSERT_EQ(UV_EALREADY, uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb)); @@ -107,37 +107,37 @@ static void connect_cb(uv_connect_t *req, int status) { uv_shutdown(&shutdown_req, (uv_stream_t*) &tcp, shutdown_cb); called_connect_cb++; - ASSERT(called_shutdown_cb == 0); + ASSERT_OK(called_shutdown_cb); } static void tcp_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &tcp); + ASSERT_PTR_EQ(handle, (uv_handle_t*) &tcp); - ASSERT(called_connect_cb == 1); + ASSERT_EQ(1, called_connect_cb); ASSERT(got_q); ASSERT(got_eof); - ASSERT(called_timer_cb == 1); + ASSERT_EQ(1, called_timer_cb); called_tcp_close_cb++; } static void timer_close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &timer); + ASSERT_PTR_EQ(handle, (uv_handle_t*) &timer); called_timer_close_cb++; } static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); + ASSERT_PTR_EQ(handle, &timer); uv_close((uv_handle_t*) handle, timer_close_cb); /* * The most important assert of the test: we have not received * tcp_close_cb yet. */ - ASSERT(called_tcp_close_cb == 0); + ASSERT_OK(called_tcp_close_cb); uv_close((uv_handle_t*) &tcp, tcp_close_cb); called_timer_cb++; @@ -158,11 +158,11 @@ TEST_IMPL(shutdown_eof) { qbuf.len = 1; r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); uv_timer_start(&timer, timer_cb, 100, 0); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); r = uv_tcp_init(uv_default_loop(), &tcp); ASSERT(!r); @@ -174,13 +174,13 @@ TEST_IMPL(shutdown_eof) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(called_connect_cb == 1); - ASSERT(called_shutdown_cb == 1); + ASSERT_EQ(1, called_connect_cb); + ASSERT_EQ(1, called_shutdown_cb); ASSERT(got_eof); ASSERT(got_q); - ASSERT(called_tcp_close_cb == 1); - ASSERT(called_timer_close_cb == 1); - ASSERT(called_timer_cb == 1); + ASSERT_EQ(1, called_tcp_close_cb); + ASSERT_EQ(1, called_timer_close_cb); + ASSERT_EQ(1, called_timer_cb); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-shutdown-simultaneous.c b/deps/libuv/test/test-shutdown-simultaneous.c index 14cc4437..0dd8e353 100644 --- a/deps/libuv/test/test-shutdown-simultaneous.c +++ b/deps/libuv/test/test-shutdown-simultaneous.c @@ -44,8 +44,8 @@ static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { static void shutdown_cb(uv_shutdown_t *req, int status) { ASSERT_PTR_EQ(req, &shutdown_req); - ASSERT_EQ(called_connect_cb, 1); - ASSERT_EQ(called_tcp_close_cb, 0); + ASSERT_EQ(1, called_connect_cb); + ASSERT_OK(called_tcp_close_cb); } @@ -58,8 +58,8 @@ static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { } if (!got_q) { - ASSERT_EQ(nread, 4); - ASSERT_EQ(got_eof, 0); + ASSERT_EQ(4, nread); + ASSERT_OK(got_eof); ASSERT_MEM_EQ(buf->base, "QQSS", 4); free(buf->base); got_q = 1; @@ -79,11 +79,11 @@ static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { static void connect_cb(uv_connect_t *req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_PTR_EQ(req, &connect_req); /* Start reading from our connection so we can receive the EOF. */ - ASSERT_EQ(0, uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb)); /* Check error handling. */ ASSERT_EQ(UV_EALREADY, uv_read_start((uv_stream_t*)&tcp, alloc_cb, read_cb)); @@ -98,7 +98,7 @@ static void connect_cb(uv_connect_t *req, int status) { ASSERT_EQ(qbuf.len, uv_try_write((uv_stream_t*) &tcp, &qbuf, 1)); called_connect_cb++; - ASSERT_EQ(called_shutdown_cb, 0); + ASSERT_OK(called_shutdown_cb); } @@ -113,22 +113,22 @@ TEST_IMPL(shutdown_simultaneous) { qbuf.base = "QQSS"; qbuf.len = 4; - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &tcp, (const struct sockaddr*) &server_addr, connect_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(called_connect_cb, 1); - ASSERT_EQ(called_shutdown_cb, 1); - ASSERT_EQ(got_eof, 1); - ASSERT_EQ(got_q, 1); + ASSERT_EQ(1, called_connect_cb); + ASSERT_EQ(1, called_shutdown_cb); + ASSERT_EQ(1, got_eof); + ASSERT_EQ(1, got_q); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-shutdown-twice.c b/deps/libuv/test/test-shutdown-twice.c index d936a70c..c21a9834 100644 --- a/deps/libuv/test/test-shutdown-twice.c +++ b/deps/libuv/test/test-shutdown-twice.c @@ -37,8 +37,8 @@ static void close_cb(uv_handle_t* handle) { } static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &req1); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &req1); + ASSERT_OK(status); shutdown_cb_called++; uv_close((uv_handle_t*) req->handle, close_cb); } @@ -46,12 +46,12 @@ static void shutdown_cb(uv_shutdown_t* req, int status) { static void connect_cb(uv_connect_t* req, int status) { int r; - ASSERT(status == 0); + ASSERT_OK(status); r = uv_shutdown(&req1, req->handle, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_shutdown(&req2, req->handle, shutdown_cb); - ASSERT(r != 0); + ASSERT(r); } @@ -63,22 +63,22 @@ TEST_IMPL(shutdown_twice) { uv_connect_t connect_req; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); r = uv_tcp_init(loop, &h); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &h, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(1, shutdown_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-signal-multiple-loops.c b/deps/libuv/test/test-signal-multiple-loops.c index de511fc0..e68eabf6 100644 --- a/deps/libuv/test/test-signal-multiple-loops.c +++ b/deps/libuv/test/test-signal-multiple-loops.c @@ -66,14 +66,14 @@ static void increment_counter(int* counter) { static void signal1_cb(uv_signal_t* handle, int signum) { - ASSERT(signum == SIGUSR1); + ASSERT_EQ(signum, SIGUSR1); increment_counter(&signal1_cb_counter); uv_signal_stop(handle); } static void signal2_cb(uv_signal_t* handle, int signum) { - ASSERT(signum == SIGUSR2); + ASSERT_EQ(signum, SIGUSR2); increment_counter(&signal2_cb_counter); uv_signal_stop(handle); } @@ -89,25 +89,25 @@ static void signal_handling_worker(void* context) { action = (enum signal_action) (uintptr_t) context; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); /* Setup the signal watchers and start them. */ if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) { r = uv_signal_init(&loop, &signal1a); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_signal_start(&signal1a, signal1_cb, SIGUSR1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_signal_init(&loop, &signal1b); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_signal_start(&signal1b, signal1_cb, SIGUSR1); - ASSERT(r == 0); + ASSERT_OK(r); } if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) { r = uv_signal_init(&loop, &signal2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_signal_start(&signal2, signal2_cb, SIGUSR2); - ASSERT(r == 0); + ASSERT_OK(r); } /* Signal watchers are now set up. */ @@ -117,26 +117,26 @@ static void signal_handling_worker(void* context) { * will return when all signal watchers caught a signal. */ r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); /* Restart the signal watchers. */ if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) { r = uv_signal_start(&signal1a, signal1_cb, SIGUSR1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_signal_start(&signal1b, signal1_cb, SIGUSR1); - ASSERT(r == 0); + ASSERT_OK(r); } if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) { r = uv_signal_start(&signal2, signal2_cb, SIGUSR2); - ASSERT(r == 0); + ASSERT_OK(r); } /* Wait for signals once more. */ uv_sem_post(&sem); r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); /* Close the watchers. */ if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) { @@ -150,7 +150,7 @@ static void signal_handling_worker(void* context) { /* Wait for the signal watchers to close. */ r = uv_run(&loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); uv_loop_close(&loop); } @@ -173,18 +173,18 @@ static void loop_creating_worker(void* context) { loop = malloc(sizeof(*loop)); ASSERT_NOT_NULL(loop); - ASSERT(0 == uv_loop_init(loop)); + ASSERT_OK(uv_loop_init(loop)); r = uv_signal_init(loop, &signal); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_signal_start(&signal, signal_unexpected_cb, SIGTERM); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &signal, NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); uv_loop_close(loop); free(loop); @@ -229,17 +229,17 @@ TEST_IMPL(signal_multiple_loops) { int r; r = uv_sem_init(&sem, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_mutex_init(&lock); - ASSERT(r == 0); + ASSERT_OK(r); /* Create a couple of threads that create a destroy loops continuously. */ for (i = 0; i < NUM_LOOP_CREATING_THREADS; i++) { r = uv_thread_create(&loop_creating_threads[i], loop_creating_worker, NULL); - ASSERT(r == 0); + ASSERT_OK(r); } /* Create a couple of threads that actually handle signals. */ @@ -253,7 +253,7 @@ TEST_IMPL(signal_multiple_loops) { r = uv_thread_create(&signal_handling_threads[i], signal_handling_worker, (void*) (uintptr_t) action); - ASSERT(r == 0); + ASSERT_OK(r); } /* Wait until all threads have started and set up their signal watchers. */ @@ -261,9 +261,9 @@ TEST_IMPL(signal_multiple_loops) { uv_sem_wait(&sem); r = kill(getpid(), SIGUSR1); - ASSERT(r == 0); + ASSERT_OK(r); r = kill(getpid(), SIGUSR2); - ASSERT(r == 0); + ASSERT_OK(r); /* Wait for all threads to handle these signals. */ for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) @@ -277,14 +277,14 @@ TEST_IMPL(signal_multiple_loops) { pthread_sigmask(SIG_SETMASK, &sigset, NULL); r = kill(getpid(), SIGUSR1); - ASSERT(r == 0); + ASSERT_OK(r); r = kill(getpid(), SIGUSR2); - ASSERT(r == 0); + ASSERT_OK(r); /* Wait for all signal handling threads to exit. */ for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) { r = uv_thread_join(&signal_handling_threads[i]); - ASSERT(r == 0); + ASSERT_OK(r); } /* Tell all loop creating threads to stop. */ @@ -295,7 +295,7 @@ TEST_IMPL(signal_multiple_loops) { /* Wait for all loop creating threads to exit. */ for (i = 0; i < NUM_LOOP_CREATING_THREADS; i++) { r = uv_thread_join(&loop_creating_threads[i]); - ASSERT(r == 0); + ASSERT_OK(r); } uv_sem_destroy(&sem); @@ -306,13 +306,13 @@ TEST_IMPL(signal_multiple_loops) { /* The division by three reflects the fact that we spawn three different * thread groups of (NUM_SIGNAL_HANDLING_THREADS / 3) threads each. */ - ASSERT(signal1_cb_counter == 8 * (NUM_SIGNAL_HANDLING_THREADS / 3)); - ASSERT(signal2_cb_counter == 4 * (NUM_SIGNAL_HANDLING_THREADS / 3)); + ASSERT_EQ(signal1_cb_counter, 8 * (NUM_SIGNAL_HANDLING_THREADS / 3)); + ASSERT_EQ(signal2_cb_counter, 4 * (NUM_SIGNAL_HANDLING_THREADS / 3)); /* We don't know exactly how much loops will be created and destroyed, but at * least there should be 1 for every loop creating thread. */ - ASSERT(loop_creation_counter >= NUM_LOOP_CREATING_THREADS); + ASSERT_GE(loop_creation_counter, NUM_LOOP_CREATING_THREADS); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-signal-pending-on-close.c b/deps/libuv/test/test-signal-pending-on-close.c index e0b9bc30..42a42967 100644 --- a/deps/libuv/test/test-signal-pending-on-close.c +++ b/deps/libuv/test/test-signal-pending-on-close.c @@ -35,7 +35,7 @@ static int close_cb_called; static void stop_loop_cb(uv_signal_t* signal, int signum) { - ASSERT(signum == SIGPIPE); + ASSERT_EQ(signum, SIGPIPE); uv_stop(signal->loop); } @@ -50,7 +50,7 @@ static void close_cb(uv_handle_t *handle) { static void write_cb(uv_write_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == UV_EPIPE); + ASSERT_EQ(status, UV_EPIPE); free(buf); uv_close((uv_handle_t *) &pipe_hdl, close_cb); uv_close((uv_handle_t *) &signal_hdl, close_cb); @@ -62,17 +62,17 @@ TEST_IMPL(signal_pending_on_close) { uv_buf_t buffer; int r; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); - ASSERT(0 == uv_signal_init(&loop, &signal_hdl)); + ASSERT_OK(uv_signal_init(&loop, &signal_hdl)); - ASSERT(0 == uv_signal_start(&signal_hdl, signal_cb, SIGPIPE)); + ASSERT_OK(uv_signal_start(&signal_hdl, signal_cb, SIGPIPE)); - ASSERT(0 == pipe(pipefds)); + ASSERT_OK(pipe(pipefds)); - ASSERT(0 == uv_pipe_init(&loop, &pipe_hdl, 0)); + ASSERT_OK(uv_pipe_init(&loop, &pipe_hdl, 0)); - ASSERT(0 == uv_pipe_open(&pipe_hdl, pipefds[1])); + ASSERT_OK(uv_pipe_open(&pipe_hdl, pipefds[1])); /* Write data large enough so it needs loop iteration */ buf = malloc(1<<24); @@ -81,14 +81,14 @@ TEST_IMPL(signal_pending_on_close) { buffer = uv_buf_init(buf, 1<<24); r = uv_write(&write_req, (uv_stream_t *) &pipe_hdl, &buffer, 1, write_cb); - ASSERT(0 == r); + ASSERT_OK(r); /* cause a SIGPIPE on write in next iteration */ close(pipefds[0]); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(2 == close_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; @@ -96,18 +96,18 @@ TEST_IMPL(signal_pending_on_close) { TEST_IMPL(signal_close_loop_alive) { - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_signal_init(&loop, &signal_hdl)); - ASSERT(0 == uv_signal_start(&signal_hdl, stop_loop_cb, SIGPIPE)); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_signal_init(&loop, &signal_hdl)); + ASSERT_OK(uv_signal_start(&signal_hdl, stop_loop_cb, SIGPIPE)); uv_unref((uv_handle_t*) &signal_hdl); - ASSERT(0 == uv_kill(uv_os_getpid(), SIGPIPE)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_kill(uv_os_getpid(), SIGPIPE)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); uv_close((uv_handle_t*) &signal_hdl, close_cb); - ASSERT(1 == uv_loop_alive(&loop)); + ASSERT_EQ(1, uv_loop_alive(&loop)); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(1 == close_cb_called); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(&loop); return 0; diff --git a/deps/libuv/test/test-signal.c b/deps/libuv/test/test-signal.c index f8222d14..b1e24bb0 100644 --- a/deps/libuv/test/test-signal.c +++ b/deps/libuv/test/test-signal.c @@ -31,12 +31,12 @@ TEST_IMPL(kill_invalid_signum) { pid = uv_os_getpid(); - ASSERT(uv_kill(pid, -1) == UV_EINVAL); + ASSERT_EQ(uv_kill(pid, -1), UV_EINVAL); #ifdef _WIN32 /* NSIG is not available on all platforms. */ - ASSERT(uv_kill(pid, NSIG) == UV_EINVAL); + ASSERT_EQ(uv_kill(pid, NSIG), UV_EINVAL); #endif - ASSERT(uv_kill(pid, 4096) == UV_EINVAL); + ASSERT_EQ(uv_kill(pid, 4096), UV_EINVAL); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -55,20 +55,20 @@ TEST_IMPL(win32_signum_number) { loop = uv_default_loop(); uv_signal_init(loop, &signal); - ASSERT(uv_signal_start(&signal, signum_test_cb, 0) == UV_EINVAL); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGINT) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGBREAK) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGHUP) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGWINCH) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGILL) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGABRT_COMPAT) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGFPE) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGSEGV) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGTERM) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, SIGABRT) == 0); - ASSERT(uv_signal_start(&signal, signum_test_cb, -1) == UV_EINVAL); - ASSERT(uv_signal_start(&signal, signum_test_cb, NSIG) == UV_EINVAL); - ASSERT(uv_signal_start(&signal, signum_test_cb, 1024) == UV_EINVAL); + ASSERT_EQ(uv_signal_start(&signal, signum_test_cb, 0), UV_EINVAL); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGINT)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGBREAK)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGHUP)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGWINCH)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGILL)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGABRT_COMPAT)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGFPE)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGSEGV)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGTERM)); + ASSERT_OK(uv_signal_start(&signal, signum_test_cb, SIGABRT)); + ASSERT_EQ(uv_signal_start(&signal, signum_test_cb, -1), UV_EINVAL); + ASSERT_EQ(uv_signal_start(&signal, signum_test_cb, NSIG), UV_EINVAL); + ASSERT_EQ(uv_signal_start(&signal, signum_test_cb, 1024), UV_EINVAL); MAKE_VALGRIND_HAPPY(loop); return 0; } @@ -100,7 +100,7 @@ struct signal_ctx { static void signal_cb(uv_signal_t* handle, int signum) { struct signal_ctx* ctx = container_of(handle, struct signal_ctx, handle); - ASSERT(signum == ctx->signum); + ASSERT_EQ(signum, ctx->signum); if (++ctx->ncalls == NSIGNALS) { if (ctx->stop_or_close == STOP) uv_signal_stop(handle); @@ -113,8 +113,8 @@ static void signal_cb(uv_signal_t* handle, int signum) { static void signal_cb_one_shot(uv_signal_t* handle, int signum) { struct signal_ctx* ctx = container_of(handle, struct signal_ctx, handle); - ASSERT(signum == ctx->signum); - ASSERT(++ctx->ncalls == 1); + ASSERT_EQ(signum, ctx->signum); + ASSERT_EQ(1, ++ctx->ncalls); if (ctx->stop_or_close == CLOSE) uv_close((uv_handle_t*)handle, NULL); } @@ -138,18 +138,18 @@ static void start_watcher(uv_loop_t* loop, ctx->signum = signum; ctx->stop_or_close = CLOSE; ctx->one_shot = one_shot; - ASSERT(0 == uv_signal_init(loop, &ctx->handle)); + ASSERT_OK(uv_signal_init(loop, &ctx->handle)); if (one_shot) - ASSERT(0 == uv_signal_start_oneshot(&ctx->handle, signal_cb_one_shot, signum)); + ASSERT_OK(uv_signal_start_oneshot(&ctx->handle, signal_cb_one_shot, signum)); else - ASSERT(0 == uv_signal_start(&ctx->handle, signal_cb, signum)); + ASSERT_OK(uv_signal_start(&ctx->handle, signal_cb, signum)); } static void start_timer(uv_loop_t* loop, int signum, struct timer_ctx* ctx) { ctx->ncalls = 0; ctx->signum = signum; - ASSERT(0 == uv_timer_init(loop, &ctx->handle)); - ASSERT(0 == uv_timer_start(&ctx->handle, timer_cb, 5, 5)); + ASSERT_OK(uv_timer_init(loop, &ctx->handle)); + ASSERT_OK(uv_timer_start(&ctx->handle, timer_cb, 5, 5)); } @@ -162,23 +162,23 @@ TEST_IMPL(we_get_signal) { start_timer(loop, SIGCHLD, &tc); start_watcher(loop, SIGCHLD, &sc, 0); sc.stop_or_close = STOP; /* stop, don't close the signal handle */ - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == NSIGNALS); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(sc.ncalls, NSIGNALS); start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == NSIGNALS); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(sc.ncalls, NSIGNALS); sc.ncalls = 0; sc.stop_or_close = CLOSE; /* now close it when it's done */ uv_signal_start(&sc.handle, signal_cb, SIGCHLD); start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == NSIGNALS); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(sc.ncalls, NSIGNALS); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -198,13 +198,13 @@ TEST_IMPL(we_get_signals) { start_watcher(loop, SIGUSR2, sc + 3, 0); start_timer(loop, SIGUSR1, tc + 0); start_timer(loop, SIGUSR2, tc + 1); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); for (i = 0; i < ARRAY_SIZE(sc); i++) - ASSERT(sc[i].ncalls == NSIGNALS); + ASSERT_EQ(sc[i].ncalls, NSIGNALS); for (i = 0; i < ARRAY_SIZE(tc); i++) - ASSERT(tc[i].ncalls == NSIGNALS); + ASSERT_EQ(tc[i].ncalls, NSIGNALS); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -219,21 +219,21 @@ TEST_IMPL(we_get_signal_one_shot) { start_timer(loop, SIGCHLD, &tc); start_watcher(loop, SIGCHLD, &sc, 1); sc.stop_or_close = NOOP; - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == 1); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(1, sc.ncalls); start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(sc.ncalls == 1); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, sc.ncalls); sc.ncalls = 0; sc.stop_or_close = CLOSE; /* now close it when it's done */ uv_signal_start_oneshot(&sc.handle, signal_cb_one_shot, SIGCHLD); start_timer(loop, SIGCHLD, &tc); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc.ncalls == 1); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(1, sc.ncalls); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -252,10 +252,10 @@ TEST_IMPL(we_get_signals_mixed) { start_watcher(loop, SIGCHLD, sc + 1, 1); sc[0].stop_or_close = CLOSE; sc[1].stop_or_close = CLOSE; - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 1); - ASSERT(sc[1].ncalls == 1); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(1, sc[0].ncalls); + ASSERT_EQ(1, sc[1].ncalls); /* 2 one-shot, 1 normal then remove normal */ start_timer(loop, SIGCHLD, &tc); @@ -265,11 +265,11 @@ TEST_IMPL(we_get_signals_mixed) { sc[1].stop_or_close = CLOSE; start_watcher(loop, SIGCHLD, sc + 2, 0); uv_close((uv_handle_t*)&(sc[2]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 1); - ASSERT(sc[1].ncalls == 1); - ASSERT(sc[2].ncalls == 0); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(1, sc[0].ncalls); + ASSERT_EQ(1, sc[1].ncalls); + ASSERT_OK(sc[2].ncalls); /* 2 normal, 1 one-shot then remove one-shot */ start_timer(loop, SIGCHLD, &tc); @@ -279,11 +279,11 @@ TEST_IMPL(we_get_signals_mixed) { sc[1].stop_or_close = CLOSE; start_watcher(loop, SIGCHLD, sc + 2, 1); uv_close((uv_handle_t*)&(sc[2]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == NSIGNALS); - ASSERT(sc[1].ncalls == NSIGNALS); - ASSERT(sc[2].ncalls == 0); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_EQ(sc[0].ncalls, NSIGNALS); + ASSERT_EQ(sc[1].ncalls, NSIGNALS); + ASSERT_OK(sc[2].ncalls); /* 2 normal, 2 one-shot then remove 2 normal */ start_timer(loop, SIGCHLD, &tc); @@ -295,12 +295,12 @@ TEST_IMPL(we_get_signals_mixed) { sc[3].stop_or_close = CLOSE; uv_close((uv_handle_t*)&(sc[0]).handle, NULL); uv_close((uv_handle_t*)&(sc[1]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 0); - ASSERT(sc[1].ncalls == 0); - ASSERT(sc[2].ncalls == 1); - ASSERT(sc[2].ncalls == 1); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_OK(sc[0].ncalls); + ASSERT_OK(sc[1].ncalls); + ASSERT_EQ(1, sc[2].ncalls); + ASSERT_EQ(1, sc[2].ncalls); /* 1 normal, 1 one-shot, 2 normal then remove 1st normal, 2nd normal */ start_timer(loop, SIGCHLD, &tc); @@ -311,12 +311,12 @@ TEST_IMPL(we_get_signals_mixed) { sc[3].stop_or_close = CLOSE; uv_close((uv_handle_t*)&(sc[0]).handle, NULL); uv_close((uv_handle_t*)&(sc[2]).handle, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(tc.ncalls == NSIGNALS); - ASSERT(sc[0].ncalls == 0); - ASSERT(sc[1].ncalls == 1); - ASSERT(sc[2].ncalls == 0); - ASSERT(sc[3].ncalls == NSIGNALS); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(tc.ncalls, NSIGNALS); + ASSERT_OK(sc[0].ncalls); + ASSERT_EQ(1, sc[1].ncalls); + ASSERT_OK(sc[2].ncalls); + ASSERT_EQ(sc[3].ncalls, NSIGNALS); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-socket-buffer-size.c b/deps/libuv/test/test-socket-buffer-size.c index 5f072cb0..64904e93 100644 --- a/deps/libuv/test/test-socket-buffer-size.c +++ b/deps/libuv/test/test-socket-buffer-size.c @@ -40,14 +40,14 @@ static void check_buffer_size(uv_handle_t* handle) { int value; value = 0; - ASSERT(0 == uv_recv_buffer_size(handle, &value)); - ASSERT(value > 0); + ASSERT_OK(uv_recv_buffer_size(handle, &value)); + ASSERT_GT(value, 0); value = 10000; - ASSERT(0 == uv_recv_buffer_size(handle, &value)); + ASSERT_OK(uv_recv_buffer_size(handle, &value)); value = 0; - ASSERT(0 == uv_recv_buffer_size(handle, &value)); + ASSERT_OK(uv_recv_buffer_size(handle, &value)); /* linux sets double the value */ ASSERT(value == 10000 || value == 20000); } @@ -56,21 +56,21 @@ static void check_buffer_size(uv_handle_t* handle) { TEST_IMPL(socket_buffer_size) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp)); - ASSERT(0 == uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &tcp)); + ASSERT_OK(uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0)); check_buffer_size((uv_handle_t*) &tcp); uv_close((uv_handle_t*) &tcp, close_cb); - ASSERT(0 == uv_udp_init(uv_default_loop(), &udp)); - ASSERT(0 == uv_udp_bind(&udp, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_udp_init(uv_default_loop(), &udp)); + ASSERT_OK(uv_udp_bind(&udp, (struct sockaddr*) &addr, 0)); check_buffer_size((uv_handle_t*) &udp); uv_close((uv_handle_t*) &udp, close_cb); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-spawn.c b/deps/libuv/test/test-spawn.c index 5e84dcdb..bbb7cb49 100644 --- a/deps/libuv/test/test-spawn.c +++ b/deps/libuv/test/test-spawn.c @@ -65,8 +65,8 @@ static void exit_cb(uv_process_t* process, int term_signal) { printf("exit_cb\n"); exit_cb_called++; - ASSERT(exit_status == 1); - ASSERT(term_signal == 0); + ASSERT_EQ(1, exit_status); + ASSERT_OK(term_signal); uv_close((uv_handle_t*) process, close_cb); } @@ -86,9 +86,9 @@ static void kill_cb(uv_process_t* process, printf("exit_cb\n"); exit_cb_called++; #ifdef _WIN32 - ASSERT(exit_status == 1); + ASSERT_EQ(1, exit_status); #else - ASSERT(exit_status == 0); + ASSERT_OK(exit_status); #endif #if defined(__APPLE__) || defined(__MVS__) /* @@ -108,7 +108,7 @@ static void kill_cb(uv_process_t* process, * This process should be dead. */ err = uv_kill(process->pid, 0); - ASSERT(err == UV_ESRCH); + ASSERT_EQ(err, UV_ESRCH); } static void detach_failure_cb(uv_process_t* process, @@ -130,7 +130,7 @@ static void on_read(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { if (nread > 0) { output_used += nread; } else if (nread < 0) { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); uv_close((uv_handle_t*) tcp, close_cb); } } @@ -143,20 +143,20 @@ static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); uv_close((uv_handle_t*) req->handle, close_cb); } static void write_null_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); } static void init_process_options(char* test, uv_exit_cb exit_cb) { /* Note spawn_helper1 defined in test/run-tests.c */ int r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); + ASSERT_OK(r); exepath[exepath_size] = '\0'; args[0] = exepath; args[1] = test; @@ -189,9 +189,9 @@ TEST_IMPL(spawn_fails) { r = uv_spawn(uv_default_loop(), &process, &options); ASSERT(r == UV_ENOENT || r == UV_EACCES); - ASSERT(0 == uv_is_active((uv_handle_t*) &process)); + ASSERT_OK(uv_is_active((uv_handle_t*) &process)); uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -209,19 +209,19 @@ TEST_IMPL(spawn_fails_check_for_waitpid_cleanup) { r = uv_spawn(uv_default_loop(), &process, &options); ASSERT(r == UV_ENOENT || r == UV_EACCES); - ASSERT(0 == uv_is_active((uv_handle_t*) &process)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_is_active((uv_handle_t*) &process)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); /* verify the child is successfully cleaned up within libuv */ do err = waitpid(process.pid, &status, 0); while (err == -1 && errno == EINTR); - ASSERT(err == -1); - ASSERT(errno == ECHILD); + ASSERT_EQ(err, -1); + ASSERT_EQ(errno, ECHILD); uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -247,11 +247,11 @@ TEST_IMPL(spawn_empty_env) { options.env = env; env[0] = NULL; - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -264,13 +264,13 @@ TEST_IMPL(spawn_exit_code) { init_process_options("spawn_helper1", exit_cb); r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -292,18 +292,18 @@ TEST_IMPL(spawn_stdout) { options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); /* Once for process once for the pipe. */ printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0); + ASSERT_OK(strcmp("hello world\n", output)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -324,7 +324,7 @@ TEST_IMPL(spawn_stdout_to_file) { r = uv_fs_open(NULL, &fs_req, "stdout_file", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); + ASSERT_NE(r, -1); uv_fs_req_cleanup(&fs_req); file = r; @@ -336,25 +336,25 @@ TEST_IMPL(spawn_stdout_to_file) { options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); buf = uv_buf_init(output, sizeof(output)); r = uv_fs_read(NULL, &fs_req, file, &buf, 1, 0, NULL); - ASSERT(r == 12); + ASSERT_EQ(12, r); uv_fs_req_cleanup(&fs_req); r = uv_fs_close(NULL, &fs_req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&fs_req); printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0); + ASSERT_OK(strcmp("hello world\n", output)); /* Cleanup. */ unlink("stdout_file"); @@ -378,7 +378,7 @@ TEST_IMPL(spawn_stdout_and_stderr_to_file) { r = uv_fs_open(NULL, &fs_req, "stdout_file", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); + ASSERT_NE(r, -1); uv_fs_req_cleanup(&fs_req); file = r; @@ -392,25 +392,25 @@ TEST_IMPL(spawn_stdout_and_stderr_to_file) { options.stdio_count = 3; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); buf = uv_buf_init(output, sizeof(output)); r = uv_fs_read(NULL, &fs_req, file, &buf, 1, 0, NULL); - ASSERT(r == 27); + ASSERT_EQ(27, r); uv_fs_req_cleanup(&fs_req); r = uv_fs_close(NULL, &fs_req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&fs_req); printf("output is: %s", output); - ASSERT(strcmp("hello world\nhello errworld\n", output) == 0); + ASSERT_OK(strcmp("hello world\nhello errworld\n", output)); /* Cleanup. */ unlink("stdout_file"); @@ -440,10 +440,10 @@ TEST_IMPL(spawn_stdout_and_stderr_to_file2) { O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); + ASSERT_NE(r, -1); uv_fs_req_cleanup(&fs_req); file = dup2(r, STDERR_FILENO); - ASSERT(file != -1); + ASSERT_NE(file, -1); options.stdio = stdio; options.stdio[0].flags = UV_IGNORE; @@ -454,25 +454,25 @@ TEST_IMPL(spawn_stdout_and_stderr_to_file2) { options.stdio_count = 3; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); buf = uv_buf_init(output, sizeof(output)); r = uv_fs_read(NULL, &fs_req, file, &buf, 1, 0, NULL); - ASSERT(r == 27); + ASSERT_EQ(27, r); uv_fs_req_cleanup(&fs_req); r = uv_fs_close(NULL, &fs_req, file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&fs_req); printf("output is: %s", output); - ASSERT(strcmp("hello world\nhello errworld\n", output) == 0); + ASSERT_OK(strcmp("hello world\nhello errworld\n", output)); /* Cleanup. */ unlink("stdout_file"); @@ -507,18 +507,18 @@ TEST_IMPL(spawn_stdout_and_stderr_to_file_swap) { O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); + ASSERT_NE(r, -1); uv_fs_req_cleanup(&fs_req); stdout_file = dup2(r, STDOUT_FILENO); - ASSERT(stdout_file != -1); + ASSERT_NE(stdout_file, -1); /* open 'stderr_file' and replace STDERR_FILENO with it */ r = uv_fs_open(NULL, &fs_req, "stderr_file", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL); - ASSERT(r != -1); + ASSERT_NE(r, -1); uv_fs_req_cleanup(&fs_req); stderr_file = dup2(r, STDERR_FILENO); - ASSERT(stderr_file != -1); + ASSERT_NE(stderr_file, -1); /* now we're going to swap them: the child process' stdout will be our * stderr_file and vice versa */ @@ -531,39 +531,39 @@ TEST_IMPL(spawn_stdout_and_stderr_to_file_swap) { options.stdio_count = 3; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); buf = uv_buf_init(output, sizeof(output)); /* check the content of stdout_file */ r = uv_fs_read(NULL, &fs_req, stdout_file, &buf, 1, 0, NULL); - ASSERT(r >= 15); + ASSERT_GE(r, 15); uv_fs_req_cleanup(&fs_req); r = uv_fs_close(NULL, &fs_req, stdout_file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&fs_req); printf("output is: %s", output); - ASSERT(strncmp("hello errworld\n", output, 15) == 0); + ASSERT_OK(strncmp("hello errworld\n", output, 15)); /* check the content of stderr_file */ r = uv_fs_read(NULL, &fs_req, stderr_file, &buf, 1, 0, NULL); - ASSERT(r >= 12); + ASSERT_GE(r, 12); uv_fs_req_cleanup(&fs_req); r = uv_fs_close(NULL, &fs_req, stderr_file, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_fs_req_cleanup(&fs_req); printf("output is: %s", output); - ASSERT(strncmp("hello world\n", output, 12) == 0); + ASSERT_OK(strncmp("hello world\n", output, 12)); /* Cleanup. */ unlink("stdout_file"); @@ -598,22 +598,22 @@ TEST_IMPL(spawn_stdin) { options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); buf.base = buffer; buf.len = sizeof(buffer); r = uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 3); /* Once for process twice for the pipe. */ - ASSERT(strcmp(buffer, output) == 0); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(3, close_cb_called); /* Once for process twice for the pipe. */ + ASSERT_OK(strcmp(buffer, output)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -637,18 +637,18 @@ TEST_IMPL(spawn_stdio_greater_than_3) { options.stdio_count = 4; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &pipe, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); /* Once for process once for the pipe. */ printf("output from stdio[3] is: %s", output); - ASSERT(strcmp("fourth stdio!\n", output) == 0); + ASSERT_OK(strcmp("fourth stdio!\n", output)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -661,7 +661,7 @@ int spawn_tcp_server_helper(void) { int r; r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 handle = _get_osfhandle(3); @@ -669,13 +669,13 @@ int spawn_tcp_server_helper(void) { handle = 3; #endif r = uv_tcp_open(&tcp, handle); - ASSERT(r == 0); + ASSERT_OK(r); /* Make sure that we can listen on a socket that was * passed down from the parent process */ r = uv_listen((uv_stream_t*) &tcp, SOMAXCONN, NULL); - ASSERT(r == 0); + ASSERT_OK(r); return 1; } @@ -692,21 +692,21 @@ TEST_IMPL(spawn_tcp_server) { init_process_options("spawn_tcp_server_helper", exit_cb); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); fd = -1; r = uv_tcp_init_ex(uv_default_loop(), &tcp_server, AF_INET); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 r = uv_fileno((uv_handle_t*) &tcp_server, &handle); fd = _open_osfhandle((intptr_t) handle, 0); #else r = uv_fileno((uv_handle_t*) &tcp_server, &fd); #endif - ASSERT(r == 0); - ASSERT(fd > 0); + ASSERT_OK(r); + ASSERT_GT(fd, 0); options.stdio = stdio; options.stdio[0].flags = UV_INHERIT_FD; @@ -720,13 +720,13 @@ TEST_IMPL(spawn_tcp_server) { options.stdio_count = 4; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -742,13 +742,13 @@ TEST_IMPL(spawn_ignored_stdio) { options.stdio_count = 0; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -761,19 +761,19 @@ TEST_IMPL(spawn_and_kill) { init_process_options("spawn_helper4", kill_cb); r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 500, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process and once for timer. */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); /* Once for process and once for timer. */ MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -795,25 +795,25 @@ TEST_IMPL(spawn_preserve_env) { options.stdio_count = 2; r = putenv("ENV_TEST=testval"); - ASSERT(r == 0); + ASSERT_OK(r); /* Explicitly set options.env to NULL to test for env clobbering. */ options.env = NULL; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); printf("output is: %s", output); - ASSERT(strcmp("testval", output) == 0); + ASSERT_OK(strcmp("testval", output)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -828,22 +828,22 @@ TEST_IMPL(spawn_detached) { options.flags |= UV_PROCESS_DETACHED; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*) &process); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 0); + ASSERT_OK(exit_cb_called); - ASSERT(process.pid == uv_process_get_pid(&process)); + ASSERT_EQ(process.pid, uv_process_get_pid(&process)); r = uv_kill(process.pid, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_kill(process.pid, SIGTERM); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -861,13 +861,13 @@ TEST_IMPL(spawn_and_kill_with_std) { init_process_options("spawn_helper4", kill_cb); r = uv_pipe_init(uv_default_loop(), &in, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(uv_default_loop(), &out, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(uv_default_loop(), &err, 0); - ASSERT(r == 0); + ASSERT_OK(r); options.stdio = stdio; options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; @@ -879,29 +879,29 @@ TEST_IMPL(spawn_and_kill_with_std) { options.stdio_count = 3; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init(message, sizeof message); r = uv_write(&write, (uv_stream_t*) &in, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &err, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 500, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 5); /* process x 1, timer x 1, stdio x 3. */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(5, close_cb_called); /* process x 1, timer x 1, stdio x 3. */ MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -928,27 +928,27 @@ TEST_IMPL(spawn_and_ping) { options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); /* Sending signum == 0 should check if the * child process is still alive, not kill it. */ r = uv_process_kill(&process, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 0); + ASSERT_OK(exit_cb_called); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(strcmp(output, "TEST") == 0); + ASSERT_EQ(1, exit_cb_called); + ASSERT_OK(strcmp(output, "TEST")); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -975,27 +975,27 @@ TEST_IMPL(spawn_same_stdout_stderr) { options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); /* Sending signum == 0 should check if the * child process is still alive, not kill it. */ r = uv_process_kill(&process, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 0); + ASSERT_OK(exit_cb_called); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(strcmp(output, "TEST") == 0); + ASSERT_EQ(1, exit_cb_called); + ASSERT_OK(strcmp(output, "TEST")); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1019,15 +1019,15 @@ TEST_IMPL(spawn_closed_process_io) { close(0); /* Close process stdin. */ - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); buf = uv_buf_init(buffer, sizeof(buffer)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb)); + ASSERT_OK(uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* process, child stdin */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); /* process, child stdin */ MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1049,39 +1049,39 @@ TEST_IMPL(kill) { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGTERM); - ASSERT(0 == pthread_sigmask(SIG_BLOCK, &set, NULL)); + ASSERT_OK(pthread_sigmask(SIG_BLOCK, &set, NULL)); } - ASSERT(SIG_ERR != signal(SIGTERM, SIG_IGN)); + ASSERT_NE(SIG_ERR, signal(SIGTERM, SIG_IGN)); #endif r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGTERM); - ASSERT(0 == pthread_sigmask(SIG_UNBLOCK, &set, NULL)); + ASSERT_OK(pthread_sigmask(SIG_UNBLOCK, &set, NULL)); } - ASSERT(SIG_ERR != signal(SIGTERM, SIG_DFL)); + ASSERT_NE(SIG_ERR, signal(SIGTERM, SIG_DFL)); #endif /* Sending signum == 0 should check if the * child process is still alive, not kill it. */ r = uv_kill(process.pid, 0); - ASSERT(r == 0); + ASSERT_OK(r); /* Kill the process. */ r = uv_kill(process.pid, SIGTERM); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1119,21 +1119,21 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { 65536, 0, NULL); - ASSERT(pipe_handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(pipe_handle, INVALID_HANDLE_VALUE); r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); /* Once for process once for the pipe. */ printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0); + ASSERT_OK(strcmp("hello world\n", output)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1197,7 +1197,7 @@ TEST_IMPL(argument_escaping) { cracked = CommandLineToArgvW(command_line, &num_args); for (i = 0; i < num_args; ++i) { wprintf(L"%d: %s\t%s\n", i, test_str[i], cracked[i]); - ASSERT(wcscmp(test_str[i], cracked[i]) == 0); + ASSERT_OK(wcscmp(test_str[i], cracked[i])); } LocalFree(cracked); @@ -1207,19 +1207,19 @@ TEST_IMPL(argument_escaping) { free(test_output); result = make_program_args(verbatim, 1, &verbatim_output); - ASSERT(result == 0); + ASSERT_OK(result); result = make_program_args(verbatim, 0, &non_verbatim_output); - ASSERT(result == 0); + ASSERT_OK(result); wprintf(L" verbatim_output: %s\n", verbatim_output); wprintf(L"non_verbatim_output: %s\n", non_verbatim_output); - ASSERT(wcscmp(verbatim_output, - L"cmd.exe /c c:\\path\\to\\node.exe --eval " - L"\"require('c:\\\\path\\\\to\\\\test.js')\"") == 0); - ASSERT(wcscmp(non_verbatim_output, - L"cmd.exe /c \"c:\\path\\to\\node.exe --eval " - L"\\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"") == 0); + ASSERT_OK(wcscmp(verbatim_output, + L"cmd.exe /c c:\\path\\to\\node.exe --eval " + L"\"require('c:\\\\path\\\\to\\\\test.js')\"")); + ASSERT_OK(wcscmp(non_verbatim_output, + L"cmd.exe /c \"c:\\path\\to\\node.exe --eval " + L"\\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"")); free(verbatim_output); free(non_verbatim_output); @@ -1303,7 +1303,7 @@ TEST_IMPL(environment_creation) { } result = make_program_env(environment, &env); - ASSERT(result == 0); + ASSERT_OK(result); for (str = env, prev = NULL; *str; prev = str, str += wcslen(str) + 1) { int found = 0; @@ -1327,7 +1327,7 @@ TEST_IMPL(environment_creation) { } if (prev) { /* verify sort order */ #if !defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR) - ASSERT(CompareStringOrdinal(prev, -1, str, -1, TRUE) == 1); + ASSERT_EQ(1, CompareStringOrdinal(prev, -1, str, -1, TRUE)); #endif } ASSERT(found); /* verify that we expected this variable */ @@ -1359,9 +1359,37 @@ TEST_IMPL(spawn_with_an_odd_path) { options.file = options.args[0] = "program-that-had-better-not-exist"; r = uv_spawn(uv_default_loop(), &process, &options); ASSERT(r == UV_ENOENT || r == UV_EACCES); - ASSERT(0 == uv_is_active((uv_handle_t*) &process)); + ASSERT_OK(uv_is_active((uv_handle_t*) &process)); uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + + MAKE_VALGRIND_HAPPY(uv_default_loop()); + return 0; +} + + +TEST_IMPL(spawn_no_path) { + char* env[1]; + WCHAR* old_path = NULL; + DWORD old_path_len; + + if ((old_path_len = GetEnvironmentVariableW(L"PATH", NULL, 0)) > 0) { + old_path = malloc(old_path_len * sizeof(WCHAR)); + GetEnvironmentVariableW(L"PATH", old_path, old_path_len); + SetEnvironmentVariableW(L"PATH", NULL); + } + + init_process_options("spawn_helper1", exit_cb); + options.env = env; + env[0] = NULL; + + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); + + SetEnvironmentVariableW(L"PATH", old_path); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1398,13 +1426,13 @@ TEST_IMPL(spawn_setuid_setgid) { if (r == UV_EACCES) RETURN_SKIP("user 'nobody' cannot access the test runner"); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1424,8 +1452,8 @@ TEST_IMPL(spawn_setuid_fails) { struct passwd* pw; pw = getpwnam("nobody"); ASSERT_NOT_NULL(pw); - ASSERT(0 == setgid(pw->pw_gid)); - ASSERT(0 == setuid(pw->pw_uid)); + ASSERT_OK(setgid(pw->pw_gid)); + ASSERT_OK(setuid(pw->pw_uid)); } #endif /* !__PASE__ */ @@ -1449,15 +1477,15 @@ TEST_IMPL(spawn_setuid_fails) { r = uv_spawn(uv_default_loop(), &process, &options); #if defined(__CYGWIN__) - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); #else - ASSERT(r == UV_EPERM); + ASSERT_EQ(r, UV_EPERM); #endif r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); + ASSERT_OK(close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1475,8 +1503,8 @@ TEST_IMPL(spawn_setgid_fails) { struct passwd* pw; pw = getpwnam("nobody"); ASSERT_NOT_NULL(pw); - ASSERT(0 == setgid(pw->pw_gid)); - ASSERT(0 == setuid(pw->pw_uid)); + ASSERT_OK(setgid(pw->pw_gid)); + ASSERT_OK(setuid(pw->pw_uid)); } #endif /* !__PASE__ */ @@ -1494,15 +1522,15 @@ TEST_IMPL(spawn_setgid_fails) { r = uv_spawn(uv_default_loop(), &process, &options); #if defined(__CYGWIN__) || defined(__MVS__) - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); #else - ASSERT(r == UV_EPERM); + ASSERT_EQ(r, UV_EPERM); #endif r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); + ASSERT_OK(close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1528,12 +1556,12 @@ TEST_IMPL(spawn_setuid_fails) { options.uid = (uv_uid_t) -42424242; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOTSUP); + ASSERT_EQ(r, UV_ENOTSUP); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); + ASSERT_OK(close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1549,12 +1577,12 @@ TEST_IMPL(spawn_setgid_fails) { options.gid = (uv_gid_t) -42424242; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == UV_ENOTSUP); + ASSERT_EQ(r, UV_ENOTSUP); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); + ASSERT_OK(close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1564,12 +1592,12 @@ TEST_IMPL(spawn_setgid_fails) { TEST_IMPL(spawn_auto_unref) { init_process_options("spawn_helper1", NULL); - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_is_closing((uv_handle_t*) &process)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_is_closing((uv_handle_t*) &process)); uv_close((uv_handle_t*) &process, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(1 == uv_is_closing((uv_handle_t*) &process)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, uv_is_closing((uv_handle_t*) &process)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } @@ -1594,13 +1622,13 @@ TEST_IMPL(spawn_fs_open) { #endif r = uv_fs_open(NULL, &fs_req, dev_null, O_RDWR, 0, NULL); - ASSERT(r != -1); + ASSERT_NE(r, -1); fd = uv_get_osfhandle((uv_file) fs_req.result); uv_fs_req_cleanup(&fs_req); init_process_options("spawn_helper8", exit_cb); - ASSERT(0 == uv_pipe_init(uv_default_loop(), &in, 0)); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &in, 0)); options.stdio = stdio; options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; @@ -1609,29 +1637,35 @@ TEST_IMPL(spawn_fs_open) { /* make an inheritable copy */ #ifdef _WIN32 - ASSERT(0 != DuplicateHandle(GetCurrentProcess(), fd, GetCurrentProcess(), &dup_fd, - 0, /* inherit */ TRUE, DUPLICATE_SAME_ACCESS)); + ASSERT_NE(0, DuplicateHandle(GetCurrentProcess(), fd, GetCurrentProcess(), &dup_fd, + 0, /* inherit */ TRUE, DUPLICATE_SAME_ACCESS)); kernelbase_module = GetModuleHandleA("kernelbase.dll"); pCompareObjectHandles = (sCompareObjectHandles) GetProcAddress(kernelbase_module, "CompareObjectHandles"); - ASSERT(pCompareObjectHandles == NULL || pCompareObjectHandles(fd, dup_fd)); + ASSERT_NE(pCompareObjectHandles == NULL || + pCompareObjectHandles(fd, dup_fd), + 0); #else dup_fd = dup(fd); #endif - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); buf = uv_buf_init((char*) &fd, sizeof(fd)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_null_cb)); + ASSERT_OK(uv_write(&write_req, + (uv_stream_t*) &in, + &buf, + 1, + write_null_cb)); buf = uv_buf_init((char*) &dup_fd, sizeof(fd)); - ASSERT(0 == uv_write(&write_req2, (uv_stream_t*) &in, &buf, 1, write_cb)); + ASSERT_OK(uv_write(&write_req2, (uv_stream_t*) &in, &buf, 1, write_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(0 == uv_fs_close(NULL, &fs_req, r, NULL)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_fs_close(NULL, &fs_req, r, NULL)); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 2); /* One for `in`, one for process */ + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(2, close_cb_called); /* One for `in`, one for process */ MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1647,9 +1681,9 @@ TEST_IMPL(closed_fd_events) { bufs[0] = uv_buf_init("", 1); /* create a pipe and share it with a child process */ - ASSERT(0 == uv_pipe(fd, 0, 0)); - ASSERT(fd[0] > 2); - ASSERT(fd[1] > 2); + ASSERT_OK(uv_pipe(fd, 0, 0)); + ASSERT_GT(fd[0], 2); + ASSERT_GT(fd[1], 2); /* spawn_helper4 blocks indefinitely. */ init_process_options("spawn_helper4", exit_cb); @@ -1660,49 +1694,51 @@ TEST_IMPL(closed_fd_events) { options.stdio[1].flags = UV_IGNORE; options.stdio[2].flags = UV_IGNORE; - ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); uv_unref((uv_handle_t*) &process); /* read from the pipe with uv */ - ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); - ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); + ASSERT_OK(uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); + ASSERT_OK(uv_pipe_open(&pipe_handle, fd[0])); /* uv_pipe_open() takes ownership of the file descriptor. */ fd[0] = -1; - ASSERT(0 == uv_read_start((uv_stream_t*) &pipe_handle, on_alloc, on_read_once)); + ASSERT_OK(uv_read_start((uv_stream_t*) &pipe_handle, + on_alloc, + on_read_once)); - ASSERT(1 == uv_fs_write(NULL, &req, fd[1], bufs, 1, -1, NULL)); - ASSERT(req.result == 1); + ASSERT_EQ(1, uv_fs_write(NULL, &req, fd[1], bufs, 1, -1, NULL)); + ASSERT_EQ(1, req.result); uv_fs_req_cleanup(&req); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); /* should have received just one byte */ - ASSERT(output_used == 1); + ASSERT_EQ(1, output_used); /* close the pipe and see if we still get events */ uv_close((uv_handle_t*) &pipe_handle, close_cb); - ASSERT(1 == uv_fs_write(NULL, &req, fd[1], bufs, 1, -1, NULL)); - ASSERT(req.result == 1); + ASSERT_EQ(1, uv_fs_write(NULL, &req, fd[1], bufs, 1, -1, NULL)); + ASSERT_EQ(1, req.result); uv_fs_req_cleanup(&req); - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_counter_cb, 10, 0)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_counter_cb, 10, 0)); /* see if any spurious events interrupt the timer */ if (1 == uv_run(uv_default_loop(), UV_RUN_ONCE)) /* have to run again to really trigger the timer */ - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(timer_counter == 1); + ASSERT_EQ(1, timer_counter); /* cleanup */ - ASSERT(0 == uv_process_kill(&process, SIGTERM)); + ASSERT_OK(uv_process_kill(&process, SIGTERM)); #ifdef _WIN32 - ASSERT(0 == _close(fd[1])); + ASSERT_OK(_close(fd[1])); #else - ASSERT(0 == close(fd[1])); + ASSERT_OK(close(fd[1])); #endif MAKE_VALGRIND_HAPPY(uv_default_loop()); @@ -1767,13 +1803,13 @@ TEST_IMPL(spawn_reads_child_path) { options.env = env; r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1799,27 +1835,27 @@ TEST_IMPL(spawn_inherit_streams) { init_process_options("spawn_helper9", exit_cb); loop = uv_default_loop(); - ASSERT(uv_pipe_init(loop, &pipe_stdin_child, 0) == 0); - ASSERT(uv_pipe_init(loop, &pipe_stdout_child, 0) == 0); - ASSERT(uv_pipe_init(loop, &pipe_stdin_parent, 0) == 0); - ASSERT(uv_pipe_init(loop, &pipe_stdout_parent, 0) == 0); + ASSERT_OK(uv_pipe_init(loop, &pipe_stdin_child, 0)); + ASSERT_OK(uv_pipe_init(loop, &pipe_stdout_child, 0)); + ASSERT_OK(uv_pipe_init(loop, &pipe_stdin_parent, 0)); + ASSERT_OK(uv_pipe_init(loop, &pipe_stdout_parent, 0)); - ASSERT(uv_pipe(fds_stdin, 0, 0) == 0); - ASSERT(uv_pipe(fds_stdout, 0, 0) == 0); + ASSERT_OK(uv_pipe(fds_stdin, 0, 0)); + ASSERT_OK(uv_pipe(fds_stdout, 0, 0)); - ASSERT(uv_pipe_open(&pipe_stdin_child, fds_stdin[0]) == 0); - ASSERT(uv_pipe_open(&pipe_stdout_child, fds_stdout[1]) == 0); - ASSERT(uv_pipe_open(&pipe_stdin_parent, fds_stdin[1]) == 0); - ASSERT(uv_pipe_open(&pipe_stdout_parent, fds_stdout[0]) == 0); + ASSERT_OK(uv_pipe_open(&pipe_stdin_child, fds_stdin[0])); + ASSERT_OK(uv_pipe_open(&pipe_stdout_child, fds_stdout[1])); + ASSERT_OK(uv_pipe_open(&pipe_stdin_parent, fds_stdin[1])); + ASSERT_OK(uv_pipe_open(&pipe_stdout_parent, fds_stdout[0])); ASSERT(uv_is_readable((uv_stream_t*) &pipe_stdin_child)); ASSERT(uv_is_writable((uv_stream_t*) &pipe_stdout_child)); ASSERT(uv_is_writable((uv_stream_t*) &pipe_stdin_parent)); ASSERT(uv_is_readable((uv_stream_t*) &pipe_stdout_parent)); /* Some systems (SVR4) open a bidirectional pipe, most don't. */ bidir = uv_is_writable((uv_stream_t*) &pipe_stdin_child); - ASSERT(uv_is_readable((uv_stream_t*) &pipe_stdout_child) == bidir); - ASSERT(uv_is_readable((uv_stream_t*) &pipe_stdin_parent) == bidir); - ASSERT(uv_is_writable((uv_stream_t*) &pipe_stdout_parent) == bidir); + ASSERT_EQ(uv_is_readable((uv_stream_t*) &pipe_stdout_child), bidir); + ASSERT_EQ(uv_is_readable((uv_stream_t*) &pipe_stdin_parent), bidir); + ASSERT_EQ(uv_is_writable((uv_stream_t*) &pipe_stdout_parent), bidir); child_stdio[0].flags = UV_INHERIT_STREAM; child_stdio[0].data.stream = (uv_stream_t *) &pipe_stdin_child; @@ -1830,7 +1866,7 @@ TEST_IMPL(spawn_inherit_streams) { options.stdio = child_stdio; options.stdio_count = 2; - ASSERT(uv_spawn(loop, &child_req, &options) == 0); + ASSERT_OK(uv_spawn(loop, &child_req, &options)); uv_close((uv_handle_t*) &pipe_stdin_child, NULL); uv_close((uv_handle_t*) &pipe_stdout_child, NULL); @@ -1845,19 +1881,19 @@ TEST_IMPL(spawn_inherit_streams) { &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &pipe_stdout_parent, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 3); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(3, close_cb_called); r = memcmp(ubuf, output, sizeof ubuf); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -1898,7 +1934,7 @@ TEST_IMPL(spawn_exercise_sigchld_issue) { init_process_options("spawn_helper1", exit_cb); r = uv_spawn(uv_default_loop(), &process, &options); - ASSERT_EQ(r, 0); + ASSERT_OK(r); // This test exercises a bug in the darwin kernel that causes SIGCHLD not to // be delivered sometimes. Calling posix_spawn many times increases the @@ -1917,10 +1953,10 @@ TEST_IMPL(spawn_exercise_sigchld_issue) { } r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(exit_cb_called, 1); - ASSERT_EQ(close_cb_called, 101); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(101, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -1939,14 +1975,14 @@ void spawn_stdin_stdout(void) { if (r == 0) { return; } - ASSERT(r > 0); + ASSERT_GT(r, 0); c = r; pbuf = buf; while (c) { do { w = write(1, pbuf, (size_t)c); } while (w == -1 && errno == EINTR); - ASSERT(w >= 0); + ASSERT_GE(w, 0); pbuf = pbuf + w; c = c - w; } @@ -1958,14 +1994,14 @@ void spawn_stdin_stdout(void) { char* pbuf; HANDLE h_stdin = GetStdHandle(STD_INPUT_HANDLE); HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE); - ASSERT(h_stdin != INVALID_HANDLE_VALUE); - ASSERT(h_stdout != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(h_stdin, INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(h_stdout, INVALID_HANDLE_VALUE); for (;;) { DWORD n_read; DWORD n_written; DWORD to_write; if (!ReadFile(h_stdin, buf, sizeof buf, &n_read, NULL)) { - ASSERT(GetLastError() == ERROR_BROKEN_PIPE); + ASSERT_EQ(GetLastError(), ERROR_BROKEN_PIPE); return; } to_write = n_read; @@ -1985,7 +2021,7 @@ TEST_IMPL(spawn_relative_path) { init_process_options("spawn_helper1", exit_cb); exepath_size = sizeof(exepath) - 2; - ASSERT_EQ(0, uv_exepath(exepath, &exepath_size)); + ASSERT_OK(uv_exepath(exepath, &exepath_size)); exepath[exepath_size] = '\0'; /* Poor man's basename(3). */ @@ -2003,8 +2039,8 @@ TEST_IMPL(spawn_relative_path) { options.cwd = exepath; options.file = options.args[0] = sep + 1; - ASSERT_EQ(0, uv_spawn(uv_default_loop(), &process, &options)); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_spawn(uv_default_loop(), &process, &options)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT_EQ(1, exit_cb_called); ASSERT_EQ(1, close_cb_called); diff --git a/deps/libuv/test/test-stdio-over-pipes.c b/deps/libuv/test/test-stdio-over-pipes.c index 1b7f1729..c41040ee 100644 --- a/deps/libuv/test/test-stdio-over-pipes.c +++ b/deps/libuv/test/test-stdio-over-pipes.c @@ -52,8 +52,8 @@ static void exit_cb(uv_process_t* process, int term_signal) { printf("exit_cb\n"); exit_cb_called++; - ASSERT(exit_status == 0); - ASSERT(term_signal == 0); + ASSERT_OK(exit_status); + ASSERT_OK(term_signal); uv_close((uv_handle_t*)process, close_cb); uv_close((uv_handle_t*)&in, close_cb); uv_close((uv_handle_t*)&out, close_cb); @@ -62,7 +62,7 @@ static void exit_cb(uv_process_t* process, static void init_process_options(char* test, uv_exit_cb exit_cb) { int r = uv_exepath(exepath, &exepath_size); - ASSERT(r == 0); + ASSERT_OK(r); exepath[exepath_size] = '\0'; args[0] = exepath; args[1] = test; @@ -104,11 +104,11 @@ static void on_read(uv_stream_t* pipe, ssize_t nread, const uv_buf_t* rdbuf) { if (nread > 0) { output_used += nread; if (output_used % 12 == 0) { - ASSERT(memcmp("hello world\n", output, 12) == 0); + ASSERT_OK(memcmp("hello world\n", output, 12)); wrbuf = uv_buf_init(output, 12); req = malloc(sizeof(*req)); r = uv_write(req, (uv_stream_t*) &in, &wrbuf, 1, after_write); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -140,20 +140,20 @@ static void test_stdio_over_pipes(int overlapped) { options.stdio_count = 3; r = uv_spawn(loop, &process, &options); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(on_read_cb_called > 1); - ASSERT(after_write_cb_called == 2); - ASSERT(exit_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(memcmp("hello world\nhello world\n", output, 24) == 0); - ASSERT(output_used == 24); + ASSERT_GT(on_read_cb_called, 1); + ASSERT_EQ(2, after_write_cb_called); + ASSERT_EQ(1, exit_cb_called); + ASSERT_EQ(3, close_cb_called); + ASSERT_OK(memcmp("hello world\nhello world\n", output, 24)); + ASSERT_EQ(24, output_used); MAKE_VALGRIND_HAPPY(loop); } @@ -179,8 +179,8 @@ static uv_pipe_t stdin_pipe2; static uv_pipe_t stdout_pipe2; static void on_pipe_read(uv_stream_t* pipe, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread > 0); - ASSERT(memcmp("hello world\n", buf->base, nread) == 0); + ASSERT_GT(nread, 0); + ASSERT_OK(memcmp("hello world\n", buf->base, nread)); on_pipe_read_called++; free(buf->base); @@ -190,7 +190,7 @@ static void on_pipe_read(uv_stream_t* pipe, ssize_t nread, const uv_buf_t* buf) static void after_pipe_write(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); after_write_called++; } @@ -222,17 +222,17 @@ int stdio_over_pipes_helper(void) { int r; uv_loop_t* loop = uv_default_loop(); - ASSERT(UV_NAMED_PIPE == uv_guess_handle(0)); - ASSERT(UV_NAMED_PIPE == uv_guess_handle(1)); + ASSERT_EQ(UV_NAMED_PIPE, uv_guess_handle(0)); + ASSERT_EQ(UV_NAMED_PIPE, uv_guess_handle(1)); r = uv_pipe_init(loop, &stdin_pipe1, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(loop, &stdout_pipe1, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(loop, &stdin_pipe2, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_pipe_init(loop, &stdout_pipe2, 0); - ASSERT(r == 0); + ASSERT_OK(r); uv_pipe_open(&stdin_pipe1, 0); uv_pipe_open(&stdout_pipe1, 1); @@ -256,15 +256,15 @@ int stdio_over_pipes_helper(void) { &buf[i], 1, after_pipe_write); - ASSERT(r == 0); + ASSERT_OK(r); } notify_parent_process(); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(after_write_called == 7 * (j + 1)); - ASSERT(on_pipe_read_called == j); - ASSERT(close_cb_called == 0); + ASSERT_EQ(after_write_called, 7 * (j + 1)); + ASSERT_EQ(on_pipe_read_called, j); + ASSERT_OK(close_cb_called); uv_ref((uv_handle_t*) &stdout_pipe1); uv_ref((uv_handle_t*) &stdin_pipe1); @@ -274,13 +274,13 @@ int stdio_over_pipes_helper(void) { r = uv_read_start((uv_stream_t*) (j == 0 ? &stdin_pipe1 : &stdin_pipe2), on_read_alloc, on_pipe_read); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(after_write_called == 7 * (j + 1)); - ASSERT(on_pipe_read_called == j + 1); - ASSERT(close_cb_called == 0); + ASSERT_EQ(after_write_called, 7 * (j + 1)); + ASSERT_EQ(on_pipe_read_called, j + 1); + ASSERT_OK(close_cb_called); } uv_close((uv_handle_t*)&stdin_pipe1, close_cb); @@ -290,9 +290,9 @@ int stdio_over_pipes_helper(void) { uv_run(loop, UV_RUN_DEFAULT); - ASSERT(after_write_called == 14); - ASSERT(on_pipe_read_called == 2); - ASSERT(close_cb_called == 4); + ASSERT_EQ(14, after_write_called); + ASSERT_EQ(2, on_pipe_read_called); + ASSERT_EQ(4, close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-strscpy.c b/deps/libuv/test/test-strscpy.c index 4e7db6ff..b4699cff 100644 --- a/deps/libuv/test/test-strscpy.c +++ b/deps/libuv/test/test-strscpy.c @@ -29,25 +29,25 @@ TEST_IMPL(strscpy) { char d[4]; - ASSERT(0 == uv__strscpy(d, "", 0)); - ASSERT(0 == uv__strscpy(d, "x", 0)); + ASSERT_OK(uv__strscpy(d, "", 0)); + ASSERT_OK(uv__strscpy(d, "x", 0)); memset(d, 0, sizeof(d)); - ASSERT(1 == uv__strscpy(d, "x", sizeof(d))); - ASSERT(0 == memcmp(d, "x\0\0", sizeof(d))); + ASSERT_EQ(1, uv__strscpy(d, "x", sizeof(d))); + ASSERT_OK(memcmp(d, "x\0\0", sizeof(d))); memset(d, 0, sizeof(d)); - ASSERT(2 == uv__strscpy(d, "xy", sizeof(d))); - ASSERT(0 == memcmp(d, "xy\0", sizeof(d))); + ASSERT_EQ(2, uv__strscpy(d, "xy", sizeof(d))); + ASSERT_OK(memcmp(d, "xy\0", sizeof(d))); - ASSERT(3 == uv__strscpy(d, "xyz", sizeof(d))); - ASSERT(0 == memcmp(d, "xyz", sizeof(d))); + ASSERT_EQ(3, uv__strscpy(d, "xyz", sizeof(d))); + ASSERT_OK(memcmp(d, "xyz", sizeof(d))); - ASSERT(UV_E2BIG == uv__strscpy(d, "xyzz", sizeof(d))); - ASSERT(0 == memcmp(d, "xyz", sizeof(d))); + ASSERT_EQ(UV_E2BIG, uv__strscpy(d, "xyzz", sizeof(d))); + ASSERT_OK(memcmp(d, "xyz", sizeof(d))); - ASSERT(UV_E2BIG == uv__strscpy(d, "xyzzy", sizeof(d))); - ASSERT(0 == memcmp(d, "xyz", sizeof(d))); + ASSERT_EQ(UV_E2BIG, uv__strscpy(d, "xyzzy", sizeof(d))); + ASSERT_OK(memcmp(d, "xyz", sizeof(d))); return 0; } diff --git a/deps/libuv/test/test-strtok.c b/deps/libuv/test/test-strtok.c index 6c3d8359..f4e6cdf8 100644 --- a/deps/libuv/test/test-strtok.c +++ b/deps/libuv/test/test-strtok.c @@ -56,7 +56,7 @@ const char* tokens[] = { }; #define ASSERT_STRCMP(x, y) \ - ASSERT((x != NULL && y != NULL && strcmp(x, y) == 0) || (x == y && x == NULL)) + ASSERT_NE((x != NULL && y != NULL && strcmp(x, y) == 0) || (x == y && x == NULL), 0) TEST_IMPL(strtok) { struct strtok_test_case tests[] = { @@ -74,13 +74,13 @@ TEST_IMPL(strtok) { char current_test[2048]; for (i = 0, j = 0; i < tests_len; i += 1) { - ASSERT(j < tokens_len); + ASSERT_LT(j, tokens_len); snprintf(current_test, sizeof(current_test), "%s", tests[i].str); tok_r = uv__strtok(current_test, tests[i].sep, &itr); ASSERT_STRCMP(tok_r, tokens[j]); j++; while (tok_r) { - ASSERT(j < tokens_len); + ASSERT_LT(j, tokens_len); tok_r = uv__strtok(NULL, tests[i].sep, &itr); ASSERT_STRCMP(tok_r, tokens[j]); j++; diff --git a/deps/libuv/test/test-tcp-alloc-cb-fail.c b/deps/libuv/test/test-tcp-alloc-cb-fail.c index a1b5e84d..ff1cfcb8 100644 --- a/deps/libuv/test/test-tcp-alloc-cb-fail.c +++ b/deps/libuv/test/test-tcp-alloc-cb-fail.c @@ -42,7 +42,7 @@ static void close_cb(uv_handle_t* handle) { } static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); } static void conn_alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { @@ -52,9 +52,9 @@ static void conn_alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { static void conn_read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread == UV_ENOBUFS); + ASSERT_EQ(nread, UV_ENOBUFS); ASSERT_NULL(buf->base); - ASSERT(buf->len == 0); + ASSERT_OK(buf->len); uv_close((uv_handle_t*) &incoming, close_cb); uv_close((uv_handle_t*) &client, close_cb); @@ -65,23 +65,23 @@ static void connect_cb(uv_connect_t* req, int status) { int r; uv_buf_t buf; - ASSERT(status == 0); + ASSERT_OK(status); connect_cb_called++; buf = uv_buf_init(hello, sizeof(hello)); r = uv_write(&write_req, req->handle, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); + ASSERT_OK(status); - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); - ASSERT(0 == uv_read_start((uv_stream_t*) &incoming, - conn_alloc_cb, - conn_read_cb)); + ASSERT_OK(uv_tcp_init(tcp->loop, &incoming)); + ASSERT_OK(uv_accept(tcp, (uv_stream_t*) &incoming)); + ASSERT_OK(uv_read_start((uv_stream_t*) &incoming, + conn_alloc_cb, + conn_read_cb)); connection_cb_called++; } @@ -90,11 +90,11 @@ static void connection_cb(uv_stream_t* tcp, int status) { static void start_server(void) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, connection_cb)); } @@ -104,19 +104,19 @@ TEST_IMPL(tcp_alloc_cb_fail) { start_server(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client, + (struct sockaddr*) &addr, + connect_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(connection_cb_called == 1); - ASSERT(close_cb_called == 3); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, connection_cb_called); + ASSERT_EQ(3, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-bind-error.c b/deps/libuv/test/test-tcp-bind-error.c index edb44c21..89e4e339 100644 --- a/deps/libuv/test/test-tcp-bind-error.c +++ b/deps/libuv/test/test-tcp-bind-error.c @@ -36,7 +36,7 @@ static void close_cb(uv_handle_t* handle) { static void connect_cb(uv_connect_t* req, int status) { - ASSERT(status == UV_EADDRINUSE); + ASSERT_EQ(status, UV_EADDRINUSE); uv_close((uv_handle_t*) req->handle, close_cb); connect_cb_called++; } @@ -53,24 +53,24 @@ TEST_IMPL(tcp_bind_error_addrinuse_connect) { * (greatest common denominator across platforms) but the connect callback * should receive an UV_EADDRINUSE error. */ - ASSERT(0 == uv_tcp_init(uv_default_loop(), &conn)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_bind(&conn, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &conn)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_tcp_bind(&conn, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT + 1, &addr)); - ASSERT(0 == uv_tcp_connect(&req, - &conn, - (const struct sockaddr*) &addr, - connect_cb)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT + 1, &addr)); + ASSERT_OK(uv_tcp_connect(&req, + &conn, + (const struct sockaddr*) &addr, + connect_cb)); addrlen = sizeof(addr); - ASSERT(UV_EADDRINUSE == uv_tcp_getsockname(&conn, - (struct sockaddr*) &addr, - &addrlen)); + ASSERT_EQ(UV_EADDRINUSE, uv_tcp_getsockname(&conn, + (struct sockaddr*) &addr, + &addrlen)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -82,28 +82,28 @@ TEST_IMPL(tcp_bind_error_addrinuse_listen) { uv_tcp_t server1, server2; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server1, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &server2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server2, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server1, 128, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server2, 128, NULL); - ASSERT(r == UV_EADDRINUSE); + ASSERT_EQ(r, UV_EADDRINUSE); uv_close((uv_handle_t*)&server1, close_cb); uv_close((uv_handle_t*)&server2, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -115,10 +115,10 @@ TEST_IMPL(tcp_bind_error_addrnotavail_1) { uv_tcp_t server; int r; - ASSERT(0 == uv_ip4_addr("127.255.255.255", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.255.255.255", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); /* It seems that Linux is broken here - bind succeeds. */ r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); @@ -128,7 +128,7 @@ TEST_IMPL(tcp_bind_error_addrnotavail_1) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -140,18 +140,18 @@ TEST_IMPL(tcp_bind_error_addrnotavail_2) { uv_tcp_t server; int r; - ASSERT(0 == uv_ip4_addr("4.4.4.4", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("4.4.4.4", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == UV_EADDRNOTAVAIL); + ASSERT_EQ(r, UV_EADDRNOTAVAIL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -168,15 +168,15 @@ TEST_IMPL(tcp_bind_error_fault) { garbage_addr = (struct sockaddr_in*) &garbage; r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) garbage_addr, 0); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -190,21 +190,21 @@ TEST_IMPL(tcp_bind_error_inval) { uv_tcp_t server; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr1)); - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT_2, &addr2)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr1)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT_2, &addr2)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr1, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr2, 0); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -216,12 +216,12 @@ TEST_IMPL(tcp_bind_localhost_ok) { uv_tcp_t server; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -233,12 +233,12 @@ TEST_IMPL(tcp_bind_invalid_flags) { uv_tcp_t server; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, UV_TCP_IPV6ONLY); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -250,9 +250,9 @@ TEST_IMPL(tcp_listen_without_bind) { uv_tcp_t server; r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, 128, NULL); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -267,32 +267,32 @@ TEST_IMPL(tcp_bind_writable_flags) { uv_shutdown_t shutdown_req; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server, 128, NULL); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_is_writable((uv_stream_t*) &server)); - ASSERT(0 == uv_is_readable((uv_stream_t*) &server)); + ASSERT_OK(uv_is_writable((uv_stream_t*) &server)); + ASSERT_OK(uv_is_readable((uv_stream_t*) &server)); buf = uv_buf_init("PING", 4); r = uv_write(&write_req, (uv_stream_t*) &server, &buf, 1, NULL); - ASSERT(r == UV_EPIPE); + ASSERT_EQ(r, UV_EPIPE); r = uv_shutdown(&shutdown_req, (uv_stream_t*) &server, NULL); - ASSERT(r == UV_ENOTCONN); + ASSERT_EQ(r, UV_ENOTCONN); r = uv_read_start((uv_stream_t*) &server, (uv_alloc_cb) abort, (uv_read_cb) abort); - ASSERT(r == UV_ENOTCONN); + ASSERT_EQ(r, UV_ENOTCONN); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -307,11 +307,11 @@ TEST_IMPL(tcp_bind_or_listen_error_after_close) { addr.sin_port = htons(9999); addr.sin_family = AF_INET; - ASSERT_EQ(uv_tcp_init(uv_default_loop(), &tcp), 0); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &tcp)); uv_close((uv_handle_t*) &tcp, NULL); ASSERT_EQ(uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0), UV_EINVAL); ASSERT_EQ(uv_listen((uv_stream_t*) &tcp, 5, NULL), UV_EINVAL); - ASSERT_EQ(uv_run(uv_default_loop(), UV_RUN_DEFAULT), 0); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } diff --git a/deps/libuv/test/test-tcp-bind6-error.c b/deps/libuv/test/test-tcp-bind6-error.c index 656ebe34..f44d3b7e 100644 --- a/deps/libuv/test/test-tcp-bind6-error.c +++ b/deps/libuv/test/test-tcp-bind6-error.c @@ -42,29 +42,29 @@ TEST_IMPL(tcp_bind6_error_addrinuse) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server1, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &server2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server2, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server1, 128, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&server2, 128, NULL); - ASSERT(r == UV_EADDRINUSE); + ASSERT_EQ(r, UV_EADDRINUSE); uv_close((uv_handle_t*)&server1, close_cb); uv_close((uv_handle_t*)&server2, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -79,18 +79,18 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip6_addr("4:4:4:4:4:4:4:4", TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr("4:4:4:4:4:4:4:4", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == UV_EADDRNOTAVAIL); + ASSERT_EQ(r, UV_EADDRNOTAVAIL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -110,15 +110,15 @@ TEST_IMPL(tcp_bind6_error_fault) { garbage_addr = (struct sockaddr_in6*) &garbage; r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) garbage_addr, 0); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -135,21 +135,21 @@ TEST_IMPL(tcp_bind6_error_inval) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr1)); - ASSERT(0 == uv_ip6_addr("::", TEST_PORT_2, &addr2)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &addr1)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT_2, &addr2)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr1, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr2, 0); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -164,12 +164,12 @@ TEST_IMPL(tcp_bind6_localhost_ok) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr("::1", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-close-accept.c b/deps/libuv/test/test-tcp-close-accept.c index b255cfbd..4988dd13 100644 --- a/deps/libuv/test/test-tcp-close-accept.c +++ b/deps/libuv/test/test-tcp-close-accept.c @@ -47,7 +47,7 @@ static void close_cb(uv_handle_t* handle) { } static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); write_cb_called++; } @@ -57,7 +57,7 @@ static void connect_cb(uv_connect_t* req, int status) { uv_stream_t* outgoing; if (req == &tcp_check_req) { - ASSERT(status != 0); + ASSERT(status); /* * Time to finish the test: close both the check and pending incoming @@ -68,14 +68,14 @@ static void connect_cb(uv_connect_t* req, int status) { return; } - ASSERT(status == 0); - ASSERT(connect_reqs <= req); - ASSERT(req <= connect_reqs + ARRAY_SIZE(connect_reqs)); + ASSERT_OK(status); + ASSERT_LE(connect_reqs, req); + ASSERT_LE(req, connect_reqs + ARRAY_SIZE(connect_reqs)); i = req - connect_reqs; buf = uv_buf_init("x", 1); outgoing = (uv_stream_t*) &tcp_outgoing[i]; - ASSERT(0 == uv_write(&write_reqs[i], outgoing, &buf, 1, write_cb)); + ASSERT_OK(uv_write(&write_reqs[i], outgoing, &buf, 1, write_cb)); } static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { @@ -89,9 +89,9 @@ static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { unsigned int i; pending_incoming = (uv_tcp_t*) stream - &tcp_incoming[0]; - ASSERT(pending_incoming < got_connections); - ASSERT(0 == uv_read_stop(stream)); - ASSERT(1 == nread); + ASSERT_LT(pending_incoming, got_connections); + ASSERT_OK(uv_read_stop(stream)); + ASSERT_EQ(1, nread); loop = stream->loop; read_cb_called++; @@ -106,19 +106,19 @@ static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { uv_close((uv_handle_t*) &tcp_server, close_cb); /* Create new fd that should be one of the closed incomings */ - ASSERT(0 == uv_tcp_init(loop, &tcp_check)); - ASSERT(0 == uv_tcp_connect(&tcp_check_req, - &tcp_check, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_read_start((uv_stream_t*) &tcp_check, alloc_cb, read_cb)); + ASSERT_OK(uv_tcp_init(loop, &tcp_check)); + ASSERT_OK(uv_tcp_connect(&tcp_check_req, + &tcp_check, + (const struct sockaddr*) &addr, + connect_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) &tcp_check, alloc_cb, read_cb)); } static void connection_cb(uv_stream_t* server, int status) { unsigned int i; uv_tcp_t* incoming; - ASSERT(server == (uv_stream_t*) &tcp_server); + ASSERT_PTR_EQ(server, (uv_stream_t*) &tcp_server); /* Ignore tcp_check connection */ if (got_connections == ARRAY_SIZE(tcp_incoming)) @@ -126,8 +126,8 @@ static void connection_cb(uv_stream_t* server, int status) { /* Accept everyone */ incoming = &tcp_incoming[got_connections++]; - ASSERT(0 == uv_tcp_init(server->loop, incoming)); - ASSERT(0 == uv_accept(server, (uv_stream_t*) incoming)); + ASSERT_OK(uv_tcp_init(server->loop, incoming)); + ASSERT_OK(uv_accept(server, (uv_stream_t*) incoming)); if (got_connections != ARRAY_SIZE(tcp_incoming)) return; @@ -135,7 +135,7 @@ static void connection_cb(uv_stream_t* server, int status) { /* Once all clients are accepted - start reading */ for (i = 0; i < ARRAY_SIZE(tcp_incoming); i++) { incoming = &tcp_incoming[i]; - ASSERT(0 == uv_read_start((uv_stream_t*) incoming, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) incoming, alloc_cb, read_cb)); } } @@ -162,30 +162,30 @@ TEST_IMPL(tcp_close_accept) { */ loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &tcp_server)); - ASSERT(0 == uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &tcp_server, - ARRAY_SIZE(tcp_outgoing), - connection_cb)); + ASSERT_OK(uv_tcp_init(loop, &tcp_server)); + ASSERT_OK(uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &tcp_server, + ARRAY_SIZE(tcp_outgoing), + connection_cb)); for (i = 0; i < ARRAY_SIZE(tcp_outgoing); i++) { client = tcp_outgoing + i; - ASSERT(0 == uv_tcp_init(loop, client)); - ASSERT(0 == uv_tcp_connect(&connect_reqs[i], - client, - (const struct sockaddr*) &addr, - connect_cb)); + ASSERT_OK(uv_tcp_init(loop, client)); + ASSERT_OK(uv_tcp_connect(&connect_reqs[i], + client, + (const struct sockaddr*) &addr, + connect_cb)); } uv_run(loop, UV_RUN_DEFAULT); - ASSERT(ARRAY_SIZE(tcp_outgoing) == got_connections); - ASSERT((ARRAY_SIZE(tcp_outgoing) + 2) == close_cb_called); - ASSERT(ARRAY_SIZE(tcp_outgoing) == write_cb_called); - ASSERT(1 == read_cb_called); + ASSERT_EQ(ARRAY_SIZE(tcp_outgoing), got_connections); + ASSERT_EQ((ARRAY_SIZE(tcp_outgoing) + 2), close_cb_called); + ASSERT_EQ(ARRAY_SIZE(tcp_outgoing), write_cb_called); + ASSERT_EQ(1, read_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-close-after-read-timeout.c b/deps/libuv/test/test-tcp-close-after-read-timeout.c index 098e405a..1b816301 100644 --- a/deps/libuv/test/test-tcp-close-after-read-timeout.c +++ b/deps/libuv/test/test-tcp-close-after-read-timeout.c @@ -48,10 +48,10 @@ static void on_client_connect(uv_connect_t* conn_req, int status) { int r; r = uv_read_start((uv_stream_t*) &client, on_client_alloc, on_client_read); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_timer_start(&timer, on_client_timeout, 1000, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } @@ -72,8 +72,8 @@ static void on_client_read(uv_stream_t* stream, ssize_t nread, static void on_client_timeout(uv_timer_t* handle) { - ASSERT_EQ(handle, &timer); - ASSERT_EQ(read_cb_called, 0); + ASSERT_PTR_EQ(handle, &timer); + ASSERT_OK(read_cb_called); uv_read_stop((uv_stream_t*) &client); uv_close((uv_handle_t*) &client, on_close); uv_close((uv_handle_t*) &timer, on_close); @@ -101,20 +101,20 @@ static void on_connection_read(uv_stream_t* stream, static void on_connection(uv_stream_t* server, int status) { int r; - ASSERT_EQ(status, 0); - ASSERT_EQ(uv_accept(server, (uv_stream_t*) &connection), 0); + ASSERT_OK(status); + ASSERT_OK(uv_accept(server, (uv_stream_t*) &connection)); r = uv_read_start((uv_stream_t*) &connection, on_connection_alloc, on_connection_read); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } static void on_close(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &client || - handle == (uv_handle_t*) &connection || - handle == (uv_handle_t*) &timer); + ASSERT_NE(handle == (uv_handle_t*) &client || + handle == (uv_handle_t*) &connection || + handle == (uv_handle_t*) &timer, 0); on_close_called++; } @@ -123,16 +123,16 @@ static void start_server(uv_loop_t* loop, uv_tcp_t* handle) { struct sockaddr_in addr; int r; - ASSERT_EQ(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr), 0); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(loop, handle); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_bind(handle, (const struct sockaddr*) &addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*) handle, 128, on_connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_unref((uv_handle_t*) handle); } @@ -147,7 +147,7 @@ TEST_IMPL(tcp_close_after_read_timeout) { uv_loop_t* loop; int r; - ASSERT_EQ(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr), 0); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); @@ -155,28 +155,28 @@ TEST_IMPL(tcp_close_after_read_timeout) { start_server(loop, &tcp_server); r = uv_tcp_init(loop, &client); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &client, (const struct sockaddr*) &addr, on_client_connect); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_init(loop, &connection); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_timer_init(loop, &timer); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(read_cb_called, 0); - ASSERT_EQ(on_close_called, 0); + ASSERT_OK(read_cb_called); + ASSERT_OK(on_close_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(read_cb_called, 1); - ASSERT_EQ(on_close_called, 3); + ASSERT_EQ(1, read_cb_called); + ASSERT_EQ(3, on_close_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-close-reset.c b/deps/libuv/test/test-tcp-close-reset.c index 74156469..74941789 100644 --- a/deps/libuv/test/test-tcp-close-reset.c +++ b/deps/libuv/test/test-tcp-close-reset.c @@ -62,7 +62,7 @@ static void do_write(uv_tcp_t* handle) { buf = uv_buf_init("PING", 4); for (i = 0; i < ARRAY_SIZE(write_reqs); i++) { r = uv_write(&write_reqs[i], (uv_stream_t*) handle, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -72,21 +72,25 @@ static void do_close(uv_tcp_t* handle) { int r; if (shutdown_before_close == 1) { - ASSERT(0 == uv_shutdown(&shutdown_req, (uv_stream_t*) handle, shutdown_cb)); - ASSERT(UV_EINVAL == uv_tcp_close_reset(handle, close_cb)); + ASSERT_OK(uv_shutdown(&shutdown_req, + (uv_stream_t*) handle, + shutdown_cb)); + ASSERT_EQ(UV_EINVAL, uv_tcp_close_reset(handle, close_cb)); } else if (shutdown_before_close == 2) { r = uv_fileno((const uv_handle_t*) handle, &fd); - ASSERT_EQ(r, 0); - ASSERT_NE(fd, INVALID_FD); + ASSERT_OK(r); #ifdef _WIN32 - ASSERT_EQ(0, shutdown(fd, SD_BOTH)); + ASSERT_PTR_NE(fd, INVALID_FD); + ASSERT_OK(shutdown((SOCKET)fd, SD_BOTH)); #else - ASSERT_EQ(0, shutdown(fd, SHUT_RDWR)); + ASSERT_NE(fd, INVALID_FD); + ASSERT_OK(shutdown(fd, SHUT_RDWR)); #endif - ASSERT_EQ(0, uv_tcp_close_reset(handle, close_cb)); + ASSERT_OK(uv_tcp_close_reset(handle, close_cb)); } else { - ASSERT(0 == uv_tcp_close_reset(handle, close_cb)); - ASSERT(UV_ENOTCONN == uv_shutdown(&shutdown_req, (uv_stream_t*) handle, shutdown_cb)); + ASSERT_OK(uv_tcp_close_reset(handle, close_cb)); + ASSERT_EQ(UV_ENOTCONN, uv_shutdown(&shutdown_req, (uv_stream_t*) handle, + shutdown_cb)); } uv_close((uv_handle_t*) &tcp_server, NULL); @@ -99,14 +103,14 @@ static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { } static void read_cb2(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - ASSERT((uv_tcp_t*)stream == &tcp_client); + ASSERT_PTR_EQ((uv_tcp_t*)stream, &tcp_client); if (nread == UV_EOF) uv_close((uv_handle_t*) stream, NULL); } static void connect_cb(uv_connect_t* conn_req, int status) { - ASSERT(conn_req == &connect_req); + ASSERT_PTR_EQ(conn_req, &connect_req); uv_read_start((uv_stream_t*) &tcp_client, alloc_cb, read_cb2); do_write(&tcp_client); if (client_close) @@ -116,33 +120,33 @@ static void connect_cb(uv_connect_t* conn_req, int status) { static void write_cb(uv_write_t* req, int status) { /* write callbacks should run before the close callback */ - ASSERT(close_cb_called == 0); - ASSERT(req->handle == (uv_stream_t*)&tcp_client); + ASSERT_OK(close_cb_called); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*)&tcp_client); write_cb_called++; } static void close_cb(uv_handle_t* handle) { if (client_close) - ASSERT(handle == (uv_handle_t*) &tcp_client); + ASSERT_PTR_EQ(handle, (uv_handle_t*) &tcp_client); else - ASSERT(handle == (uv_handle_t*) &tcp_accepted); + ASSERT_PTR_EQ(handle, (uv_handle_t*) &tcp_accepted); close_cb_called++; } static void shutdown_cb(uv_shutdown_t* req, int status) { if (client_close) - ASSERT(req->handle == (uv_stream_t*) &tcp_client); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*) &tcp_client); else - ASSERT(req->handle == (uv_stream_t*) &tcp_accepted); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*) &tcp_accepted); shutdown_cb_called++; } static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - ASSERT((uv_tcp_t*)stream == &tcp_accepted); + ASSERT_PTR_EQ((uv_tcp_t*)stream, &tcp_accepted); if (nread < 0) { uv_close((uv_handle_t*) stream, NULL); } else { @@ -154,10 +158,10 @@ static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { static void connection_cb(uv_stream_t* server, int status) { - ASSERT(status == 0); + ASSERT_OK(status); - ASSERT(0 == uv_tcp_init(loop, &tcp_accepted)); - ASSERT(0 == uv_accept(server, (uv_stream_t*) &tcp_accepted)); + ASSERT_OK(uv_tcp_init(loop, &tcp_accepted)); + ASSERT_OK(uv_accept(server, (uv_stream_t*) &tcp_accepted)); uv_read_start((uv_stream_t*) &tcp_accepted, alloc_cb, read_cb); } @@ -167,16 +171,16 @@ static void start_server(uv_loop_t* loop, uv_tcp_t* handle) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(loop, handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(handle, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)handle, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -184,16 +188,16 @@ static void do_connect(uv_loop_t* loop, uv_tcp_t* tcp_client) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(loop, tcp_client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, tcp_client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -212,16 +216,16 @@ TEST_IMPL(tcp_close_reset_client) { do_connect(loop, &tcp_client); - ASSERT(write_cb_called == 0); - ASSERT(close_cb_called == 0); - ASSERT(shutdown_cb_called == 0); + ASSERT_OK(write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_OK(shutdown_cb_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(write_cb_called == 4); - ASSERT(close_cb_called == 1); - ASSERT(shutdown_cb_called == 0); + ASSERT_EQ(4, write_cb_called); + ASSERT_EQ(1, close_cb_called); + ASSERT_OK(shutdown_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -239,16 +243,16 @@ TEST_IMPL(tcp_close_reset_client_after_shutdown) { do_connect(loop, &tcp_client); - ASSERT(write_cb_called == 0); - ASSERT(close_cb_called == 0); - ASSERT(shutdown_cb_called == 0); + ASSERT_OK(write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_OK(shutdown_cb_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(write_cb_called == 4); - ASSERT(close_cb_called == 0); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(4, write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_EQ(1, shutdown_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -266,16 +270,16 @@ TEST_IMPL(tcp_close_reset_accepted) { do_connect(loop, &tcp_client); - ASSERT(write_cb_called == 0); - ASSERT(close_cb_called == 0); - ASSERT(shutdown_cb_called == 0); + ASSERT_OK(write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_OK(shutdown_cb_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(write_cb_called == 4); - ASSERT(close_cb_called == 1); - ASSERT(shutdown_cb_called == 0); + ASSERT_EQ(4, write_cb_called); + ASSERT_EQ(1, close_cb_called); + ASSERT_OK(shutdown_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -293,16 +297,16 @@ TEST_IMPL(tcp_close_reset_accepted_after_shutdown) { do_connect(loop, &tcp_client); - ASSERT(write_cb_called == 0); - ASSERT(close_cb_called == 0); - ASSERT(shutdown_cb_called == 0); + ASSERT_OK(write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_OK(shutdown_cb_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(write_cb_called == 4); - ASSERT(close_cb_called == 0); - ASSERT(shutdown_cb_called == 1); + ASSERT_EQ(4, write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_EQ(1, shutdown_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -320,16 +324,16 @@ TEST_IMPL(tcp_close_reset_accepted_after_socket_shutdown) { do_connect(loop, &tcp_client); - ASSERT_EQ(write_cb_called, 0); - ASSERT_EQ(close_cb_called, 0); - ASSERT_EQ(shutdown_cb_called, 0); + ASSERT_OK(write_cb_called); + ASSERT_OK(close_cb_called); + ASSERT_OK(shutdown_cb_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); - ASSERT_EQ(write_cb_called, 4); - ASSERT_EQ(close_cb_called, 1); - ASSERT_EQ(shutdown_cb_called, 0); + ASSERT_EQ(4, write_cb_called); + ASSERT_EQ(1, close_cb_called); + ASSERT_OK(shutdown_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-close-while-connecting.c b/deps/libuv/test/test-tcp-close-while-connecting.c index 49041389..ba5e4690 100644 --- a/deps/libuv/test/test-tcp-close-while-connecting.c +++ b/deps/libuv/test/test-tcp-close-while-connecting.c @@ -69,24 +69,24 @@ TEST_IMPL(tcp_close_while_connecting) { int r; loop = uv_default_loop(); - ASSERT(0 == uv_ip4_addr("1.2.3.4", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &tcp_handle)); + ASSERT_OK(uv_ip4_addr("1.2.3.4", TEST_PORT, &addr)); + ASSERT_OK(uv_tcp_init(loop, &tcp_handle)); r = uv_tcp_connect(&connect_req, &tcp_handle, (const struct sockaddr*) &addr, connect_cb); if (r == UV_ENETUNREACH) RETURN_SKIP("Network unreachable."); - ASSERT(r == 0); - ASSERT(0 == uv_timer_init(loop, &timer1_handle)); - ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 1, 0)); - ASSERT(0 == uv_timer_init(loop, &timer2_handle)); - ASSERT(0 == uv_timer_start(&timer2_handle, timer2_cb, 86400 * 1000, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(r); + ASSERT_OK(uv_timer_init(loop, &timer1_handle)); + ASSERT_OK(uv_timer_start(&timer1_handle, timer1_cb, 1, 0)); + ASSERT_OK(uv_timer_init(loop, &timer2_handle)); + ASSERT_OK(uv_timer_start(&timer2_handle, timer2_cb, 86400 * 1000, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(timer1_cb_called == 1); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, timer1_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(loop); diff --git a/deps/libuv/test/test-tcp-close.c b/deps/libuv/test/test-tcp-close.c index 6879bae2..ed19da6f 100644 --- a/deps/libuv/test/test-tcp-close.c +++ b/deps/libuv/test/test-tcp-close.c @@ -49,7 +49,7 @@ static void connect_cb(uv_connect_t* conn_req, int status) { ASSERT_NOT_NULL(req); r = uv_write(req, (uv_stream_t*)&tcp_handle, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } uv_close((uv_handle_t*)&tcp_handle, close_cb); @@ -58,21 +58,21 @@ static void connect_cb(uv_connect_t* conn_req, int status) { static void write_cb(uv_write_t* req, int status) { /* write callbacks should run before the close callback */ - ASSERT(close_cb_called == 0); - ASSERT(req->handle == (uv_stream_t*)&tcp_handle); + ASSERT_OK(close_cb_called); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*)&tcp_handle); write_cb_called++; free(req); } static void close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*)&tcp_handle); + ASSERT_PTR_EQ(handle, (uv_handle_t*)&tcp_handle); close_cb_called++; } static void connection_cb(uv_stream_t* server, int status) { - ASSERT(status == 0); + ASSERT_OK(status); } @@ -80,16 +80,16 @@ static void start_server(uv_loop_t* loop, uv_tcp_t* handle) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(loop, handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(handle, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)handle, 128, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*)handle); } @@ -104,7 +104,7 @@ TEST_IMPL(tcp_close) { uv_loop_t* loop; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); @@ -112,24 +112,24 @@ TEST_IMPL(tcp_close) { start_server(loop, &tcp_server); r = uv_tcp_init(loop, &tcp_handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &tcp_handle, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(write_cb_called == 0); - ASSERT(close_cb_called == 0); + ASSERT_OK(write_cb_called); + ASSERT_OK(close_cb_called); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); printf("%d of %d write reqs seen\n", write_cb_called, NUM_WRITE_REQS); - ASSERT(write_cb_called == NUM_WRITE_REQS); - ASSERT(close_cb_called == 1); + ASSERT_EQ(write_cb_called, NUM_WRITE_REQS); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-connect-error-after-write.c b/deps/libuv/test/test-tcp-connect-error-after-write.c index 1800b4d6..73212596 100644 --- a/deps/libuv/test/test-tcp-connect-error-after-write.c +++ b/deps/libuv/test/test-tcp-connect-error-after-write.c @@ -37,14 +37,14 @@ static void close_cb(uv_handle_t* handle) { static void connect_cb(uv_connect_t* req, int status) { - ASSERT(status < 0); + ASSERT_LT(status, 0); connect_cb_called++; uv_close((uv_handle_t*)req->handle, close_cb); } static void write_cb(uv_write_t* req, int status) { - ASSERT(status < 0); + ASSERT_LT(status, 0); write_cb_called++; } @@ -67,30 +67,30 @@ TEST_IMPL(tcp_connect_error_after_write) { uv_buf_t buf; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); buf = uv_buf_init("TEST", 4); r = uv_tcp_init(uv_default_loop(), &conn); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == UV_EBADF); + ASSERT_EQ(r, UV_EBADF); r = uv_tcp_connect(&connect_req, &conn, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-connect-error.c b/deps/libuv/test/test-tcp-connect-error.c index 9384ebce..ee0f9ee5 100644 --- a/deps/libuv/test/test-tcp-connect-error.c +++ b/deps/libuv/test/test-tcp-connect-error.c @@ -54,19 +54,19 @@ TEST_IMPL(tcp_connect_error_fault) { garbage_addr = (const struct sockaddr_in*) &garbage; r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&req, &server, (const struct sockaddr*) garbage_addr, connect_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 0); - ASSERT(close_cb_called == 1); + ASSERT_OK(connect_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-connect-timeout.c b/deps/libuv/test/test-tcp-connect-timeout.c index 4cd83e1d..4eb834e1 100644 --- a/deps/libuv/test/test-tcp-connect-timeout.c +++ b/deps/libuv/test/test-tcp-connect-timeout.c @@ -38,14 +38,14 @@ static void close_cb(uv_handle_t* handle); static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == UV_ECANCELED); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_EQ(status, UV_ECANCELED); connect_cb_called++; } static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); + ASSERT_PTR_EQ(handle, &timer); uv_close((uv_handle_t*)&conn, close_cb); uv_close((uv_handle_t*)&timer, close_cb); } @@ -64,16 +64,16 @@ TEST_IMPL(tcp_connect_timeout) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("8.8.8.8", 9999, &addr)); + ASSERT_OK(uv_ip4_addr("8.8.8.8", 9999, &addr)); r = uv_timer_init(uv_default_loop(), &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 50, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &conn); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &conn, @@ -81,10 +81,10 @@ TEST_IMPL(tcp_connect_timeout) { connect_cb); if (r == UV_ENETUNREACH) RETURN_SKIP("Network unreachable."); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -105,7 +105,7 @@ static int is_supported_system(void) { int min_semver[3] = {10, 0, 16299}; int cnt; uv_utsname_t uname; - ASSERT_EQ(uv_os_uname(&uname), 0); + ASSERT_OK(uv_os_uname(&uname)); if (strcmp(uname.sysname, "Windows_NT") == 0) { cnt = sscanf(uname.release, "%d.%d.%d", &semver[0], &semver[1], &semver[2]); if (cnt != 3) { @@ -130,17 +130,17 @@ TEST_IMPL(tcp_local_connect_timeout) { if (!is_supported_system()) { RETURN_SKIP("Unsupported system"); } - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_timer_init(uv_default_loop(), &timer); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* Give it 1s to timeout. */ r = uv_timer_start(&timer, timer_cb, 1000, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &conn, @@ -148,10 +148,10 @@ TEST_IMPL(tcp_local_connect_timeout) { connect_local_cb); if (r == UV_ENETUNREACH) RETURN_SKIP("Network unreachable."); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -168,17 +168,17 @@ TEST_IMPL(tcp6_local_connect_timeout) { RETURN_SKIP("IPv6 not supported"); } - ASSERT_EQ(0, uv_ip6_addr("::1", 9999, &addr)); + ASSERT_OK(uv_ip6_addr("::1", 9999, &addr)); r = uv_timer_init(uv_default_loop(), &timer); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* Give it 1s to timeout. */ r = uv_timer_start(&timer, timer_cb, 1000, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_init(uv_default_loop(), &conn); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &conn, @@ -186,10 +186,10 @@ TEST_IMPL(tcp6_local_connect_timeout) { connect_local_cb); if (r == UV_ENETUNREACH) RETURN_SKIP("Network unreachable."); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(r, 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-connect6-error.c b/deps/libuv/test/test-tcp-connect6-error.c index 8646dd56..1e6d7c78 100644 --- a/deps/libuv/test/test-tcp-connect6-error.c +++ b/deps/libuv/test/test-tcp-connect6-error.c @@ -49,22 +49,63 @@ TEST_IMPL(tcp_connect6_error_fault) { int r; uv_connect_t req; + if (!can_ipv6()) + RETURN_SKIP("IPv6 not supported"); + garbage_addr = (const struct sockaddr_in6*) &garbage; r = uv_tcp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&req, &server, (const struct sockaddr*) garbage_addr, connect_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_close((uv_handle_t*)&server, close_cb); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 0); - ASSERT(close_cb_called == 1); + ASSERT_OK(connect_cb_called); + ASSERT_EQ(1, close_cb_called); + + MAKE_VALGRIND_HAPPY(uv_default_loop()); + return 0; +} + + +TEST_IMPL(tcp_connect6_link_local) { + struct sockaddr_in6 addr; + uv_connect_t req; + uv_tcp_t server; + + if (!can_ipv6()) + RETURN_SKIP("IPv6 not supported"); + +#if defined(__QEMU__) + /* qemu's sockaddr_in6 translation is broken pre-qemu 8.0.0 + * when host endianness != guest endiannes. + * Fixed in https://github.com/qemu/qemu/commit/44cf6731d6b. + */ + RETURN_SKIP("Test does not currently work in QEMU"); +#endif /* defined(__QEMU__) */ + + ASSERT_OK(uv_ip6_addr("fe80::0bad:babe", 1337, &addr)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); + + /* We're making two shaky assumptions here: + * 1. There is a network interface that routes IPv6 link-local traffic, and + * 2. There is no firewall rule that blackholes or otherwise hard-kills the + * connection attempt to the address above, i.e., we don't expect the + * connect() system call to fail synchronously. + */ + ASSERT_OK(uv_tcp_connect(&req, + &server, + (struct sockaddr*) &addr, + connect_cb)); + + uv_close((uv_handle_t*) &server, NULL); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-create-socket-early.c b/deps/libuv/test/test-tcp-create-socket-early.c index c84882da..e8c1aaab 100644 --- a/deps/libuv/test/test-tcp-create-socket-early.c +++ b/deps/libuv/test/test-tcp-create-socket-early.c @@ -32,7 +32,7 @@ static void on_connect(uv_connect_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); uv_close((uv_handle_t*) req->handle, NULL); } @@ -41,16 +41,16 @@ static void on_connection(uv_stream_t* server, int status) { uv_tcp_t* handle; int r; - ASSERT(status == 0); + ASSERT_OK(status); handle = malloc(sizeof(*handle)); ASSERT_NOT_NULL(handle); r = uv_tcp_init_ex(server->loop, handle, AF_INET); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)handle); - ASSERT(r == UV_EBUSY); + ASSERT_EQ(r, UV_EBUSY); uv_close((uv_handle_t*) server, NULL); uv_close((uv_handle_t*) handle, (uv_close_cb)free); @@ -61,16 +61,16 @@ static void tcp_listener(uv_loop_t* loop, uv_tcp_t* server) { struct sockaddr_in addr; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_tcp_init(loop, server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*) server, 128, on_connection); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -78,16 +78,16 @@ static void tcp_connector(uv_loop_t* loop, uv_tcp_t* client, uv_connect_t* req) struct sockaddr_in server_addr; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); r = uv_tcp_init(loop, client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(req, client, (const struct sockaddr*) &server_addr, on_connect); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -98,32 +98,34 @@ TEST_IMPL(tcp_create_early) { uv_os_fd_t fd; int r, namelen; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init_ex(uv_default_loop(), &client, AF_INET); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); + ASSERT_OK(r); /* Windows returns WSAEINVAL if the socket is not bound */ #ifndef _WIN32 + ASSERT_NE(fd, INVALID_FD); namelen = sizeof sockname; r = uv_tcp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin_family == AF_INET); + ASSERT_OK(r); + ASSERT_EQ(sockname.sin_family, AF_INET); +#else + ASSERT_PTR_NE(fd, INVALID_FD); #endif r = uv_tcp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); namelen = sizeof sockname; r = uv_tcp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(memcmp(&addr.sin_addr, - &sockname.sin_addr, - sizeof(addr.sin_addr)) == 0); + ASSERT_OK(r); + ASSERT_OK(memcmp(&addr.sin_addr, + &sockname.sin_addr, + sizeof(addr.sin_addr))); uv_close((uv_handle_t*) &client, NULL); uv_run(uv_default_loop(), UV_RUN_DEFAULT); @@ -142,32 +144,34 @@ TEST_IMPL(tcp_create_early_bad_bind) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init_ex(uv_default_loop(), &client, AF_INET6); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); + ASSERT_OK(r); /* Windows returns WSAEINVAL if the socket is not bound */ #ifndef _WIN32 + ASSERT_NE(fd, INVALID_FD); { int namelen; struct sockaddr_in6 sockname; namelen = sizeof sockname; r = uv_tcp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin6_family == AF_INET6); + ASSERT_OK(r); + ASSERT_EQ(sockname.sin6_family, AF_INET6); } +#else + ASSERT_PTR_NE(fd, INVALID_FD); #endif r = uv_tcp_bind(&client, (const struct sockaddr*) &addr, 0); #if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MSYS__) - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); #else - ASSERT(r == UV_EFAULT); + ASSERT_EQ(r, UV_EFAULT); #endif uv_close((uv_handle_t*) &client, NULL); @@ -183,10 +187,10 @@ TEST_IMPL(tcp_create_early_bad_domain) { int r; r = uv_tcp_init_ex(uv_default_loop(), &client, 47); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_tcp_init_ex(uv_default_loop(), &client, 1024); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(uv_default_loop(), UV_RUN_DEFAULT); diff --git a/deps/libuv/test/test-tcp-flags.c b/deps/libuv/test/test-tcp-flags.c index 6856429a..30178d70 100644 --- a/deps/libuv/test/test-tcp-flags.c +++ b/deps/libuv/test/test-tcp-flags.c @@ -34,18 +34,18 @@ TEST_IMPL(tcp_flags) { loop = uv_default_loop(); r = uv_tcp_init(loop, &handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_nodelay(&handle, 1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_keepalive(&handle, 1, 60); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&handle, NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-oob.c b/deps/libuv/test/test-tcp-oob.c index 989454ed..7962fa93 100644 --- a/deps/libuv/test/test-tcp-oob.c +++ b/deps/libuv/test/test-tcp-oob.c @@ -61,22 +61,22 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { #endif uv_os_fd_t fd; - ASSERT(nread >= 0); - ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd)); - ASSERT(0 == uv_idle_start(&idle, idle_cb)); + ASSERT_GE(nread, 0); + ASSERT_OK(uv_fileno((uv_handle_t*)handle, &fd)); + ASSERT_OK(uv_idle_start(&idle, idle_cb)); #ifdef __MVS__ /* Need to flush out the OOB data. Otherwise, this callback will get * triggered on every poll with nread = 0. */ - ASSERT(-1 != recv(fd, lbuf, sizeof(lbuf), MSG_OOB)); + ASSERT_NE(-1, recv(fd, lbuf, sizeof(lbuf), MSG_OOB)); #endif } static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &client_handle); - ASSERT(0 == status); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*) &client_handle); + ASSERT_OK(status); } @@ -84,14 +84,14 @@ static void connection_cb(uv_stream_t* handle, int status) { int r; uv_os_fd_t fd; - ASSERT(0 == status); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); + ASSERT_OK(status); + ASSERT_OK(uv_accept(handle, (uv_stream_t*) &peer_handle)); + ASSERT_OK(uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); /* Send some OOB data */ - ASSERT(0 == uv_fileno((uv_handle_t*) &client_handle, &fd)); + ASSERT_OK(uv_fileno((uv_handle_t*) &client_handle, &fd)); - ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &client_handle, 1)); + ASSERT_OK(uv_stream_set_blocking((uv_stream_t*) &client_handle, 1)); /* The problem triggers only on a second message, it seem that xnu is not * triggering `kevent()` for the first one @@ -99,14 +99,14 @@ static void connection_cb(uv_stream_t* handle, int status) { do { r = send(fd, "hello", 5, MSG_OOB); } while (r < 0 && errno == EINTR); - ASSERT(5 == r); + ASSERT_EQ(5, r); do { r = send(fd, "hello", 5, MSG_OOB); } while (r < 0 && errno == EINTR); - ASSERT(5 == r); + ASSERT_EQ(5, r); - ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &client_handle, 0)); + ASSERT_OK(uv_stream_set_blocking((uv_stream_t*) &client_handle, 0)); } @@ -114,26 +114,26 @@ TEST_IMPL(tcp_oob) { struct sockaddr_in addr; uv_loop_t* loop; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_init(loop, &peer_handle)); - ASSERT(0 == uv_idle_init(loop, &idle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); + ASSERT_OK(uv_tcp_init(loop, &server_handle)); + ASSERT_OK(uv_tcp_init(loop, &client_handle)); + ASSERT_OK(uv_tcp_init(loop, &peer_handle)); + ASSERT_OK(uv_idle_init(loop, &idle)); + ASSERT_OK(uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); /* Ensure two separate packets */ - ASSERT(0 == uv_tcp_nodelay(&client_handle, 1)); + ASSERT_OK(uv_tcp_nodelay(&client_handle, 1)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client_handle, + (const struct sockaddr*) &addr, + connect_cb)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(ticks == kMaxTicks); + ASSERT_EQ(ticks, kMaxTicks); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-open.c b/deps/libuv/test/test-tcp-open.c index b5c5621a..3fbcf2a5 100644 --- a/deps/libuv/test/test-tcp-open.c +++ b/deps/libuv/test/test-tcp-open.c @@ -46,7 +46,7 @@ static void startup(void) { #ifdef _WIN32 struct WSAData wsa_data; int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); #endif } @@ -56,9 +56,9 @@ static uv_os_sock_t create_tcp_socket(void) { sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); #ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); #else - ASSERT(sock >= 0); + ASSERT_GE(sock, 0); #endif #ifndef _WIN32 @@ -66,7 +66,7 @@ static uv_os_sock_t create_tcp_socket(void) { /* Allow reuse of the port. */ int yes = 1; int r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); - ASSERT(r == 0); + ASSERT_OK(r); } #endif @@ -81,7 +81,7 @@ static void close_socket(uv_os_sock_t sock) { #else r = close(sock); #endif - ASSERT(r == 0); + ASSERT_OK(r); } @@ -89,7 +89,7 @@ static void alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { static char slab[65536]; - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -102,8 +102,8 @@ static void close_cb(uv_handle_t* handle) { static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(req == &shutdown_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &shutdown_req); + ASSERT_OK(status); /* Now we wait for the EOF */ shutdown_cb_called++; @@ -114,11 +114,11 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { ASSERT_NOT_NULL(tcp); if (nread >= 0) { - ASSERT(nread == 4); - ASSERT(memcmp("PING", buf->base, nread) == 0); + ASSERT_EQ(4, nread); + ASSERT_OK(memcmp("PING", buf->base, nread)); } else { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); uv_close((uv_handle_t*)tcp, close_cb); } } @@ -130,9 +130,9 @@ static void read1_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { if (nread >= 0) { for (i = 0; i < nread; ++i) - ASSERT(buf->base[i] == 'P'); + ASSERT_EQ(buf->base[i], 'P'); } else { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); printf("GOT EOF\n"); uv_close((uv_handle_t*)tcp, close_cb); } @@ -166,7 +166,7 @@ static void write1_cb(uv_write_t* req, int status) { buf = uv_buf_init("P", 1); r = uv_write(&write_req, req->handle, &buf, 1, write1_cb); - ASSERT(r == 0); + ASSERT_OK(r); write_cb_called++; } @@ -177,7 +177,7 @@ static void timer_cb(uv_timer_t* handle) { /* Shutdown on drain. */ r = uv_shutdown(&shutdown_req, (uv_stream_t*) &client, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); shutdown_requested++; } @@ -187,22 +187,22 @@ static void connect_cb(uv_connect_t* req, int status) { uv_stream_t* stream; int r; - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); stream = req->handle; connect_cb_called++; r = uv_write(&write_req, stream, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); /* Shutdown on drain. */ r = uv_shutdown(&shutdown_req, stream, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); /* Start reading */ r = uv_read_start(stream, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -211,25 +211,25 @@ static void connect1_cb(uv_connect_t* req, int status) { uv_stream_t* stream; int r; - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); stream = req->handle; connect_cb_called++; r = uv_timer_init(uv_default_loop(), &tm); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&tm, timer_cb, 2000, 0); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init("P", 1); r = uv_write(&write_req, stream, &buf, 1, write1_cb); - ASSERT(r == 0); + ASSERT_OK(r); /* Start reading */ r = uv_read_start(stream, alloc_cb, read1_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -239,30 +239,30 @@ TEST_IMPL(tcp_open) { int r; uv_tcp_t client2; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); startup(); sock = create_tcp_socket(); r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_open(&client, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 { r = uv_tcp_init(uv_default_loop(), &client2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_open(&client2, sock); - ASSERT(r == UV_EEXIST); + ASSERT_EQ(r, UV_EEXIST); uv_close((uv_handle_t*) &client2, NULL); } @@ -272,10 +272,10 @@ TEST_IMPL(tcp_open) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(shutdown_cb_called == 1); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -292,13 +292,13 @@ TEST_IMPL(tcp_open_twice) { sock2 = create_tcp_socket(); r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_open(&client, sock1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_open(&client, sock2); - ASSERT(r == UV_EBUSY); + ASSERT_EQ(r, UV_EBUSY); close_socket(sock2); uv_close((uv_handle_t*) &client, NULL); @@ -317,15 +317,15 @@ TEST_IMPL(tcp_open_bound) { startup(); sock = create_tcp_socket(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == bind(sock, (struct sockaddr*) &addr, sizeof(addr))); + ASSERT_OK(bind(sock, (struct sockaddr*) &addr, sizeof(addr))); - ASSERT(0 == uv_tcp_open(&server, sock)); + ASSERT_OK(uv_tcp_open(&server, sock)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, NULL)); + ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, NULL)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -338,28 +338,34 @@ TEST_IMPL(tcp_open_connected) { uv_os_sock_t sock; uv_buf_t buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); startup(); sock = create_tcp_socket(); - ASSERT(0 == connect(sock, (struct sockaddr*) &addr, sizeof(addr))); + ASSERT_OK(connect(sock, (struct sockaddr*) &addr, sizeof(addr))); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_open(&client, sock)); + ASSERT_OK(uv_tcp_open(&client, sock)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &client, &buf, 1, write_cb)); + ASSERT_OK(uv_write(&write_req, + (uv_stream_t*) &client, + &buf, + 1, + write_cb)); - ASSERT(0 == uv_shutdown(&shutdown_req, (uv_stream_t*) &client, shutdown_cb)); + ASSERT_OK(uv_shutdown(&shutdown_req, + (uv_stream_t*) &client, + shutdown_cb)); - ASSERT(0 == uv_read_start((uv_stream_t*) &client, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) &client, alloc_cb, read_cb)); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(shutdown_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -371,30 +377,30 @@ TEST_IMPL(tcp_write_ready) { uv_os_sock_t sock; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); startup(); sock = create_tcp_socket(); r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_open(&client, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &client, (const struct sockaddr*) &addr, connect1_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(shutdown_cb_called == 1); - ASSERT(shutdown_requested == 1); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called > 0); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, shutdown_requested); + ASSERT_EQ(1, connect_cb_called); + ASSERT_GT(write_cb_called, 0); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-read-stop-start.c b/deps/libuv/test/test-tcp-read-stop-start.c index 9be12bb7..68d6f7c2 100644 --- a/deps/libuv/test/test-tcp-read-stop-start.c +++ b/deps/libuv/test/test-tcp-read-stop-start.c @@ -33,14 +33,14 @@ static uv_connect_t connect_req; static void on_read2(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf); static void on_write_close_immediately(uv_write_t* req, int status) { - ASSERT(0 == status); + ASSERT_OK(status); uv_close((uv_handle_t*)req->handle, NULL); /* Close immediately */ free(req); } static void on_write(uv_write_t* req, int status) { - ASSERT(0 == status); + ASSERT_OK(status); free(req); } @@ -50,7 +50,7 @@ static void do_write(uv_stream_t* stream, uv_write_cb cb) { uv_buf_t buf; buf.base = "1234578"; buf.len = 8; - ASSERT(0 == uv_write(req, stream, &buf, 1, cb)); + ASSERT_OK(uv_write(req, stream, &buf, 1, cb)); } static void on_alloc(uv_handle_t* handle, @@ -62,22 +62,22 @@ static void on_alloc(uv_handle_t* handle, } static void on_read1(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread >= 0); + ASSERT_GE(nread, 0); /* Do write on a half open connection to force WSAECONNABORTED (on Windows) * in the subsequent uv_read_start() */ do_write(stream, on_write); - ASSERT(0 == uv_read_stop(stream)); + ASSERT_OK(uv_read_stop(stream)); - ASSERT(0 == uv_read_start(stream, on_alloc, on_read2)); + ASSERT_OK(uv_read_start(stream, on_alloc, on_read2)); read_cb_called++; } static void on_read2(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { - ASSERT(nread < 0); + ASSERT_LT(nread, 0); uv_close((uv_handle_t*)stream, NULL); uv_close((uv_handle_t*)&server, NULL); @@ -86,17 +86,17 @@ static void on_read2(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { } static void on_connection(uv_stream_t* server, int status) { - ASSERT(0 == status); + ASSERT_OK(status); - ASSERT(0 == uv_tcp_init(server->loop, &connection)); + ASSERT_OK(uv_tcp_init(server->loop, &connection)); - ASSERT(0 == uv_accept(server, (uv_stream_t* )&connection)); + ASSERT_OK(uv_accept(server, (uv_stream_t* )&connection)); - ASSERT(0 == uv_read_start((uv_stream_t*)&connection, on_alloc, on_read1)); + ASSERT_OK(uv_read_start((uv_stream_t*)&connection, on_alloc, on_read1)); } static void on_connect(uv_connect_t* req, int status) { - ASSERT(0 == status); + ASSERT_OK(status); do_write((uv_stream_t*)&client, on_write_close_immediately); } @@ -107,29 +107,29 @@ TEST_IMPL(tcp_read_stop_start) { { /* Server */ struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &server)); + ASSERT_OK(uv_tcp_init(loop, &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) & addr, 0)); + ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) & addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*)&server, 10, on_connection)); + ASSERT_OK(uv_listen((uv_stream_t*)&server, 10, on_connection)); } { /* Client */ struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(loop, &client)); + ASSERT_OK(uv_tcp_init(loop, &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, &client, - (const struct sockaddr*) & addr, on_connect)); + ASSERT_OK(uv_tcp_connect(&connect_req, &client, + (const struct sockaddr*) & addr, on_connect)); } - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(read_cb_called >= 2); + ASSERT_GE(read_cb_called, 2); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-read-stop.c b/deps/libuv/test/test-tcp-read-stop.c index 1754876d..114c5ec1 100644 --- a/deps/libuv/test/test-tcp-read-stop.c +++ b/deps/libuv/test/test-tcp-read-stop.c @@ -40,21 +40,21 @@ static void write_cb(uv_write_t* req, int status) { static void timer_cb(uv_timer_t* handle) { uv_buf_t buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_write(&write_req, - (uv_stream_t*) &tcp_handle, - &buf, - 1, - write_cb)); - ASSERT(0 == uv_read_stop((uv_stream_t*) &tcp_handle)); + ASSERT_OK(uv_write(&write_req, + (uv_stream_t*) &tcp_handle, + &buf, + 1, + write_cb)); + ASSERT_OK(uv_read_stop((uv_stream_t*) &tcp_handle)); } static void connect_cb(uv_connect_t* req, int status) { - ASSERT(0 == status); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 50, 0)); - ASSERT(0 == uv_read_start((uv_stream_t*) &tcp_handle, - (uv_alloc_cb) fail_cb, - (uv_read_cb) fail_cb)); + ASSERT_OK(status); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 50, 0)); + ASSERT_OK(uv_read_start((uv_stream_t*) &tcp_handle, + (uv_alloc_cb) fail_cb, + (uv_read_cb) fail_cb)); } @@ -62,14 +62,14 @@ TEST_IMPL(tcp_read_stop) { uv_connect_t connect_req; struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp_handle)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &tcp_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &tcp_handle)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &tcp_handle, + (const struct sockaddr*) &addr, + connect_cb)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-rst.c b/deps/libuv/test/test-tcp-rst.c index b5d216ce..7729f03e 100644 --- a/deps/libuv/test/test-tcp-rst.c +++ b/deps/libuv/test/test-tcp-rst.c @@ -31,7 +31,7 @@ static int called_close_cb; static void close_cb(uv_handle_t* handle) { - ASSERT(handle == (uv_handle_t*) &tcp); + ASSERT_PTR_EQ(handle, (uv_handle_t*) &tcp); called_close_cb++; } @@ -48,7 +48,7 @@ static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { ASSERT_EQ(nread, UV_ECONNRESET); int fd; - ASSERT_EQ(0, uv_fileno((uv_handle_t*) t, &fd)); + ASSERT_OK(uv_fileno((uv_handle_t*) t, &fd)); uv_handle_type type = uv_guess_handle(fd); ASSERT_EQ(type, UV_TCP); @@ -58,11 +58,11 @@ static void read_cb(uv_stream_t* t, ssize_t nread, const uv_buf_t* buf) { static void connect_cb(uv_connect_t *req, int status) { - ASSERT_EQ(status, 0); + ASSERT_OK(status); ASSERT_PTR_EQ(req, &connect_req); /* Start reading from the connection so we receive the RST in uv__read. */ - ASSERT_EQ(0, uv_read_start((uv_stream_t*) &tcp, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) &tcp, alloc_cb, read_cb)); /* Write 'QSH' to receive RST from the echo server. */ ASSERT_EQ(qbuf.len, uv_try_write((uv_stream_t*) &tcp, &qbuf, 1)); @@ -86,21 +86,21 @@ TEST_IMPL(tcp_rst) { qbuf.base = "QSH"; qbuf.len = 3; - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); r = uv_tcp_init(uv_default_loop(), &tcp); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &tcp, (const struct sockaddr*) &server_addr, connect_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(called_alloc_cb, 1); - ASSERT_EQ(called_connect_cb, 1); - ASSERT_EQ(called_close_cb, 1); + ASSERT_EQ(1, called_alloc_cb); + ASSERT_EQ(1, called_connect_cb); + ASSERT_EQ(1, called_close_cb); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-shutdown-after-write.c b/deps/libuv/test/test-tcp-shutdown-after-write.c index d2401e8f..cd8c24dd 100644 --- a/deps/libuv/test/test-tcp-shutdown-after-write.c +++ b/deps/libuv/test/test-tcp-shutdown-after-write.c @@ -66,10 +66,10 @@ static void timer_cb(uv_timer_t* handle) { buf = uv_buf_init("TEST", 4); r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_shutdown(&shutdown_req, (uv_stream_t*)&conn, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -80,22 +80,22 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { static void connect_cb(uv_connect_t* req, int status) { int r; - ASSERT(status == 0); + ASSERT_OK(status); connect_cb_called++; r = uv_read_start((uv_stream_t*)&conn, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); } static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); write_cb_called++; } static void shutdown_cb(uv_shutdown_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); shutdown_cb_called++; uv_close((uv_handle_t*)&conn, close_cb); } @@ -106,32 +106,32 @@ TEST_IMPL(tcp_shutdown_after_write) { uv_loop_t* loop; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 125, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_init(loop, &conn); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &conn, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(shutdown_cb_called == 1); - ASSERT(conn_close_cb_called == 1); - ASSERT(timer_close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, conn_close_cb_called); + ASSERT_EQ(1, timer_close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-try-write-error.c b/deps/libuv/test/test-tcp-try-write-error.c index 97deccaa..80a23ed7 100644 --- a/deps/libuv/test/test-tcp-try-write-error.c +++ b/deps/libuv/test/test-tcp-try-write-error.c @@ -49,21 +49,21 @@ static void incoming_close_cb(uv_handle_t* handle) { r = uv_try_write((uv_stream_t*) &client, &buf, 1); fprintf(stderr, "uv_try_write error: %d %s\n", r, uv_strerror(r)); ASSERT(r == UV_EPIPE || r == UV_ECONNABORTED || r == UV_ECONNRESET); - ASSERT(client.write_queue_size == 0); + ASSERT_OK(client.write_queue_size); } static void connect_cb(uv_connect_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); connect_cb_called++; } static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); + ASSERT_OK(status); - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); + ASSERT_OK(uv_tcp_init(tcp->loop, &incoming)); + ASSERT_OK(uv_accept(tcp, (uv_stream_t*) &incoming)); connection_cb_called++; uv_close((uv_handle_t*) &incoming, incoming_close_cb); @@ -74,11 +74,11 @@ static void connection_cb(uv_stream_t* tcp, int status) { static void start_server(void) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, connection_cb)); } @@ -88,21 +88,21 @@ TEST_IMPL(tcp_try_write_error) { start_server(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client, + (struct sockaddr*) &addr, + connect_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); uv_close((uv_handle_t*) &client, close_cb); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(connection_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(3, close_cb_called); + ASSERT_EQ(1, connection_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-try-write.c b/deps/libuv/test/test-tcp-try-write.c index 6458857a..afb20ec7 100644 --- a/deps/libuv/test/test-tcp-try-write.c +++ b/deps/libuv/test/test-tcp-try-write.c @@ -46,7 +46,7 @@ static void close_cb(uv_handle_t* handle) { static void connect_cb(uv_connect_t* req, int status) { int r; uv_buf_t buf; - ASSERT(status == 0); + ASSERT_OK(status); connect_cb_called++; do { @@ -87,24 +87,24 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); + ASSERT_OK(status); - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); + ASSERT_OK(uv_tcp_init(tcp->loop, &incoming)); + ASSERT_OK(uv_accept(tcp, (uv_stream_t*) &incoming)); connection_cb_called++; - ASSERT(0 == uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb)); + ASSERT_OK(uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb)); } static void start_server(void) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, connection_cb)); } @@ -114,21 +114,21 @@ TEST_IMPL(tcp_try_write) { start_server(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client, + (struct sockaddr*) &addr, + connect_cb)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(close_cb_called == 3); - ASSERT(connection_cb_called == 1); - ASSERT(bytes_read == bytes_written); - ASSERT(bytes_written > 0); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(3, close_cb_called); + ASSERT_EQ(1, connection_cb_called); + ASSERT_EQ(bytes_read, bytes_written); + ASSERT_GT(bytes_written, 0); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-unexpected-read.c b/deps/libuv/test/test-tcp-unexpected-read.c index e11f7747..aef7a2f7 100644 --- a/deps/libuv/test/test-tcp-unexpected-read.c +++ b/deps/libuv/test/test-tcp-unexpected-read.c @@ -60,14 +60,14 @@ static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &client_handle); - ASSERT(0 == status); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*) &client_handle); + ASSERT_OK(status); } static void write_cb(uv_write_t* req, int status) { - ASSERT(req->handle == (uv_stream_t*) &peer_handle); - ASSERT(0 == status); + ASSERT_PTR_EQ(req->handle, (uv_stream_t*) &peer_handle); + ASSERT_OK(status); } @@ -76,11 +76,11 @@ static void connection_cb(uv_stream_t* handle, int status) { buf = uv_buf_init("PING", 4); - ASSERT(0 == status); - ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle)); - ASSERT(0 == uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); - ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &peer_handle, - &buf, 1, write_cb)); + ASSERT_OK(status); + ASSERT_OK(uv_accept(handle, (uv_stream_t*) &peer_handle)); + ASSERT_OK(uv_read_start((uv_stream_t*) &peer_handle, alloc_cb, read_cb)); + ASSERT_OK(uv_write(&write_req, (uv_stream_t*) &peer_handle, + &buf, 1, write_cb)); } @@ -88,29 +88,29 @@ TEST_IMPL(tcp_unexpected_read) { struct sockaddr_in addr; uv_loop_t* loop; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); - ASSERT(0 == uv_timer_init(loop, &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1000, 0)); - ASSERT(0 == uv_check_init(loop, &check_handle)); - ASSERT(0 == uv_check_start(&check_handle, check_cb)); - ASSERT(0 == uv_tcp_init(loop, &server_handle)); - ASSERT(0 == uv_tcp_init(loop, &client_handle)); - ASSERT(0 == uv_tcp_init(loop, &peer_handle)); - ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client_handle, - (const struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_init(loop, &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 1000, 0)); + ASSERT_OK(uv_check_init(loop, &check_handle)); + ASSERT_OK(uv_check_start(&check_handle, check_cb)); + ASSERT_OK(uv_tcp_init(loop, &server_handle)); + ASSERT_OK(uv_tcp_init(loop, &client_handle)); + ASSERT_OK(uv_tcp_init(loop, &peer_handle)); + ASSERT_OK(uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server_handle, 1, connection_cb)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client_handle, + (const struct sockaddr*) &addr, + connect_cb)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); /* This is somewhat inexact but the idea is that the event loop should not * start busy looping when the server sends a message and the client isn't * reading. */ - ASSERT(ticks <= 20); + ASSERT_LE(ticks, 20); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-write-after-connect.c b/deps/libuv/test/test-tcp-write-after-connect.c index 4a786995..63845bc4 100644 --- a/deps/libuv/test/test-tcp-write-after-connect.c +++ b/deps/libuv/test/test-tcp-write-after-connect.c @@ -32,13 +32,13 @@ uv_buf_t buf = { "HELLO", 4 }; static void write_cb(uv_write_t *req, int status) { - ASSERT(status == UV_ECANCELED); + ASSERT_EQ(status, UV_ECANCELED); uv_close((uv_handle_t*) req->handle, NULL); } static void connect_cb(uv_connect_t *req, int status) { - ASSERT(status == UV_ECONNREFUSED); + ASSERT_EQ(status, UV_ECONNREFUSED); } @@ -49,20 +49,20 @@ TEST_IMPL(tcp_write_after_connect) { #endif struct sockaddr_in sa; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &sa)); - ASSERT(0 == uv_loop_init(&loop)); - ASSERT(0 == uv_tcp_init(&loop, &tcp_client)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &sa)); + ASSERT_OK(uv_loop_init(&loop)); + ASSERT_OK(uv_tcp_init(&loop, &tcp_client)); - ASSERT(0 == uv_tcp_connect(&connection_request, - &tcp_client, - (const struct sockaddr *) - &sa, - connect_cb)); + ASSERT_OK(uv_tcp_connect(&connection_request, + &tcp_client, + (const struct sockaddr *) + &sa, + connect_cb)); - ASSERT(0 == uv_write(&write_request, - (uv_stream_t *)&tcp_client, - &buf, 1, - write_cb)); + ASSERT_OK(uv_write(&write_request, + (uv_stream_t *)&tcp_client, + &buf, 1, + write_cb)); uv_run(&loop, UV_RUN_DEFAULT); diff --git a/deps/libuv/test/test-tcp-write-fail.c b/deps/libuv/test/test-tcp-write-fail.c index 2912e7c5..530329a3 100644 --- a/deps/libuv/test/test-tcp-write-fail.c +++ b/deps/libuv/test/test-tcp-write-fail.c @@ -41,13 +41,13 @@ static void close_socket(uv_tcp_t* sock) { int r; r = uv_fileno((uv_handle_t*)sock, &fd); - ASSERT(r == 0); + ASSERT_OK(r); #ifdef _WIN32 r = closesocket((uv_os_sock_t)fd); #else r = close(fd); #endif - ASSERT(r == 0); + ASSERT_OK(r); } @@ -60,7 +60,7 @@ static void close_cb(uv_handle_t* handle) { static void write_cb(uv_write_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status != 0); + ASSERT(status); fprintf(stderr, "uv_write error: %s\n", uv_strerror(status)); write_cb_called++; @@ -73,8 +73,8 @@ static void connect_cb(uv_connect_t* req, int status) { uv_stream_t* stream; int r; - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); stream = req->handle; connect_cb_called++; @@ -84,7 +84,7 @@ static void connect_cb(uv_connect_t* req, int status) { buf = uv_buf_init("hello\n", 6); r = uv_write(&write_req, stream, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -93,22 +93,22 @@ TEST_IMPL(tcp_write_fail) { uv_tcp_t client; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, write_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-write-in-a-row.c b/deps/libuv/test/test-tcp-write-in-a-row.c index 99f4dee1..89304eb5 100644 --- a/deps/libuv/test/test-tcp-write-in-a-row.c +++ b/deps/libuv/test/test-tcp-write-in-a-row.c @@ -45,7 +45,7 @@ static void close_cb(uv_handle_t* handle) { static void write_cb(uv_write_t* w, int status) { /* the small write should finish immediately after the big write */ - ASSERT_EQ(0, uv_stream_get_write_queue_size((uv_stream_t*) &client)); + ASSERT_OK(uv_stream_get_write_queue_size((uv_stream_t*) &client)); write_cb_called++; @@ -62,13 +62,13 @@ static void connect_cb(uv_connect_t* _, int status) { uv_buf_t buf; size_t write_queue_size0, write_queue_size1; - ASSERT_EQ(0, status); + ASSERT_OK(status); connect_cb_called++; /* fire a big write */ buf = uv_buf_init(data, sizeof(data)); r = uv_write(&small_write, (uv_stream_t*) &client, &buf, 1, write_cb); - ASSERT_EQ(0, r); + ASSERT_OK(r); /* check that the write process gets stuck */ write_queue_size0 = uv_stream_get_write_queue_size((uv_stream_t*) &client); @@ -77,7 +77,7 @@ static void connect_cb(uv_connect_t* _, int status) { /* fire a small write, which should be queued */ buf = uv_buf_init("A", 1); r = uv_write(&big_write, (uv_stream_t*) &client, &buf, 1, write_cb); - ASSERT_EQ(0, r); + ASSERT_OK(r); write_queue_size1 = uv_stream_get_write_queue_size((uv_stream_t*) &client); ASSERT_EQ(write_queue_size1, write_queue_size0 + 1); @@ -93,22 +93,22 @@ static void alloc_cb(uv_handle_t* handle, size_t size, uv_buf_t* buf) { static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {} static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT_EQ(0, status); + ASSERT_OK(status); connection_cb_called++; - ASSERT_EQ(0, uv_tcp_init(tcp->loop, &incoming)); - ASSERT_EQ(0, uv_accept(tcp, (uv_stream_t*) &incoming)); - ASSERT_EQ(0, uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb)); + ASSERT_OK(uv_tcp_init(tcp->loop, &incoming)); + ASSERT_OK(uv_accept(tcp, (uv_stream_t*) &incoming)); + ASSERT_OK(uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb)); } static void start_server(void) { struct sockaddr_in addr; - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_tcp_init(uv_default_loop(), &server)); - ASSERT_EQ(0, uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT_EQ(0, uv_listen((uv_stream_t*) &server, 128, connection_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, connection_cb)); } TEST_IMPL(tcp_write_in_a_row) { @@ -121,15 +121,15 @@ TEST_IMPL(tcp_write_in_a_row) { start_server(); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_tcp_init(uv_default_loop(), &client)); - ASSERT_EQ(0, uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client, + (struct sockaddr*) &addr, + connect_cb)); - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT_EQ(1, connect_cb_called); ASSERT_EQ(3, close_cb_called); diff --git a/deps/libuv/test/test-tcp-write-queue-order.c b/deps/libuv/test/test-tcp-write-queue-order.c index 7562c41d..e838c88a 100644 --- a/deps/libuv/test/test-tcp-write-queue-order.c +++ b/deps/libuv/test/test-tcp-write-queue-order.c @@ -67,7 +67,7 @@ static void connect_cb(uv_connect_t* req, int status) { int i; uv_buf_t buf; - ASSERT(status == 0); + ASSERT_OK(status); connect_cb_called++; buf = uv_buf_init(base, sizeof(base)); @@ -78,19 +78,19 @@ static void connect_cb(uv_connect_t* req, int status) { &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } } static void connection_cb(uv_stream_t* tcp, int status) { - ASSERT(status == 0); + ASSERT_OK(status); - ASSERT(0 == uv_tcp_init(tcp->loop, &incoming)); - ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming)); + ASSERT_OK(uv_tcp_init(tcp->loop, &incoming)); + ASSERT_OK(uv_accept(tcp, (uv_stream_t*) &incoming)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer)); - ASSERT(0 == uv_timer_start(&timer, timer_cb, 1000, 0)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer)); + ASSERT_OK(uv_timer_start(&timer, timer_cb, 1000, 0)); connection_cb_called++; } @@ -99,11 +99,11 @@ static void connection_cb(uv_stream_t* tcp, int status) { static void start_server(void) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &server)); - ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); - ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, connection_cb)); } @@ -114,25 +114,25 @@ TEST_IMPL(tcp_write_queue_order) { start_server(); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(0 == uv_tcp_init(uv_default_loop(), &client)); - ASSERT(0 == uv_tcp_connect(&connect_req, - &client, - (struct sockaddr*) &addr, - connect_cb)); - ASSERT(0 == uv_send_buffer_size((uv_handle_t*) &client, &buffer_size)); + ASSERT_OK(uv_tcp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_tcp_connect(&connect_req, + &client, + (struct sockaddr*) &addr, + connect_cb)); + ASSERT_OK(uv_send_buffer_size((uv_handle_t*) &client, &buffer_size)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(connect_cb_called == 1); - ASSERT(connection_cb_called == 1); - ASSERT(write_callbacks > 0); - ASSERT(write_cancelled_callbacks > 0); - ASSERT(write_callbacks + - write_error_callbacks + - write_cancelled_callbacks == REQ_COUNT); - ASSERT(close_cb_called == 3); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(1, connection_cb_called); + ASSERT_GT(write_callbacks, 0); + ASSERT_GT(write_cancelled_callbacks, 0); + ASSERT_EQ(write_callbacks + + write_error_callbacks + + write_cancelled_callbacks, REQ_COUNT); + ASSERT_EQ(3, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tcp-write-to-half-open-connection.c b/deps/libuv/test/test-tcp-write-to-half-open-connection.c index 8978211d..2b2f5644 100644 --- a/deps/libuv/test/test-tcp-write-to-half-open-connection.c +++ b/deps/libuv/test/test-tcp-write-to-half-open-connection.c @@ -45,23 +45,23 @@ static void connection_cb(uv_stream_t* server, int status) { int r; uv_buf_t buf; - ASSERT(server == (uv_stream_t*)&tcp_server); - ASSERT(status == 0); + ASSERT_PTR_EQ(server, (uv_stream_t*)&tcp_server); + ASSERT_OK(status); r = uv_tcp_init(server->loop, &tcp_peer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_accept(server, (uv_stream_t*)&tcp_peer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*)&tcp_peer, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); buf.base = "hello\n"; buf.len = 6; r = uv_write(&write_req, (uv_stream_t*)&tcp_peer, &buf, 1, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -88,8 +88,8 @@ static void read_cb(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) { static void connect_cb(uv_connect_t* req, int status) { - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); /* Close the client. */ uv_close((uv_handle_t*)&tcp_client, NULL); @@ -97,7 +97,7 @@ static void connect_cb(uv_connect_t* req, int status) { static void write_cb(uv_write_t* req, int status) { - ASSERT(status == 0); + ASSERT_OK(status); write_cb_called++; } @@ -107,34 +107,34 @@ TEST_IMPL(tcp_write_to_half_open_connection) { uv_loop_t* loop; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); loop = uv_default_loop(); ASSERT_NOT_NULL(loop); r = uv_tcp_init(loop, &tcp_server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_bind(&tcp_server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_listen((uv_stream_t*)&tcp_server, 1, connection_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_init(loop, &tcp_client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &tcp_client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(write_cb_called > 0); - ASSERT(read_cb_called > 0); + ASSERT_GT(write_cb_called, 0); + ASSERT_GT(read_cb_called, 0); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-tcp-writealot.c b/deps/libuv/test/test-tcp-writealot.c index 3c6c149e..ebafb179 100644 --- a/deps/libuv/test/test-tcp-writealot.c +++ b/deps/libuv/test/test-tcp-writealot.c @@ -65,19 +65,19 @@ static void close_cb(uv_handle_t* handle) { static void shutdown_cb(uv_shutdown_t* req, int status) { uv_tcp_t* tcp; - ASSERT(req == &shutdown_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &shutdown_req); + ASSERT_OK(status); tcp = (uv_tcp_t*)(req->handle); /* The write buffer should be empty by now. */ - ASSERT(tcp->write_queue_size == 0); + ASSERT_OK(tcp->write_queue_size); /* Now we wait for the EOF */ shutdown_cb_called++; /* We should have had all the writes called already. */ - ASSERT(write_cb_called == WRITES); + ASSERT_EQ(write_cb_called, WRITES); } @@ -88,7 +88,7 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { bytes_received_done += nread; } else { - ASSERT(nread == UV_EOF); + ASSERT_EQ(nread, UV_EOF); printf("GOT EOF\n"); uv_close((uv_handle_t*)tcp, close_cb); } @@ -115,8 +115,8 @@ static void connect_cb(uv_connect_t* req, int status) { uv_stream_t* stream; int i, j, r; - ASSERT(req == &connect_req); - ASSERT(status == 0); + ASSERT_PTR_EQ(req, &connect_req); + ASSERT_OK(status); stream = req->handle; connect_cb_called++; @@ -131,16 +131,16 @@ static void connect_cb(uv_connect_t* req, int status) { } r = uv_write(write_req, stream, send_bufs, CHUNKS_PER_WRITE, write_cb); - ASSERT(r == 0); + ASSERT_OK(r); } /* Shutdown on drain. */ r = uv_shutdown(&shutdown_req, stream, shutdown_cb); - ASSERT(r == 0); + ASSERT_OK(r); /* Start reading */ r = uv_read_start(stream, alloc_cb, read_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -153,29 +153,29 @@ TEST_IMPL(tcp_writealot) { RETURN_SKIP("Test is too slow to run under ThreadSanitizer"); #endif - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); send_buffer = calloc(1, TOTAL_BYTES); ASSERT_NOT_NULL(send_buffer); r = uv_tcp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tcp_connect(&connect_req, &client, (const struct sockaddr*) &addr, connect_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(shutdown_cb_called == 1); - ASSERT(connect_cb_called == 1); - ASSERT(write_cb_called == WRITES); - ASSERT(close_cb_called == 1); - ASSERT(bytes_sent == TOTAL_BYTES); - ASSERT(bytes_sent_done == TOTAL_BYTES); - ASSERT(bytes_received_done == TOTAL_BYTES); + ASSERT_EQ(1, shutdown_cb_called); + ASSERT_EQ(1, connect_cb_called); + ASSERT_EQ(write_cb_called, WRITES); + ASSERT_EQ(1, close_cb_called); + ASSERT_EQ(bytes_sent, TOTAL_BYTES); + ASSERT_EQ(bytes_sent_done, TOTAL_BYTES); + ASSERT_EQ(bytes_received_done, TOTAL_BYTES); free(send_buffer); diff --git a/deps/libuv/test/test-thread-affinity.c b/deps/libuv/test/test-thread-affinity.c index 2c9b696e..d21487d9 100644 --- a/deps/libuv/test/test-thread-affinity.c +++ b/deps/libuv/test/test-thread-affinity.c @@ -1,4 +1,22 @@ /* Copyright libuv project 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" @@ -16,12 +34,12 @@ static void check_affinity(void* arg) { cpumask = (char*)arg; cpumasksize = uv_cpumask_size(); - ASSERT(cpumasksize > 0); + ASSERT_GT(cpumasksize, 0); tid = uv_thread_self(); r = uv_thread_setaffinity(&tid, cpumask, NULL, cpumasksize); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_thread_setaffinity(&tid, cpumask + cpumasksize, cpumask, cpumasksize); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -45,13 +63,13 @@ TEST_IMPL(thread_affinity) { threads[0] = uv_thread_self(); #endif cpumasksize = uv_cpumask_size(); - ASSERT(cpumasksize > 0); + ASSERT_GT(cpumasksize, 0); cpumask = calloc(4 * cpumasksize, 1); ASSERT(cpumask); r = uv_thread_getaffinity(&threads[0], cpumask, cpumasksize); - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(cpumask[0] && "test must be run with cpu 0 affinity"); ncpus = 0; while (cpumask[++ncpus]) { } @@ -82,24 +100,24 @@ TEST_IMPL(thread_affinity) { } #endif - ASSERT(0 == uv_thread_create(threads + 1, - check_affinity, - &cpumask[t1first])); - ASSERT(0 == uv_thread_create(threads + 2, - check_affinity, - &cpumask[t2first])); - ASSERT(0 == uv_thread_join(threads + 1)); - ASSERT(0 == uv_thread_join(threads + 2)); + ASSERT_OK(uv_thread_create(threads + 1, + check_affinity, + &cpumask[t1first])); + ASSERT_OK(uv_thread_create(threads + 2, + check_affinity, + &cpumask[t2first])); + ASSERT_OK(uv_thread_join(threads + 1)); + ASSERT_OK(uv_thread_join(threads + 2)); ASSERT(cpumask[t1first + 0] == (ncpus == 1)); ASSERT(cpumask[t1first + 1] == (ncpus >= 2)); - ASSERT(cpumask[t1first + 2] == 0); + ASSERT_OK(cpumask[t1first + 2]); ASSERT(cpumask[t1first + 3] == (ncpus >= 4)); - ASSERT(cpumask[t2first + 0] == 1); - ASSERT(cpumask[t2first + 1] == 0); + ASSERT_EQ(1, cpumask[t2first + 0]); + ASSERT_OK(cpumask[t2first + 1]); ASSERT(cpumask[t2first + 2] == (ncpus >= 3)); - ASSERT(cpumask[t2first + 3] == 0); + ASSERT_OK(cpumask[t2first + 3]); c = uv_thread_getcpu(); ASSERT_GE(c, 0); @@ -107,16 +125,16 @@ TEST_IMPL(thread_affinity) { memset(cpumask, 0, cpumasksize); cpumask[c] = 1; r = uv_thread_setaffinity(&threads[0], cpumask, NULL, cpumasksize); - ASSERT_EQ(r, 0); + ASSERT_OK(r); memset(cpumask, 0, cpumasksize); r = uv_thread_getaffinity(&threads[0], cpumask, cpumasksize); - ASSERT_EQ(r, 0); + ASSERT_OK(r); for (i = 0; i < cpumasksize; i++) { if (i == c) ASSERT_EQ(1, cpumask[i]); else - ASSERT_EQ(0, cpumask[i]); + ASSERT_OK(cpumask[i]); } free(cpumask); @@ -129,7 +147,7 @@ TEST_IMPL(thread_affinity) { TEST_IMPL(thread_affinity) { int cpumasksize; cpumasksize = uv_cpumask_size(); - ASSERT(cpumasksize == UV_ENOTSUP); + ASSERT_EQ(cpumasksize, UV_ENOTSUP); return 0; } diff --git a/deps/libuv/test/test-thread-equal.c b/deps/libuv/test/test-thread-equal.c index f7bde71b..3b2ba8df 100644 --- a/deps/libuv/test/test-thread-equal.c +++ b/deps/libuv/test/test-thread-equal.c @@ -31,7 +31,7 @@ static void check_thread(void* arg) { #ifdef _WIN32 ASSERT_NOT_NULL(self_id); #endif - ASSERT(uv_thread_equal(&main_thread_id, &self_id) == 0); + ASSERT_OK(uv_thread_equal(&main_thread_id, &self_id)); *thread_id = uv_thread_self(); } @@ -41,11 +41,11 @@ TEST_IMPL(thread_equal) { #ifdef _WIN32 ASSERT_NOT_NULL(main_thread_id); #endif - ASSERT(0 != uv_thread_equal(&main_thread_id, &main_thread_id)); - ASSERT(0 == uv_thread_create(threads + 0, check_thread, subthreads + 0)); - ASSERT(0 == uv_thread_create(threads + 1, check_thread, subthreads + 1)); - ASSERT(0 == uv_thread_join(threads + 0)); - ASSERT(0 == uv_thread_join(threads + 1)); - ASSERT(0 == uv_thread_equal(subthreads + 0, subthreads + 1)); + ASSERT_NE(0, uv_thread_equal(&main_thread_id, &main_thread_id)); + ASSERT_OK(uv_thread_create(threads + 0, check_thread, subthreads + 0)); + ASSERT_OK(uv_thread_create(threads + 1, check_thread, subthreads + 1)); + ASSERT_OK(uv_thread_join(threads + 0)); + ASSERT_OK(uv_thread_join(threads + 1)); + ASSERT_OK(uv_thread_equal(subthreads + 0, subthreads + 1)); return 0; } diff --git a/deps/libuv/test/test-thread.c b/deps/libuv/test/test-thread.c index 82f80833..d0094e30 100644 --- a/deps/libuv/test/test-thread.c +++ b/deps/libuv/test/test-thread.c @@ -71,7 +71,7 @@ static void getaddrinfo_do(struct getaddrinfo_req* req) { "localhost", NULL, NULL); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -80,7 +80,7 @@ static void getaddrinfo_cb(uv_getaddrinfo_t* handle, struct addrinfo* res) { struct getaddrinfo_req* req; - ASSERT(status == 0); + ASSERT_OK(status); req = container_of(handle, struct getaddrinfo_req, handle); uv_freeaddrinfo(res); @@ -94,7 +94,7 @@ static void fs_do(struct fs_req* req) { int r; r = uv_fs_stat(req->loop, &req->handle, ".", fs_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -115,7 +115,7 @@ static void do_work(void* arg) { size_t i; struct test_thread* thread = arg; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); for (i = 0; i < ARRAY_SIZE(getaddrinfo_reqs); i++) { struct getaddrinfo_req* req = getaddrinfo_reqs + i; @@ -131,14 +131,14 @@ static void do_work(void* arg) { fs_do(req); } - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); - ASSERT(0 == uv_loop_close(&loop)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_loop_close(&loop)); thread->thread_called = 1; } static void thread_entry(void* arg) { - ASSERT(arg == (void *) 42); + ASSERT_PTR_EQ(arg, (void *) 42); thread_called++; } @@ -148,12 +148,12 @@ TEST_IMPL(thread_create) { int r; r = uv_thread_create(&tid, thread_entry, (void *) 42); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_thread_join(&tid); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(thread_called == 1); + ASSERT_EQ(1, thread_called); return 0; } @@ -176,13 +176,13 @@ TEST_IMPL(threadpool_multiple_event_loops) { for (i = 0; i < ARRAY_SIZE(threads); i++) { r = uv_thread_create(&threads[i].thread_id, do_work, &threads[i]); - ASSERT(r == 0); + ASSERT_OK(r); } for (i = 0; i < ARRAY_SIZE(threads); i++) { r = uv_thread_join(&threads[i].thread_id); - ASSERT(r == 0); - ASSERT(threads[i].thread_called == 1); + ASSERT_OK(r); + ASSERT_EQ(1, threads[i].thread_called); } return 0; @@ -192,7 +192,7 @@ TEST_IMPL(threadpool_multiple_event_loops) { static void tls_thread(void* arg) { ASSERT_NULL(uv_key_get(&tls_key)); uv_key_set(&tls_key, arg); - ASSERT(arg == uv_key_get(&tls_key)); + ASSERT_PTR_EQ(arg, uv_key_get(&tls_key)); uv_key_set(&tls_key, NULL); ASSERT_NULL(uv_key_get(&tls_key)); } @@ -201,14 +201,14 @@ static void tls_thread(void* arg) { TEST_IMPL(thread_local_storage) { char name[] = "main"; uv_thread_t threads[2]; - ASSERT(0 == uv_key_create(&tls_key)); + ASSERT_OK(uv_key_create(&tls_key)); ASSERT_NULL(uv_key_get(&tls_key)); uv_key_set(&tls_key, name); - ASSERT(name == uv_key_get(&tls_key)); - ASSERT(0 == uv_thread_create(threads + 0, tls_thread, threads + 0)); - ASSERT(0 == uv_thread_create(threads + 1, tls_thread, threads + 1)); - ASSERT(0 == uv_thread_join(threads + 0)); - ASSERT(0 == uv_thread_join(threads + 1)); + ASSERT_PTR_EQ(name, uv_key_get(&tls_key)); + ASSERT_OK(uv_thread_create(threads + 0, tls_thread, threads + 0)); + ASSERT_OK(uv_thread_create(threads + 1, tls_thread, threads + 1)); + ASSERT_OK(uv_thread_join(threads + 0)); + ASSERT_OK(uv_thread_join(threads + 1)); uv_key_delete(&tls_key); return 0; } @@ -222,30 +222,30 @@ static void thread_check_stack(void* arg) { * on MacOS. */ if (expected == 0) expected = 512 * 1024; - ASSERT(pthread_get_stacksize_np(pthread_self()) >= expected); + ASSERT_GE(pthread_get_stacksize_np(pthread_self()), expected); #elif defined(__linux__) && defined(__GLIBC__) size_t expected; struct rlimit lim; size_t stack_size; pthread_attr_t attr; - ASSERT(0 == getrlimit(RLIMIT_STACK, &lim)); + ASSERT_OK(getrlimit(RLIMIT_STACK, &lim)); if (lim.rlim_cur == RLIM_INFINITY) lim.rlim_cur = 2 << 20; /* glibc default. */ - ASSERT(0 == pthread_getattr_np(pthread_self(), &attr)); - ASSERT(0 == pthread_attr_getstacksize(&attr, &stack_size)); + ASSERT_OK(pthread_getattr_np(pthread_self(), &attr)); + ASSERT_OK(pthread_attr_getstacksize(&attr, &stack_size)); expected = arg == NULL ? 0 : ((uv_thread_options_t*)arg)->stack_size; if (expected == 0) expected = (size_t)lim.rlim_cur; - ASSERT(stack_size >= expected); - ASSERT(0 == pthread_attr_destroy(&attr)); + ASSERT_GE(stack_size, expected); + ASSERT_OK(pthread_attr_destroy(&attr)); #endif } TEST_IMPL(thread_stack_size) { uv_thread_t thread; - ASSERT(0 == uv_thread_create(&thread, thread_check_stack, NULL)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create(&thread, thread_check_stack, NULL)); + ASSERT_OK(uv_thread_join(&thread)); return 0; } @@ -255,42 +255,42 @@ TEST_IMPL(thread_stack_size_explicit) { options.flags = UV_THREAD_HAS_STACK_SIZE; options.stack_size = 1024 * 1024; - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); options.stack_size = 8 * 1024 * 1024; /* larger than most default os sizes */ - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); options.stack_size = 0; - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); options.stack_size = 42; - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); #ifdef PTHREAD_STACK_MIN options.stack_size = PTHREAD_STACK_MIN - 42; /* unaligned size */ - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); options.stack_size = PTHREAD_STACK_MIN / 2 - 42; /* unaligned size */ - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); #endif /* unaligned size, should be larger than PTHREAD_STACK_MIN */ options.stack_size = 1234567; - ASSERT(0 == uv_thread_create_ex(&thread, &options, - thread_check_stack, &options)); - ASSERT(0 == uv_thread_join(&thread)); + ASSERT_OK(uv_thread_create_ex(&thread, &options, + thread_check_stack, &options)); + ASSERT_OK(uv_thread_join(&thread)); return 0; } diff --git a/deps/libuv/test/test-threadpool-cancel.c b/deps/libuv/test/test-threadpool-cancel.c index fed0b07a..b758ac4f 100644 --- a/deps/libuv/test/test-threadpool-cancel.c +++ b/deps/libuv/test/test-threadpool-cancel.c @@ -73,8 +73,8 @@ static void saturate_threadpool(void) { loop = uv_default_loop(); for (i = 0; i < ARRAY_SIZE(pause_reqs); i += 1) { - ASSERT(0 == uv_sem_init(pause_sems + i, 0)); - ASSERT(0 == uv_queue_work(loop, pause_reqs + i, work_cb, done_cb)); + ASSERT_OK(uv_sem_init(pause_sems + i, 0)); + ASSERT_OK(uv_queue_work(loop, pause_reqs + i, work_cb, done_cb)); } } @@ -119,7 +119,8 @@ static int known_broken(uv_req_t* req) { static void fs_cb(uv_fs_t* req) { - ASSERT(known_broken((uv_req_t*) req) || req->result == UV_ECANCELED); + ASSERT_NE(known_broken((uv_req_t*) req) || \ + req->result == UV_ECANCELED, 0); uv_fs_req_cleanup(req); fs_cb_called++; } @@ -128,7 +129,7 @@ static void fs_cb(uv_fs_t* req) { static void getaddrinfo_cb(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { - ASSERT(status == UV_EAI_CANCELED); + ASSERT_EQ(status, UV_EAI_CANCELED); ASSERT_NULL(res); uv_freeaddrinfo(res); /* Should not crash. */ } @@ -138,7 +139,7 @@ static void getnameinfo_cb(uv_getnameinfo_t* handle, int status, const char* hostname, const char* service) { - ASSERT(status == UV_EAI_CANCELED); + ASSERT_EQ(status, UV_EAI_CANCELED); ASSERT_NULL(hostname); ASSERT_NULL(service); } @@ -150,7 +151,7 @@ static void work2_cb(uv_work_t* req) { static void done2_cb(uv_work_t* req, int status) { - ASSERT(status == UV_ECANCELED); + ASSERT_EQ(status, UV_ECANCELED); done2_cb_called++; } @@ -174,7 +175,7 @@ static void timer_cb(uv_timer_t* handle) { static void nop_done_cb(uv_work_t* req, int status) { - ASSERT(status == UV_ECANCELED); + ASSERT_EQ(status, UV_ECANCELED); done_cb_called++; } @@ -184,9 +185,9 @@ static void nop_random_cb(uv_random_t* req, int status, void* buf, size_t len) { ri = container_of(req, struct random_info, random_req); - ASSERT(status == UV_ECANCELED); - ASSERT(buf == (void*) ri->buf); - ASSERT(len == sizeof(ri->buf)); + ASSERT_EQ(status, UV_ECANCELED); + ASSERT_PTR_EQ(buf, (void*) ri->buf); + ASSERT_EQ(len, sizeof(ri->buf)); done_cb_called++; } @@ -204,21 +205,21 @@ TEST_IMPL(threadpool_cancel_getaddrinfo) { saturate_threadpool(); r = uv_getaddrinfo(loop, reqs + 0, getaddrinfo_cb, "fail", NULL, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getaddrinfo(loop, reqs + 1, getaddrinfo_cb, NULL, "fail", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getaddrinfo(loop, reqs + 2, getaddrinfo_cb, "fail", "fail", NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getaddrinfo(loop, reqs + 3, getaddrinfo_cb, "fail", NULL, &hints); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); + ASSERT_OK(uv_timer_init(loop, &ci.timer_handle)); + ASSERT_OK(uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, timer_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -233,28 +234,28 @@ TEST_IMPL(threadpool_cancel_getnameinfo) { int r; r = uv_ip4_addr("127.0.0.1", 80, &addr4); - ASSERT(r == 0); + ASSERT_OK(r); INIT_CANCEL_INFO(&ci, reqs); loop = uv_default_loop(); saturate_threadpool(); r = uv_getnameinfo(loop, reqs + 0, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getnameinfo(loop, reqs + 1, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getnameinfo(loop, reqs + 2, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_getnameinfo(loop, reqs + 3, getnameinfo_cb, (const struct sockaddr*)&addr4, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); + ASSERT_OK(uv_timer_init(loop, &ci.timer_handle)); + ASSERT_OK(uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, timer_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -267,17 +268,17 @@ TEST_IMPL(threadpool_cancel_random) { saturate_threadpool(); loop = uv_default_loop(); - ASSERT(0 == uv_random(loop, - &req.random_req, - &req.buf, - sizeof(req.buf), - 0, - nop_random_cb)); - ASSERT(0 == uv_cancel((uv_req_t*) &req)); - ASSERT(0 == done_cb_called); + ASSERT_OK(uv_random(loop, + &req.random_req, + &req.buf, + sizeof(req.buf), + 0, + nop_random_cb)); + ASSERT_OK(uv_cancel((uv_req_t*) &req)); + ASSERT_OK(done_cb_called); unblock_threadpool(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == done_cb_called); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, done_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -295,13 +296,13 @@ TEST_IMPL(threadpool_cancel_work) { saturate_threadpool(); for (i = 0; i < ARRAY_SIZE(reqs); i++) - ASSERT(0 == uv_queue_work(loop, reqs + i, work2_cb, done2_cb)); + ASSERT_OK(uv_queue_work(loop, reqs + i, work2_cb, done2_cb)); - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == timer_cb_called); - ASSERT(ARRAY_SIZE(reqs) == done2_cb_called); + ASSERT_OK(uv_timer_init(loop, &ci.timer_handle)); + ASSERT_OK(uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, timer_cb_called); + ASSERT_EQ(ARRAY_SIZE(reqs), done2_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -322,39 +323,39 @@ TEST_IMPL(threadpool_cancel_fs) { /* Needs to match ARRAY_SIZE(fs_reqs). */ n = 0; - ASSERT(0 == uv_fs_chmod(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_chown(loop, reqs + n++, "/", 0, 0, fs_cb)); - ASSERT(0 == uv_fs_close(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_fchmod(loop, reqs + n++, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_fchown(loop, reqs + n++, 0, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_fdatasync(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_fstat(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_fsync(loop, reqs + n++, 0, fs_cb)); - ASSERT(0 == uv_fs_ftruncate(loop, reqs + n++, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_futime(loop, reqs + n++, 0, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_link(loop, reqs + n++, "/", "/", fs_cb)); - ASSERT(0 == uv_fs_lstat(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_open(loop, reqs + n++, "/", 0, 0, fs_cb)); - ASSERT(0 == uv_fs_read(loop, reqs + n++, -1, &iov, 1, 0, fs_cb)); - ASSERT(0 == uv_fs_scandir(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_readlink(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_realpath(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_rename(loop, reqs + n++, "/", "/", fs_cb)); - ASSERT(0 == uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb)); - ASSERT(0 == uv_fs_sendfile(loop, reqs + n++, 0, 0, 0, 0, fs_cb)); - ASSERT(0 == uv_fs_stat(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_symlink(loop, reqs + n++, "/", "/", 0, fs_cb)); - ASSERT(0 == uv_fs_unlink(loop, reqs + n++, "/", fs_cb)); - ASSERT(0 == uv_fs_utime(loop, reqs + n++, "/", 0, 0, fs_cb)); - ASSERT(0 == uv_fs_write(loop, reqs + n++, -1, &iov, 1, 0, fs_cb)); - ASSERT(n == ARRAY_SIZE(reqs)); + ASSERT_OK(uv_fs_chmod(loop, reqs + n++, "/", 0, fs_cb)); + ASSERT_OK(uv_fs_chown(loop, reqs + n++, "/", 0, 0, fs_cb)); + ASSERT_OK(uv_fs_close(loop, reqs + n++, 0, fs_cb)); + ASSERT_OK(uv_fs_fchmod(loop, reqs + n++, 0, 0, fs_cb)); + ASSERT_OK(uv_fs_fchown(loop, reqs + n++, 0, 0, 0, fs_cb)); + ASSERT_OK(uv_fs_fdatasync(loop, reqs + n++, 0, fs_cb)); + ASSERT_OK(uv_fs_fstat(loop, reqs + n++, 0, fs_cb)); + ASSERT_OK(uv_fs_fsync(loop, reqs + n++, 0, fs_cb)); + ASSERT_OK(uv_fs_ftruncate(loop, reqs + n++, 0, 0, fs_cb)); + ASSERT_OK(uv_fs_futime(loop, reqs + n++, 0, 0, 0, fs_cb)); + ASSERT_OK(uv_fs_link(loop, reqs + n++, "/", "/", fs_cb)); + ASSERT_OK(uv_fs_lstat(loop, reqs + n++, "/", fs_cb)); + ASSERT_OK(uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb)); + ASSERT_OK(uv_fs_open(loop, reqs + n++, "/", 0, 0, fs_cb)); + ASSERT_OK(uv_fs_read(loop, reqs + n++, -1, &iov, 1, 0, fs_cb)); + ASSERT_OK(uv_fs_scandir(loop, reqs + n++, "/", 0, fs_cb)); + ASSERT_OK(uv_fs_readlink(loop, reqs + n++, "/", fs_cb)); + ASSERT_OK(uv_fs_realpath(loop, reqs + n++, "/", fs_cb)); + ASSERT_OK(uv_fs_rename(loop, reqs + n++, "/", "/", fs_cb)); + ASSERT_OK(uv_fs_mkdir(loop, reqs + n++, "/", 0, fs_cb)); + ASSERT_OK(uv_fs_sendfile(loop, reqs + n++, 0, 0, 0, 0, fs_cb)); + ASSERT_OK(uv_fs_stat(loop, reqs + n++, "/", fs_cb)); + ASSERT_OK(uv_fs_symlink(loop, reqs + n++, "/", "/", 0, fs_cb)); + ASSERT_OK(uv_fs_unlink(loop, reqs + n++, "/", fs_cb)); + ASSERT_OK(uv_fs_utime(loop, reqs + n++, "/", 0, 0, fs_cb)); + ASSERT_OK(uv_fs_write(loop, reqs + n++, -1, &iov, 1, 0, fs_cb)); + ASSERT_EQ(n, ARRAY_SIZE(reqs)); - ASSERT(0 == uv_timer_init(loop, &ci.timer_handle)); - ASSERT(0 == uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(n == fs_cb_called); - ASSERT(1 == timer_cb_called); + ASSERT_OK(uv_timer_init(loop, &ci.timer_handle)); + ASSERT_OK(uv_timer_start(&ci.timer_handle, timer_cb, 10, 0)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(n, fs_cb_called); + ASSERT_EQ(1, timer_cb_called); MAKE_VALGRIND_HAPPY(loop); @@ -368,12 +369,12 @@ TEST_IMPL(threadpool_cancel_single) { saturate_threadpool(); loop = uv_default_loop(); - ASSERT(0 == uv_queue_work(loop, &req, (uv_work_cb) abort, nop_done_cb)); - ASSERT(0 == uv_cancel((uv_req_t*) &req)); - ASSERT(0 == done_cb_called); + ASSERT_OK(uv_queue_work(loop, &req, (uv_work_cb) abort, nop_done_cb)); + ASSERT_OK(uv_cancel((uv_req_t*) &req)); + ASSERT_OK(done_cb_called); unblock_threadpool(); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); - ASSERT(1 == done_cb_called); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_EQ(1, done_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -404,7 +405,7 @@ TEST_IMPL(threadpool_cancel_when_busy) { ASSERT_EQ(uv_cancel((uv_req_t*) &req), UV_EBUSY); ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT_EQ(done_cb_called, 1); + ASSERT_EQ(1, done_cb_called); uv_sem_destroy(&sem_lock); diff --git a/deps/libuv/test/test-threadpool.c b/deps/libuv/test/test-threadpool.c index 5254131b..fb5e5732 100644 --- a/deps/libuv/test/test-threadpool.c +++ b/deps/libuv/test/test-threadpool.c @@ -29,16 +29,16 @@ static char data; static void work_cb(uv_work_t* req) { - ASSERT(req == &work_req); - ASSERT(req->data == &data); + ASSERT_PTR_EQ(req, &work_req); + ASSERT_PTR_EQ(req->data, &data); work_cb_count++; } static void after_work_cb(uv_work_t* req, int status) { - ASSERT(status == 0); - ASSERT(req == &work_req); - ASSERT(req->data == &data); + ASSERT_OK(status); + ASSERT_PTR_EQ(req, &work_req); + ASSERT_PTR_EQ(req->data, &data); after_work_cb_count++; } @@ -48,11 +48,11 @@ TEST_IMPL(threadpool_queue_work_simple) { work_req.data = &data; r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(work_cb_count == 1); - ASSERT(after_work_cb_count == 1); + ASSERT_EQ(1, work_cb_count); + ASSERT_EQ(1, after_work_cb_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -64,12 +64,12 @@ TEST_IMPL(threadpool_queue_work_einval) { work_req.data = &data; r = uv_queue_work(uv_default_loop(), &work_req, NULL, after_work_cb); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(work_cb_count == 0); - ASSERT(after_work_cb_count == 0); + ASSERT_OK(work_cb_count); + ASSERT_OK(after_work_cb_count); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-timer-again.c b/deps/libuv/test/test-timer-again.c index cb298956..d7f0b83a 100644 --- a/deps/libuv/test/test-timer-again.c +++ b/deps/libuv/test/test-timer-again.c @@ -44,8 +44,8 @@ static void close_cb(uv_handle_t* handle) { static void repeat_1_cb(uv_timer_t* handle) { int r; - ASSERT(handle == &repeat_1); - ASSERT(uv_timer_get_repeat((uv_timer_t*)handle) == 50); + ASSERT_PTR_EQ(handle, &repeat_1); + ASSERT_EQ(50, uv_timer_get_repeat((uv_timer_t*)handle)); fprintf(stderr, "repeat_1_cb called after %ld ms\n", (long int)(uv_now(uv_default_loop()) - start_time)); @@ -54,7 +54,7 @@ static void repeat_1_cb(uv_timer_t* handle) { repeat_1_cb_called++; r = uv_timer_again(&repeat_2); - ASSERT(r == 0); + ASSERT_OK(r); if (repeat_1_cb_called == 10) { uv_close((uv_handle_t*)handle, close_cb); @@ -67,7 +67,7 @@ static void repeat_1_cb(uv_timer_t* handle) { static void repeat_2_cb(uv_timer_t* handle) { - ASSERT(handle == &repeat_2); + ASSERT_PTR_EQ(handle, &repeat_2); ASSERT(repeat_2_cb_allowed); fprintf(stderr, "repeat_2_cb called after %ld ms\n", @@ -77,7 +77,7 @@ static void repeat_2_cb(uv_timer_t* handle) { repeat_2_cb_called++; if (uv_timer_get_repeat(&repeat_2) == 0) { - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); + ASSERT_OK(uv_is_active((uv_handle_t*) handle)); uv_close((uv_handle_t*)handle, close_cb); return; } @@ -85,7 +85,7 @@ static void repeat_2_cb(uv_timer_t* handle) { fprintf(stderr, "uv_timer_get_repeat %ld ms\n", (long int)uv_timer_get_repeat(&repeat_2)); fflush(stderr); - ASSERT(uv_timer_get_repeat(&repeat_2) == 100); + ASSERT_EQ(100, uv_timer_get_repeat(&repeat_2)); /* This shouldn't take effect immediately. */ uv_timer_set_repeat(&repeat_2, 0); @@ -96,41 +96,41 @@ TEST_IMPL(timer_again) { int r; start_time = uv_now(uv_default_loop()); - ASSERT(0 < start_time); + ASSERT_LT(0, start_time); /* Verify that it is not possible to uv_timer_again a never-started timer. */ r = uv_timer_init(uv_default_loop(), &dummy); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_again(&dummy); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_unref((uv_handle_t*)&dummy); /* Start timer repeat_1. */ r = uv_timer_init(uv_default_loop(), &repeat_1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&repeat_1, repeat_1_cb, 50, 0); - ASSERT(r == 0); - ASSERT(uv_timer_get_repeat(&repeat_1) == 0); + ASSERT_OK(r); + ASSERT_OK(uv_timer_get_repeat(&repeat_1)); /* Actually make repeat_1 repeating. */ uv_timer_set_repeat(&repeat_1, 50); - ASSERT(uv_timer_get_repeat(&repeat_1) == 50); + ASSERT_EQ(50, uv_timer_get_repeat(&repeat_1)); /* * Start another repeating timer. It'll be again()ed by the repeat_1 so * it should not time out until repeat_1 stops. */ r = uv_timer_init(uv_default_loop(), &repeat_2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&repeat_2, repeat_2_cb, 100, 100); - ASSERT(r == 0); - ASSERT(uv_timer_get_repeat(&repeat_2) == 100); + ASSERT_OK(r); + ASSERT_EQ(100, uv_timer_get_repeat(&repeat_2)); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(repeat_1_cb_called == 10); - ASSERT(repeat_2_cb_called == 2); - ASSERT(close_cb_called == 2); + ASSERT_EQ(10, repeat_1_cb_called); + ASSERT_EQ(2, repeat_2_cb_called); + ASSERT_EQ(2, close_cb_called); fprintf(stderr, "Test took %ld ms (expected ~700 ms)\n", (long int)(uv_now(uv_default_loop()) - start_time)); diff --git a/deps/libuv/test/test-timer-from-check.c b/deps/libuv/test/test-timer-from-check.c index e1a002d8..e5f5cb2f 100644 --- a/deps/libuv/test/test-timer-from-check.c +++ b/deps/libuv/test/test-timer-from-check.c @@ -32,49 +32,49 @@ static int timer_cb_called; static void prepare_cb(uv_prepare_t* handle) { - ASSERT(0 == uv_prepare_stop(&prepare_handle)); - ASSERT(0 == prepare_cb_called); - ASSERT(1 == check_cb_called); - ASSERT(0 == timer_cb_called); + ASSERT_OK(uv_prepare_stop(&prepare_handle)); + ASSERT_OK(prepare_cb_called); + ASSERT_EQ(1, check_cb_called); + ASSERT_OK(timer_cb_called); prepare_cb_called++; } static void timer_cb(uv_timer_t* handle) { - ASSERT(0 == uv_timer_stop(&timer_handle)); - ASSERT(1 == prepare_cb_called); - ASSERT(1 == check_cb_called); - ASSERT(0 == timer_cb_called); + ASSERT_OK(uv_timer_stop(&timer_handle)); + ASSERT_EQ(1, prepare_cb_called); + ASSERT_EQ(1, check_cb_called); + ASSERT_OK(timer_cb_called); timer_cb_called++; } static void check_cb(uv_check_t* handle) { - 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); + ASSERT_OK(uv_check_stop(&check_handle)); + ASSERT_OK(uv_timer_stop(&timer_handle)); /* Runs before timer_cb. */ + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 50, 0)); + ASSERT_OK(uv_prepare_start(&prepare_handle, prepare_cb)); + ASSERT_OK(prepare_cb_called); + ASSERT_OK(check_cb_called); + ASSERT_OK(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); + ASSERT_OK(uv_prepare_init(uv_default_loop(), &prepare_handle)); + ASSERT_OK(uv_check_init(uv_default_loop(), &check_handle)); + ASSERT_OK(uv_check_start(&check_handle, check_cb)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_cb, 50, 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_EQ(1, prepare_cb_called); + ASSERT_EQ(1, check_cb_called); + ASSERT_EQ(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)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } diff --git a/deps/libuv/test/test-timer.c b/deps/libuv/test/test-timer.c index 2488f14c..d889e707 100644 --- a/deps/libuv/test/test-timer.c +++ b/deps/libuv/test/test-timer.c @@ -41,7 +41,7 @@ static void once_close_cb(uv_handle_t* handle) { printf("ONCE_CLOSE_CB\n"); ASSERT_NOT_NULL(handle); - ASSERT(0 == uv_is_active(handle)); + ASSERT_OK(uv_is_active(handle)); once_close_cb_called++; } @@ -51,7 +51,7 @@ static void once_cb(uv_timer_t* handle) { printf("ONCE_CB %d\n", once_cb_called); ASSERT_NOT_NULL(handle); - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); + ASSERT_OK(uv_is_active((uv_handle_t*) handle)); once_cb_called++; @@ -65,7 +65,7 @@ static void twice_close_cb(uv_handle_t* handle) { printf("TWICE_CLOSE_CB\n"); ASSERT_NOT_NULL(handle); - ASSERT(0 == uv_is_active(handle)); + ASSERT_OK(uv_is_active(handle)); twice_close_cb_called++; } @@ -74,7 +74,7 @@ static void twice_cb(uv_timer_t* handle) { printf("TWICE_CB %d\n", twice_cb_called); ASSERT_NOT_NULL(handle); - ASSERT(0 == uv_is_active((uv_handle_t*) handle)); + ASSERT_OK(uv_is_active((uv_handle_t*) handle)); twice_cb_called++; @@ -96,7 +96,7 @@ static void repeat_cb(uv_timer_t* handle) { printf("REPEAT_CB\n"); ASSERT_NOT_NULL(handle); - ASSERT(1 == uv_is_active((uv_handle_t*) handle)); + ASSERT_EQ(1, uv_is_active((uv_handle_t*) handle)); repeat_cb_called++; @@ -119,41 +119,41 @@ TEST_IMPL(timer) { int r; start_time = uv_now(uv_default_loop()); - ASSERT(0 < start_time); + ASSERT_LT(0, start_time); /* Let 10 timers time out in 500 ms total. */ for (i = 0; i < ARRAY_SIZE(once_timers); i++) { once = once_timers + i; r = uv_timer_init(uv_default_loop(), once); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(once, once_cb, i * 50, 0); - ASSERT(r == 0); + ASSERT_OK(r); } /* The 11th timer is a repeating timer that runs 4 times */ r = uv_timer_init(uv_default_loop(), &repeat); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&repeat, repeat_cb, 100, 100); - ASSERT(r == 0); + ASSERT_OK(r); /* The 12th timer should not do anything. */ r = uv_timer_init(uv_default_loop(), &never); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&never, never_cb, 100, 100); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_stop(&never); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*)&never); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(once_cb_called == 10); - ASSERT(once_close_cb_called == 10); + ASSERT_EQ(10, once_cb_called); + ASSERT_EQ(10, once_close_cb_called); printf("repeat_cb_called %d\n", repeat_cb_called); - ASSERT(repeat_cb_called == 5); - ASSERT(repeat_close_cb_called == 1); + ASSERT_EQ(5, repeat_cb_called); + ASSERT_EQ(1, repeat_close_cb_called); - ASSERT(500 <= uv_now(uv_default_loop()) - start_time); + ASSERT_LE(500, uv_now(uv_default_loop()) - start_time); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -165,15 +165,15 @@ TEST_IMPL(timer_start_twice) { int r; r = uv_timer_init(uv_default_loop(), &once); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&once, never_cb, 86400 * 1000, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&once, twice_cb, 10, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(twice_cb_called == 1); + ASSERT_EQ(1, twice_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -183,10 +183,10 @@ TEST_IMPL(timer_start_twice) { TEST_IMPL(timer_init) { uv_timer_t handle; - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); - ASSERT(0 == uv_timer_get_repeat(&handle)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &handle)); + ASSERT_OK(uv_timer_get_repeat(&handle)); ASSERT_UINT64_LE(0, uv_timer_get_due_in(&handle)); - ASSERT(0 == uv_is_active((uv_handle_t*) &handle)); + ASSERT_OK(uv_is_active((uv_handle_t*) &handle)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -194,12 +194,12 @@ TEST_IMPL(timer_init) { static void order_cb_a(uv_timer_t *handle) { - ASSERT(order_cb_called++ == *(int*)handle->data); + ASSERT_EQ(order_cb_called++, *(int*)handle->data); } static void order_cb_b(uv_timer_t *handle) { - ASSERT(order_cb_called++ == *(int*)handle->data); + ASSERT_EQ(order_cb_called++, *(int*)handle->data); } @@ -211,31 +211,31 @@ TEST_IMPL(timer_order) { first = 0; second = 1; - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle_a)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle_b)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &handle_a)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &handle_b)); /* Test for starting handle_a then handle_b */ handle_a.data = &first; - ASSERT(0 == uv_timer_start(&handle_a, order_cb_a, 0, 0)); + ASSERT_OK(uv_timer_start(&handle_a, order_cb_a, 0, 0)); handle_b.data = &second; - ASSERT(0 == uv_timer_start(&handle_b, order_cb_b, 0, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_start(&handle_b, order_cb_b, 0, 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(order_cb_called == 2); + ASSERT_EQ(2, order_cb_called); - ASSERT(0 == uv_timer_stop(&handle_a)); - ASSERT(0 == uv_timer_stop(&handle_b)); + ASSERT_OK(uv_timer_stop(&handle_a)); + ASSERT_OK(uv_timer_stop(&handle_b)); /* Test for starting handle_b then handle_a */ order_cb_called = 0; handle_b.data = &first; - ASSERT(0 == uv_timer_start(&handle_b, order_cb_b, 0, 0)); + ASSERT_OK(uv_timer_start(&handle_b, order_cb_b, 0, 0)); handle_a.data = &second; - ASSERT(0 == uv_timer_start(&handle_a, order_cb_a, 0, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_start(&handle_a, order_cb_a, 0, 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT(order_cb_called == 2); + ASSERT_EQ(2, order_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -243,7 +243,7 @@ TEST_IMPL(timer_order) { static void tiny_timer_cb(uv_timer_t* handle) { - ASSERT(handle == &tiny_timer); + ASSERT_PTR_EQ(handle, &tiny_timer); uv_close((uv_handle_t*) &tiny_timer, NULL); uv_close((uv_handle_t*) &huge_timer1, NULL); uv_close((uv_handle_t*) &huge_timer2, NULL); @@ -251,16 +251,19 @@ static void tiny_timer_cb(uv_timer_t* handle) { TEST_IMPL(timer_huge_timeout) { - ASSERT(0 == uv_timer_init(uv_default_loop(), &tiny_timer)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &huge_timer1)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &huge_timer2)); - ASSERT(0 == uv_timer_start(&tiny_timer, tiny_timer_cb, 1, 0)); - ASSERT(0 == uv_timer_start(&huge_timer1, tiny_timer_cb, 0xffffffffffffLL, 0)); - ASSERT(0 == uv_timer_start(&huge_timer2, tiny_timer_cb, (uint64_t) -1, 0)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &tiny_timer)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &huge_timer1)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &huge_timer2)); + ASSERT_OK(uv_timer_start(&tiny_timer, tiny_timer_cb, 1, 0)); + ASSERT_OK(uv_timer_start(&huge_timer1, + tiny_timer_cb, + 0xffffffffffffLL, + 0)); + ASSERT_OK(uv_timer_start(&huge_timer2, tiny_timer_cb, (uint64_t) -1, 0)); ASSERT_UINT64_EQ(1, uv_timer_get_due_in(&tiny_timer)); ASSERT_UINT64_EQ(281474976710655, uv_timer_get_due_in(&huge_timer1)); ASSERT_UINT64_LE(0, uv_timer_get_due_in(&huge_timer2)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } @@ -270,9 +273,9 @@ static void huge_repeat_cb(uv_timer_t* handle) { static int ncalls; if (ncalls == 0) - ASSERT(handle == &huge_timer1); + ASSERT_PTR_EQ(handle, &huge_timer1); else - ASSERT(handle == &tiny_timer); + ASSERT_PTR_EQ(handle, &tiny_timer); if (++ncalls == 10) { uv_close((uv_handle_t*) &tiny_timer, NULL); @@ -282,11 +285,11 @@ static void huge_repeat_cb(uv_timer_t* handle) { TEST_IMPL(timer_huge_repeat) { - ASSERT(0 == uv_timer_init(uv_default_loop(), &tiny_timer)); - ASSERT(0 == uv_timer_init(uv_default_loop(), &huge_timer1)); - ASSERT(0 == uv_timer_start(&tiny_timer, huge_repeat_cb, 2, 2)); - ASSERT(0 == uv_timer_start(&huge_timer1, huge_repeat_cb, 1, (uint64_t) -1)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &tiny_timer)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &huge_timer1)); + ASSERT_OK(uv_timer_start(&tiny_timer, huge_repeat_cb, 2, 2)); + ASSERT_OK(uv_timer_start(&huge_timer1, huge_repeat_cb, 1, (uint64_t) -1)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; } @@ -303,17 +306,17 @@ static void timer_run_once_timer_cb(uv_timer_t* handle) { TEST_IMPL(timer_run_once) { uv_timer_t timer_handle; - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_run_once_timer_cb, 0, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(1 == timer_run_once_timer_cb_called); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, timer_run_once_timer_cb, 0, 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_EQ(1, timer_run_once_timer_cb_called); - ASSERT(0 == uv_timer_start(&timer_handle, timer_run_once_timer_cb, 1, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); - ASSERT(2 == timer_run_once_timer_cb_called); + ASSERT_OK(uv_timer_start(&timer_handle, timer_run_once_timer_cb, 1, 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_EQ(2, timer_run_once_timer_cb_called); uv_close((uv_handle_t*) &timer_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_ONCE)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -323,10 +326,10 @@ TEST_IMPL(timer_run_once) { TEST_IMPL(timer_is_closing) { uv_timer_t handle; - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &handle)); uv_close((uv_handle_t *)&handle, NULL); - ASSERT(UV_EINVAL == uv_timer_start(&handle, never_cb, 100, 100)); + ASSERT_EQ(UV_EINVAL, uv_timer_start(&handle, never_cb, 100, 100)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -336,8 +339,8 @@ TEST_IMPL(timer_is_closing) { TEST_IMPL(timer_null_callback) { uv_timer_t handle; - ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); - ASSERT(UV_EINVAL == uv_timer_start(&handle, NULL, 100, 100)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &handle)); + ASSERT_EQ(UV_EINVAL, uv_timer_start(&handle, NULL, 100, 100)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -349,7 +352,7 @@ static uint64_t timer_early_check_expected_time; static void timer_early_check_cb(uv_timer_t* handle) { uint64_t hrtime = uv_hrtime() / 1000000; - ASSERT(hrtime >= timer_early_check_expected_time); + ASSERT_GE(hrtime, timer_early_check_expected_time); } @@ -359,12 +362,15 @@ TEST_IMPL(timer_early_check) { timer_early_check_expected_time = uv_now(uv_default_loop()) + timeout_ms; - ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT(0 == uv_timer_start(&timer_handle, timer_early_check_cb, timeout_ms, 0)); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, + timer_early_check_cb, + timeout_ms, + 0)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); uv_close((uv_handle_t*) &timer_handle, NULL); - ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -378,11 +384,11 @@ TEST_IMPL(timer_no_double_call_once) { uv_timer_t timer_handle; const uint64_t timeout_ms = 10; - ASSERT_EQ(0, uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT_EQ(0, uv_timer_start(&timer_handle, - timer_check_double_call, - timeout_ms, - timeout_ms)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, + timer_check_double_call, + timeout_ms, + timeout_ms)); uv_sleep(timeout_ms * 2); ASSERT_EQ(1, uv_run(uv_default_loop(), UV_RUN_ONCE)); ASSERT_EQ(1, timer_check_double_call_called); @@ -395,11 +401,11 @@ TEST_IMPL(timer_no_double_call_nowait) { uv_timer_t timer_handle; const uint64_t timeout_ms = 10; - ASSERT_EQ(0, uv_timer_init(uv_default_loop(), &timer_handle)); - ASSERT_EQ(0, uv_timer_start(&timer_handle, - timer_check_double_call, - timeout_ms, - timeout_ms)); + ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT_OK(uv_timer_start(&timer_handle, + timer_check_double_call, + timeout_ms, + timeout_ms)); uv_sleep(timeout_ms * 2); ASSERT_EQ(1, uv_run(uv_default_loop(), UV_RUN_NOWAIT)); ASSERT_EQ(1, timer_check_double_call_called); @@ -414,7 +420,7 @@ TEST_IMPL(timer_no_run_on_unref) { ASSERT_OK(uv_timer_init(uv_default_loop(), &timer_handle)); ASSERT_OK(uv_timer_start(&timer_handle, (uv_timer_cb) abort, 0, 0)); uv_unref((uv_handle_t*) &timer_handle); - ASSERT_EQ(uv_run(uv_default_loop(), UV_RUN_DEFAULT), 0); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-tmpdir.c b/deps/libuv/test/test-tmpdir.c index 86f72e25..a4e9ce95 100644 --- a/deps/libuv/test/test-tmpdir.c +++ b/deps/libuv/test/test-tmpdir.c @@ -36,46 +36,46 @@ TEST_IMPL(tmpdir) { len = sizeof tmpdir; tmpdir[0] = '\0'; - ASSERT(strlen(tmpdir) == 0); + ASSERT_OK(strlen(tmpdir)); r = uv_os_tmpdir(tmpdir, &len); - ASSERT(r == 0); - ASSERT(strlen(tmpdir) == len); - ASSERT(len > 0); - ASSERT(tmpdir[len] == '\0'); + ASSERT_OK(r); + ASSERT_EQ(strlen(tmpdir), len); + ASSERT_GT(len, 0); + ASSERT_EQ(tmpdir[len], '\0'); if (len > 1) { last = tmpdir[len - 1]; #ifdef _WIN32 - ASSERT(last != '\\'); + ASSERT_NE(last, '\\'); #else - ASSERT(last != '/'); + ASSERT_NE(last, '/'); #endif } /* Test the case where the buffer is too small */ len = SMALLPATH; r = uv_os_tmpdir(tmpdir, &len); - ASSERT(r == UV_ENOBUFS); - ASSERT(len > SMALLPATH); + ASSERT_EQ(r, UV_ENOBUFS); + ASSERT_GT(len, SMALLPATH); /* Test invalid inputs */ r = uv_os_tmpdir(NULL, &len); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_os_tmpdir(tmpdir, NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); len = 0; r = uv_os_tmpdir(tmpdir, &len); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); #ifdef _WIN32 const char *name = "TMP"; char tmpdir_win[] = "C:\\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; r = uv_os_setenv(name, tmpdir_win); - ASSERT(r == 0); + ASSERT_OK(r); char tmpdirx[PATHMAX]; size_t lenx = sizeof tmpdirx; r = uv_os_tmpdir(tmpdirx, &lenx); - ASSERT(r == 0); + ASSERT_OK(r); #endif return 0; diff --git a/deps/libuv/test/test-tty-duplicate-key.c b/deps/libuv/test/test-tty-duplicate-key.c index 6ba96c81..871d5802 100644 --- a/deps/libuv/test/test-tty-duplicate-key.c +++ b/deps/libuv/test/test-tty-duplicate-key.c @@ -73,7 +73,7 @@ static void tty_read(uv_stream_t* tty_in, ssize_t nread, const uv_buf_t* buf) { } uv_close((uv_handle_t*) tty_in, NULL); } else { - ASSERT(nread == 0); + ASSERT_OK(nread); } } @@ -150,25 +150,25 @@ TEST_IMPL(tty_duplicate_vt100_fn_key) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyin_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); + ASSERT_GE(ttyin_fd, 0); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_is_readable((uv_stream_t*) &tty_in)); ASSERT(!uv_is_writable((uv_stream_t*) &tty_in)); r = uv_read_start((uv_stream_t*)&tty_in, tty_alloc, tty_read); - ASSERT(r == 0); + ASSERT_OK(r); expect_str = ESC"[[A"; expect_nread = strlen(expect_str); /* Turn on raw mode. */ r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); + ASSERT_OK(r); /* * Send F1 keystrokes. Test of issue cause by #2114 that vt100 fn key @@ -176,7 +176,7 @@ TEST_IMPL(tty_duplicate_vt100_fn_key) { */ make_key_event_records(VK_F1, 0, TRUE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == ARRAY_SIZE(records)); + ASSERT_EQ(written, ARRAY_SIZE(records)); uv_run(loop, UV_RUN_DEFAULT); @@ -204,45 +204,45 @@ TEST_IMPL(tty_duplicate_alt_modifier_key) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyin_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); + ASSERT_GE(ttyin_fd, 0); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_is_readable((uv_stream_t*) &tty_in)); ASSERT(!uv_is_writable((uv_stream_t*) &tty_in)); r = uv_read_start((uv_stream_t*)&tty_in, tty_alloc, tty_read); - ASSERT(r == 0); + ASSERT_OK(r); expect_str = ESC"a"ESC"a"; expect_nread = strlen(expect_str); /* Turn on raw mode. */ r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); + ASSERT_OK(r); /* Emulate transmission of M-a at normal console */ make_key_event_records(VK_MENU, 0, TRUE, alt_records); WriteConsoleInputW(handle, &alt_records[0], 1, &written); - ASSERT(written == 1); + ASSERT_EQ(1, written); make_key_event_records(L'A', LEFT_ALT_PRESSED, FALSE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == 2); + ASSERT_EQ(2, written); WriteConsoleInputW(handle, &alt_records[1], 1, &written); - ASSERT(written == 1); + ASSERT_EQ(1, written); /* Emulate transmission of M-a at WSL(#2111) */ make_key_event_records(VK_MENU, 0, TRUE, alt_records); WriteConsoleInputW(handle, &alt_records[0], 1, &written); - ASSERT(written == 1); + ASSERT_EQ(1, written); make_key_event_records(L'A', LEFT_ALT_PRESSED, TRUE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == 2); + ASSERT_EQ(2, written); WriteConsoleInputW(handle, &alt_records[1], 1, &written); - ASSERT(written == 1); + ASSERT_EQ(1, written); uv_run(loop, UV_RUN_DEFAULT); @@ -270,25 +270,25 @@ TEST_IMPL(tty_composing_character) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyin_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); + ASSERT_GE(ttyin_fd, 0); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_is_readable((uv_stream_t*) &tty_in)); ASSERT(!uv_is_writable((uv_stream_t*) &tty_in)); r = uv_read_start((uv_stream_t*)&tty_in, tty_alloc, tty_read); - ASSERT(r == 0); + ASSERT_OK(r); expect_str = EUR_UTF8; expect_nread = strlen(expect_str); /* Turn on raw mode. */ r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); + ASSERT_OK(r); /* Emulate EUR inputs by LEFT ALT+NUMPAD ASCII KeyComos */ make_key_event_records(VK_MENU, 0, FALSE, alt_records); @@ -296,16 +296,16 @@ TEST_IMPL(tty_composing_character) { WriteConsoleInputW(handle, &alt_records[0], 1, &written); make_key_event_records(VK_NUMPAD0, LEFT_ALT_PRESSED, FALSE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == ARRAY_SIZE(records)); + ASSERT_EQ(written, ARRAY_SIZE(records)); make_key_event_records(VK_NUMPAD1, LEFT_ALT_PRESSED, FALSE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == ARRAY_SIZE(records)); + ASSERT_EQ(written, ARRAY_SIZE(records)); make_key_event_records(VK_NUMPAD2, LEFT_ALT_PRESSED, FALSE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == ARRAY_SIZE(records)); + ASSERT_EQ(written, ARRAY_SIZE(records)); make_key_event_records(VK_NUMPAD8, LEFT_ALT_PRESSED, FALSE, records); WriteConsoleInputW(handle, records, ARRAY_SIZE(records), &written); - ASSERT(written == ARRAY_SIZE(records)); + ASSERT_EQ(written, ARRAY_SIZE(records)); WriteConsoleInputW(handle, &alt_records[1], 1, &written); uv_run(loop, UV_RUN_DEFAULT); diff --git a/deps/libuv/test/test-tty-escape-sequence-processing.c b/deps/libuv/test/test-tty-escape-sequence-processing.c index 2f7d0364..4a041db1 100644 --- a/deps/libuv/test/test-tty-escape-sequence-processing.c +++ b/deps/libuv/test/test-tty-escape-sequence-processing.c @@ -165,8 +165,8 @@ static void write_console(uv_tty_t* tty_out, char* src) { buf.len = strlen(buf.base); r = uv_try_write((uv_stream_t*) tty_out, &buf, 1); - ASSERT(r >= 0); - ASSERT((unsigned int) r == buf.len); + ASSERT_GE(r, 0); + ASSERT_EQ((unsigned int) r, buf.len); } static void setup_screen(uv_tty_t* tty_out) { @@ -178,8 +178,8 @@ static void setup_screen(uv_tty_t* tty_out) { origin.X = 0; origin.Y = info.srWindow.Top; ASSERT(FillConsoleOutputCharacter( - tty_out->handle, '.', length, origin, &number_of_written)); - ASSERT(length == number_of_written); + tty_out->handle, '.', length, origin, &number_of_written)); + ASSERT_EQ(length, number_of_written); } static void clear_screen(uv_tty_t* tty_out, struct screen_info* si) { @@ -192,10 +192,10 @@ static void clear_screen(uv_tty_t* tty_out, struct screen_info* si) { origin.Y = info.srWindow.Top; FillConsoleOutputCharacterA( tty_out->handle, ' ', length, origin, &number_of_written); - ASSERT(length == number_of_written); + ASSERT_EQ(length, number_of_written); FillConsoleOutputAttribute( tty_out->handle, si->default_attr, length, origin, &number_of_written); - ASSERT(length == number_of_written); + ASSERT_EQ(length, number_of_written); } static void free_screen(struct captured_screen* cs) { @@ -216,11 +216,11 @@ static void capture_screen(uv_tty_t* tty_out, struct captured_screen* cs) { cs->attributes = (WORD*) malloc(cs->si.length * sizeof(*cs->attributes)); ASSERT_NOT_NULL(cs->attributes); ASSERT(ReadConsoleOutputCharacter( - tty_out->handle, cs->text, cs->si.length, origin, &length)); - ASSERT((unsigned int) cs->si.length == length); + tty_out->handle, cs->text, cs->si.length, origin, &length)); + ASSERT_EQ((unsigned int) cs->si.length, length); ASSERT(ReadConsoleOutputAttribute( - tty_out->handle, cs->attributes, cs->si.length, origin, &length)); - ASSERT((unsigned int) cs->si.length == length); + tty_out->handle, cs->attributes, cs->si.length, origin, &length)); + ASSERT_EQ((unsigned int) cs->si.length, length); } static void make_expect_screen_erase(struct captured_screen* cs, @@ -261,8 +261,8 @@ static void make_expect_screen_erase(struct captured_screen* cs, } else { ASSERT(FALSE); } - ASSERT(start < end); - ASSERT(end - cs->text <= cs->si.length); + ASSERT_PTR_LT(start, end); + ASSERT_LE(end - cs->text, cs->si.length); for (; start < end; start++) { *start = ' '; } @@ -360,13 +360,13 @@ static void initialize_tty(uv_tty_t* tty_out) { NULL, CONSOLE_TEXTMODE_BUFFER, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyout_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyout_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); + ASSERT_GE(ttyout_fd, 0); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyout_fd)); r = uv_tty_init(uv_default_loop(), tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); + ASSERT_OK(r); } static void terminate_tty(uv_tty_t* tty_out) { @@ -394,16 +394,16 @@ TEST_IMPL(tty_cursor_up) { snprintf(buffer, sizeof(buffer), "%sA", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y - 1 == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y - 1, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); /* cursor up nth times */ cursor_pos_old = cursor_pos; snprintf(buffer, sizeof(buffer), "%s%dA", CSI, si.height / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y - si.height / 4 == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y - si.height / 4, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); /* cursor up from Window top does nothing */ cursor_pos_old.X = 1; @@ -412,8 +412,8 @@ TEST_IMPL(tty_cursor_up) { snprintf(buffer, sizeof(buffer), "%sA", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -445,16 +445,16 @@ TEST_IMPL(tty_cursor_down) { snprintf(buffer, sizeof(buffer), "%sB", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y + 1 == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y + 1, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); /* cursor down nth times */ cursor_pos_old = cursor_pos; snprintf(buffer, sizeof(buffer), "%s%dB", CSI, si.height / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y + si.height / 4 == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y + si.height / 4, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); /* cursor down from bottom line does nothing */ cursor_pos_old.X = si.width / 2; @@ -463,8 +463,8 @@ TEST_IMPL(tty_cursor_down) { snprintf(buffer, sizeof(buffer), "%sB", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -496,16 +496,16 @@ TEST_IMPL(tty_cursor_forward) { snprintf(buffer, sizeof(buffer), "%sC", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X + 1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X + 1, cursor_pos.X); /* cursor forward nth times */ cursor_pos_old = cursor_pos; snprintf(buffer, sizeof(buffer), "%s%dC", CSI, si.width / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X + si.width / 4 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X + si.width / 4, cursor_pos.X); /* cursor forward from end of line does nothing*/ cursor_pos_old.X = si.width; @@ -514,8 +514,8 @@ TEST_IMPL(tty_cursor_forward) { snprintf(buffer, sizeof(buffer), "%sC", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); /* cursor forward from end of screen does nothing */ cursor_pos_old.X = si.width; @@ -524,8 +524,8 @@ TEST_IMPL(tty_cursor_forward) { snprintf(buffer, sizeof(buffer), "%sC", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -557,16 +557,16 @@ TEST_IMPL(tty_cursor_back) { snprintf(buffer, sizeof(buffer), "%sD", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X - 1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X - 1, cursor_pos.X); /* cursor back nth times */ cursor_pos_old = cursor_pos; snprintf(buffer, sizeof(buffer), "%s%dD", CSI, si.width / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X - si.width / 4 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X - si.width / 4, cursor_pos.X); /* cursor back from beginning of line does nothing */ cursor_pos_old.X = 1; @@ -575,8 +575,8 @@ TEST_IMPL(tty_cursor_back) { snprintf(buffer, sizeof(buffer), "%sD", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(cursor_pos_old.X == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(cursor_pos_old.X, cursor_pos.X); /* cursor back from top of screen does nothing */ cursor_pos_old.X = 1; @@ -585,8 +585,8 @@ TEST_IMPL(tty_cursor_back) { snprintf(buffer, sizeof(buffer), "%sD", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(1 == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(1, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -618,16 +618,16 @@ TEST_IMPL(tty_cursor_next_line) { snprintf(buffer, sizeof(buffer), "%sE", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y + 1 == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y + 1, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); /* cursor next line nth times */ cursor_pos_old = cursor_pos; snprintf(buffer, sizeof(buffer), "%s%dE", CSI, si.height / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y + si.height / 4 == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y + si.height / 4, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); /* cursor next line from buttom row moves beginning of line */ cursor_pos_old.X = si.width / 2; @@ -636,8 +636,8 @@ TEST_IMPL(tty_cursor_next_line) { snprintf(buffer, sizeof(buffer), "%sE", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -669,16 +669,16 @@ TEST_IMPL(tty_cursor_previous_line) { snprintf(buffer, sizeof(buffer), "%sF", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y - 1 == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y - 1, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); /* cursor previous line nth times */ cursor_pos_old = cursor_pos; snprintf(buffer, sizeof(buffer), "%s%dF", CSI, si.height / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos_old.Y - si.height / 4 == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y - si.height / 4, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); /* cursor previous line from top of screen does nothing */ cursor_pos_old.X = 1; @@ -687,8 +687,8 @@ TEST_IMPL(tty_cursor_previous_line) { snprintf(buffer, sizeof(buffer), "%sD", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(1 == cursor_pos.Y); - ASSERT(1 == cursor_pos.X); + ASSERT_EQ(1, cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -720,22 +720,22 @@ TEST_IMPL(tty_cursor_horizontal_move_absolute) { snprintf(buffer, sizeof(buffer), "%sG", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(1 == cursor_pos.X); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); /* Move cursor to nth character */ snprintf(buffer, sizeof(buffer), "%s%dG", CSI, si.width / 4); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(si.width / 4 == cursor_pos.X); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); + ASSERT_EQ(si.width / 4, cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); /* Moving out of screen will fit within screen */ snprintf(buffer, sizeof(buffer), "%s%dG", CSI, si.width + 1); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(si.width == cursor_pos.X); - ASSERT(cursor_pos_old.Y == cursor_pos.Y); + ASSERT_EQ(si.width, cursor_pos.X); + ASSERT_EQ(cursor_pos_old.Y, cursor_pos.Y); terminate_tty(&tty_out); @@ -766,31 +766,31 @@ TEST_IMPL(tty_cursor_move_absolute) { snprintf(buffer, sizeof(buffer), "%sH", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(1 == cursor_pos.X); - ASSERT(1 == cursor_pos.Y); + ASSERT_EQ(1, cursor_pos.X); + ASSERT_EQ(1, cursor_pos.Y); /* Move the cursor to the middle of the screen */ snprintf( buffer, sizeof(buffer), "%s%d;%df", CSI, si.height / 2, si.width / 2); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(si.width / 2 == cursor_pos.X); - ASSERT(si.height / 2 == cursor_pos.Y); + ASSERT_EQ(si.width / 2, cursor_pos.X); + ASSERT_EQ(si.height / 2, cursor_pos.Y); /* Moving out of screen will fit within screen */ snprintf( buffer, sizeof(buffer), "%s%d;%df", CSI, si.height / 2, si.width + 1); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(si.width == cursor_pos.X); - ASSERT(si.height / 2 == cursor_pos.Y); + ASSERT_EQ(si.width, cursor_pos.X); + ASSERT_EQ(si.height / 2, cursor_pos.Y); snprintf( buffer, sizeof(buffer), "%s%d;%df", CSI, si.height + 1, si.width / 2); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(si.width / 2 == cursor_pos.X); - ASSERT(si.height == cursor_pos.Y); + ASSERT_EQ(si.width / 2, cursor_pos.X); + ASSERT_EQ(si.height, cursor_pos.Y); ASSERT(!is_scrolling(&tty_out, si)); terminate_tty(&tty_out); @@ -1000,38 +1000,38 @@ TEST_IMPL(tty_set_cursor_shape) { set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_LARGE); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_LARGE); /* cursor size large */ set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s1 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_LARGE); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_LARGE); set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s2 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_LARGE); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_LARGE); /* cursor size small */ set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s3 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_SMALL); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_SMALL); set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s6 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_SMALL); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_SMALL); /* Nothing occurs with arguments outside valid range */ set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s7 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_MIDDLE); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_MIDDLE); /* restore cursor size if arguments is zero */ snprintf(buffer, sizeof(buffer), "%s0 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == saved_cursor_size); + ASSERT_EQ(get_cursor_size(&tty_out), saved_cursor_size); terminate_tty(&tty_out); @@ -1122,7 +1122,7 @@ TEST_IMPL(tty_set_style) { } /* Set foreground and background color */ - ASSERT(ARRAY_SIZE(fg_attrs) == ARRAY_SIZE(bg_attrs)); + ASSERT_EQ(ARRAY_SIZE(fg_attrs), ARRAY_SIZE(bg_attrs)); length = ARRAY_SIZE(bg_attrs); for (i = 0; i < length; i++) { capture_screen(&tty_out, &expect); @@ -1271,8 +1271,8 @@ TEST_IMPL(tty_save_restore_cursor_position) { snprintf(buffer, sizeof(buffer), "%su", CSI); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos.X == cursor_pos_old.X); - ASSERT(cursor_pos.Y == cursor_pos_old.Y); + ASSERT_EQ(cursor_pos.X, cursor_pos_old.X); + ASSERT_EQ(cursor_pos.Y, cursor_pos_old.Y); cursor_pos_old.X = si.width / 2; cursor_pos_old.Y = si.height / 2; @@ -1290,8 +1290,8 @@ TEST_IMPL(tty_save_restore_cursor_position) { snprintf(buffer, sizeof(buffer), "%s8", ESC); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos.X == cursor_pos_old.X); - ASSERT(cursor_pos.Y == cursor_pos_old.Y); + ASSERT_EQ(cursor_pos.X, cursor_pos_old.X); + ASSERT_EQ(cursor_pos.Y, cursor_pos_old.Y); terminate_tty(&tty_out); @@ -1332,9 +1332,9 @@ TEST_IMPL(tty_full_reset) { write_console(&tty_out, buffer); capture_screen(&tty_out, &actual); ASSERT(compare_screen(&tty_out, &actual, &expect)); - ASSERT(get_cursor_size(&tty_out) == saved_cursor_size); - ASSERT(get_cursor_visibility(&tty_out) == saved_cursor_visibility); - ASSERT(actual.si.csbi.srWindow.Top == 0); + ASSERT_EQ(get_cursor_size(&tty_out), saved_cursor_size); + ASSERT_EQ(get_cursor_visibility(&tty_out), saved_cursor_visibility); + ASSERT_OK(actual.si.csbi.srWindow.Top); terminate_tty(&tty_out); @@ -1520,8 +1520,8 @@ TEST_IMPL(tty_escape_sequence_processing) { snprintf(buffer, sizeof(buffer), "%s1;%dH", CSI, UINT16_MAX + 1); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos.X == 1); - ASSERT(cursor_pos.Y == 1); + ASSERT_EQ(1, cursor_pos.X); + ASSERT_EQ(1, cursor_pos.Y); /* Too many argument are ignored */ cursor_pos.X = 1; @@ -1554,18 +1554,18 @@ TEST_IMPL(tty_escape_sequence_processing) { expect.si.width / 2); write_console(&tty_out, buffer); get_cursor_position(&tty_out, &cursor_pos); - ASSERT(cursor_pos.X == 1); - ASSERT(cursor_pos.Y == 1); + ASSERT_EQ(1, cursor_pos.X); + ASSERT_EQ(1, cursor_pos.Y); /* Invalid sequence are ignored */ saved_cursor_size = get_cursor_size(&tty_out); set_cursor_size(&tty_out, CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s 1q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_MIDDLE); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_MIDDLE); snprintf(buffer, sizeof(buffer), "%s 1 q", CSI); write_console(&tty_out, buffer); - ASSERT(get_cursor_size(&tty_out) == CURSOR_SIZE_MIDDLE); + ASSERT_EQ(get_cursor_size(&tty_out), CURSOR_SIZE_MIDDLE); set_cursor_size(&tty_out, saved_cursor_size); /* #1874 2. */ diff --git a/deps/libuv/test/test-tty.c b/deps/libuv/test/test-tty.c index 418ec31e..1b113038 100644 --- a/deps/libuv/test/test-tty.c +++ b/deps/libuv/test/test-tty.c @@ -57,7 +57,7 @@ TEST_IMPL(tty) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyin_fd = _open_osfhandle((intptr_t) handle, 0); handle = CreateFileA("conout$", @@ -67,7 +67,7 @@ TEST_IMPL(tty) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyout_fd = _open_osfhandle((intptr_t) handle, 0); #else /* unix */ @@ -86,26 +86,26 @@ TEST_IMPL(tty) { } #endif - ASSERT(ttyin_fd >= 0); - ASSERT(ttyout_fd >= 0); + ASSERT_GE(ttyin_fd, 0); + ASSERT_GE(ttyout_fd, 0); - ASSERT(UV_UNKNOWN_HANDLE == uv_guess_handle(-1)); + ASSERT_EQ(UV_UNKNOWN_HANDLE, uv_guess_handle(-1)); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyin_fd)); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyout_fd)); r = uv_tty_init(loop, &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_is_readable((uv_stream_t*) &tty_in)); ASSERT(!uv_is_writable((uv_stream_t*) &tty_in)); r = uv_tty_init(loop, &tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(!uv_is_readable((uv_stream_t*) &tty_out)); ASSERT(uv_is_writable((uv_stream_t*) &tty_out)); r = uv_tty_get_winsize(&tty_out, &width, &height); - ASSERT(r == 0); + ASSERT_OK(r); printf("width=%d height=%d\n", width, height); @@ -121,18 +121,18 @@ TEST_IMPL(tty) { /* Turn on raw mode. */ r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); + ASSERT_OK(r); /* Turn off raw mode. */ r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_NORMAL); - ASSERT(r == 0); + ASSERT_OK(r); /* Calling uv_tty_reset_mode() repeatedly should not clobber errno. */ errno = 0; - ASSERT(0 == uv_tty_reset_mode()); - ASSERT(0 == uv_tty_reset_mode()); - ASSERT(0 == uv_tty_reset_mode()); - ASSERT(0 == errno); + ASSERT_OK(uv_tty_reset_mode()); + ASSERT_OK(uv_tty_reset_mode()); + ASSERT_OK(uv_tty_reset_mode()); + ASSERT_OK(errno); /* TODO check the actual mode! */ @@ -154,11 +154,11 @@ static void tty_raw_alloc(uv_handle_t* handle, size_t size, uv_buf_t* buf) { static void tty_raw_read(uv_stream_t* tty_in, ssize_t nread, const uv_buf_t* buf) { if (nread > 0) { - ASSERT(nread == 1); - ASSERT(buf->base[0] == ' '); + ASSERT_EQ(1, nread ); + ASSERT_EQ(buf->base[0], ' '); uv_close((uv_handle_t*) tty_in, NULL); } else { - ASSERT(nread == 0); + ASSERT_OK(nread); } } @@ -179,25 +179,25 @@ TEST_IMPL(tty_raw) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyin_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); + ASSERT_GE(ttyin_fd, 0); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyin_fd)); r = uv_tty_init(loop, &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(uv_is_readable((uv_stream_t*) &tty_in)); ASSERT(!uv_is_writable((uv_stream_t*) &tty_in)); r = uv_read_start((uv_stream_t*)&tty_in, tty_raw_alloc, tty_raw_read); - ASSERT(r == 0); + ASSERT_OK(r); /* Give uv_tty_line_read_thread time to block on ReadConsoleW */ Sleep(100); /* Turn on raw mode. */ r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); + ASSERT_OK(r); /* Write ' ' that should be read in raw mode */ record.EventType = KEY_EVENT; @@ -235,15 +235,15 @@ TEST_IMPL(tty_empty_write) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyout_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyout_fd >= 0); + ASSERT_GE(ttyout_fd, 0); - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyout_fd)); r = uv_tty_init(loop, &tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); + ASSERT_OK(r); ASSERT(!uv_is_readable((uv_stream_t*) &tty_out)); ASSERT(uv_is_writable((uv_stream_t*) &tty_out)); @@ -251,7 +251,7 @@ TEST_IMPL(tty_empty_write) { bufs[0].base = &dummy[0]; r = uv_try_write((uv_stream_t*) &tty_out, bufs, 1); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &tty_out, NULL); @@ -281,15 +281,15 @@ TEST_IMPL(tty_large_write) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyout_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyout_fd >= 0); + ASSERT_GE(ttyout_fd, 0); - ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyout_fd)); r = uv_tty_init(loop, &tty_out, ttyout_fd, 0); /* Writable. */ - ASSERT(r == 0); + ASSERT_OK(r); memset(dummy, '.', sizeof(dummy) - 1); dummy[sizeof(dummy) - 1] = '\n'; @@ -297,7 +297,7 @@ TEST_IMPL(tty_large_write) { bufs[0] = uv_buf_init(dummy, sizeof(dummy)); r = uv_try_write((uv_stream_t*) &tty_out, bufs, 1); - ASSERT(r == 10000); + ASSERT_EQ(10000, r); uv_close((uv_handle_t*) &tty_out, NULL); @@ -321,20 +321,20 @@ TEST_IMPL(tty_raw_cancel) { OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - ASSERT(handle != INVALID_HANDLE_VALUE); + ASSERT_PTR_NE(handle, INVALID_HANDLE_VALUE); ttyin_fd = _open_osfhandle((intptr_t) handle, 0); - ASSERT(ttyin_fd >= 0); - ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); + ASSERT_GE(ttyin_fd, 0); + ASSERT_EQ(UV_TTY, uv_guess_handle(ttyin_fd)); r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ - ASSERT(r == 0); + ASSERT_OK(r); r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_start((uv_stream_t*)&tty_in, tty_raw_alloc, tty_raw_read); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_read_stop((uv_stream_t*) &tty_in); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -350,35 +350,35 @@ TEST_IMPL(tty_file) { uv_tty_t tty_wo; int fd; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); fd = open("test/fixtures/empty_file", O_RDONLY); if (fd != -1) { - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); + ASSERT_EQ(UV_EINVAL, uv_tty_init(&loop, &tty, fd, 1)); + ASSERT_OK(close(fd)); /* test EBADF handling */ - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); + ASSERT_EQ(UV_EINVAL, uv_tty_init(&loop, &tty, fd, 1)); } /* Bug on AIX where '/dev/random' returns 1 from isatty() */ #ifndef _AIX fd = open("/dev/random", O_RDONLY); if (fd != -1) { - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); + ASSERT_EQ(UV_EINVAL, uv_tty_init(&loop, &tty, fd, 1)); + ASSERT_OK(close(fd)); } #endif /* _AIX */ fd = open("/dev/zero", O_RDONLY); if (fd != -1) { - ASSERT(UV_EINVAL == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); + ASSERT_EQ(UV_EINVAL, uv_tty_init(&loop, &tty, fd, 1)); + ASSERT_OK(close(fd)); } fd = open("/dev/tty", O_RDWR); if (fd != -1) { - ASSERT(0 == uv_tty_init(&loop, &tty, fd, 1)); - ASSERT(0 == close(fd)); /* TODO: it's indeterminate who owns fd now */ + ASSERT_OK(uv_tty_init(&loop, &tty, fd, 1)); + ASSERT_OK(close(fd)); /* TODO: it's indeterminate who owns fd now */ ASSERT(uv_is_readable((uv_stream_t*) &tty)); ASSERT(uv_is_writable((uv_stream_t*) &tty)); uv_close((uv_handle_t*) &tty, NULL); @@ -388,8 +388,8 @@ TEST_IMPL(tty_file) { fd = open("/dev/tty", O_RDONLY); if (fd != -1) { - ASSERT(0 == uv_tty_init(&loop, &tty_ro, fd, 1)); - ASSERT(0 == close(fd)); /* TODO: it's indeterminate who owns fd now */ + ASSERT_OK(uv_tty_init(&loop, &tty_ro, fd, 1)); + ASSERT_OK(close(fd)); /* TODO: it's indeterminate who owns fd now */ ASSERT(uv_is_readable((uv_stream_t*) &tty_ro)); ASSERT(!uv_is_writable((uv_stream_t*) &tty_ro)); uv_close((uv_handle_t*) &tty_ro, NULL); @@ -399,8 +399,8 @@ TEST_IMPL(tty_file) { fd = open("/dev/tty", O_WRONLY); if (fd != -1) { - ASSERT(0 == uv_tty_init(&loop, &tty_wo, fd, 0)); - ASSERT(0 == close(fd)); /* TODO: it's indeterminate who owns fd now */ + ASSERT_OK(uv_tty_init(&loop, &tty_wo, fd, 0)); + ASSERT_OK(close(fd)); /* TODO: it's indeterminate who owns fd now */ ASSERT(!uv_is_readable((uv_stream_t*) &tty_wo)); ASSERT(uv_is_writable((uv_stream_t*) &tty_wo)); uv_close((uv_handle_t*) &tty_wo, NULL); @@ -409,7 +409,7 @@ TEST_IMPL(tty_file) { } - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(&loop); #endif @@ -436,14 +436,14 @@ TEST_IMPL(tty_pty) { uv_loop_t loop; uv_tty_t master_tty, slave_tty; - ASSERT(0 == uv_loop_init(&loop)); + ASSERT_OK(uv_loop_init(&loop)); r = openpty(&master_fd, &slave_fd, NULL, NULL, &w); if (r != 0) RETURN_SKIP("No pty available, skipping."); - ASSERT(0 == uv_tty_init(&loop, &slave_tty, slave_fd, 0)); - ASSERT(0 == uv_tty_init(&loop, &master_tty, master_fd, 0)); + ASSERT_OK(uv_tty_init(&loop, &slave_tty, slave_fd, 0)); + ASSERT_OK(uv_tty_init(&loop, &master_tty, master_fd, 0)); ASSERT(uv_is_readable((uv_stream_t*) &slave_tty)); ASSERT(uv_is_writable((uv_stream_t*) &slave_tty)); ASSERT(uv_is_readable((uv_stream_t*) &master_tty)); @@ -451,16 +451,16 @@ TEST_IMPL(tty_pty) { /* Check if the file descriptor was reopened. If it is, * UV_HANDLE_BLOCKING_WRITES (value 0x100000) isn't set on flags. */ - ASSERT(0 == (slave_tty.flags & 0x100000)); + ASSERT_OK((slave_tty.flags & 0x100000)); /* The master_fd of a pty should never be reopened. */ ASSERT(master_tty.flags & 0x100000); - ASSERT(0 == close(slave_fd)); + ASSERT_OK(close(slave_fd)); uv_close((uv_handle_t*) &slave_tty, NULL); - ASSERT(0 == close(master_fd)); + ASSERT_OK(close(master_fd)); uv_close((uv_handle_t*) &master_tty, NULL); - ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(&loop, UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(&loop); #endif diff --git a/deps/libuv/test/test-udp-alloc-cb-fail.c b/deps/libuv/test/test-udp-alloc-cb-fail.c index 073dea97..ae4bbee3 100644 --- a/deps/libuv/test/test-udp-alloc-cb-fail.c +++ b/deps/libuv/test/test-udp-alloc-cb-fail.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -60,7 +60,7 @@ static void cl_alloc_cb(uv_handle_t* handle, static void close_cb(uv_handle_t* handle) { CHECK_HANDLE(handle); - ASSERT(1 == uv_is_closing(handle)); + ASSERT_EQ(1, uv_is_closing(handle)); close_cb_called++; } @@ -71,8 +71,8 @@ static void cl_recv_cb(uv_udp_t* handle, const struct sockaddr* addr, unsigned flags) { CHECK_HANDLE(handle); - ASSERT(flags == 0); - ASSERT(nread == UV_ENOBUFS); + ASSERT_OK(flags); + ASSERT_EQ(nread, UV_ENOBUFS); cl_recv_cb_called++; @@ -84,11 +84,11 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { int r; ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); r = uv_udp_recv_start(req->handle, cl_alloc_cb, cl_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); cl_send_cb_called++; } @@ -96,7 +96,7 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { static void sv_send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); uv_close((uv_handle_t*) req->handle, close_cb); @@ -126,21 +126,21 @@ static void sv_recv_cb(uv_udp_t* handle, } CHECK_HANDLE(handle); - ASSERT(flags == 0); + ASSERT_OK(flags); ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT(!memcmp("PING", rcvbuf->base, nread)); r = uv_udp_recv_stop(handle); - ASSERT(r == 0); + ASSERT_OK(r); req = malloc(sizeof *req); ASSERT_NOT_NULL(req); sndbuf = uv_buf_init("PONG", 4); r = uv_udp_send(req, handle, &sndbuf, 1, addr, sv_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); sv_recv_cb_called++; } @@ -152,21 +152,21 @@ TEST_IMPL(udp_alloc_cb_fail) { uv_buf_t buf; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, sv_alloc_cb, sv_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init("PING", 4); r = uv_udp_send(&req, @@ -175,21 +175,21 @@ TEST_IMPL(udp_alloc_cb_fail) { 1, (const struct sockaddr*) &addr, cl_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(cl_send_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - ASSERT(sv_recv_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(cl_send_cb_called); + ASSERT_OK(cl_recv_cb_called); + ASSERT_OK(sv_send_cb_called); + ASSERT_OK(sv_recv_cb_called); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(cl_send_cb_called == 1); - ASSERT(cl_recv_cb_called == 1); - ASSERT(sv_send_cb_called == 1); - ASSERT(sv_recv_cb_called == 1); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, cl_send_cb_called); + ASSERT_EQ(1, cl_recv_cb_called); + ASSERT_EQ(1, sv_send_cb_called); + ASSERT_EQ(1, sv_recv_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-bind.c b/deps/libuv/test/test-udp-bind.c index 200cdc7c..519f9b02 100644 --- a/deps/libuv/test/test-udp-bind.c +++ b/deps/libuv/test/test-udp-bind.c @@ -33,27 +33,27 @@ TEST_IMPL(udp_bind) { uv_udp_t h1, h2; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); loop = uv_default_loop(); r = uv_udp_init(loop, &h1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(loop, &h2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&h1, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&h2, (const struct sockaddr*) &addr, 0); - ASSERT(r == UV_EADDRINUSE); + ASSERT_EQ(r, UV_EADDRINUSE); uv_close((uv_handle_t*) &h1, NULL); uv_close((uv_handle_t*) &h2, NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -66,27 +66,27 @@ TEST_IMPL(udp_bind_reuseaddr) { uv_udp_t h1, h2; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); loop = uv_default_loop(); r = uv_udp_init(loop, &h1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(loop, &h2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&h1, (const struct sockaddr*) &addr, UV_UDP_REUSEADDR); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&h2, (const struct sockaddr*) &addr, UV_UDP_REUSEADDR); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &h1, NULL); uv_close((uv_handle_t*) &h2, NULL); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-udp-connect.c b/deps/libuv/test/test-udp-connect.c index c1e4064b..88314acc 100644 --- a/deps/libuv/test/test-udp-connect.c +++ b/deps/libuv/test/test-udp-connect.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -45,7 +45,7 @@ static void alloc_cb(uv_handle_t* handle, uv_buf_t* buf) { static char slab[65536]; CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -62,19 +62,19 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { int r; ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); if (++cl_send_cb_called == 1) { uv_udp_connect(&client, NULL); r = uv_udp_send(req, &client, &buf, 1, NULL, cl_send_cb); - ASSERT(r == UV_EDESTADDRREQ); + ASSERT_EQ(r, UV_EDESTADDRREQ); r = uv_udp_send(req, &client, &buf, 1, (const struct sockaddr*) &lo_addr, cl_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -86,9 +86,9 @@ static void sv_recv_cb(uv_udp_t* handle, const struct sockaddr* addr, unsigned flags) { if (nread > 0) { - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT_NOT_NULL(addr); - ASSERT(memcmp("EXIT", rcvbuf->base, nread) == 0); + ASSERT_OK(memcmp("EXIT", rcvbuf->base, nread)); if (++sv_recv_cb_called == 4) { uv_close((uv_handle_t*) &server, close_cb); uv_close((uv_handle_t*) &client, close_cb); @@ -107,89 +107,89 @@ TEST_IMPL(udp_connect) { int r; int addrlen; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &lo_addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &lo_addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &lo_addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init("EXIT", 4); /* connect() to INADDR_ANY fails on Windows with WSAEADDRNOTAVAIL */ - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &tmp_addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &tmp_addr)); r = uv_udp_connect(&client, (const struct sockaddr*) &tmp_addr); #ifdef _WIN32 ASSERT_EQ(r, UV_EADDRNOTAVAIL); #else - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_connect(&client, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); #endif - ASSERT(0 == uv_ip4_addr("8.8.8.8", TEST_PORT, &ext_addr)); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &lo_addr)); + ASSERT_OK(uv_ip4_addr("8.8.8.8", TEST_PORT, &ext_addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &lo_addr)); r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_connect(&client, (const struct sockaddr*) &ext_addr); - ASSERT(r == UV_EISCONN); + ASSERT_EQ(r, UV_EISCONN); addrlen = sizeof(tmp_addr); r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen); - ASSERT(r == 0); + ASSERT_OK(r); /* To send messages in connected UDP sockets addr must be NULL */ r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr); - ASSERT(r == UV_EISCONN); + ASSERT_EQ(r, UV_EISCONN); r = uv_udp_try_send(&client, &buf, 1, NULL); - ASSERT(r == 4); + ASSERT_EQ(4, r); r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &ext_addr); - ASSERT(r == UV_EISCONN); + ASSERT_EQ(r, UV_EISCONN); r = uv_udp_connect(&client, NULL); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_connect(&client, NULL); - ASSERT(r == UV_ENOTCONN); + ASSERT_EQ(r, UV_ENOTCONN); addrlen = sizeof(tmp_addr); r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen); - ASSERT(r == UV_ENOTCONN); + ASSERT_EQ(r, UV_ENOTCONN); /* To send messages in disconnected UDP sockets addr must be set */ r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr); - ASSERT(r == 4); + ASSERT_EQ(4, r); r = uv_udp_try_send(&client, &buf, 1, NULL); - ASSERT(r == UV_EDESTADDRREQ); + ASSERT_EQ(r, UV_EDESTADDRREQ); r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_send(&req, &client, &buf, 1, (const struct sockaddr*) &lo_addr, cl_send_cb); - ASSERT(r == UV_EISCONN); + ASSERT_EQ(r, UV_EISCONN); r = uv_udp_send(&req, &client, &buf, 1, NULL, cl_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); - ASSERT(sv_recv_cb_called == 4); - ASSERT(cl_send_cb_called == 2); + ASSERT_EQ(2, close_cb_called); + ASSERT_EQ(4, sv_recv_cb_called); + ASSERT_EQ(2, cl_send_cb_called); - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); + ASSERT_OK(client.send_queue_size); + ASSERT_OK(server.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-connect6.c b/deps/libuv/test/test-udp-connect6.c index 076d8d77..bbc4033c 100644 --- a/deps/libuv/test/test-udp-connect6.c +++ b/deps/libuv/test/test-udp-connect6.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -62,7 +62,7 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { int r; ASSERT_NOT_NULL(req); - ASSERT_EQ(status, 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); if (++cl_send_cb_called == 1) { uv_udp_connect(&client, NULL); @@ -74,7 +74,7 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { 1, (const struct sockaddr*) &lo_addr, cl_send_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } } @@ -86,9 +86,9 @@ static void sv_recv_cb(uv_udp_t* handle, const struct sockaddr* addr, unsigned flags) { if (nread > 0) { - ASSERT_EQ(nread, 4); + ASSERT_EQ(4, nread); ASSERT_NOT_NULL(addr); - ASSERT_EQ(memcmp("EXIT", rcvbuf->base, nread), 0); + ASSERT_OK(memcmp("EXIT", rcvbuf->base, nread)); if (++sv_recv_cb_called == 4) { uv_close((uv_handle_t*) &server, close_cb); uv_close((uv_handle_t*) &client, close_cb); @@ -110,55 +110,55 @@ TEST_IMPL(udp_connect6) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT_EQ(0, uv_ip6_addr("::", TEST_PORT, &lo_addr)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &lo_addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &lo_addr, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT_EQ(r, 0); + ASSERT_OK(r); buf = uv_buf_init("EXIT", 4); /* connect() to INADDR_ANY fails on Windows wih WSAEADDRNOTAVAIL */ - ASSERT_EQ(0, uv_ip6_addr("::", TEST_PORT, &tmp_addr)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &tmp_addr)); r = uv_udp_connect(&client, (const struct sockaddr*) &tmp_addr); #ifdef _WIN32 ASSERT_EQ(r, UV_EADDRNOTAVAIL); #else - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_connect(&client, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); #endif - ASSERT_EQ(0, uv_ip6_addr("2001:4860:4860::8888", TEST_PORT, &ext_addr)); - ASSERT_EQ(0, uv_ip6_addr("::1", TEST_PORT, &lo_addr)); + ASSERT_OK(uv_ip6_addr("2001:4860:4860::8888", TEST_PORT, &ext_addr)); + ASSERT_OK(uv_ip6_addr("::1", TEST_PORT, &lo_addr)); r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_connect(&client, (const struct sockaddr*) &ext_addr); ASSERT_EQ(r, UV_EISCONN); addrlen = sizeof(tmp_addr); r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* To send messages in connected UDP sockets addr must be NULL */ r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr); ASSERT_EQ(r, UV_EISCONN); r = uv_udp_try_send(&client, &buf, 1, NULL); - ASSERT_EQ(r, 4); + ASSERT_EQ(4, r); r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &ext_addr); ASSERT_EQ(r, UV_EISCONN); r = uv_udp_connect(&client, NULL); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_connect(&client, NULL); ASSERT_EQ(r, UV_ENOTCONN); @@ -168,13 +168,13 @@ TEST_IMPL(udp_connect6) { /* To send messages in disconnected UDP sockets addr must be set */ r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr); - ASSERT_EQ(r, 4); + ASSERT_EQ(4, r); r = uv_udp_try_send(&client, &buf, 1, NULL); ASSERT_EQ(r, UV_EDESTADDRREQ); r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_send(&req, &client, &buf, @@ -183,16 +183,16 @@ TEST_IMPL(udp_connect6) { cl_send_cb); ASSERT_EQ(r, UV_EISCONN); r = uv_udp_send(&req, &client, &buf, 1, NULL, cl_send_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT_EQ(close_cb_called, 2); - ASSERT_EQ(sv_recv_cb_called, 4); - ASSERT_EQ(cl_send_cb_called, 2); + ASSERT_EQ(2, close_cb_called); + ASSERT_EQ(4, sv_recv_cb_called); + ASSERT_EQ(2, cl_send_cb_called); - ASSERT_EQ(client.send_queue_size, 0); - ASSERT_EQ(server.send_queue_size, 0); + ASSERT_OK(client.send_queue_size); + ASSERT_OK(server.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-create-socket-early.c b/deps/libuv/test/test-udp-create-socket-early.c index f51e275b..f2e166af 100644 --- a/deps/libuv/test/test-udp-create-socket-early.c +++ b/deps/libuv/test/test-udp-create-socket-early.c @@ -38,32 +38,34 @@ TEST_IMPL(udp_create_early) { uv_os_fd_t fd; int r, namelen; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init_ex(uv_default_loop(), &client, AF_INET); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); + ASSERT_OK(r); /* Windows returns WSAEINVAL if the socket is not bound */ #ifndef _WIN32 + ASSERT_NE(fd, INVALID_FD); namelen = sizeof sockname; r = uv_udp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin_family == AF_INET); + ASSERT_OK(r); + ASSERT_EQ(sockname.sin_family, AF_INET); +#else + ASSERT_PTR_NE(fd, INVALID_FD); #endif r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); namelen = sizeof sockname; r = uv_udp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(memcmp(&addr.sin_addr, - &sockname.sin_addr, - sizeof(addr.sin_addr)) == 0); + ASSERT_OK(r); + ASSERT_OK(memcmp(&addr.sin_addr, + &sockname.sin_addr, + sizeof(addr.sin_addr))); uv_close((uv_handle_t*) &client, NULL); uv_run(uv_default_loop(), UV_RUN_DEFAULT); @@ -82,32 +84,34 @@ TEST_IMPL(udp_create_early_bad_bind) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init_ex(uv_default_loop(), &client, AF_INET6); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_fileno((const uv_handle_t*) &client, &fd); - ASSERT(r == 0); - ASSERT(fd != INVALID_FD); + ASSERT_OK(r); /* Windows returns WSAEINVAL if the socket is not bound */ -#ifndef _WIN32 - { +#ifndef _WIN32 + ASSERT_NE(fd, INVALID_FD); + { int namelen; struct sockaddr_in6 sockname; namelen = sizeof sockname; r = uv_udp_getsockname(&client, (struct sockaddr*) &sockname, &namelen); - ASSERT(r == 0); - ASSERT(sockname.sin6_family == AF_INET6); + ASSERT_OK(r); + ASSERT_EQ(sockname.sin6_family, AF_INET6); } +#else + ASSERT_PTR_NE(fd, INVALID_FD); #endif r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); #if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MSYS__) - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); #else - ASSERT(r == UV_EFAULT); + ASSERT_EQ(r, UV_EFAULT); #endif uv_close((uv_handle_t*) &client, NULL); @@ -123,10 +127,10 @@ TEST_IMPL(udp_create_early_bad_domain) { int r; r = uv_udp_init_ex(uv_default_loop(), &client, 47); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); r = uv_udp_init_ex(uv_default_loop(), &client, 1024); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); uv_run(uv_default_loop(), UV_RUN_DEFAULT); diff --git a/deps/libuv/test/test-udp-dgram-too-big.c b/deps/libuv/test/test-udp-dgram-too-big.c index 9db8b47b..8fae756e 100644 --- a/deps/libuv/test/test-udp-dgram-too-big.c +++ b/deps/libuv/test/test-udp-dgram-too-big.c @@ -27,10 +27,10 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &handle_) + ASSERT_PTR_EQ((uv_udp_t*)(handle), &handle_) #define CHECK_REQ(req) \ - ASSERT((req) == &req_); + ASSERT_PTR_EQ((req), &req_); static uv_udp_t handle_; static uv_udp_send_t req_; @@ -49,7 +49,7 @@ static void send_cb(uv_udp_send_t* req, int status) { CHECK_REQ(req); CHECK_HANDLE(req->handle); - ASSERT(status == UV_EMSGSIZE); + ASSERT_EQ(status, UV_EMSGSIZE); uv_close((uv_handle_t*)req->handle, close_cb); send_cb_called++; @@ -65,10 +65,10 @@ TEST_IMPL(udp_dgram_too_big) { memset(dgram, 42, sizeof dgram); /* silence valgrind */ r = uv_udp_init(uv_default_loop(), &handle_); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init(dgram, sizeof dgram); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_send(&req_, &handle_, @@ -76,15 +76,15 @@ TEST_IMPL(udp_dgram_too_big) { 1, (const struct sockaddr*) &addr, send_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(send_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(send_cb_called); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(send_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, send_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-ipv6.c b/deps/libuv/test/test-udp-ipv6.c index ae55cd01..8ad80b9b 100644 --- a/deps/libuv/test/test-udp-ipv6.c +++ b/deps/libuv/test/test-udp-ipv6.c @@ -30,13 +30,13 @@ #include #endif -#define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server \ - || (uv_udp_t*)(handle) == &client \ - || (uv_timer_t*)(handle) == &timeout) +#define CHECK_HANDLE(handle) \ + ASSERT_NE((uv_udp_t*)(handle) == &server \ + || (uv_udp_t*)(handle) == &client \ + || (uv_timer_t*)(handle) == &timeout, 0) #define CHECK_REQ(req) \ - ASSERT((req) == &req_); + ASSERT_PTR_EQ((req), &req_); static uv_udp_t client; static uv_udp_t server; @@ -81,7 +81,7 @@ static void close_cb(uv_handle_t* handle) { static void send_cb(uv_udp_send_t* req, int status) { CHECK_REQ(req); CHECK_HANDLE(req->handle); - ASSERT(status == 0); + ASSERT_OK(status); send_cb_called++; } @@ -92,7 +92,7 @@ static int is_from_client(const struct sockaddr* addr) { /* Debugging output, and filter out unwanted network traffic */ if (addr != NULL) { - ASSERT(addr->sa_family == AF_INET6); + ASSERT_EQ(addr->sa_family, AF_INET6); addr6 = (struct sockaddr_in6*) addr; r = uv_inet_ntop(addr->sa_family, &addr6->sin6_addr, dst, sizeof(dst)); if (r == 0) @@ -129,7 +129,7 @@ static void ipv6_recv_ok(uv_udp_t* handle, if (!is_from_client(addr) || (nread == 0 && addr == NULL)) return; - ASSERT(nread == 9); + ASSERT_EQ(9, nread); ASSERT(!memcmp(buf->base, data, 9)); recv_cb_called++; } @@ -151,31 +151,39 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) { char dst[256]; int r; - ASSERT(0 == uv_ip6_addr("::0", TEST_PORT, &addr6)); + ASSERT_OK(uv_ip6_addr("::0", TEST_PORT, &addr6)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &addr6, bind_flags); - ASSERT(r == 0); + ASSERT_OK(r); addr6_len = sizeof(addr6); - ASSERT(uv_udp_getsockname(&server, (struct sockaddr*) &addr6, &addr6_len) == 0); - ASSERT(uv_inet_ntop(addr6.sin6_family, &addr6.sin6_addr, dst, sizeof(dst)) == 0); + ASSERT_OK(uv_udp_getsockname(&server, + (struct sockaddr*) &addr6, + &addr6_len)); + ASSERT_OK(uv_inet_ntop(addr6.sin6_family, + &addr6.sin6_addr, + dst, + sizeof(dst))); printf("on [%.*s]:%d\n", (int) sizeof(dst), dst, addr6.sin6_port); r = uv_udp_recv_start(&server, alloc_cb, recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT(uv_inet_ntop(addr.sin_family, &addr.sin_addr, dst, sizeof(dst)) == 0); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_inet_ntop(addr.sin_family, &addr.sin_addr, dst, sizeof(dst))); printf("to [%.*s]:%d\n", (int) sizeof(dst), dst, addr.sin_port); /* Create some unique data to send */ - ASSERT(9 == snprintf(data, sizeof(data), "PING%5u", uv_os_getpid() & 0xFFFF)); + ASSERT_EQ(9, snprintf(data, + sizeof(data), + "PING%5u", + uv_os_getpid() & 0xFFFF)); buf = uv_buf_init(data, 9); printf("sending %s\n", data); @@ -185,27 +193,27 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) { 1, (const struct sockaddr*) &addr, send_cb); - ASSERT(r == 0); + ASSERT_OK(r); addr_len = sizeof(addr); - ASSERT(uv_udp_getsockname(&client, (struct sockaddr*) &addr, &addr_len) == 0); - ASSERT(uv_inet_ntop(addr.sin_family, &addr.sin_addr, dst, sizeof(dst)) == 0); + ASSERT_OK(uv_udp_getsockname(&client, (struct sockaddr*) &addr, &addr_len)); + ASSERT_OK(uv_inet_ntop(addr.sin_family, &addr.sin_addr, dst, sizeof(dst))); printf("from [%.*s]:%d\n", (int) sizeof(dst), dst, addr.sin_port); client_port = addr.sin_port; r = uv_timer_init(uv_default_loop(), &timeout); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timeout, timeout_cb, 500, 0); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(send_cb_called == 0); - ASSERT(recv_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(send_cb_called); + ASSERT_OK(recv_cb_called); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 3); + ASSERT_EQ(3, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); } @@ -231,8 +239,8 @@ TEST_IMPL(udp_dual_stack) { printf("recv_cb_called %d\n", recv_cb_called); printf("send_cb_called %d\n", send_cb_called); - ASSERT(recv_cb_called == 1); - ASSERT(send_cb_called == 1); + ASSERT_EQ(1, recv_cb_called); + ASSERT_EQ(1, send_cb_called); return 0; } @@ -244,8 +252,8 @@ TEST_IMPL(udp_ipv6_only) { do_test(ipv6_recv_fail, UV_UDP_IPV6ONLY); - ASSERT(recv_cb_called == 0); - ASSERT(send_cb_called == 1); + ASSERT_OK(recv_cb_called); + ASSERT_EQ(1, send_cb_called); return 0; } diff --git a/deps/libuv/test/test-udp-mmsg.c b/deps/libuv/test/test-udp-mmsg.c index c37343f8..c0e000b9 100644 --- a/deps/libuv/test/test-udp-mmsg.c +++ b/deps/libuv/test/test-udp-mmsg.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &recver || (uv_udp_t*)(handle) == &sender) + ASSERT_NE((uv_udp_t*)(handle) == &recver || (uv_udp_t*)(handle) == &sender, 0) #define BUFFER_MULTIPLIER 20 #define MAX_DGRAM_SIZE (64 * 1024) @@ -77,7 +77,7 @@ static void recv_cb(uv_udp_t* handle, /* free and return if this is a mmsg free-only callback invocation */ if (flags & UV_UDP_MMSG_FREE) { - ASSERT_EQ(nread, 0); + ASSERT_OK(nread); ASSERT_NULL(addr); free(rcvbuf->base); return; @@ -87,7 +87,7 @@ static void recv_cb(uv_udp_t* handle, /* There can be no more available data for the time being. */ ASSERT_NULL(addr); } else { - ASSERT_EQ(nread, 4); + ASSERT_EQ(4, nread); ASSERT_NOT_NULL(addr); ASSERT_MEM_EQ("PING", rcvbuf->base, nread); received_datagrams++; @@ -110,31 +110,31 @@ TEST_IMPL(udp_mmsg) { uv_buf_t buf; int i; - ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_udp_init_ex(uv_default_loop(), &recver, - AF_UNSPEC | UV_UDP_RECVMMSG)); + ASSERT_OK(uv_udp_init_ex(uv_default_loop(), &recver, + AF_UNSPEC | UV_UDP_RECVMMSG)); - ASSERT_EQ(0, uv_udp_bind(&recver, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_udp_bind(&recver, (const struct sockaddr*) &addr, 0)); - ASSERT_EQ(0, uv_udp_recv_start(&recver, alloc_cb, recv_cb)); + ASSERT_OK(uv_udp_recv_start(&recver, alloc_cb, recv_cb)); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_udp_init(uv_default_loop(), &sender)); + ASSERT_OK(uv_udp_init(uv_default_loop(), &sender)); buf = uv_buf_init("PING", 4); for (i = 0; i < NUM_SENDS; i++) { ASSERT_EQ(4, uv_udp_try_send(&sender, &buf, 1, (const struct sockaddr*) &addr)); } - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); - ASSERT_EQ(close_cb_called, 2); + ASSERT_EQ(2, close_cb_called); ASSERT_EQ(received_datagrams, NUM_SENDS); - ASSERT_EQ(sender.send_queue_size, 0); - ASSERT_EQ(recver.send_queue_size, 0); + ASSERT_OK(sender.send_queue_size); + ASSERT_OK(recver.send_queue_size); printf("%d allocs for %d recvs\n", alloc_cb_called, recv_cb_called); diff --git a/deps/libuv/test/test-udp-multicast-interface.c b/deps/libuv/test/test-udp-multicast-interface.c index 447d3487..2c558c8b 100644 --- a/deps/libuv/test/test-udp-multicast-interface.c +++ b/deps/libuv/test/test-udp-multicast-interface.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -65,17 +65,17 @@ TEST_IMPL(udp_multicast_interface) { struct sockaddr_in addr; struct sockaddr_in baddr; - ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("239.255.0.1", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &baddr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", 0, &baddr)); r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_multicast_interface(&server, "0.0.0.0"); - ASSERT(r == 0); + ASSERT_OK(r); /* server sends "PING" */ buf = uv_buf_init("PING", 4); @@ -85,19 +85,19 @@ TEST_IMPL(udp_multicast_interface) { 1, (const struct sockaddr*)&addr, sv_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(sv_send_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(sv_send_cb_called); /* run the loop till all events are processed */ uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, sv_send_cb_called); + ASSERT_EQ(1, close_cb_called); - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); + ASSERT_OK(client.send_queue_size); + ASSERT_OK(server.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-multicast-interface6.c b/deps/libuv/test/test-udp-multicast-interface6.c index 1d40aefa..54fc87ed 100644 --- a/deps/libuv/test/test-udp-multicast-interface6.c +++ b/deps/libuv/test/test-udp-multicast-interface6.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -44,7 +44,7 @@ static void close_cb(uv_handle_t* handle) { static void sv_send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); sv_send_cb_called++; @@ -68,21 +68,21 @@ TEST_IMPL(udp_multicast_interface6) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr("::1", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip6_addr("::", 0, &baddr)); + ASSERT_OK(uv_ip6_addr("::", 0, &baddr)); r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0); - ASSERT(r == 0); + ASSERT_OK(r); #if defined(__APPLE__) || defined(__FreeBSD__) r = uv_udp_set_multicast_interface(&server, "::1%lo0"); #else r = uv_udp_set_multicast_interface(&server, NULL); #endif - ASSERT(r == 0); + ASSERT_OK(r); /* server sends "PING" */ buf = uv_buf_init("PING", 4); @@ -92,16 +92,16 @@ TEST_IMPL(udp_multicast_interface6) { 1, (const struct sockaddr*)&addr, sv_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(sv_send_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(sv_send_cb_called); /* run the loop till all events are processed */ uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, sv_send_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-multicast-join.c b/deps/libuv/test/test-udp-multicast-join.c index dddcea46..7e8fbe39 100644 --- a/deps/libuv/test/test-udp-multicast-join.c +++ b/deps/libuv/test/test-udp-multicast-join.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) #define MULTICAST_ADDR "239.255.0.1" @@ -47,7 +47,7 @@ static void alloc_cb(uv_handle_t* handle, uv_buf_t* buf) { static char slab[65536]; CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -61,7 +61,7 @@ static void close_cb(uv_handle_t* handle) { static void sv_send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); sv_send_cb_called++; @@ -77,7 +77,7 @@ static int do_send(uv_udp_send_t* send_req) { buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr(MULTICAST_ADDR, TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr(MULTICAST_ADDR, TEST_PORT, &addr)); /* client sends "PING" */ return uv_udp_send(send_req, @@ -95,7 +95,7 @@ static void cl_recv_cb(uv_udp_t* handle, const struct sockaddr* addr, unsigned flags) { CHECK_HANDLE(handle); - ASSERT(flags == 0); + ASSERT_OK(flags); if (nread < 0) { ASSERT(0 && "unexpected error"); @@ -108,7 +108,7 @@ static void cl_recv_cb(uv_udp_t* handle, } ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT(!memcmp("PING", buf->base, nread)); cl_recv_cb_called++; @@ -121,18 +121,18 @@ static void cl_recv_cb(uv_udp_t* handle, char source_addr[64]; r = uv_ip4_name((const struct sockaddr_in*)addr, source_addr, sizeof(source_addr)); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_membership(&server, MULTICAST_ADDR, NULL, UV_LEAVE_GROUP); - ASSERT(r == 0); + ASSERT_OK(r); #if !defined(__OpenBSD__) && !defined(__NetBSD__) r = uv_udp_set_source_membership(&server, MULTICAST_ADDR, NULL, source_addr, UV_JOIN_GROUP); - ASSERT(r == 0); + ASSERT_OK(r); #endif r = do_send(&req_ss); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -144,40 +144,40 @@ TEST_IMPL(udp_multicast_join) { int r; struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); /* bind to the desired port */ r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); /* join the multicast channel */ r = uv_udp_set_membership(&server, MULTICAST_ADDR, NULL, UV_JOIN_GROUP); if (r == UV_ENODEV) RETURN_SKIP("No multicast support."); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, cl_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = do_send(&req); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(cl_recv_cb_called); + ASSERT_OK(sv_send_cb_called); /* run the loop till all events are processed */ uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(cl_recv_cb_called == 2); - ASSERT(sv_send_cb_called == 2); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, cl_recv_cb_called); + ASSERT_EQ(2, sv_send_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-multicast-join6.c b/deps/libuv/test/test-udp-multicast-join6.c index d5262b6a..11efb0a6 100644 --- a/deps/libuv/test/test-udp-multicast-join6.c +++ b/deps/libuv/test/test-udp-multicast-join6.c @@ -28,7 +28,7 @@ #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) #if defined(__APPLE__) || \ defined(_AIX) || \ @@ -58,7 +58,7 @@ static void alloc_cb(uv_handle_t* handle, uv_buf_t* buf) { static char slab[65536]; CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -72,7 +72,7 @@ static void close_cb(uv_handle_t* handle) { static void sv_send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); sv_send_cb_called++; @@ -88,7 +88,7 @@ static int do_send(uv_udp_send_t* send_req) { buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip6_addr(MULTICAST_ADDR, TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr(MULTICAST_ADDR, TEST_PORT, &addr)); /* client sends "PING" */ return uv_udp_send(send_req, @@ -106,7 +106,7 @@ static void cl_recv_cb(uv_udp_t* handle, const struct sockaddr* addr, unsigned flags) { CHECK_HANDLE(handle); - ASSERT(flags == 0); + ASSERT_OK(flags); if (nread < 0) { ASSERT(0 && "unexpected error"); @@ -119,7 +119,7 @@ static void cl_recv_cb(uv_udp_t* handle, } ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT(!memcmp("PING", buf->base, nread)); cl_recv_cb_called++; @@ -132,16 +132,16 @@ static void cl_recv_cb(uv_udp_t* handle, char source_addr[64]; r = uv_ip6_name((const struct sockaddr_in6*)addr, source_addr, sizeof(source_addr)); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_membership(&server, MULTICAST_ADDR, INTERFACE_ADDR, UV_LEAVE_GROUP); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_source_membership(&server, MULTICAST_ADDR, INTERFACE_ADDR, source_addr, UV_JOIN_GROUP); - ASSERT(r == 0); + ASSERT_OK(r); r = do_send(&req_ss); - ASSERT(r == 0); + ASSERT_OK(r); } } @@ -172,17 +172,17 @@ TEST_IMPL(udp_multicast_join6) { if (!can_ipv6_external()) RETURN_SKIP("No external IPv6 interface available"); - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); /* bind to the desired port */ r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_membership(&server, MULTICAST_ADDR, INTERFACE_ADDR, UV_JOIN_GROUP); if (r == UV_ENODEV) { @@ -190,28 +190,28 @@ TEST_IMPL(udp_multicast_join6) { RETURN_SKIP("No ipv6 multicast route"); } - ASSERT(r == 0); + ASSERT_OK(r); /* TODO(gengjiawen): Fix test on QEMU. */ #if defined(__QEMU__) RETURN_SKIP("Test does not currently work in QEMU"); #endif r = uv_udp_recv_start(&server, alloc_cb, cl_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = do_send(&req); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(cl_recv_cb_called); + ASSERT_OK(sv_send_cb_called); /* run the loop till all events are processed */ uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(cl_recv_cb_called == 2); - ASSERT(sv_send_cb_called == 2); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, cl_recv_cb_called); + ASSERT_EQ(2, sv_send_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-multicast-ttl.c b/deps/libuv/test/test-udp-multicast-ttl.c index 9aa5bb91..50bc54a0 100644 --- a/deps/libuv/test/test-udp-multicast-ttl.c +++ b/deps/libuv/test/test-udp-multicast-ttl.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -60,34 +60,34 @@ TEST_IMPL(udp_multicast_ttl) { struct sockaddr_in addr; r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", 0, &addr)); r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_multicast_ttl(&server, 32); - ASSERT(r == 0); + ASSERT_OK(r); /* server sends "PING" */ buf = uv_buf_init("PING", 4); - ASSERT(0 == uv_ip4_addr("239.255.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("239.255.0.1", TEST_PORT, &addr)); r = uv_udp_send(&req, &server, &buf, 1, (const struct sockaddr*) &addr, sv_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(sv_send_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(sv_send_cb_called); /* run the loop till all events are processed */ uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(sv_send_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, sv_send_cb_called); + ASSERT_EQ(1, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-open.c b/deps/libuv/test/test-udp-open.c index 0e09f56a..6fddc937 100644 --- a/deps/libuv/test/test-udp-open.c +++ b/deps/libuv/test/test-udp-open.c @@ -41,7 +41,7 @@ static void startup(void) { #ifdef _WIN32 struct WSAData wsa_data; int r = WSAStartup(MAKEWORD(2, 2), &wsa_data); - ASSERT(r == 0); + ASSERT_OK(r); #endif } @@ -51,9 +51,9 @@ static uv_os_sock_t create_udp_socket(void) { sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); #ifdef _WIN32 - ASSERT(sock != INVALID_SOCKET); + ASSERT_NE(sock, INVALID_SOCKET); #else - ASSERT(sock >= 0); + ASSERT_GE(sock, 0); #endif #ifndef _WIN32 @@ -61,7 +61,7 @@ static uv_os_sock_t create_udp_socket(void) { /* Allow reuse of the port. */ int yes = 1; int r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); - ASSERT(r == 0); + ASSERT_OK(r); } #endif @@ -76,7 +76,7 @@ static void close_socket(uv_os_sock_t sock) { #else r = close(sock); #endif - ASSERT(r == 0); + ASSERT_OK(r); } @@ -84,7 +84,7 @@ static void alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { static char slab[65536]; - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -113,14 +113,14 @@ static void recv_cb(uv_udp_t* handle, return; } - ASSERT(flags == 0); + ASSERT_OK(flags); ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); - ASSERT(memcmp("PING", buf->base, nread) == 0); + ASSERT_EQ(4, nread); + ASSERT_OK(memcmp("PING", buf->base, nread)); r = uv_udp_recv_stop(handle); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) handle, close_cb); } @@ -128,7 +128,7 @@ static void recv_cb(uv_udp_t* handle, static void send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); send_cb_called++; uv_close((uv_handle_t*)req->handle, close_cb); @@ -142,22 +142,22 @@ TEST_IMPL(udp_open) { uv_os_sock_t sock; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); startup(); sock = create_udp_socket(); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&client, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&client, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&client, alloc_cb, recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_send(&send_req, &client, @@ -165,15 +165,15 @@ TEST_IMPL(udp_open) { 1, (const struct sockaddr*) &addr, send_cb); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 { r = uv_udp_init(uv_default_loop(), &client2); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&client2, sock); - ASSERT(r == UV_EEXIST); + ASSERT_EQ(r, UV_EEXIST); uv_close((uv_handle_t*) &client2, NULL); } @@ -183,10 +183,10 @@ TEST_IMPL(udp_open) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(send_cb_called == 1); - ASSERT(close_cb_called == 1); + ASSERT_EQ(1, send_cb_called); + ASSERT_EQ(1, close_cb_called); - ASSERT(client.send_queue_size == 0); + ASSERT_OK(client.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -203,13 +203,13 @@ TEST_IMPL(udp_open_twice) { sock2 = create_udp_socket(); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&client, sock1); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&client, sock2); - ASSERT(r == UV_EBUSY); + ASSERT_EQ(r, UV_EBUSY); close_socket(sock2); uv_close((uv_handle_t*) &client, NULL); @@ -225,22 +225,22 @@ TEST_IMPL(udp_open_bound) { uv_os_sock_t sock; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); startup(); sock = create_udp_socket(); r = bind(sock, (struct sockaddr*) &addr, sizeof(addr)); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&client, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&client, alloc_cb, recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*) &client, NULL); uv_run(uv_default_loop(), UV_RUN_DEFAULT); @@ -257,28 +257,28 @@ TEST_IMPL(udp_open_connect) { uv_os_sock_t sock; int r; - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); startup(); sock = create_udp_socket(); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); r = connect(sock, (const struct sockaddr*) &addr, sizeof(addr)); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&client, sock); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_send(&send_req, &client, @@ -286,14 +286,14 @@ TEST_IMPL(udp_open_connect) { 1, NULL, send_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(send_cb_called == 1); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, send_cb_called); + ASSERT_EQ(2, close_cb_called); - ASSERT(client.send_queue_size == 0); + ASSERT_OK(client.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; @@ -315,20 +315,20 @@ TEST_IMPL(udp_send_unix) { memset(&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; - ASSERT(strlen(TEST_PIPENAME) < sizeof(addr.sun_path)); + ASSERT_LT(strlen(TEST_PIPENAME), sizeof(addr.sun_path)); memcpy(addr.sun_path, TEST_PIPENAME, strlen(TEST_PIPENAME)); fd = socket(AF_UNIX, SOCK_STREAM, 0); - ASSERT(fd >= 0); + ASSERT_GE(fd, 0); unlink(TEST_PIPENAME); - ASSERT(0 == bind(fd, (const struct sockaddr*)&addr, sizeof addr)); - ASSERT(0 == listen(fd, 1)); + ASSERT_OK(bind(fd, (const struct sockaddr*)&addr, sizeof addr)); + ASSERT_OK(listen(fd, 1)); r = uv_udp_init(loop, &handle); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_open(&handle, fd); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(loop, UV_RUN_DEFAULT); r = uv_udp_send(&req, @@ -337,7 +337,7 @@ TEST_IMPL(udp_send_unix) { 1, (const struct sockaddr*) &addr, NULL); - ASSERT(r == 0); + ASSERT_OK(r); uv_close((uv_handle_t*)&handle, NULL); uv_run(loop, UV_RUN_DEFAULT); diff --git a/deps/libuv/test/test-udp-options.c b/deps/libuv/test/test-udp-options.c index 11e58b99..bb4a24ca 100644 --- a/deps/libuv/test/test-udp-options.c +++ b/deps/libuv/test/test-udp-options.c @@ -36,56 +36,56 @@ static int udp_options_test(const struct sockaddr* addr) { loop = uv_default_loop(); r = uv_udp_init(loop, &h); - ASSERT(r == 0); + ASSERT_OK(r); uv_unref((uv_handle_t*)&h); /* don't keep the loop alive */ r = uv_udp_bind(&h, addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_set_broadcast(&h, 1); r |= uv_udp_set_broadcast(&h, 1); r |= uv_udp_set_broadcast(&h, 0); r |= uv_udp_set_broadcast(&h, 0); - ASSERT(r == 0); + ASSERT_OK(r); /* values 1-255 should work */ for (i = 1; i <= 255; i++) { r = uv_udp_set_ttl(&h, i); #if defined(__MVS__) if (addr->sa_family == AF_INET6) - ASSERT(r == 0); + ASSERT_OK(r); else - ASSERT(r == UV_ENOTSUP); + ASSERT_EQ(r, UV_ENOTSUP); #else - ASSERT(r == 0); + ASSERT_OK(r); #endif } for (i = 0; i < (int) ARRAY_SIZE(invalid_ttls); i++) { r = uv_udp_set_ttl(&h, invalid_ttls[i]); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); } r = uv_udp_set_multicast_loop(&h, 1); r |= uv_udp_set_multicast_loop(&h, 1); r |= uv_udp_set_multicast_loop(&h, 0); r |= uv_udp_set_multicast_loop(&h, 0); - ASSERT(r == 0); + ASSERT_OK(r); /* values 0-255 should work */ for (i = 0; i <= 255; i++) { r = uv_udp_set_multicast_ttl(&h, i); - ASSERT(r == 0); + ASSERT_OK(r); } /* anything >255 should fail */ r = uv_udp_set_multicast_ttl(&h, 256); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* don't test ttl=-1, it's a valid value on some platforms */ r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); + ASSERT_OK(r); MAKE_VALGRIND_HAPPY(loop); return 0; @@ -95,7 +95,7 @@ static int udp_options_test(const struct sockaddr* addr) { TEST_IMPL(udp_options) { struct sockaddr_in addr; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); return udp_options_test((const struct sockaddr*) &addr); } @@ -106,7 +106,7 @@ TEST_IMPL(udp_options6) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); - ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr)); + ASSERT_OK(uv_ip6_addr("::", TEST_PORT, &addr)); return udp_options_test((const struct sockaddr*) &addr); } @@ -119,41 +119,41 @@ TEST_IMPL(udp_no_autobind) { loop = uv_default_loop(); /* Test a lazy initialized socket. */ - ASSERT(0 == uv_udp_init(loop, &h)); - ASSERT(UV_EBADF == uv_udp_set_multicast_ttl(&h, 32)); - ASSERT(UV_EBADF == uv_udp_set_broadcast(&h, 1)); + ASSERT_OK(uv_udp_init(loop, &h)); + ASSERT_EQ(UV_EBADF, uv_udp_set_multicast_ttl(&h, 32)); + ASSERT_EQ(UV_EBADF, uv_udp_set_broadcast(&h, 1)); #if defined(__MVS__) - ASSERT(UV_ENOTSUP == uv_udp_set_ttl(&h, 1)); + ASSERT_EQ(UV_ENOTSUP, uv_udp_set_ttl(&h, 1)); #else - ASSERT(UV_EBADF == uv_udp_set_ttl(&h, 1)); + ASSERT_EQ(UV_EBADF, uv_udp_set_ttl(&h, 1)); #endif - ASSERT(UV_EBADF == uv_udp_set_multicast_loop(&h, 1)); + ASSERT_EQ(UV_EBADF, uv_udp_set_multicast_loop(&h, 1)); /* TODO(gengjiawen): Fix test on QEMU. */ #if defined(__QEMU__) RETURN_SKIP("Test does not currently work in QEMU"); #endif - ASSERT(UV_EBADF == uv_udp_set_multicast_interface(&h, "0.0.0.0")); + ASSERT_EQ(UV_EBADF, uv_udp_set_multicast_interface(&h, "0.0.0.0")); uv_close((uv_handle_t*) &h, NULL); /* Test a non-lazily initialized socket. */ - ASSERT(0 == uv_udp_init_ex(loop, &h2, AF_INET | UV_UDP_RECVMMSG)); - ASSERT(0 == uv_udp_set_multicast_ttl(&h2, 32)); - ASSERT(0 == uv_udp_set_broadcast(&h2, 1)); + ASSERT_OK(uv_udp_init_ex(loop, &h2, AF_INET | UV_UDP_RECVMMSG)); + ASSERT_OK(uv_udp_set_multicast_ttl(&h2, 32)); + ASSERT_OK(uv_udp_set_broadcast(&h2, 1)); #if defined(__MVS__) /* zOS only supports setting ttl for IPv6 sockets. */ - ASSERT(UV_ENOTSUP == uv_udp_set_ttl(&h2, 1)); + ASSERT_EQ(UV_ENOTSUP, uv_udp_set_ttl(&h2, 1)); #else - ASSERT(0 == uv_udp_set_ttl(&h2, 1)); + ASSERT_OK(uv_udp_set_ttl(&h2, 1)); #endif - ASSERT(0 == uv_udp_set_multicast_loop(&h2, 1)); - ASSERT(0 == uv_udp_set_multicast_interface(&h2, "0.0.0.0")); + ASSERT_OK(uv_udp_set_multicast_loop(&h2, 1)); + ASSERT_OK(uv_udp_set_multicast_interface(&h2, "0.0.0.0")); uv_close((uv_handle_t*) &h2, NULL); - ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(loop, UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-udp-recv-in-a-row.c b/deps/libuv/test/test-udp-recv-in-a-row.c index 98aca28e..30745def 100644 --- a/deps/libuv/test/test-udp-recv-in-a-row.c +++ b/deps/libuv/test/test-udp-recv-in-a-row.c @@ -53,7 +53,7 @@ static void sv_recv_cb(uv_udp_t* handle, if (++ recv_cnt < N) { ASSERT_EQ(sizeof(send_data), nread); } else { - ASSERT_EQ(0, nread); + ASSERT_OK(nread); } } @@ -69,7 +69,7 @@ static void check_cb(uv_check_t* handle) { check_cb_called = 1; /* we are done */ - ASSERT_EQ(0, uv_check_stop(handle)); + ASSERT_OK(uv_check_stop(handle)); uv_close((uv_handle_t*) &client, NULL); uv_close((uv_handle_t*) &check_handle, NULL); uv_close((uv_handle_t*) &server, NULL); @@ -79,16 +79,16 @@ static void check_cb(uv_check_t* handle) { TEST_IMPL(udp_recv_in_a_row) { int i, r; - ASSERT_EQ(0, uv_check_init(uv_default_loop(), &check_handle)); - ASSERT_EQ(0, uv_check_start(&check_handle, check_cb)); + ASSERT_OK(uv_check_init(uv_default_loop(), &check_handle)); + ASSERT_OK(uv_check_start(&check_handle, check_cb)); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_udp_init(uv_default_loop(), &server)); - ASSERT_EQ(0, uv_udp_bind(&server, (const struct sockaddr*) &addr, 0)); - ASSERT_EQ(0, uv_udp_recv_start(&server, alloc_cb, sv_recv_cb)); + ASSERT_OK(uv_udp_init(uv_default_loop(), &server)); + ASSERT_OK(uv_udp_bind(&server, (const struct sockaddr*) &addr, 0)); + ASSERT_OK(uv_udp_recv_start(&server, alloc_cb, sv_recv_cb)); - ASSERT_EQ(0, uv_udp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_udp_init(uv_default_loop(), &client)); /* send N-1 udp packets */ buf = uv_buf_init(send_data, sizeof(send_data)); @@ -106,13 +106,13 @@ TEST_IMPL(udp_recv_in_a_row) { &buf, 1, (const struct sockaddr*) &addr); - ASSERT_EQ(0, r); + ASSERT_OK(r); /* check_cb() asserts that the N packets can be received * before it gets called. */ - ASSERT_EQ(0, uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT)); ASSERT(check_cb_called); diff --git a/deps/libuv/test/test-udp-send-and-recv.c b/deps/libuv/test/test-udp-send-and-recv.c index ab60e84a..b24fe1d0 100644 --- a/deps/libuv/test/test-udp-send-and-recv.c +++ b/deps/libuv/test/test-udp-send-and-recv.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -46,7 +46,7 @@ static void alloc_cb(uv_handle_t* handle, uv_buf_t* buf) { static char slab[65536]; CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -54,7 +54,7 @@ static void alloc_cb(uv_handle_t* handle, static void close_cb(uv_handle_t* handle) { CHECK_HANDLE(handle); - ASSERT(1 == uv_is_closing(handle)); + ASSERT_EQ(1, uv_is_closing(handle)); close_cb_called++; } @@ -65,7 +65,7 @@ static void cl_recv_cb(uv_udp_t* handle, const struct sockaddr* addr, unsigned flags) { CHECK_HANDLE(handle); - ASSERT(flags == 0); + ASSERT_OK(flags); if (nread < 0) { ASSERT(0 && "unexpected error"); @@ -78,7 +78,7 @@ static void cl_recv_cb(uv_udp_t* handle, } ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT(!memcmp("PONG", buf->base, nread)); cl_recv_cb_called++; @@ -91,11 +91,11 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { int r; ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); r = uv_udp_recv_start(req->handle, alloc_cb, cl_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); cl_send_cb_called++; } @@ -103,7 +103,7 @@ static void cl_send_cb(uv_udp_send_t* req, int status) { static void sv_send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); uv_close((uv_handle_t*) req->handle, close_cb); @@ -133,10 +133,10 @@ static void sv_recv_cb(uv_udp_t* handle, } CHECK_HANDLE(handle); - ASSERT(flags == 0); + ASSERT_OK(flags); ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT(!memcmp("PING", rcvbuf->base, nread)); /* FIXME? `uv_udp_recv_stop` does what it says: recv_cb is not called @@ -144,14 +144,14 @@ static void sv_recv_cb(uv_udp_t* handle, * either... Not sure I like that but it's consistent with `uv_read_stop`. */ r = uv_udp_recv_stop(handle); - ASSERT(r == 0); + ASSERT_OK(r); req = malloc(sizeof *req); ASSERT_NOT_NULL(req); sndbuf = uv_buf_init("PONG", 4); r = uv_udp_send(req, handle, &sndbuf, 1, addr, sv_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); sv_recv_cb_called++; } @@ -163,21 +163,21 @@ TEST_IMPL(udp_send_and_recv) { uv_buf_t buf; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); /* client sends "PING", expects "PONG" */ buf = uv_buf_init("PING", 4); @@ -188,24 +188,24 @@ TEST_IMPL(udp_send_and_recv) { 1, (const struct sockaddr*) &addr, cl_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(close_cb_called == 0); - ASSERT(cl_send_cb_called == 0); - ASSERT(cl_recv_cb_called == 0); - ASSERT(sv_send_cb_called == 0); - ASSERT(sv_recv_cb_called == 0); + ASSERT_OK(close_cb_called); + ASSERT_OK(cl_send_cb_called); + ASSERT_OK(cl_recv_cb_called); + ASSERT_OK(sv_send_cb_called); + ASSERT_OK(sv_recv_cb_called); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(cl_send_cb_called == 1); - ASSERT(cl_recv_cb_called == 1); - ASSERT(sv_send_cb_called == 1); - ASSERT(sv_recv_cb_called == 1); - ASSERT(close_cb_called == 2); + ASSERT_EQ(1, cl_send_cb_called); + ASSERT_EQ(1, cl_recv_cb_called); + ASSERT_EQ(1, sv_send_cb_called); + ASSERT_EQ(1, sv_recv_cb_called); + ASSERT_EQ(2, close_cb_called); - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); + ASSERT_OK(client.send_queue_size); + ASSERT_OK(server.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-send-hang-loop.c b/deps/libuv/test/test-udp-send-hang-loop.c index b1e02263..763bb28b 100644 --- a/deps/libuv/test/test-udp-send-hang-loop.c +++ b/deps/libuv/test/test-udp-send-hang-loop.c @@ -27,7 +27,7 @@ #include #define CHECK_OBJECT(handle, type, parent) \ - ASSERT((type*)(handle) == &(parent)) + ASSERT_PTR_EQ((type*)(handle), &(parent)) static uv_udp_t client; static uv_idle_t idle_handle; @@ -46,7 +46,7 @@ static void idle_cb(uv_idle_t* handle) { ASSERT_NULL(send_req.handle); CHECK_OBJECT(handle, uv_idle_t, idle_handle); - ASSERT(0 == uv_idle_stop(handle)); + ASSERT_OK(uv_idle_stop(handle)); /* It probably would have stalled by now if it's going to stall at all. */ if (++loop_hang_called > 1000) { @@ -61,7 +61,7 @@ static void idle_cb(uv_idle_t* handle) { 1, (const struct sockaddr*) &addr, send_cb); - ASSERT(r == 0); + ASSERT_OK(r); } @@ -72,27 +72,27 @@ static void send_cb(uv_udp_send_t* req, int status) { CHECK_OBJECT(req, uv_udp_send_t, send_req); req->handle = NULL; - ASSERT(0 == uv_idle_start(&idle_handle, idle_cb)); + ASSERT_OK(uv_idle_start(&idle_handle, idle_cb)); } TEST_IMPL(udp_send_hang_loop) { - ASSERT(0 == uv_idle_init(uv_default_loop(), &idle_handle)); + ASSERT_OK(uv_idle_init(uv_default_loop(), &idle_handle)); - /* 192.0.2.0/8 is "TEST-NET" and reserved for documentation. + /* 192.0.2.0/24 is "TEST-NET" and reserved for documentation. * Good for us, though. Since we want to have something unreachable. */ - ASSERT(0 == uv_ip4_addr("192.0.2.3", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("192.0.2.3", TEST_PORT, &addr)); - ASSERT(0 == uv_udp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_udp_init(uv_default_loop(), &client)); buf = uv_buf_init(send_data, sizeof(send_data)); - ASSERT(0 == uv_idle_start(&idle_handle, idle_cb)); + ASSERT_OK(uv_idle_start(&idle_handle, idle_cb)); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(loop_hang_called > 1000); + ASSERT_GT(loop_hang_called, 1000); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-send-immediate.c b/deps/libuv/test/test-udp-send-immediate.c index ee70a616..8e7f83ff 100644 --- a/deps/libuv/test/test-udp-send-immediate.c +++ b/deps/libuv/test/test-udp-send-immediate.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -42,7 +42,7 @@ static void alloc_cb(uv_handle_t* handle, uv_buf_t* buf) { static char slab[65536]; CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -50,14 +50,14 @@ static void alloc_cb(uv_handle_t* handle, static void close_cb(uv_handle_t* handle) { CHECK_HANDLE(handle); - ASSERT(1 == uv_is_closing(handle)); + ASSERT_EQ(1, uv_is_closing(handle)); close_cb_called++; } static void cl_send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); + ASSERT_OK(status); CHECK_HANDLE(req->handle); cl_send_cb_called++; @@ -80,10 +80,10 @@ static void sv_recv_cb(uv_udp_t* handle, } CHECK_HANDLE(handle); - ASSERT(flags == 0); + ASSERT_OK(flags); ASSERT_NOT_NULL(addr); - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT(memcmp("PING", rcvbuf->base, nread) == 0 || memcmp("PANG", rcvbuf->base, nread) == 0); @@ -100,21 +100,21 @@ TEST_IMPL(udp_send_immediate) { uv_buf_t buf; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); /* client sends "PING", then "PANG" */ buf = uv_buf_init("PING", 4); @@ -125,7 +125,7 @@ TEST_IMPL(udp_send_immediate) { 1, (const struct sockaddr*) &addr, cl_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init("PANG", 4); @@ -135,13 +135,13 @@ TEST_IMPL(udp_send_immediate) { 1, (const struct sockaddr*) &addr, cl_send_cb); - ASSERT(r == 0); + ASSERT_OK(r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(cl_send_cb_called == 2); - ASSERT(sv_recv_cb_called == 2); - ASSERT(close_cb_called == 2); + ASSERT_EQ(2, cl_send_cb_called); + ASSERT_EQ(2, sv_recv_cb_called); + ASSERT_EQ(2, close_cb_called); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-send-unreachable.c b/deps/libuv/test/test-udp-send-unreachable.c index 7075deb1..0a2f4a47 100644 --- a/deps/libuv/test/test-udp-send-unreachable.c +++ b/deps/libuv/test/test-udp-send-unreachable.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &client || (uv_udp_t*)(handle) == &client2) + ASSERT_NE((uv_udp_t*)(handle) == &client || (uv_udp_t*)(handle) == &client2, 0) static uv_udp_t client; static uv_udp_t client2; @@ -61,8 +61,8 @@ static void close_cb(uv_handle_t* handle) { static void send_cb(uv_udp_send_t* req, int status) { ASSERT_NOT_NULL(req); - ASSERT(status == 0); - ASSERT_EQ(status, 0); + ASSERT_OK(status); + ASSERT_OK(status); CHECK_HANDLE(req->handle); send_cb_called++; } @@ -115,24 +115,24 @@ TEST_IMPL(udp_send_unreachable) { can_recverr = 1; #endif - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT_2, &addr2)); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT_3, &addr3)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT_2, &addr2)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT_3, &addr3)); r = uv_timer_init( uv_default_loop(), &timer ); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_timer_start( &timer, timer_cb, 1000, 0 ); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_init(uv_default_loop(), &client); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_bind(&client, (const struct sockaddr*) &addr2, 0); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_recv_start(&client, alloc_cb, recv_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* client sends "PING", then "PANG" */ buf = uv_buf_init("PING", 4); @@ -143,7 +143,7 @@ TEST_IMPL(udp_send_unreachable) { 1, (const struct sockaddr*) &addr, send_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); buf = uv_buf_init("PANG", 4); @@ -153,19 +153,19 @@ TEST_IMPL(udp_send_unreachable) { 1, (const struct sockaddr*) &addr, send_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); if (can_recverr) { r = uv_udp_init(uv_default_loop(), &client2); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_bind(&client2, (const struct sockaddr*) &addr3, UV_UDP_LINUX_RECVERR); - ASSERT_EQ(r, 0); + ASSERT_OK(r); r = uv_udp_recv_start(&client2, alloc_cb, recv_cb); - ASSERT_EQ(r, 0); + ASSERT_OK(r); /* client sends "PING", then "PANG" */ buf = uv_buf_init("PING", 4); @@ -176,7 +176,7 @@ TEST_IMPL(udp_send_unreachable) { 1, (const struct sockaddr*) &addr, send_cb_recverr); - ASSERT_EQ(r, 0); + ASSERT_OK(r); buf = uv_buf_init("PANG", 4); @@ -186,14 +186,14 @@ TEST_IMPL(udp_send_unreachable) { 1, (const struct sockaddr*) &addr, send_cb_recverr); - ASSERT_EQ(r, 0); + ASSERT_OK(r); } uv_run(uv_default_loop(), UV_RUN_DEFAULT); ASSERT_EQ(send_cb_called, (long)(can_recverr ? 4 : 2)); ASSERT_EQ(recv_cb_called, alloc_cb_called); - ASSERT_EQ(timer_cb_called, 1); + ASSERT_EQ(1, timer_cb_called); ASSERT_EQ(close_cb_called, (long)(can_recverr ? 3 : 2)); MAKE_VALGRIND_HAPPY(uv_default_loop()); diff --git a/deps/libuv/test/test-udp-sendmmsg-error.c b/deps/libuv/test/test-udp-sendmmsg-error.c index 7b1741a3..0b647585 100644 --- a/deps/libuv/test/test-udp-sendmmsg-error.c +++ b/deps/libuv/test/test-udp-sendmmsg-error.c @@ -55,20 +55,20 @@ TEST_IMPL(udp_sendmmsg_error) { uv_buf_t buf; int i; - ASSERT_EQ(0, uv_udp_init(uv_default_loop(), &client)); - ASSERT_EQ(0, uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - ASSERT_EQ(0, uv_udp_connect(&client, (const struct sockaddr*)&addr)); + ASSERT_OK(uv_udp_init(uv_default_loop(), &client)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_udp_connect(&client, (const struct sockaddr*)&addr)); buf = uv_buf_init("TEST", 4); for (i = 0; i < DATAGRAMS; ++i) - ASSERT_EQ(0, uv_udp_send(&req[i], &client, &buf, 1, NULL, send_cb)); + ASSERT_OK(uv_udp_send(&req[i], &client, &buf, 1, NULL, send_cb)); uv_run(uv_default_loop(), UV_RUN_DEFAULT); ASSERT_EQ(1, close_cb_called); ASSERT_EQ(DATAGRAMS, send_cb_called); - ASSERT_EQ(0, client.send_queue_size); + ASSERT_OK(client.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-udp-try-send.c b/deps/libuv/test/test-udp-try-send.c index b81506cc..0c76fb1c 100644 --- a/deps/libuv/test/test-udp-try-send.c +++ b/deps/libuv/test/test-udp-try-send.c @@ -27,7 +27,7 @@ #include #define CHECK_HANDLE(handle) \ - ASSERT((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client) + ASSERT_NE((uv_udp_t*)(handle) == &server || (uv_udp_t*)(handle) == &client, 0) static uv_udp_t server; static uv_udp_t client; @@ -42,7 +42,7 @@ static void alloc_cb(uv_handle_t* handle, uv_buf_t* buf) { static char slab[65536]; CHECK_HANDLE(handle); - ASSERT(suggested_size <= sizeof(slab)); + ASSERT_LE(suggested_size, sizeof(slab)); buf->base = slab; buf->len = sizeof(slab); } @@ -60,17 +60,17 @@ static void sv_recv_cb(uv_udp_t* handle, const uv_buf_t* rcvbuf, const struct sockaddr* addr, unsigned flags) { - ASSERT(nread > 0); + ASSERT_GT(nread, 0); if (nread == 0) { ASSERT_NULL(addr); return; } - ASSERT(nread == 4); + ASSERT_EQ(4, nread); ASSERT_NOT_NULL(addr); - ASSERT(memcmp("EXIT", rcvbuf->base, nread) == 0); + ASSERT_OK(memcmp("EXIT", rcvbuf->base, nread)); uv_close((uv_handle_t*) handle, close_cb); uv_close((uv_handle_t*) &client, close_cb); @@ -84,37 +84,37 @@ TEST_IMPL(udp_try_send) { uv_buf_t buf; int r; - ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &server); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_bind(&server, (const struct sockaddr*) &addr, 0); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb); - ASSERT(r == 0); + ASSERT_OK(r); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init(uv_default_loop(), &client); - ASSERT(r == 0); + ASSERT_OK(r); buf = uv_buf_init(buffer, sizeof(buffer)); r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &addr); - ASSERT(r == UV_EMSGSIZE); + ASSERT_EQ(r, UV_EMSGSIZE); buf = uv_buf_init("EXIT", 4); r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &addr); - ASSERT(r == 4); + ASSERT_EQ(4, r); uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(close_cb_called == 2); - ASSERT(sv_recv_cb_called == 1); + ASSERT_EQ(2, close_cb_called); + ASSERT_EQ(1, sv_recv_cb_called); - ASSERT(client.send_queue_size == 0); - ASSERT(server.send_queue_size == 0); + ASSERT_OK(client.send_queue_size); + ASSERT_OK(server.send_queue_size); MAKE_VALGRIND_HAPPY(uv_default_loop()); return 0; diff --git a/deps/libuv/test/test-uname.c b/deps/libuv/test/test-uname.c index 105a17fe..a384e9f8 100644 --- a/deps/libuv/test/test-uname.c +++ b/deps/libuv/test/test-uname.c @@ -39,28 +39,28 @@ TEST_IMPL(uname) { /* Verify that NULL is handled properly. */ r = uv_os_uname(NULL); - ASSERT(r == UV_EINVAL); + ASSERT_EQ(r, UV_EINVAL); /* Verify the happy path. */ r = uv_os_uname(&buffer); - ASSERT(r == 0); + ASSERT_OK(r); #ifndef _WIN32 - ASSERT(uname(&buf) != -1); - ASSERT(strcmp(buffer.sysname, buf.sysname) == 0); - ASSERT(strcmp(buffer.version, buf.version) == 0); + ASSERT_NE(uname(&buf), -1); + ASSERT_OK(strcmp(buffer.sysname, buf.sysname)); + ASSERT_OK(strcmp(buffer.version, buf.version)); # ifdef _AIX snprintf(temp, sizeof(temp), "%s.%s", buf.version, buf.release); - ASSERT(strcmp(buffer.release, temp) == 0); + ASSERT_OK(strcmp(buffer.release, temp)); # else - ASSERT(strcmp(buffer.release, buf.release) == 0); + ASSERT_OK(strcmp(buffer.release, buf.release)); # endif /* _AIX */ # if defined(_AIX) || defined(__PASE__) - ASSERT(strcmp(buffer.machine, "ppc64") == 0); + ASSERT_OK(strcmp(buffer.machine, "ppc64")); # else - ASSERT(strcmp(buffer.machine, buf.machine) == 0); + ASSERT_OK(strcmp(buffer.machine, buf.machine)); # endif /* defined(_AIX) || defined(__PASE__) */ #endif /* _WIN32 */ diff --git a/deps/libuv/test/test-walk-handles.c b/deps/libuv/test/test-walk-handles.c index 50f0ce84..86fcb049 100644 --- a/deps/libuv/test/test-walk-handles.c +++ b/deps/libuv/test/test-walk-handles.c @@ -31,7 +31,7 @@ static uv_timer_t timer; static void walk_cb(uv_handle_t* handle, void* arg) { - ASSERT(arg == (void*)magic_cookie); + ASSERT_PTR_EQ(arg, (void*)magic_cookie); if (handle == (uv_handle_t*)&timer) { seen_timer_handle++; @@ -42,7 +42,7 @@ static void walk_cb(uv_handle_t* handle, void* arg) { static void timer_cb(uv_timer_t* handle) { - ASSERT(handle == &timer); + ASSERT_PTR_EQ(handle, &timer); uv_walk(handle->loop, walk_cb, magic_cookie); uv_close((uv_handle_t*)handle, NULL); @@ -56,21 +56,21 @@ TEST_IMPL(walk_handles) { loop = uv_default_loop(); r = uv_timer_init(loop, &timer); - ASSERT(r == 0); + ASSERT_OK(r); r = uv_timer_start(&timer, timer_cb, 1, 0); - ASSERT(r == 0); + ASSERT_OK(r); /* Start event loop, expect to see the timer handle in walk_cb. */ - ASSERT(seen_timer_handle == 0); + ASSERT_OK(seen_timer_handle); r = uv_run(loop, UV_RUN_DEFAULT); - ASSERT(r == 0); - ASSERT(seen_timer_handle == 1); + ASSERT_OK(r); + ASSERT_EQ(1, seen_timer_handle); /* Loop is finished, walk_cb should not see our timer handle. */ seen_timer_handle = 0; uv_walk(loop, walk_cb, magic_cookie); - ASSERT(seen_timer_handle == 0); + ASSERT_OK(seen_timer_handle); MAKE_VALGRIND_HAPPY(loop); return 0; diff --git a/deps/libuv/test/test-watcher-cross-stop.c b/deps/libuv/test/test-watcher-cross-stop.c index bbc0c305..8f79abb7 100644 --- a/deps/libuv/test/test-watcher-cross-stop.c +++ b/deps/libuv/test/test-watcher-cross-stop.c @@ -76,22 +76,22 @@ TEST_IMPL(watcher_cross_stop) { TEST_FILE_LIMIT(ARRAY_SIZE(sockets) + 32); - ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); + ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); memset(big_string, 'A', sizeof(big_string)); buf = uv_buf_init(big_string, sizeof(big_string)); for (i = 0; i < ARRAY_SIZE(sockets); i++) { - ASSERT(0 == uv_udp_init(loop, &sockets[i])); - ASSERT(0 == uv_udp_bind(&sockets[i], - (const struct sockaddr*) &addr, - UV_UDP_REUSEADDR)); - ASSERT(0 == uv_udp_recv_start(&sockets[i], alloc_cb, recv_cb)); - ASSERT(0 == uv_udp_send(&reqs[i], - &sockets[i], - &buf, - 1, - (const struct sockaddr*) &addr, - send_cb)); + ASSERT_OK(uv_udp_init(loop, &sockets[i])); + ASSERT_OK(uv_udp_bind(&sockets[i], + (const struct sockaddr*) &addr, + UV_UDP_REUSEADDR)); + ASSERT_OK(uv_udp_recv_start(&sockets[i], alloc_cb, recv_cb)); + ASSERT_OK(uv_udp_send(&reqs[i], + &sockets[i], + &buf, + 1, + (const struct sockaddr*) &addr, + send_cb)); } while (recv_cb_called == 0) @@ -100,12 +100,12 @@ TEST_IMPL(watcher_cross_stop) { for (i = 0; i < ARRAY_SIZE(sockets); i++) uv_close((uv_handle_t*) &sockets[i], close_cb); - ASSERT(recv_cb_called > 0); + ASSERT_GT(recv_cb_called, 0); uv_run(loop, UV_RUN_DEFAULT); - ASSERT(ARRAY_SIZE(sockets) == send_cb_called); - ASSERT(ARRAY_SIZE(sockets) == close_cb_called); + ASSERT_EQ(ARRAY_SIZE(sockets), send_cb_called); + ASSERT_EQ(ARRAY_SIZE(sockets), close_cb_called); MAKE_VALGRIND_HAPPY(loop); return 0;