diff --git a/src/script_opt/CPP/maint/README b/src/script_opt/CPP/maint/README new file mode 100644 index 0000000000..d7ca841e80 --- /dev/null +++ b/src/script_opt/CPP/maint/README @@ -0,0 +1,79 @@ +This is a collection of scripts to support maintenance of -O gen-C++ +(and friends). They're oriented around running against the BTest test +suite, and are currently tailored for the lead maintainer's own environment. +The scripts all assume you're running them from build/ . + +The maintenance workflow: + +1. Update this timestamp, so this file will be changed and you'll remember + to check in updates to the list of how the compiler currently fares + on various btests (see end of this doc): + + Thu May 12 12:54:10 PDT 2022 + +2. Run "find-test-files.sh" to generate a list (to stdout) of all of the + possible Zeek source files found in the test suite. + +3. For each such Zeek file, run "check-zeek.sh" to see whether Zeek can + parse it. This helps remove from further consideration difficult + tests (like those that have embedded input files, or multiple separate + scripts). + +4. "mkdir CPP-test" - a directory for holding results relating to C++ testing + +5. Run "check-CPP-gen.sh" for each Zeek file that passed "check-zeek.sh". + This will generate a corresponding file in CPP-test/out* indicating whether + "-O gen-C++" can successfully run on the input. Presently, it should + be able to do so for all of them. + +6. Copy ./src/zeek to ./zeek.HOLD. This is used to speed up recompilation used + in the next step. However, it's also a headache to do development to + fix a bug and then forget to update zeek.HOLD, which means you wind up + running the old version. You can combat that by removing ./zeek.HOLD + every time you start working on fixing a bug. + +7. Use the appended database to remove inputs that have known issues. + +8. For every input that survives that pruning, run "do-CPP-btest.sh". + This will generate C++ for the BTest, compile it, and run the result + to see if it succeeds. It populates CPP-test/diag* with the Btest + diagnostic output (empty means success). For non-empty output, + either fix the problem or update the database if it's not fixable. + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +Database Of Known Issues (be sure to keep sorted) + +These BTests won't successfully run due to the indicated issue: + + @if - has conditional code + bad-when - deliberately has old-style "when" without captures + command-line-error - a deliberate command-line error + complex-to-debug - hard-to-figure-out failure + deprecated - uses features deprecated for -O C++ + no-script - there's no actual script to compile + ZAM - meant specifically for -O ZAM + +../testing/btest/core/negative-time.test no-script +../testing/btest/core/pcap/dumper.zeek no-script +../testing/btest/core/pcap/input-error.zeek command-line-error +../testing/btest/core/proc-status-file.zeek no-script +../testing/btest/language/at-if-event.zeek @if +../testing/btest/language/at-if.zeek @if +../testing/btest/language/at-ifdef.zeek @if +../testing/btest/language/at-ifndef.zeek @if +../testing/btest/language/vector-in-operator.zeek deprecated +../testing/btest/language/when-aggregates.zeek bad-when +../testing/btest/opt/opt-files.zeek ZAM +../testing/btest/opt/opt-files2.zeek ZAM +../testing/btest/opt/opt-files3.zeek ZAM +../testing/btest/opt/opt-func.zeek ZAM +../testing/btest/opt/opt-func2.zeek ZAM +../testing/btest/opt/opt-func3.zeek ZAM +../testing/btest/scripts/base/protocols/dhcp/dhcp-ack-msg-types.zeek no-script +../testing/btest/scripts/base/protocols/dhcp/dhcp-all-msg-types.zeek no-script +../testing/btest/scripts/base/protocols/dhcp/dhcp-discover-msg-types.zeek no-script +../testing/btest/scripts/base/protocols/dhcp/inform.test no-script +../testing/btest/scripts/base/utils/active-http.test complex-to-debug +../testing/btest/scripts/policy/protocols/ssl/validate-certs.zeek no-script +../testing/btest/supervisor/config-bare-mode.zeek @if diff --git a/src/script_opt/CPP/maint/check-CPP-gen.sh b/src/script_opt/CPP/maint/check-CPP-gen.sh new file mode 100644 index 0000000000..3b72e5f14b --- /dev/null +++ b/src/script_opt/CPP/maint/check-CPP-gen.sh @@ -0,0 +1,6 @@ +#! /bin/sh + +out=out.`echo $1 | sed 's,\.\./,,;s,/,#,g'` + +(/bin/echo -n $1" " +(src/zeek -O gen-C++ --optimize-files=testing/btest --optimize-func="" $1 >& /dev/null && echo "success") || echo "fail") >CPP-test/$out 2>&1 diff --git a/src/script_opt/CPP/maint/check-zeek.sh b/src/script_opt/CPP/maint/check-zeek.sh new file mode 100644 index 0000000000..4bcbe544c7 --- /dev/null +++ b/src/script_opt/CPP/maint/check-zeek.sh @@ -0,0 +1,4 @@ +#! /bin/sh + +/bin/echo -n $1" " +(src/zeek --parse-only $1 >& /dev/null && echo "success") || echo "fail" diff --git a/src/script_opt/CPP/maint/do-CPP-btest.sh b/src/script_opt/CPP/maint/do-CPP-btest.sh new file mode 100644 index 0000000000..0648016347 --- /dev/null +++ b/src/script_opt/CPP/maint/do-CPP-btest.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +rm -f CPP-gen.cc +cp zeek.HOLD src/zeek || (echo Need to create clean zeek.HOLD; exit 1) || exit 1 + +base=`echo $1 | sed 's,\.\./,,;s,/,#,g'` +rel_test=`echo $1 | sed 's,.*testing/btest/,,'` + +export ZEEK_GEN_CPP=1 +export ZEEK_CPP_DIR=`pwd` +# export ZEEK_OPT_FUNCS="" +export ZEEK_OPT_FILES="testing/btest" + +(cd ../testing/btest; ../../auxil/btest/btest $rel_test) + +# export -n ZEEK_GEN_CPP ZEEK_CPP_DIR ZEEK_OPT_FUNCS ZEEK_OPT_FILES +export -n ZEEK_GEN_CPP ZEEK_CPP_DIR ZEEK_OPT_FILES + +ninja + +(cd ../testing/btest; ../../auxil/btest/btest -a cpp -d -f ../../build/CPP-test/diag.$base $rel_test) diff --git a/src/script_opt/CPP/maint/find-test-files.sh b/src/script_opt/CPP/maint/find-test-files.sh new file mode 100644 index 0000000000..9d420758ed --- /dev/null +++ b/src/script_opt/CPP/maint/find-test-files.sh @@ -0,0 +1,6 @@ +#! /bin/sh + +find ../testing/btest -type f | +egrep -v 'Baseline|\.tmp' | +egrep '\.(zeek|test)$' | +sort