From fdf7c2ad1ddcd915cc9d8786b412f82427a6b12e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 23 Jan 2018 20:39:04 +0100 Subject: [PATCH] build: split off tests into separate gyp file Make it easier for Node.js to ship libuv in its tarballs without also including the test suite. Node.js already does so but recent changes to its build system complicate that. Kills two birds with one stone: it helps out Node.js and it makes it harder for us to introduce hidden dependencies between the library and the test suite. PR-URL: https://github.com/libuv/libuv/pull/1725 Refs: https://github.com/nodejs/node/pull/18287 Reviewed-By: Colin Ihrig --- gyp_uv.py | 2 +- test/test.gyp | 279 +++++++++++++++++++++++++++++++++++++++ uv.gyp | 357 +++++++------------------------------------------- vcbuild.bat | 7 +- 4 files changed, 331 insertions(+), 314 deletions(-) create mode 100644 test/test.gyp diff --git a/gyp_uv.py b/gyp_uv.py index e5759cdd30b..c2add5caecc 100755 --- a/gyp_uv.py +++ b/gyp_uv.py @@ -43,7 +43,7 @@ def run_gyp(args): if __name__ == '__main__': args = sys.argv[1:] - args.extend('-I common.gypi uv.gyp'.split(' ')) + args.extend('-I common.gypi test/test.gyp'.split(' ')) args.append('--depth=' + uv_root) # There's a bug with windows which doesn't allow this feature. diff --git a/test/test.gyp b/test/test.gyp new file mode 100644 index 00000000000..480e5a26c41 --- /dev/null +++ b/test/test.gyp @@ -0,0 +1,279 @@ +{ + 'targets': [ + { + 'target_name': 'run-tests', + 'type': 'executable', + 'dependencies': [ '../uv.gyp:libuv' ], + 'sources': [ + 'blackhole-server.c', + 'echo-server.c', + 'run-tests.c', + 'runner.c', + 'runner.h', + 'test-get-loadavg.c', + 'task.h', + 'test-active.c', + 'test-async.c', + 'test-async-null-cb.c', + 'test-callback-stack.c', + 'test-callback-order.c', + 'test-close-fd.c', + 'test-close-order.c', + 'test-connect-unspecified.c', + 'test-connection-fail.c', + 'test-cwd-and-chdir.c', + 'test-default-loop-close.c', + 'test-delayed-accept.c', + 'test-eintr-handling.c', + 'test-error.c', + 'test-embed.c', + 'test-emfile.c', + 'test-env-vars.c', + 'test-fail-always.c', + 'test-fork.c', + 'test-fs.c', + 'test-fs-copyfile.c', + 'test-fs-event.c', + 'test-getters-setters.c', + 'test-get-currentexe.c', + 'test-get-memory.c', + 'test-get-passwd.c', + 'test-getaddrinfo.c', + 'test-gethostname.c', + 'test-getnameinfo.c', + 'test-getsockname.c', + 'test-handle-fileno.c', + 'test-homedir.c', + 'test-hrtime.c', + 'test-idle.c', + 'test-ip6-addr.c', + 'test-ipc.c', + 'test-ipc-send-recv.c', + 'test-list.h', + 'test-loop-handles.c', + 'test-loop-alive.c', + 'test-loop-close.c', + 'test-loop-stop.c', + 'test-loop-time.c', + 'test-loop-configure.c', + 'test-walk-handles.c', + 'test-watcher-cross-stop.c', + 'test-multiple-listen.c', + 'test-osx-select.c', + 'test-pass-always.c', + 'test-ping-pong.c', + 'test-pipe-bind-error.c', + 'test-pipe-connect-error.c', + 'test-pipe-connect-multiple.c', + 'test-pipe-connect-prepare.c', + 'test-pipe-getsockname.c', + 'test-pipe-pending-instances.c', + 'test-pipe-sendmsg.c', + 'test-pipe-server-close.c', + 'test-pipe-close-stdout-read-stdin.c', + 'test-pipe-set-non-blocking.c', + 'test-pipe-set-fchmod.c', + 'test-platform-output.c', + 'test-poll.c', + 'test-poll-close.c', + 'test-poll-close-doesnt-corrupt-stack.c', + 'test-poll-closesocket.c', + 'test-poll-oob.c', + 'test-process-title.c', + 'test-process-title-threadsafe.c', + 'test-queue-foreach-delete.c', + 'test-ref.c', + 'test-run-nowait.c', + 'test-run-once.c', + 'test-semaphore.c', + 'test-shutdown-close.c', + 'test-shutdown-eof.c', + 'test-shutdown-twice.c', + 'test-signal.c', + 'test-signal-multiple-loops.c', + 'test-socket-buffer-size.c', + 'test-spawn.c', + 'test-fs-poll.c', + 'test-stdio-over-pipes.c', + 'test-tcp-alloc-cb-fail.c', + 'test-tcp-bind-error.c', + 'test-tcp-bind6-error.c', + 'test-tcp-close.c', + 'test-tcp-close-accept.c', + 'test-tcp-close-while-connecting.c', + 'test-tcp-create-socket-early.c', + 'test-tcp-connect-error-after-write.c', + 'test-tcp-shutdown-after-write.c', + 'test-tcp-flags.c', + 'test-tcp-connect-error.c', + 'test-tcp-connect-timeout.c', + 'test-tcp-connect6-error.c', + 'test-tcp-open.c', + 'test-tcp-write-to-half-open-connection.c', + 'test-tcp-write-after-connect.c', + 'test-tcp-writealot.c', + 'test-tcp-write-fail.c', + 'test-tcp-try-write.c', + 'test-tcp-unexpected-read.c', + 'test-tcp-oob.c', + 'test-tcp-read-stop.c', + 'test-tcp-write-queue-order.c', + 'test-threadpool.c', + 'test-threadpool-cancel.c', + 'test-thread-equal.c', + 'test-tmpdir.c', + 'test-mutexes.c', + 'test-thread.c', + 'test-barrier.c', + 'test-condvar.c', + 'test-timer-again.c', + 'test-timer-from-check.c', + 'test-timer.c', + 'test-tty.c', + 'test-udp-alloc-cb-fail.c', + 'test-udp-bind.c', + 'test-udp-create-socket-early.c', + 'test-udp-dgram-too-big.c', + 'test-udp-ipv6.c', + 'test-udp-open.c', + 'test-udp-options.c', + 'test-udp-send-and-recv.c', + 'test-udp-send-hang-loop.c', + 'test-udp-send-immediate.c', + 'test-udp-send-unreachable.c', + 'test-udp-multicast-join.c', + 'test-udp-multicast-join6.c', + 'test-dlerror.c', + 'test-udp-multicast-ttl.c', + 'test-ip4-addr.c', + 'test-ip6-addr.c', + 'test-udp-multicast-interface.c', + 'test-udp-multicast-interface6.c', + 'test-udp-try-send.c', + ], + 'conditions': [ + [ 'OS=="win"', { + 'sources': [ + 'runner-win.c', + 'runner-win.h', + '../src/win/snprintf.c', + ], + 'libraries': [ '-lws2_32' ] + }, { # POSIX + 'sources': [ + 'runner-unix.c', + 'runner-unix.h', + ], + 'conditions': [ + [ 'OS != "zos"', { + 'defines': [ '_GNU_SOURCE' ], + 'cflags': [ '-Wno-long-long' ], + 'xcode_settings': { + 'WARNING_CFLAGS': [ '-Wno-long-long' ] + } + }], + ]}, + ], + [ 'OS in "mac dragonflybsd freebsd linux netbsd openbsd".split()', { + 'link_settings': { + 'libraries': [ '-lutil' ], + }, + }], + [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE + 'defines': [ + '__EXTENSIONS__', + '_XOPEN_SOURCE=500', + ], + }], + [ 'OS=="aix"', { # make test-fs.c compile, needs _POSIX_C_SOURCE + 'defines': [ + '_ALL_SOURCE', + '_XOPEN_SOURCE=500', + ], + }], + [ 'OS == "zos"', { + 'cflags': [ '-qxplink' ], + 'ldflags': [ '-qxplink' ], + }], + ['uv_library=="shared_library"', { + 'defines': [ 'USING_UV_SHARED=1' ], + 'conditions': [ + [ 'OS == "zos"', { + 'cflags': [ '-Wc,DLL' ], + }], + ], + }], + ], + 'msvs-settings': { + 'VCLinkerTool': { + 'SubSystem': 1, # /subsystem:console + }, + }, + }, + + { + 'target_name': 'run-benchmarks', + 'type': 'executable', + 'dependencies': [ '../uv.gyp:libuv' ], + 'sources': [ + 'benchmark-async.c', + 'benchmark-async-pummel.c', + 'benchmark-fs-stat.c', + 'benchmark-getaddrinfo.c', + 'benchmark-list.h', + 'benchmark-loop-count.c', + 'benchmark-million-async.c', + 'benchmark-million-timers.c', + 'benchmark-multi-accept.c', + 'benchmark-ping-pongs.c', + 'benchmark-pound.c', + 'benchmark-pump.c', + 'benchmark-sizes.c', + 'benchmark-spawn.c', + 'benchmark-thread.c', + 'benchmark-tcp-write-batch.c', + 'benchmark-udp-pummel.c', + 'dns-server.c', + 'echo-server.c', + 'blackhole-server.c', + 'run-benchmarks.c', + 'runner.c', + 'runner.h', + 'task.h', + ], + 'conditions': [ + [ 'OS=="win"', { + 'sources': [ + 'runner-win.c', + 'runner-win.h', + '../src/win/snprintf.c', + ], + 'libraries': [ '-lws2_32' ] + }, { # POSIX + 'defines': [ '_GNU_SOURCE' ], + 'sources': [ + 'runner-unix.c', + 'runner-unix.h', + ] + }], + [ 'OS == "zos"', { + 'cflags': [ '-qxplink' ], + 'ldflags': [ '-qxplink' ], + }], + ['uv_library=="shared_library"', { + 'defines': [ 'USING_UV_SHARED=1' ], + 'conditions': [ + [ 'OS == "zos"', { + 'cflags': [ '-Wc,DLL' ], + }], + ], + }], + ], + 'msvs-settings': { + 'VCLinkerTool': { + 'SubSystem': 1, # /subsystem:console + }, + }, + }, + ], +} diff --git a/uv.gyp b/uv.gyp index 46606c5bda8..a5046b87ea5 100644 --- a/uv.gyp +++ b/uv.gyp @@ -1,44 +1,38 @@ { - 'target_defaults': { + 'variables': { 'conditions': [ - ['OS != "win"', { - 'defines': [ + ['OS=="win"', { + 'shared_unix_defines': [ '_LARGEFILE_SOURCE', '_FILE_OFFSET_BITS=64', ], - 'conditions': [ - ['OS=="solaris"', { - 'cflags': [ '-pthreads' ], - }], - ['OS not in "solaris android zos"', { - 'cflags': [ '-pthread' ], - }], - ['OS in "zos"', { - 'defines': [ - '_UNIX03_THREADS', - '_UNIX03_SOURCE', - '_UNIX03_WITHDRAWN', - '_OPEN_SYS_IF_EXT', - '_OPEN_SYS_SOCK_IPV6', - '_OPEN_MSGQ_EXT', - '_XOPEN_SOURCE_EXTENDED', - '_ALL_SOURCE', - '_LARGE_TIME_API', - '_OPEN_SYS_FILE_EXT', - '_AE_BIMODAL', - 'PATH_MAX=255' - ], - 'cflags': [ '-qxplink' ], - 'ldflags': [ '-qxplink' ], - }] + }, { + 'shared_unix_defines': [ ], + }], + ['OS in "mac ios"', { + 'shared_mac_defines': [ '_DARWIN_USE_64_BIT_INODE=1' ], + }, { + 'shared_mac_defines': [ ], + }], + ['OS=="zos"', { + 'shared_zos_defines': [ + '_UNIX03_THREADS', + '_UNIX03_SOURCE', + '_UNIX03_WITHDRAWN', + '_OPEN_SYS_IF_EXT', + '_OPEN_SYS_SOCK_IPV6', + '_OPEN_MSGQ_EXT', + '_XOPEN_SOURCE_EXTENDED', + '_ALL_SOURCE', + '_LARGE_TIME_API', + '_OPEN_SYS_FILE_EXT', + '_AE_BIMODAL', + 'PATH_MAX=255' ], + }, { + 'shared_zos_defines': [ ], }], ], - 'xcode_settings': { - 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden - 'WARNING_CFLAGS': [ '-Wall', '-Wextra', '-Wno-unused-parameter', '-Wstrict-prototypes' ], - 'OTHER_CFLAGS': [ '-g', '--std=gnu89', '-pedantic' ], - } }, 'targets': [ @@ -49,18 +43,19 @@ 'include', 'src/', ], + 'defines': [ + '<@(shared_mac_defines)', + '<@(shared_unix_defines)', + '<@(shared_zos_defines)', + ], 'direct_dependent_settings': { + 'defines': [ + '<@(shared_mac_defines)', + '<@(shared_unix_defines)', + '<@(shared_zos_defines)', + ], 'include_dirs': [ 'include' ], 'conditions': [ - ['OS != "win"', { - 'defines': [ - '_LARGEFILE_SOURCE', - '_FILE_OFFSET_BITS=64', - ], - }], - ['OS in "mac ios"', { - 'defines': [ '_DARWIN_USE_64_BIT_INODE=1' ], - }], ['OS == "linux"', { 'defines': [ '_POSIX_C_SOURCE=200112' ], }], @@ -83,6 +78,16 @@ 'src/uv-common.h', 'src/version.c' ], + 'xcode_settings': { + 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden + 'WARNING_CFLAGS': [ + '-Wall', + '-Wextra', + '-Wno-unused-parameter', + '-Wstrict-prototypes', + ], + 'OTHER_CFLAGS': [ '-g', '--std=gnu89', '-pedantic' ], + }, 'conditions': [ [ 'OS=="win"', { 'defines': [ @@ -346,273 +351,5 @@ }], ] }, - - { - 'target_name': 'run-tests', - 'type': 'executable', - 'dependencies': [ 'libuv' ], - 'sources': [ - 'test/blackhole-server.c', - 'test/echo-server.c', - 'test/run-tests.c', - 'test/runner.c', - 'test/runner.h', - 'test/test-get-loadavg.c', - 'test/task.h', - 'test/test-active.c', - 'test/test-async.c', - 'test/test-async-null-cb.c', - 'test/test-callback-stack.c', - 'test/test-callback-order.c', - 'test/test-close-fd.c', - 'test/test-close-order.c', - 'test/test-connect-unspecified.c', - 'test/test-connection-fail.c', - 'test/test-cwd-and-chdir.c', - 'test/test-default-loop-close.c', - 'test/test-delayed-accept.c', - 'test/test-eintr-handling.c', - 'test/test-error.c', - 'test/test-embed.c', - 'test/test-emfile.c', - 'test/test-env-vars.c', - 'test/test-fail-always.c', - 'test/test-fork.c', - 'test/test-fs.c', - 'test/test-fs-copyfile.c', - 'test/test-fs-event.c', - 'test/test-getters-setters.c', - 'test/test-get-currentexe.c', - 'test/test-get-memory.c', - 'test/test-get-passwd.c', - 'test/test-getaddrinfo.c', - 'test/test-gethostname.c', - 'test/test-getnameinfo.c', - 'test/test-getsockname.c', - 'test/test-handle-fileno.c', - 'test/test-homedir.c', - 'test/test-hrtime.c', - 'test/test-idle.c', - 'test/test-ip6-addr.c', - 'test/test-ipc.c', - 'test/test-ipc-send-recv.c', - 'test/test-list.h', - 'test/test-loop-handles.c', - 'test/test-loop-alive.c', - 'test/test-loop-close.c', - 'test/test-loop-stop.c', - 'test/test-loop-time.c', - 'test/test-loop-configure.c', - 'test/test-walk-handles.c', - 'test/test-watcher-cross-stop.c', - 'test/test-multiple-listen.c', - 'test/test-osx-select.c', - 'test/test-pass-always.c', - 'test/test-ping-pong.c', - 'test/test-pipe-bind-error.c', - 'test/test-pipe-connect-error.c', - 'test/test-pipe-connect-multiple.c', - 'test/test-pipe-connect-prepare.c', - 'test/test-pipe-getsockname.c', - 'test/test-pipe-pending-instances.c', - 'test/test-pipe-sendmsg.c', - 'test/test-pipe-server-close.c', - 'test/test-pipe-close-stdout-read-stdin.c', - 'test/test-pipe-set-non-blocking.c', - 'test/test-pipe-set-fchmod.c', - 'test/test-platform-output.c', - 'test/test-poll.c', - 'test/test-poll-close.c', - 'test/test-poll-close-doesnt-corrupt-stack.c', - 'test/test-poll-closesocket.c', - 'test/test-poll-oob.c', - 'test/test-process-title.c', - 'test/test-process-title-threadsafe.c', - 'test/test-queue-foreach-delete.c', - 'test/test-ref.c', - 'test/test-run-nowait.c', - 'test/test-run-once.c', - 'test/test-semaphore.c', - 'test/test-shutdown-close.c', - 'test/test-shutdown-eof.c', - 'test/test-shutdown-twice.c', - 'test/test-signal.c', - 'test/test-signal-multiple-loops.c', - 'test/test-socket-buffer-size.c', - 'test/test-spawn.c', - 'test/test-fs-poll.c', - 'test/test-stdio-over-pipes.c', - 'test/test-tcp-alloc-cb-fail.c', - 'test/test-tcp-bind-error.c', - 'test/test-tcp-bind6-error.c', - 'test/test-tcp-close.c', - 'test/test-tcp-close-accept.c', - 'test/test-tcp-close-while-connecting.c', - 'test/test-tcp-create-socket-early.c', - 'test/test-tcp-connect-error-after-write.c', - 'test/test-tcp-shutdown-after-write.c', - 'test/test-tcp-flags.c', - 'test/test-tcp-connect-error.c', - 'test/test-tcp-connect-timeout.c', - 'test/test-tcp-connect6-error.c', - 'test/test-tcp-open.c', - 'test/test-tcp-write-to-half-open-connection.c', - 'test/test-tcp-write-after-connect.c', - 'test/test-tcp-writealot.c', - 'test/test-tcp-write-fail.c', - 'test/test-tcp-try-write.c', - 'test/test-tcp-unexpected-read.c', - 'test/test-tcp-oob.c', - 'test/test-tcp-read-stop.c', - 'test/test-tcp-write-queue-order.c', - 'test/test-threadpool.c', - 'test/test-threadpool-cancel.c', - 'test/test-thread-equal.c', - 'test/test-tmpdir.c', - 'test/test-mutexes.c', - 'test/test-thread.c', - 'test/test-barrier.c', - 'test/test-condvar.c', - 'test/test-timer-again.c', - 'test/test-timer-from-check.c', - 'test/test-timer.c', - 'test/test-tty.c', - 'test/test-udp-alloc-cb-fail.c', - 'test/test-udp-bind.c', - 'test/test-udp-create-socket-early.c', - 'test/test-udp-dgram-too-big.c', - 'test/test-udp-ipv6.c', - 'test/test-udp-open.c', - 'test/test-udp-options.c', - 'test/test-udp-send-and-recv.c', - 'test/test-udp-send-hang-loop.c', - 'test/test-udp-send-immediate.c', - 'test/test-udp-send-unreachable.c', - 'test/test-udp-multicast-join.c', - 'test/test-udp-multicast-join6.c', - 'test/test-dlerror.c', - 'test/test-udp-multicast-ttl.c', - 'test/test-ip4-addr.c', - 'test/test-ip6-addr.c', - 'test/test-udp-multicast-interface.c', - 'test/test-udp-multicast-interface6.c', - 'test/test-udp-try-send.c', - ], - 'conditions': [ - [ 'OS=="win"', { - 'sources': [ - 'test/runner-win.c', - 'test/runner-win.h', - 'src/win/snprintf.c', - ], - 'libraries': [ '-lws2_32' ] - }, { # POSIX - 'sources': [ - 'test/runner-unix.c', - 'test/runner-unix.h', - ], - 'conditions': [ - [ 'OS != "zos"', { - 'defines': [ '_GNU_SOURCE' ], - 'cflags': [ '-Wno-long-long' ], - 'xcode_settings': { - 'WARNING_CFLAGS': [ '-Wno-long-long' ] - } - }], - ]}, - ], - [ 'OS in "mac dragonflybsd freebsd linux netbsd openbsd".split()', { - 'link_settings': { - 'libraries': [ '-lutil' ], - }, - }], - [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE - 'defines': [ - '__EXTENSIONS__', - '_XOPEN_SOURCE=500', - ], - }], - [ 'OS=="aix"', { # make test-fs.c compile, needs _POSIX_C_SOURCE - 'defines': [ - '_ALL_SOURCE', - '_XOPEN_SOURCE=500', - ], - }], - ['uv_library=="shared_library"', { - 'defines': [ 'USING_UV_SHARED=1' ], - 'conditions': [ - [ 'OS == "zos"', { - 'cflags': [ '-Wc,DLL' ], - }], - ], - }], - ], - 'msvs-settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, - }, - - { - 'target_name': 'run-benchmarks', - 'type': 'executable', - 'dependencies': [ 'libuv' ], - 'sources': [ - 'test/benchmark-async.c', - 'test/benchmark-async-pummel.c', - 'test/benchmark-fs-stat.c', - 'test/benchmark-getaddrinfo.c', - 'test/benchmark-list.h', - 'test/benchmark-loop-count.c', - 'test/benchmark-million-async.c', - 'test/benchmark-million-timers.c', - 'test/benchmark-multi-accept.c', - 'test/benchmark-ping-pongs.c', - 'test/benchmark-pound.c', - 'test/benchmark-pump.c', - 'test/benchmark-sizes.c', - 'test/benchmark-spawn.c', - 'test/benchmark-thread.c', - 'test/benchmark-tcp-write-batch.c', - 'test/benchmark-udp-pummel.c', - 'test/dns-server.c', - 'test/echo-server.c', - 'test/blackhole-server.c', - 'test/run-benchmarks.c', - 'test/runner.c', - 'test/runner.h', - 'test/task.h', - ], - 'conditions': [ - [ 'OS=="win"', { - 'sources': [ - 'test/runner-win.c', - 'test/runner-win.h', - 'src/win/snprintf.c', - ], - 'libraries': [ '-lws2_32' ] - }, { # POSIX - 'defines': [ '_GNU_SOURCE' ], - 'sources': [ - 'test/runner-unix.c', - 'test/runner-unix.h', - ] - }], - ['uv_library=="shared_library"', { - 'defines': [ 'USING_UV_SHARED=1' ], - 'conditions': [ - [ 'OS == "zos"', { - 'cflags': [ '-Wc,DLL' ], - }], - ], - }], - ], - 'msvs-settings': { - 'VCLinkerTool': { - 'SubSystem': 1, # /subsystem:console - }, - }, - }, ] } diff --git a/vcbuild.bat b/vcbuild.bat index 46b34761077..c195394f37e 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -159,13 +159,14 @@ goto run :msbuild-found msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo if errorlevel 1 exit /b 1 +msbuild test\test.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo +if errorlevel 1 exit /b 1 :run @rem Run tests if requested. if "%run%"=="" goto exit -if not exist %config%\%run% goto exit -echo running '%config%\%run%' -%config%\%run% +echo running 'test\%config%\%run%' +test\%config%\%run% goto exit :create-msvs-files-failed