From 1ffc21d37843ab863e6d9ff48e17b11583606f84 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 7 Jun 2020 11:58:03 +0100 Subject: [PATCH] Problem: test_bind_fuzzer clobbers working directory with random socket files Solution: move to /tmp before running the test --- tests/test_bind_fuzzer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_bind_fuzzer.cpp b/tests/test_bind_fuzzer.cpp index 3a29a30c..547880bb 100644 --- a/tests/test_bind_fuzzer.cpp +++ b/tests/test_bind_fuzzer.cpp @@ -39,6 +39,12 @@ // Test that zmq_bind can handle malformed strings extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) { + // This test might create socket files, so move to /tmp to avoid clobbering + // the working directory with random filenames + char *pwd = get_current_dir_name (); + TEST_ASSERT_NOT_NULL (pwd); + TEST_ASSERT_SUCCESS_ERRNO (chdir ("/tmp")); + setup_test_context (); std::string my_endpoint (reinterpret_cast (data), size); void *socket = test_context_socket (ZMQ_PUB); @@ -46,6 +52,8 @@ extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) test_context_socket_close_zero_linger (socket); teardown_test_context (); + TEST_ASSERT_SUCCESS_ERRNO (chdir (pwd)); + free (pwd); return 0; }