diff --git a/testing/btest/Baseline/language.closure-binding-deprecated/out b/testing/btest/Baseline/language.closure-binding-deprecated/out new file mode 100644 index 0000000000..066ca90cec --- /dev/null +++ b/testing/btest/Baseline/language.closure-binding-deprecated/out @@ -0,0 +1,12 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +reference capture +4, 10 +6, 8 +7, 7 +reference double capture +4 +2, 10, 47 +4 +2, 8, 47 +3 +1, 7, 47 diff --git a/testing/btest/Baseline/language.closure-binding/out b/testing/btest/Baseline/language.closure-binding/out index 891492d324..d5c7c22634 100644 --- a/testing/btest/Baseline/language.closure-binding/out +++ b/testing/btest/Baseline/language.closure-binding/out @@ -1,43 +1,42 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -4, 10 -6, 8 -7, 7 +shallow copy 4, 10 5, 8 6, 7 +deep copy 4, 10 5, 9 6, 8 +mixed copy, case 1 4, 10 5, 8 6, 7 +mixed copy, case 2 4, 10 5, 9 6, 8 -4 -2, 10, 47 -4 -2, 8, 47 -3 -1, 7, 47 +double shallow copy 4 2, 10, 47 5 3, 8, 47 6 4, 7, 47 +double deep copy, case 1 4 2, 10, 47 5 3, 9, 47 6 4, 8, 47 +double deep copy, case 2 4 2, 10, 91 5 3, 9, 91 6 4, 9, 91 +double deep copy, case 3 4 2, 10, 91 5 diff --git a/testing/btest/Baseline/language.closure-sending-deprecated/recv.recv.out b/testing/btest/Baseline/language.closure-sending-deprecated/recv.recv.out new file mode 100644 index 0000000000..d48a41b96d --- /dev/null +++ b/testing/btest/Baseline/language.closure-sending-deprecated/recv.recv.out @@ -0,0 +1,27 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +hello :-) +peer added +receiver got ping: function 2 +inside: 1 | outside: 12 | global: 100 +77 +receiver got ping: function 1 +begin: 100 | base_step: 2 +begin: 100 | base_step: 2 | step: 76 +178 +receiver got ping: function 2 +inside: 3 | outside: 12 | global: 100 +79 +receiver got ping: function 1 +begin: 100 | base_step: 4 +begin: 100 | base_step: 4 | step: 76 +180 +receiver got ping: function 2 +inside: 5 | outside: 12 | global: 100 +81 +receiver got ping: function 1 +begin: 100 | base_step: 6 +begin: 100 | base_step: 6 | step: 76 +182 +receiver got ping: function 2 +inside: 7 | outside: 12 | global: 100 +83 diff --git a/testing/btest/Baseline/language.closure-sending-deprecated/send.send.out b/testing/btest/Baseline/language.closure-sending-deprecated/send.send.out new file mode 100644 index 0000000000..39d70d48d5 --- /dev/null +++ b/testing/btest/Baseline/language.closure-sending-deprecated/send.send.out @@ -0,0 +1,32 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +hello :) +peer added +begin: 100 | base_step: 50 +sender got pong: function 2 +inside: 1 | outside: 12 | global: 10 +77 +begin: 100 | base_step: 50 +sender got pong: function 1 +begin: 178 | base_step: 2 +begin: 178 | base_step: 2 | step: 76 +256 +begin: 100 | base_step: 50 +sender got pong: function 2 +inside: 3 | outside: 12 | global: 10 +79 +begin: 100 | base_step: 50 +sender got pong: function 1 +begin: 180 | base_step: 4 +begin: 180 | base_step: 4 | step: 76 +260 +begin: 100 | base_step: 50 +sender got pong: function 2 +inside: 5 | outside: 12 | global: 10 +81 +begin: 100 | base_step: 50 +sender got pong: function 1 +begin: 182 | base_step: 6 +begin: 182 | base_step: 6 | step: 76 +264 +begin: 100 | base_step: 50 +peer lost diff --git a/testing/btest/Baseline/language.uninitialized-local3/out b/testing/btest/Baseline/language.uninitialized-local3/out index 70650b5bb5..e65bf87f36 100644 --- a/testing/btest/Baseline/language.uninitialized-local3/out +++ b/testing/btest/Baseline/language.uninitialized-local3/out @@ -1,6 +1,6 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -warning in <...>/uninitialized-local3.zeek, line 33: possibly used without definition (x4) -expression error in <...>/uninitialized-local3.zeek, line 33: value used but not set (x4) +warning in <...>/uninitialized-local3.zeek, line 38: possibly used without definition (x4) +expression error in <...>/uninitialized-local3.zeek, line 38: value used but not set (x4) x$a (x <...>/uninitialized-local3.zeek, line 20) possibly used without being set x$e (x <...>/uninitialized-local3.zeek, line 20) possibly used without being set x$e (x <...>/uninitialized-local3.zeek, line 24) possibly used without being set diff --git a/testing/btest/core/conn-uid.zeek b/testing/btest/core/conn-uid.zeek index 5852236ff0..6c7c326492 100644 --- a/testing/btest/core/conn-uid.zeek +++ b/testing/btest/core/conn-uid.zeek @@ -1,7 +1,7 @@ # # In "normal" test mode, connection uids should be determistic. # -# @TEST-EXEC: zeek -b -C -r $TRACES/wikipedia.trace %INPUT >output +# @TEST-EXEC: zeek -b -D -C -r $TRACES/wikipedia.trace %INPUT >output # @TEST-EXEC: btest-diff output # # Without a seed, they should differ each time: diff --git a/testing/btest/language/closure-binding-deprecated.zeek b/testing/btest/language/closure-binding-deprecated.zeek new file mode 100644 index 0000000000..90a5c7e78f --- /dev/null +++ b/testing/btest/language/closure-binding-deprecated.zeek @@ -0,0 +1,47 @@ +# @TEST-EXEC: zeek -b %INPUT >out +# @TEST-EXEC: btest-diff out + +type mutable_aggregate: record { x: count; }; + +function reference_capture() : function() + { + local a = 3; + local b = mutable_aggregate($x=11); + local f = function() { print ++a, --b$x; }; + f(); + ++a; + --b$x; + f(); + + return f; + } + +function reference_capture_double() : function() : function() + { + local a = 3; + local b = mutable_aggregate($x=11); + local f = function() : function() { + local c = mutable_aggregate($x=88); + print ++a; + local f2 = function() { print a -= 2, --b$x, c$x += 3; }; + c$x = c$x / 2; + return f2; + }; + f()(); + ++a; + --b$x; + f()(); + + return f; + } + +event zeek_init() + { + print "reference capture"; + local rc = reference_capture(); + rc(); + + print "reference double capture"; + local rc2 = reference_capture_double(); + rc2()(); + } diff --git a/testing/btest/language/closure-binding.zeek b/testing/btest/language/closure-binding.zeek index 6e1596b6f9..241c92484d 100644 --- a/testing/btest/language/closure-binding.zeek +++ b/testing/btest/language/closure-binding.zeek @@ -3,19 +3,6 @@ type mutable_aggregate: record { x: count; }; -function reference_capture() : function() - { - local a = 3; - local b = mutable_aggregate($x=11); - local f = function() { print ++a, --b$x; }; - f(); - ++a; - --b$x; - f(); - - return f; - } - function shallow_copy_capture() : function() { local a = 3; @@ -68,25 +55,6 @@ function mixed_copy_capture_b() : function() return f; } -function reference_capture_double() : function() : function() - { - local a = 3; - local b = mutable_aggregate($x=11); - local f = function() : function() { - local c = mutable_aggregate($x=88); - print ++a; - local f2 = function() { print a -= 2, --b$x, c$x += 3; }; - c$x = c$x / 2; - return f2; - }; - f()(); - ++a; - --b$x; - f()(); - - return f; - } - function shallow_copy_capture_double() : function() : function() { local a = 3; @@ -167,33 +135,35 @@ function deep_copy3_capture_double() : function() : function() event zeek_init() { - local rc = reference_capture(); - rc(); - + print "shallow copy"; local scc = shallow_copy_capture(); scc(); + print "deep copy"; local dcc = deep_copy_capture(); dcc(); + print "mixed copy, case 1"; local mcca = mixed_copy_capture_a(); mcca(); + print "mixed copy, case 2"; local mccb = mixed_copy_capture_b(); mccb(); - local rc2 = reference_capture_double(); - rc2()(); - + print "double shallow copy"; local scc2 = shallow_copy_capture_double(); scc2()(); + print "double deep copy, case 1"; local dcc2_1 = deep_copy1_capture_double(); dcc2_1()(); + print "double deep copy, case 2"; local dcc2_2 = deep_copy2_capture_double(); dcc2_2()(); + print "double deep copy, case 3"; local dcc2_3 = deep_copy3_capture_double(); dcc2_3()(); } diff --git a/testing/btest/language/closure-sending.zeek b/testing/btest/language/closure-sending-deprecated.zeek similarity index 96% rename from testing/btest/language/closure-sending.zeek rename to testing/btest/language/closure-sending-deprecated.zeek index f5a3e44035..09f403fc9b 100644 --- a/testing/btest/language/closure-sending.zeek +++ b/testing/btest/language/closure-sending-deprecated.zeek @@ -1,7 +1,7 @@ # @TEST-PORT: BROKER_PORT # -# @TEST-EXEC: btest-bg-run recv "zeek -B broker -b ../recv.zeek >recv.out" -# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out" +# @TEST-EXEC: btest-bg-run recv "zeek -D -B broker -b ../recv.zeek >recv.out" +# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out" # # @TEST-EXEC: btest-bg-wait 45 # @TEST-EXEC: btest-diff recv/recv.out diff --git a/testing/btest/language/closure-sending-naming.zeek b/testing/btest/language/closure-sending-naming.zeek index 27bc367d6d..8244ae9577 100644 --- a/testing/btest/language/closure-sending-naming.zeek +++ b/testing/btest/language/closure-sending-naming.zeek @@ -1,7 +1,7 @@ # @TEST-PORT: BROKER_PORT # -# @TEST-EXEC: btest-bg-run recv "zeek -B broker -b ../recv.zeek >recv.out 2>recv.error" -# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out" +# @TEST-EXEC: btest-bg-run recv "zeek -D -B broker -b ../recv.zeek >recv.out 2>recv.error" +# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out" # # @TEST-EXEC: btest-bg-wait 20 # @TEST-EXEC: btest-diff recv/recv.error diff --git a/testing/btest/language/closure-sending2.zeek b/testing/btest/language/closure-sending2.zeek index c6a421a708..e447b8224c 100644 --- a/testing/btest/language/closure-sending2.zeek +++ b/testing/btest/language/closure-sending2.zeek @@ -1,7 +1,7 @@ # @TEST-PORT: BROKER_PORT # -# @TEST-EXEC: btest-bg-run recv "zeek -B broker -b ../recv.zeek >recv.out" -# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out" +# @TEST-EXEC: btest-bg-run recv "zeek -D -B broker -b ../recv.zeek >recv.out" +# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out" # # @TEST-EXEC: btest-bg-wait 45 # @TEST-EXEC: btest-diff recv/recv.out diff --git a/testing/btest/language/function-sending.zeek b/testing/btest/language/function-sending.zeek index a45911878a..234e0a5431 100644 --- a/testing/btest/language/function-sending.zeek +++ b/testing/btest/language/function-sending.zeek @@ -1,7 +1,7 @@ # @TEST-PORT: BROKER_PORT # -# @TEST-EXEC: btest-bg-run recv "zeek -B broker -b ../recv.zeek >recv.out" -# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out" +# @TEST-EXEC: btest-bg-run recv "zeek -D -B broker -b ../recv.zeek >recv.out" +# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out" # # @TEST-EXEC: btest-bg-wait 20 # @TEST-EXEC: btest-diff recv/recv.out diff --git a/testing/btest/language/paraglob-serialization.zeek b/testing/btest/language/paraglob-serialization.zeek index c5d5d516dd..788aa4e95f 100644 --- a/testing/btest/language/paraglob-serialization.zeek +++ b/testing/btest/language/paraglob-serialization.zeek @@ -1,7 +1,7 @@ # @TEST-PORT: BROKER_PORT # -# @TEST-EXEC: btest-bg-run recv "zeek -B broker -b ../recv.zeek >recv.out" -# @TEST-EXEC: btest-bg-run send "zeek -B broker -b ../send.zeek >send.out" +# @TEST-EXEC: btest-bg-run recv "zeek -D -B broker -b ../recv.zeek >recv.out" +# @TEST-EXEC: btest-bg-run send "zeek -D -B broker -b ../send.zeek >send.out" # # @TEST-EXEC: btest-bg-wait 45 # @TEST-EXEC: btest-diff recv/recv.out diff --git a/testing/btest/language/uninitialized-local3.zeek b/testing/btest/language/uninitialized-local3.zeek index b251960633..f3aae38f5b 100644 --- a/testing/btest/language/uninitialized-local3.zeek +++ b/testing/btest/language/uninitialized-local3.zeek @@ -30,5 +30,13 @@ event zeek_init() print x3; local x4: count; - print x4; # note, no execution after this point due to error + # note, no execution after this point due to error + + # We use this slightly baroque expression because compiled code + # may have x4 genuinely uninitialized, and we want deterministic + # output in that case. + if ( x4 > 5 ) + print T; + else + print T; }