From 8999f6acc78810680f282db4257e842971b80cb4 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 11:01:28 +0200 Subject: travis: build sources with tracing enabled Our tracing architecture is not built by default, causing the Travis CI to not execute some code and skip several tests. As AppVeyor has already enabled the tracing architecture when building the code, we should do the same for Travis CI to have this code being tested on macOS and Linux. Add "-DENABLE_TRACE=ON" to our release-build options of Travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 569a6a7d4..5d687f1ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ env: - secure: "YnhS+8n6B+uoyaYfaJ3Lei7cSJqHDPiKJCKFIF2c87YDfmCvAJke8QtE7IzjYDs7UFkTCM4ox+ph2bERUrxZbSCyEkHdjIZpKuMJfYWja/jgMqTMxdyOH9y8JLFbZsSXDIXDwqBlC6vVyl1fP90M35wuWcNTs6tctfVWVofEFbs=" - GITTEST_INVASIVE_FS_SIZE=1 matrix: - - OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON" + - OPTIONS="-DTHREADSAFE=ON -DENABLE_TRACE=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_WERROR=ON" - OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON -DENABLE_WERROR=ON" dist: trusty -- cgit v1.2.1 From 72c28ab011759dce113c2a0c7c36ebcd56bd6ddf Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 10:59:03 +0200 Subject: tests: status::worktree: indicate skipped tests on Win32 Some function bodies of tests which are not applicable to the Win32 platform are completely #ifdef'd out instead of calling `cl_skip()`. This leaves us with no indication that these tests are not being executed at all and may thus cause decreased scrutiny when investigating skipped tests. Improve the situation by calling `cl_skip()` instead of just doing nothing. --- tests/checkout/tree.c | 2 ++ tests/iterator/workdir.c | 2 ++ tests/repo/open.c | 2 ++ tests/status/worktree.c | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c index 56513eab7..a7e29b3db 100644 --- a/tests/checkout/tree.c +++ b/tests/checkout/tree.c @@ -1096,6 +1096,8 @@ void test_checkout_tree__filemode_preserved_in_workdir(void) cl_assert(!GIT_PERMS_IS_EXEC(read_filemode("a/b.txt"))); git_commit_free(commit); +#else + cl_skip(); #endif } diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c index f33fd98f1..618006715 100644 --- a/tests/iterator/workdir.c +++ b/tests/iterator/workdir.c @@ -741,6 +741,8 @@ void test_iterator_workdir__skips_fifos_and_special_files(void) cl_assert_equal_i(GIT_ITEROVER, git_iterator_advance(&e, i)); git_iterator_free(i); +#else + cl_skip(); #endif } diff --git a/tests/repo/open.c b/tests/repo/open.c index 3239b6fec..ab36dd587 100644 --- a/tests/repo/open.c +++ b/tests/repo/open.c @@ -180,6 +180,8 @@ void test_repo_open__from_git_new_workdir(void) cl_assert_(git__suffixcmp(git_repository_workdir(repo2), "alternate/") == 0, git_repository_workdir(repo2)); git_repository_free(repo2); +#else + cl_skip(); #endif } diff --git a/tests/status/worktree.c b/tests/status/worktree.c index 1345dbfd2..79eece85a 100644 --- a/tests/status/worktree.c +++ b/tests/status/worktree.c @@ -1072,6 +1072,8 @@ void test_status_worktree__unreadable(void) cl_assert_equal_i(counts.expected_entry_count, counts.entry_count); cl_assert_equal_i(0, counts.wrong_status_flags_count); cl_assert_equal_i(0, counts.wrong_sorted_path); +#else + cl_skip(); #endif } @@ -1106,6 +1108,8 @@ void test_status_worktree__unreadable_not_included(void) cl_assert_equal_i(counts.expected_entry_count, counts.entry_count); cl_assert_equal_i(0, counts.wrong_status_flags_count); cl_assert_equal_i(0, counts.wrong_sorted_path); +#else + cl_skip(); #endif } -- cgit v1.2.1 From 9aba76364fcb4755930856a7bafc5294ed3ee944 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 10:59:31 +0200 Subject: tests: iterator_helpers: assert number of iterator items When the function `expect_iterator_items` surpasses the number of expected items, we simply break the loop. This causes us to trigger an assert later on which has message attached, which is annoying when trying to locate the root error cause. Instead, directly assert that the current count is still smaller or equal to the expected count inside of the loop. --- tests/iterator/iterator_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/iterator/iterator_helpers.c b/tests/iterator/iterator_helpers.c index ae48fcd46..68d574126 100644 --- a/tests/iterator/iterator_helpers.c +++ b/tests/iterator/iterator_helpers.c @@ -51,8 +51,7 @@ void expect_iterator_items( cl_assert(entry->mode != GIT_FILEMODE_TREE); } - if (++count >= expected_flat) - break; + cl_assert(++count <= expected_flat); } assert_at_end(i, v); -- cgit v1.2.1 From b8c14499f9940feaab08a23651a2ef24d27b17b7 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 11:00:26 +0200 Subject: tests: iterator::workdir: fix reference count in stale test The test `iterator::workdir::filesystem_gunk` is usually not executed, as it is guarded by the environment variable "GITTEST_INVASIVE_SPEED" due to its effects on speed. As such, it has become stale and does not account for new references which have meanwhile been added to the testrepo, causing it to fail. Fix this by raising the number of expected references to 15. --- tests/iterator/workdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c index 618006715..198edc7e8 100644 --- a/tests/iterator/workdir.c +++ b/tests/iterator/workdir.c @@ -662,7 +662,7 @@ void test_iterator_workdir__filesystem_gunk(void) /* should only have 13 items, since we're not asking for trees to be * returned. the goal of this test is simply to not crash. */ - expect_iterator_items(i, 13, NULL, 13, NULL); + expect_iterator_items(i, 15, NULL, 15, NULL); git_iterator_free(i); git_buf_free(&parent); } -- cgit v1.2.1 From 543ec149b86a68e12dd141a6141e82850dabbf21 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 11:06:01 +0200 Subject: tests: perf: build but exclude performance tests by default Our performance tests (or to be more concrete, our single performance test) are not built by default, as they are always #ifdef'd out. While it is true that we don't want to run performance tests by default, not compiling them at all may cause code rot and is thus an unfavorable approach to handle this. We can easily improve this situation: this commit removes the #ifdef, causing the code to always be compiled. Furthermore, we add `-xperf` to the default command line parameters of `generate.py`, thus causing the tests to be excluded by default. Due to this approach, we are now able to execute the performance tests by passing `-sperf` to `libgit2_clar`. Unfortunately, we cannot execute the performance tests on Travis or AppVeyor as they rely on history being available for the libgit2 repository. As both do a shallow clone only, though, this is not given. --- tests/CMakeLists.txt | 2 +- tests/perf/merge.c | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 08ecb396b..4606fe979 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,7 +20,7 @@ ENDIF() ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite - COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress . + COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf . DEPENDS ${SRC_TEST} WORKING_DIRECTORY ${CLAR_PATH} ) diff --git a/tests/perf/merge.c b/tests/perf/merge.c index b2ef082eb..721902d63 100644 --- a/tests/perf/merge.c +++ b/tests/perf/merge.c @@ -25,20 +25,7 @@ #define ID_BRANCH_A "d853fb9f24e0fe63b3dce9fbc04fd9cfe17a030b" #define ID_BRANCH_B "1ce9ea3ba9b4fa666602d52a5281d41a482cc58b" - -void test_perf_merge__initialize(void) -{ -} - -void test_perf_merge__cleanup(void) -{ -} - void test_perf_merge__m1(void) { -#if 1 - cl_skip(); -#else perf__do_merge(SRC_REPO, "m1", ID_BRANCH_A, ID_BRANCH_B); -#endif } -- cgit v1.2.1 From fea6092079d5c09b499e472efead2f7aa81ce8a1 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 12:48:48 +0200 Subject: tests: online::clone: construct credential-URL from environment We support two types of passing credentials to the proxy, either via the URL or explicitly by specifying user and password. We test these types by modifying the proxy URL and executing the tests twice, which is in fact unnecessary and requires us to maintain the list of environment variables and test executions across multiple CI infrastructures. To fix the situation, we can just always pass the host, port, user and password to the tests. The tests can then assemble the complete URL either with or without included credentials, allowing us to test both cases in-process. --- appveyor.yml | 6 ++---- script/cibuild.sh | 14 +++++--------- tests/CMakeLists.txt | 3 +-- tests/online/clone.c | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e0c7b9b90..1c4c1af7e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,9 +52,7 @@ test_script: $env:GITTEST_REMOTE_USER="libgit2test" ctest -V -R libgit2_clar-cred_callback Receive-Job -Job $proxyJob - $env:GITTEST_REMOTE_PROXY_URL = "http://foo:bar@localhost:8080" - ctest -V -R libgit2_clar-proxy_credentials_in_url - $env:GITTEST_REMOTE_PROXY_URL = "http://localhost:8080" + $env:GITTEST_REMOTE_PROXY_URL = "localhost:8080" $env:GITTEST_REMOTE_PROXY_USER = "foo" $env:GITTEST_REMOTE_PROXY_PASS = "bar" - ctest -V -R libgit2_clar-proxy_credentials_request + ctest -V -R libgit2_clar-proxy_credentials diff --git a/script/cibuild.sh b/script/cibuild.sh index 1c28baae6..c06de1933 100755 --- a/script/cibuild.sh +++ b/script/cibuild.sh @@ -90,7 +90,10 @@ export GITTEST_REMOTE_USER=$USER export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa" export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub" export GITTEST_REMOTE_SSH_PASSPHRASE="" - +# Use the proxy we started at the beginning +export GITTEST_REMOTE_PROXY_URL="localhost:8080" +export GITTEST_REMOTE_PROXY_USER="foo" +export GITTEST_REMOTE_PROXY_PASS="bar" if [ -e ./libgit2_clar ]; then ./libgit2_clar -sonline::push -sonline::clone::ssh_cert && @@ -99,14 +102,7 @@ if [ -e ./libgit2_clar ]; then ./libgit2_clar -sonline::clone::cred_callback || exit $? fi - # Use the proxy we started at the beginning - export GITTEST_REMOTE_PROXY_URL="http://foo:bar@localhost:8080/" - ./libgit2_clar -sonline::clone::proxy_credentials_in_url || exit $? - export GITTEST_REMOTE_PROXY_URL="http://localhost:8080/" - export GITTEST_REMOTE_PROXY_USER="foo" - export GITTEST_REMOTE_PROXY_PASS="bar" - ./libgit2_clar -sonline::clone::proxy_credentials_request || exit $? - + ctest -V -R libgit2_clar-proxy_credentials || exit $? fi kill $(cat "$HOME/sshd/pid") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4606fe979..2d18391bd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -61,5 +61,4 @@ ENDIF () # Add a test target which runs the cred callback tests, to be # called after setting the url and user ADD_TEST(libgit2_clar-cred_callback "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::cred_callback) -ADD_TEST(libgit2_clar-proxy_credentials_in_url "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_in_url) -ADD_TEST(libgit2_clar-proxy_credentials_request "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_request) +ADD_TEST(libgit2_clar-proxy_credentials "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_in_url -sonline::clone::proxy_credentials_request) diff --git a/tests/online/clone.c b/tests/online/clone.c index 5eda73f87..b6709869e 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -677,24 +677,34 @@ static int proxy_creds(git_cred **out, const char *url, const char *username, un void test_online_clone__proxy_credentials_request(void) { + git_buf url = GIT_BUF_INIT; + if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass) cl_skip(); + cl_git_pass(git_buf_printf(&url, "http://%s/", _remote_proxy_url)); + g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED; - g_options.fetch_opts.proxy_opts.url = _remote_proxy_url; + g_options.fetch_opts.proxy_opts.url = url.ptr; g_options.fetch_opts.proxy_opts.credentials = proxy_creds; called_proxy_creds = 0; cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options)); cl_assert(called_proxy_creds); + + git_buf_free(&url); } void test_online_clone__proxy_credentials_in_url(void) { - if (!_remote_proxy_url) + git_buf url = GIT_BUF_INIT; + + if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass) cl_skip(); + cl_git_pass(git_buf_printf(&url, "http://%s:%s@%s/", _remote_proxy_user, _remote_proxy_pass, _remote_proxy_url)); + g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED; - g_options.fetch_opts.proxy_opts.url = _remote_proxy_url; + g_options.fetch_opts.proxy_opts.url = url.ptr; called_proxy_creds = 0; cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options)); cl_assert(called_proxy_creds == 0); -- cgit v1.2.1 From 54a1bf057a1123cf55ac3447c79761c817382f47 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Wed, 7 Jun 2017 13:06:53 +0200 Subject: tests: online::clone: inline creds-test with nonexistent URL Right now, we test our credential callback code twice, once via SSH on localhost and once via a non-existent GitHub repository. While the first URL makes sense to be configurable, it does not make sense to hard-code the non-existing repository, which requires us to call tests multiple times. Instead, we can just inline the URL into another set of tests. --- appveyor.yml | 3 --- script/cibuild.sh | 7 ------- tests/CMakeLists.txt | 1 - tests/online/clone.c | 8 ++++---- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1c4c1af7e..9b14a9c81 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,9 +48,6 @@ test_script: # Run this early so we know it's ready by the time we need it $proxyJob = Start-Job { java -jar $Env:APPVEYOR_BUILD_FOLDER\build\poxyproxy.jar -d --port 8080 --credentials foo:bar } ctest -V -R libgit2_clar - $env:GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent" - $env:GITTEST_REMOTE_USER="libgit2test" - ctest -V -R libgit2_clar-cred_callback Receive-Job -Job $proxyJob $env:GITTEST_REMOTE_PROXY_URL = "localhost:8080" $env:GITTEST_REMOTE_PROXY_USER = "foo" diff --git a/script/cibuild.sh b/script/cibuild.sh index c06de1933..5cebb5c17 100755 --- a/script/cibuild.sh +++ b/script/cibuild.sh @@ -98,15 +98,8 @@ export GITTEST_REMOTE_PROXY_PASS="bar" if [ -e ./libgit2_clar ]; then ./libgit2_clar -sonline::push -sonline::clone::ssh_cert && ./libgit2_clar -sonline::clone::ssh_with_paths || exit $? - if [ "$TRAVIS_OS_NAME" = "linux" ]; then - ./libgit2_clar -sonline::clone::cred_callback || exit $? - fi ctest -V -R libgit2_clar-proxy_credentials || exit $? fi kill $(cat "$HOME/sshd/pid") - -export GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent" -export GITTEST_REMOTE_USER="libgit2test" -ctest -V -R libgit2_clar-cred_callback diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2d18391bd..fbc3d41e5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -60,5 +60,4 @@ ENDIF () # Add a test target which runs the cred callback tests, to be # called after setting the url and user -ADD_TEST(libgit2_clar-cred_callback "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::cred_callback) ADD_TEST(libgit2_clar-proxy_credentials "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_in_url -sonline::clone::proxy_credentials_request) diff --git a/tests/online/clone.c b/tests/online/clone.c index b6709869e..b9230eca6 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -263,8 +263,8 @@ static int cred_failure_cb( void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void) { - if (!_remote_url || !_remote_user) - clar__skip(); + _remote_url = git__strdup("https://github.com/libgit2/non-existent"); + _remote_user = git__strdup("libgit2test"); g_options.fetch_opts.callbacks.credentials = cred_failure_cb; @@ -293,8 +293,8 @@ void test_online_clone__cred_callback_called_again_on_auth_failure(void) { size_t counter = 0; - if (!_remote_url || !_remote_user) - clar__skip(); + _remote_url = git__strdup("https://github.com/libgit2/non-existent"); + _remote_user = git__strdup("libgit2test"); g_options.fetch_opts.callbacks.credentials = cred_count_calls_cb; g_options.fetch_opts.callbacks.payload = &counter; -- cgit v1.2.1 From 5874e151d7b10de84fc1ca168339fdc622292219 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 20 Nov 2017 13:26:33 +0000 Subject: tests: create new test target for all SSH-based tests Some tests shall be run against our own SSH server we spin up in Travis. As those need to be run separate from our previous tests which run against git-daemon, we have to do this in a separate step. Instead of bundling all that knowledge in the CI script, move it into the test build instructions by creating a new test target. --- script/cibuild.sh | 11 ++++------- tests/CMakeLists.txt | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/script/cibuild.sh b/script/cibuild.sh index 5cebb5c17..5d70e7506 100755 --- a/script/cibuild.sh +++ b/script/cibuild.sh @@ -85,21 +85,18 @@ else export GITTEST_REMOTE_SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':') fi +# Use the SSH server export GITTEST_REMOTE_URL="ssh://localhost:2222/$HOME/_temp/test.git" export GITTEST_REMOTE_USER=$USER export GITTEST_REMOTE_SSH_KEY="$HOME/.ssh/id_rsa" export GITTEST_REMOTE_SSH_PUBKEY="$HOME/.ssh/id_rsa.pub" export GITTEST_REMOTE_SSH_PASSPHRASE="" +ctest -V -R libgit2_clar-ssh || exit $? + # Use the proxy we started at the beginning export GITTEST_REMOTE_PROXY_URL="localhost:8080" export GITTEST_REMOTE_PROXY_USER="foo" export GITTEST_REMOTE_PROXY_PASS="bar" - -if [ -e ./libgit2_clar ]; then - ./libgit2_clar -sonline::push -sonline::clone::ssh_cert && - ./libgit2_clar -sonline::clone::ssh_with_paths || exit $? - - ctest -V -R libgit2_clar-proxy_credentials || exit $? -fi +ctest -V -R libgit2_clar-proxy_credentials || exit $? kill $(cat "$HOME/sshd/pid") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fbc3d41e5..775f33f2d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -58,6 +58,6 @@ ELSE () ADD_TEST(libgit2_clar "${libgit2_BINARY_DIR}/libgit2_clar" -v -xclone::local::git_style_unc_paths -xclone::local::standard_unc_paths_are_written_git_style) ENDIF () -# Add a test target which runs the cred callback tests, to be -# called after setting the url and user +# Add additional test targets that require special setup ADD_TEST(libgit2_clar-proxy_credentials "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::clone::proxy_credentials_in_url -sonline::clone::proxy_credentials_request) +ADD_TEST(libgit2_clar-ssh "${libgit2_BINARY_DIR}/libgit2_clar" -v -sonline::push -sonline::clone::ssh_cert -sonline::clone::ssh_with_paths) -- cgit v1.2.1