diff options
author | Gerald Combs <gerald@wireshark.org> | 2023-09-25 15:09:11 -0700 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2023-09-26 06:54:46 +0000 |
commit | fafb3e3154f36db11293744eaded17da69d3f9f4 (patch) | |
tree | b272d3529967e6d48f31fa8580b72d8b150354db | |
parent | 54b19db4ee67a0942af4b500e2c7733b2f838b51 (diff) |
Test and handle spaces in our build directory
In .gitlab-ci.yml, add spaces and emoji to the build directory name. In
CMakeLists.txt, quote a path in a wrapper script. Quote our executable
and file paths where needed in our tests.
-rw-r--r-- | .gitlab-ci.yml | 6 | ||||
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/subprocesstest.py | 2 | ||||
-rw-r--r-- | test/suite_capture.py | 5 | ||||
-rw-r--r-- | test/suite_fileformats.py | 8 | ||||
-rw-r--r-- | test/suite_text2pcap.py | 4 |
6 files changed, 17 insertions, 12 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2bddbb1a2a..f30e8eef58 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -129,7 +129,8 @@ variables: after_script: # The cache should be large enough to be useful but it shouldn't take # too long to restore+save each run. - - ccache --max-size $( du --summarize --block-size=1M "$CI_PROJECT_DIR/build" | awk '{printf ("%dM", $1 * 1.5)}' ) + - cd "$CI_PROJECT_DIR" + - ccache --max-size $( du --total --summarize --block-size=1M *build*/ | awk 'END {printf ("%dM", $1 * 1.5)}' ) .build-rpm: extends: .build-linux @@ -620,6 +621,9 @@ Ubuntu GCC Build: needs: [ 'Commit Check' ] script: # build-ubuntu puts us in `build`. + - cd .. + - mv build "🦈 b u i l d 🦈" + - cd "🦈 b u i l d 🦈" - printf "\e[0Ksection_start:%s:cmake_section[collapsed=true]\r\e[0KRunning CMake" "$( date +%s)" # Test release build. - cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DENABLE_CCACHE=ON -DENABLE_WERROR=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=on .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 3586013319..dbc38545f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2764,7 +2764,7 @@ if(BUILD_wireshark AND QT_FOUND) file(WRITE ${CMAKE_BINARY_DIR}/run/wireshark "#!/bin/sh\n") file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n") file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "# Wrapper script which ensures that we're properly activated via Launch Services\n") - file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark \"\$\@\"\n") + file(APPEND ${CMAKE_BINARY_DIR}/run/wireshark "exec \"${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/MacOS/Wireshark\" \"\$\@\"\n") execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/wireshark) endif() endif() @@ -2875,7 +2875,7 @@ if(BUILD_logray AND QT_FOUND) file(WRITE ${CMAKE_BINARY_DIR}/run/logray "#!/bin/sh\n") file(APPEND ${CMAKE_BINARY_DIR}/run/logray "# Generated by ${CMAKE_CURRENT_LIST_FILE}\n") file(APPEND ${CMAKE_BINARY_DIR}/run/logray "# Wrapper script which ensures that we're properly activated via Launch Services\n") - file(APPEND ${CMAKE_BINARY_DIR}/run/logray "exec ${CMAKE_BINARY_DIR}/run/Logray.app/Contents/MacOS/Logray \"\$\@\"\n") + file(APPEND ${CMAKE_BINARY_DIR}/run/logray "exec \"${CMAKE_BINARY_DIR}/run/Logray.app/Contents/MacOS/Logray\" \"\$\@\"\n") execute_process(COMMAND chmod a+x ${CMAKE_BINARY_DIR}/run/logray) endif() endif() diff --git a/test/subprocesstest.py b/test/subprocesstest.py index e8e534e890..3e91815517 100644 --- a/test/subprocesstest.py +++ b/test/subprocesstest.py @@ -63,7 +63,7 @@ def cat_dhcp_command(mode): if sys.executable: sd_cmd = '"{}" '.format(sys.executable) this_dir = os.path.dirname(__file__) - sd_cmd += os.path.join(this_dir, 'util_dump_dhcp_pcap.py ' + mode) + sd_cmd += '"{}" {}'.format(os.path.join(this_dir, 'util_dump_dhcp_pcap.py'), mode) return sd_cmd def cat_cap_file_command(cap_files): diff --git a/test/suite_capture.py b/test/suite_capture.py index ffcd6cd545..48c2794d8f 100644 --- a/test/suite_capture.py +++ b/test/suite_capture.py @@ -72,12 +72,13 @@ def wireshark_k(wireshark_command): return tuple(list(wireshark_command) + ['-k']) -def capture_command(*args, shell=False): +def capture_command(*args, shell=False, quoted=False): cmd_args = list(args) if type(cmd_args[0]) != str: # Assume something like ['wireshark', '-k'] cmd_args = list(cmd_args[0]) + list(cmd_args)[1:] if shell: + cmd_args[0] = f'"{cmd_args[0]}"' cmd_args = ' '.join(cmd_args) return cmd_args @@ -156,7 +157,7 @@ def check_capture_stdin(cmd_capinfos, result_file): slow_dhcp_cmd = cat_dhcp_command('slow') capture_cmd = capture_command(cmd, '-i', '-', - '-w', testout_file, + '-w', f'"{testout_file}"', '-a', 'duration:{}'.format(capture_duration), shell=True ) diff --git a/test/suite_fileformats.py b/test/suite_fileformats.py index 37ee4bc8ce..973cd95e8c 100644 --- a/test/suite_fileformats.py +++ b/test/suite_fileformats.py @@ -31,7 +31,7 @@ def fileformats_baseline_str(dirs): class TestFileFormatPcap: def test_pcap_usec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str, test_env): '''Microsecond pcap direct vs microsecond pcap stdin''' - capture_stdout = subprocess.check_output(' '.join((cmd_tshark, + capture_stdout = subprocess.check_output(' '.join((f'"{cmd_tshark}"', '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -42,7 +42,7 @@ class TestFileFormatPcap: def test_pcap_nsec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str, test_env): '''Microsecond pcap direct vs nanosecond pcap stdin''' - capture_stdout = subprocess.check_output(' '.join((cmd_tshark, + capture_stdout = subprocess.check_output(' '.join((f'"{cmd_tshark}"', '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta', @@ -65,7 +65,7 @@ class TestFileFormatPcap: class TestFileFormatsPcapng: def test_pcapng_usec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str, test_env): '''Microsecond pcap direct vs microsecond pcapng stdin''' - capture_stdout = subprocess.check_output(' '.join((cmd_tshark, + capture_stdout = subprocess.check_output(' '.join((f'"{cmd_tshark}"', '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta' @@ -86,7 +86,7 @@ class TestFileFormatsPcapng: def test_pcapng_nsec_stdin(self, cmd_tshark, capture_file, fileformats_baseline_str, test_env): '''Microsecond pcap direct vs nanosecond pcapng stdin''' - capture_stdout = subprocess.check_output(' '.join((cmd_tshark, + capture_stdout = subprocess.check_output(' '.join((f'"{cmd_tshark}"', '-r', '-', '-Tfields', '-e', 'frame.number', '-e', 'frame.time_epoch', '-e', 'frame.time_delta' diff --git a/test/suite_text2pcap.py b/test/suite_text2pcap.py index 6163f18a0c..b42ebcb763 100644 --- a/test/suite_text2pcap.py +++ b/test/suite_text2pcap.py @@ -116,7 +116,7 @@ def check_text2pcap(cmd_tshark, cmd_text2pcap, cmd_capinfos, capture_file, resul # text2pcap_generate_input() # $TSHARK -o 'gui.column.format:"Time","%t"' -tad -P -x -r $1 > testin.txt testin_file = result_file(testin_txt) - tshark_cmd = '{cmd} -r {cf} -o gui.column.format:"Time","%t" -t ad -P --hexdump frames > {of}'.format( + tshark_cmd = '"{cmd}" -r "{cf}" -o gui.column.format:"Time","%t" -t ad -P --hexdump frames > "{of}"'.format( cmd = cmd_tshark, cf = cap_file, of = testin_file, @@ -130,7 +130,7 @@ def check_text2pcap(cmd_tshark, cmd_text2pcap, cmd_capinfos, capture_file, resul # We want the -a flag, because the tshark -x format is a hex+ASCII # format where the ASCII can be confused for hex bytes without it. # XXX: -t ISO also works now too for this output - text2pcap_cmd = '{cmd} -a -F {filetype} -l {linktype} -t "%Y-%m-%d %H:%M:%S.%f" {in_f} {out_f}'.format( + text2pcap_cmd = '"{cmd}" -a -F {filetype} -l {linktype} -t "%Y-%m-%d %H:%M:%S.%f" "{in_f}" "{out_f}"'.format( cmd = cmd_text2pcap, filetype = filetype_flag, linktype = encap_to_link_type[pre_cap_info['encapsulation']], |