From 503f0a29a7bc57d404cedf8c0bc36b9db3daa880 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 13 Feb 2016 20:04:33 +0100 Subject: [PATCH] cmake: add integration-tests --- CMakeLists.txt | 2 +- integration-tests/CMakeLists.txt | 48 ++++++++++++++++++++++++++++++++ integration-tests/setenv.in | 9 ++++-- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 integration-tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cf2656a..c36ddc60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -516,8 +516,8 @@ add_subdirectory(python) if(0) add_subdirectory(tests) #add_subdirectory(tests/testdata) -add_subdirectory(integration-tests) endif() +add_subdirectory(integration-tests) add_subdirectory(doc) add_subdirectory(contrib) add_subdirectory(script) diff --git a/integration-tests/CMakeLists.txt b/integration-tests/CMakeLists.txt new file mode 100644 index 00000000..bae2d2d8 --- /dev/null +++ b/integration-tests/CMakeLists.txt @@ -0,0 +1,48 @@ +set(GO_FILES + nghttpx_http1_test.go + nghttpx_http2_test.go + nghttpx_spdy_test.go + server_tester.go +) + +# XXX unused +set(EXTRA_DIST + ${GO_FILES} + server.key + server.crt + alt-server.key + alt-server.crt + setenv + req-set-header.rb + resp-set-header.rb + req-return.rb + resp-return.rb +) + +add_custom_target(itprep + COMMAND go get -d -v golang.org/x/net/http2 + COMMAND go get -d -v github.com/tatsuhiro-t/go-nghttp2 + COMMAND go get -d -v github.com/tatsuhiro-t/spdy + COMMAND go get -d -v golang.org/x/net/websocket +) + +# 'go test' requires both config.go and the test files in the same directory. +# For out-of-tree builds, config.go is normally not placed next to the source +# files, so copy the tests to the build directory as a workaround. +set(GO_BUILD_FILES) +if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) + foreach(gofile IN LISTS GO_FILES) + set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${gofile}") + add_custom_command(OUTPUT "${outfile}" + COMMAND ${CMAKE_COMMAND} -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/${gofile}" "${outfile}" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${gofile}" + ) + list(APPEND GO_BUILD_FILES "${outfile}") + endforeach() +endif() + +add_custom_target(it + COMMAND sh setenv go test -v + DEPENDS ${GO_BUILD_FILES} +) diff --git a/integration-tests/setenv.in b/integration-tests/setenv.in index 2c2d3c95..277b68e7 100644 --- a/integration-tests/setenv.in +++ b/integration-tests/setenv.in @@ -1,6 +1,11 @@ #!/bin/sh -e +libdir="@abs_top_builddir@/lib" +if [ -d "$libdir/.libs" ]; then + libdir="$libdir/.libs" +fi + export CGO_CFLAGS="-I@abs_top_srcdir@/lib/includes -I@abs_top_builddir@/lib/includes" -export CGO_LDFLAGS="-L@abs_top_builddir@/lib/.libs" -export LD_LIBRARY_PATH="@abs_top_builddir@/lib/.libs" +export CGO_LDFLAGS="-L$libdir" +export LD_LIBRARY_PATH="$libdir" "$@"