Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

50 lines
1.8 KiB
Plaintext

# Test that the process command can run zeek on the specified trace file,
# with or without extra Zeek options or Zeek scripts.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
. zeekctl-test-setup
touch $ZEEKCTL_INSTALL_PREFIX/share/zeek/site/test123.zeek
touch $ZEEKCTL_INSTALL_PREFIX/share/zeek/site/test456.zeek
touch $ZEEKCTL_INSTALL_PREFIX/share/zeek/site/test789.zeek
zeekctl install
test ! -e $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testing
#####################
# run without any extra zeek options
zeekctl process $TRACES/dns-session.trace > orig-out
# silence deprecation warning that will eventually be resolved in zeek scripts
grep -v rotate_file_by_name orig-out > out
# verify that tmp work directory was created
test -d $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testing
#####################
# run with extra zeek options (but no extra zeek scripts)
zeekctl process $TRACES/dns-session.trace -p test
# verify that specified zeek options are at the start of the Zeek command-line
grep "^-p test " $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testing/.cmdline
#####################
# run with extra zeek scripts (but no zeek options)
zeekctl process $TRACES/dns-session.trace -- test123.zeek test456.zeek
# verify that specified zeek scripts are at the end of the Zeek command-line
grep "test123.zeek test456.zeek$" $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testing/.cmdline
#####################
# run with extra zeek options and scripts
zeekctl process $TRACES/dns-session.trace -p opt2 -- test789.zeek
# verify that specified zeek options are at the start of the Zeek command-line
grep "^-p opt2 " $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testing/.cmdline
# verify that specified zeek scripts are at the end of the Zeek command-line
grep "test789.zeek$" $ZEEKCTL_INSTALL_PREFIX/spool/tmp/testing/.cmdline