Merge remote-tracking branch 'origin/topic/vern/bit-shift-fixes'

* origin/topic/vern/bit-shift-fixes:
  btest portability fix address review comment about shifting corner-case
  canonicalize filenames for new vector deprecation btest
  updates for gen-C++ maintenance, including skipping some inappropriate tests
  fix for profiling "when" statements
  gen-C++ support for vector bit-shift operations
  corrected wording in some btest comments
  make gen-C++ maintenance scripts directly executable
  ZAM support for bit-shifting
  don't allow deprecated-style mixing of vectors and scaling for shifting leverage restrictions placed on shifting (RHS is always unsigned) split deprecated vector operations into separate test, with separate ZAM baseline
  ZAM fix for vector "in" operator
  ensure that language tests pay attention to .stderr
  fix vector tests, including checking for errors
This commit is contained in:
Tim Wojtulewicz 2022-08-03 09:56:37 -07:00
commit 3ffffe33bc
115 changed files with 568 additions and 300 deletions

View file

@ -1,8 +1,10 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
--- Backtrace ---
#0: zeek_init()
--- Backtrace ---
| #0: zeek_init() |
--- Backtrace ---
#0: zeek_init()

View file

@ -0,0 +1,7 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
proto confirm, AllAnalyzers::ANALYZER_ANALYZER_HTTP
http_request, GET, /style/enhanced.css
T
total http messages, {
[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp]] = 1
}

View file

@ -5,16 +5,16 @@ type aliases for 'MyRec val': MyRec MyRecAlias
type aliases for 'MyRecAlias val': MyRec MyRecAlias
type aliases for 'MyRec type': MyRec MyRecAlias
type aliases for 'MyRecalias type': MyRec MyRecAlias
type aliases for 'MyString val': MyString AnotherString
type aliases for 'MyString val': it's just a 'string'
type aliases for 'MyString type': MyString AnotherString
type aliases for 'MyOtherString type': MyOtherString
type aliases for 'AnotherString type': MyString AnotherString
type aliases for 'string literal value': MyString AnotherString
type aliases for 'string literal value': it's just a 'string'
type aliases for 'count literal value': it's just a 'count'
type aliases for 'MyTable value': MyTable2 MyTable3 MyTable MyTable4
type aliases for 'MyTable2 value': MyTable2 MyTable3 MyTable MyTable4
type aliases for 'MyTable3 value': MyTable2 MyTable3 MyTable MyTable4
type aliases for 'MyTable4 value': MyTable2 MyTable3 MyTable MyTable4
type aliases for 'MyTable value': it's just a 'table[count] of string'
type aliases for 'MyTable2 value': it's just a 'table[count] of string'
type aliases for 'MyTable3 value': it's just a 'table[count] of string'
type aliases for 'MyTable4 value': it's just a 'table[count] of string'
type aliases for 'MyTable type': MyTable2 MyTable3 MyTable MyTable4
type aliases for 'MyTable2 type': MyTable2 MyTable3 MyTable MyTable4
type aliases for 'MyTable3 type': MyTable2 MyTable3 MyTable MyTable4

View file

@ -0,0 +1,11 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error in <...>/main.zeek, lines 498-499: Failed to attach master store backend_failure: (Option::set_change_handler(Broker::metrics_export_prefixes, to_any_coerceBroker::update_metrics_export_prefixes, (coerce 0 to int)))
error in <...>/main.zeek, lines 498-499: Could not create Broker master store '../fail' (Option::set_change_handler(Broker::metrics_export_prefixes, to_any_coerceBroker::update_metrics_export_prefixes, (coerce 0 to int)))
error in <no location>: invalid Broker store handle (broker::store::{})
error in <no location>: invalid Broker store handle (broker::store::{})
error in <no location>: invalid Broker store handle (broker::store::{})
error in <no location>: invalid Broker store handle (broker::store::{})
error in <no location>: invalid Broker store handle (broker::store::{})
error in <no location>: invalid Broker store handle (broker::store::{})
error in <no location>: invalid Broker store handle (broker::store::{})
received termination signal

View file

@ -0,0 +1,21 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
T
F
F
F
m1 keys result: [status=Broker::FAILURE, result=[data=<uninitialized>]]
m2 keys result: [status=Broker::SUCCESS, result=[data=broker::data{{}}]]
c2 keys result: [status=Broker::SUCCESS, result=[data=broker::data{{}}]]
T
F
F
F
T
T
T
T
m1 keys result: [status=Broker::FAILURE, result=[data=<uninitialized>]]
c1 keys result: [status=Broker::FAILURE, result=[data=<uninitialized>]]
m2 keys result: [status=Broker::FAILURE, result=[data=<uninitialized>]]
c2 keys result: [status=Broker::FAILURE, result=[data=<uninitialized>]]
c1 timeout

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -1,7 +1,7 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
reporter_info|init test-info||XXXXXXXXXX.XXXXXX
reporter_warning|init test-warning||XXXXXXXXXX.XXXXXX
reporter_error|init test-error||XXXXXXXXXX.XXXXXX
reporter_info|init test-info|<...>/main.zeek, lines 498-499|XXXXXXXXXX.XXXXXX
reporter_warning|init test-warning|<...>/main.zeek, lines 498-499|XXXXXXXXXX.XXXXXX
reporter_error|init test-error|<...>/main.zeek, lines 498-499|XXXXXXXXXX.XXXXXX
reporter_info|done test-info||XXXXXXXXXX.XXXXXX
reporter_warning|done test-warning||XXXXXXXXXX.XXXXXX
reporter_error|done test-error||XXXXXXXXXX.XXXXXX

View file

@ -2,9 +2,9 @@
pre test-info
warning: pre test-warning
error: pre test-error
init test-info
warning: init test-warning
error: init test-error
<...>/main.zeek, lines 498-499: init test-info
warning in <...>/main.zeek, lines 498-499: init test-warning
error in <...>/main.zeek, lines 498-499: init test-error
done test-info
warning: done test-warning
error: done test-error

View file

@ -0,0 +1,15 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
### NOTE: This file has been sorted with diff-sort.
[f(F)]
[f(T)]
[zeek_init()]
f() done, no exception, T
g() done, no exception, T
received termination signal
runtime error in compiled code: field value missing
runtime error in compiled code: field value missing
runtime error in compiled code: field value missing
runtime error in compiled code: field value missing
timeout
timeout g(), F
timeout g(), T

View file

@ -9,5 +9,5 @@ orig=/^?(.*PATTERN.*)$?/ (pattern) clone=/^?(.*PATTERN.*)$?/ (pattern) same_obje
orig=2,5,3,4,1 (set[count]) clone=2,5,3,4,1 (set[count]) equal=T same_object=F (ok)
orig=[1, 2, 3, 4, 5] (vector of count) clone=[1, 2, 3, 4, 5] (vector of count) equal=T same_object=F (ok)
orig=a=va;b=vb (table[string] of string) clone=a=va;b=vb (table[string] of string) equal=T same_object=F (ok)
orig=ENUMME (enum MyEnum) clone=ENUMME (enum MyEnum) equal=T same_object=F (FAIL1)
orig=[s1=s1, s2=s2, i1=[a=a], i2=[a=a], donotset=<uninitialized>, def=5] (record { s1:string; s2:string; i1:record { a:string; }; i2:record { a:string; } &optional; donotset:record { a:string; } &optional; def:count &default=5, &optional; }) clone=[s1=s1, s2=s2, i1=[a=a], i2=[a=a], donotset=<uninitialized>, def=5] (record { s1:string; s2:string; i1:record { a:string; }; i2:record { a:string; } &optional; donotset:record { a:string; } &optional; def:count &default=5, &optional; }) equal=T same_object=F (ok)
orig=ENUMME (MyEnum) clone=ENUMME (MyEnum) equal=T same_object=F (FAIL1)
orig=[s1=s1, s2=s2, i1=[a=a], i2=[a=a], donotset=<uninitialized>, def=5] (TestRecord) clone=[s1=s1, s2=s2, i1=[a=a], i2=[a=a], donotset=<uninitialized>, def=5] (TestRecord) equal=T same_object=F (ok)

View file

@ -1,6 +1,6 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
runtime error in compiled code: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>]
runtime error in compiled code: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>]
runtime error in compiled code: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>]
runtime error in compiled code: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>]
runtime error in compiled code: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>]
runtime error in <...>/queue.zeek, line 152: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>], expression: Queue::ret[Queue::j], call stack:
#0 Queue::get_vector([initialized=T, vals={[2] = test,[3] = [a=T, b=hi, c=<uninitialized>],[5] = 3,[0] = hello,[6] = jkl;,[4] = asdf,[1] = goodbye}, settings=[max_len=<uninitialized>], top=7, bottom=0, size=0], [hello, goodbye, test]) at <...>/main.zeek:498
#1 zeek_init()

View file

@ -1,11 +1,14 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
| Hook Some Info
| Hook error An Error
| Hook error An Error that does not show up in the log
Reporter::Hook - Exercise Reporter Hook (dynamic, version 1.0.0)
Implements Reporter (priority 0)
| Hook Some Info <...>/main.zeek, lines 498-499
| Hook error An Error <...>/main.zeek, lines 498-499
| Hook error An Error that does not show up in the log <...>/main.zeek, lines 498-499
| Hook runtime error in compiled code field value missing
| Hook warning A warning
Some Info
error: An Error
error: An Error that does not show up in the log
| Hook warning A warning <...>/main.zeek, lines 498-499
<...>/main.zeek, lines 498-499: Some Info
error in <...>/main.zeek, lines 498-499: An Error
error in <...>/main.zeek, lines 498-499: An Error that does not show up in the log
runtime error in compiled code: field value missing
warning: A warning
warning in <...>/main.zeek, lines 498-499: A warning

View file

@ -7,8 +7,8 @@
#open XXXX-XX-XX-XX-XX-XX
#fields ts level message location
#types time enum string string
XXXXXXXXXX.XXXXXX Reporter::INFO Some Info (empty)
XXXXXXXXXX.XXXXXX Reporter::WARNING A warning (empty)
XXXXXXXXXX.XXXXXX Reporter::ERROR An Error (empty)
XXXXXXXXXX.XXXXXX Reporter::INFO Some Info <...>/main.zeek, lines 498-499
XXXXXXXXXX.XXXXXX Reporter::WARNING A warning <...>/main.zeek, lines 498-499
XXXXXXXXXX.XXXXXX Reporter::ERROR An Error <...>/main.zeek, lines 498-499
XXXXXXXXXX.XXXXXX Reporter::ERROR field value missing (empty)
#close XXXX-XX-XX-XX-XX-XX

View file

@ -0,0 +1,7 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
all, AllAnalyzers::ANALYZER_ANALYZER_DNS
analyzer, Analyzer::ANALYZER_DNS
all, AllAnalyzers::PACKETANALYZER_ANALYZER_UDP
packet analyzer, PacketAnalyzer::ANALYZER_UDP
all, AllAnalyzers::FILES_ANALYZER_X509
file analyzer, Files::ANALYZER_X509

View file

@ -1,2 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error: file ID asdf not a known file
warning: non-void function returning without a value: Files::lookup_file

View file

@ -0,0 +1,7 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
warning in /Users/vern/warehouse/zeek/zeek-master.29Jul22/testing/btest/.tmp/language.vector-deprecated/vector-deprecated.zeek, line 18: mixing vector and scalar operands is deprecated (vector) (string)
warning in /Users/vern/warehouse/zeek/zeek-master.29Jul22/testing/btest/.tmp/language.vector-deprecated/vector-deprecated.zeek, line 21: mixing vector and scalar operands is deprecated (string) (vector)
warning in /Users/vern/warehouse/zeek/zeek-master.29Jul22/testing/btest/.tmp/language.vector-deprecated/vector-deprecated.zeek, line 24: mixing vector and scalar operands is deprecated (string) (vector)
error: deprecated mixed vector/scalar operation not supported for ZAM compiling
error: deprecated mixed vector/scalar operation not supported for ZAM compiling
error: deprecated mixed vector/scalar operation not supported for ZAM compiling

View file

@ -0,0 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
+ operator [string] (PASS)
== operator [string] (PASS)
== operator [string] (PASS)

View file

@ -1,10 +1,10 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
1 <...>/coverage-blacklist.zeek, line 13 print cover me;
1 <...>/coverage-blacklist.zeek, line 15 if (T) { print always executed; }
1 <...>/coverage-blacklist.zeek, line 17 print always executed;
1 <...>/coverage-blacklist.zeek, line 22 if (0 + 0 == 1) print impossible;
1 <...>/coverage-blacklist.zeek, line 24 if (1 == 0) { print also impossible, but included in code coverage analysis; }
0 <...>/coverage-blacklist.zeek, line 26 print also impossible, but included in code coverage analysis;
1 <...>/coverage-blacklist.zeek, line 29 print success;
1 <...>/coverage-blacklist.zeek, line 5 print first;
1 <...>/coverage-blacklist.zeek, line 7 if (F) { print hello; print world; }
1 <...>/coverage-blacklist.zeek, line 10 if (F) { print hello; print world; }
1 <...>/coverage-blacklist.zeek, line 16 print cover me;
1 <...>/coverage-blacklist.zeek, line 18 if (T) { print always executed; }
1 <...>/coverage-blacklist.zeek, line 20 print always executed;
1 <...>/coverage-blacklist.zeek, line 25 if (0 + 0 == 1) print impossible;
1 <...>/coverage-blacklist.zeek, line 27 if (1 == 0) { print also impossible, but included in code coverage analysis; }
0 <...>/coverage-blacklist.zeek, line 29 print also impossible, but included in code coverage analysis;
1 <...>/coverage-blacklist.zeek, line 32 print success;
1 <...>/coverage-blacklist.zeek, line 8 print first;

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -1,2 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
expression error in <...>/common-mistakes2.zeek, line 16: type-checking failed in vector append (v += ok)
expression error in <...>/common-mistakes2.zeek, line 17: type-checking failed in vector append (v += ok)

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -1,2 +1,2 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
warning: please_warn assignment unused: please_warn = test; <...>/unused-assignment.zeek, line 7
warning: please_warn assignment unused: please_warn = test; <...>/unused-assignment.zeek, line 10

View file

@ -0,0 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
warning in <...>/vector-deprecated.zeek, line 18: mixing vector and scalar operands is deprecated (vector) (string)
warning in <...>/vector-deprecated.zeek, line 21: mixing vector and scalar operands is deprecated (string) (vector)
warning in <...>/vector-deprecated.zeek, line 24: mixing vector and scalar operands is deprecated (string) (vector)

View file

@ -0,0 +1,4 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
+ operator [string] (PASS)
== operator [string] (PASS)
== operator [string] (PASS)

View file

@ -0,0 +1 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.

View file

@ -60,9 +60,6 @@ access element (PASS)
/ operator (PASS)
% operator (PASS)
+ operator [string] (PASS)
+ operator [string] (PASS)
== operator [string] (PASS)
== operator [string] (PASS)
== operator [string] (PASS)
&& operator (PASS)
|| operator (PASS)
@ -81,3 +78,5 @@ copy of a vector with holes (PASS)
copy of a vector with trailing holes, [0, 2, 3, 77, , ], [0, 2, 3, 77, , ]
hole in vector of managed types, 5, [[a=T], [a=T], , , [a=T]]
hole in vector of managed types after replacing slice, 3, [[a=T], [a=T], ]
left shift (PASS)
right shift (PASS)

View file

@ -4,7 +4,11 @@
global cmds = "print \"hello world\";";
cmds = string_cat(cmds, "\nprint \"foobar\";");
if ( piped_exec("zeek", cmds) != T )
# If we're using generated C++, turn that off for the pipe execution,
# as otherwise we'll get a complaint that there's no corresponding
# C++ bodies found for that zeek instance.
if ( piped_exec("unset ZEEK_USE_CPP; zeek", cmds) != T )
exit(1);
# Test null output.

View file

@ -1,5 +1,8 @@
# This tests Zeek's mechanism to prevent duplicate script loading.
#
# Don't run for C++ scripts, since it doesn't actually do anything and that
# leads to complaints that there are no scripts.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: mkdir -p foo/bar
# @TEST-EXEC: echo "@load bar/test" >loader.zeek
# @TEST-EXEC: cp %INPUT foo/bar/test.zeek

View file

@ -1,4 +1,9 @@
# This verifies Zeek's ability to load scripts from stdin.
#
# Don't run for C++ scripts because the multiple invocations lead to
# some runs having complaints that there are no scripts.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
#
# @TEST-EXEC: echo 'print "stdin";' | zeek -b >output.implicit
# @TEST-EXEC: echo 'print "stdin";' | zeek -b - >output.explicit
# @TEST-EXEC: echo 'print "stdin";' | zeek -b %INPUT >output.nostdin

View file

@ -3,6 +3,10 @@
# greps to validate that we got a syntax error in the output with the string that we passed
# as a filter.
# Don't run for C++ scripts, since first invocation doesn't use the input
# and hence leads to complaints that there are no scripts.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
#
# @TEST-EXEC-FAIL: zeek -r $TRACES/workshop_2011_browse.trace -f "kaputt" >output 2>&1
# @TEST-EXEC-FAIL: test -e conn.log
# @TEST-EXEC: grep "kaputt" output | grep -q "syntax error"

View file

@ -1,3 +1,7 @@
# Don't run for C++ scripts, since script invocation of Zeek hashes
# the script differently, leading to complaints that there are no scripts.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: printf '#!' > test.zeek
# @TEST-EXEC: printf "$BUILD/src/zeek -b --\n" >> test.zeek
# @TEST-EXEC: cat %INPUT >> test.zeek

View file

@ -1,3 +1,6 @@
# Don't run for C++ scripts, since they aren't compatible with interpreter-level
# coverage analysis.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: ZEEK_PROFILER_FILE=coverage zeek -b %INPUT
# @TEST-EXEC: grep %INPUT coverage | sort -k2 >output
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output

View file

@ -1,3 +1,6 @@
# Don't run for C++ scripts, they're not compatible.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# Shouldn't emit any warnings about not being able to document something
# that's supplied via command line script.

View file

@ -1,20 +1,33 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
# IPv4 addresses
global a1: addr = 0.0.0.0;
global a2: addr = 10.0.0.11;
global a3: addr = 255.255.255.255;
global a4 = 192.1.2.3;
# IPv6 addresses
global b1: addr = [::];
global b2: addr = [::255.255.255.255];
global b3: addr = [::ffff:ffff];
global b4: addr = [ffff::ffff];
global b5: addr = [0000:0000:0000:0000:0000:0000:0000:0000];
global b6: addr = [aaaa:bbbb:cccc:dddd:eeee:ffff:1111:2222];
global b7: addr = [AAAA:BBBB:CCCC:DDDD:EEEE:FFFF:1111:2222];
global b9 = [2001:db8:0:0:0:FFFF:192.168.0.5];
# IPv4-mapped-IPv6 (internally treated as IPv4)
global c1: addr = [::ffff:1.2.3.4];
event zeek_init()
{
# IPv4 addresses
local a1: addr = 0.0.0.0;
local a2: addr = 10.0.0.11;
local a3: addr = 255.255.255.255;
local a4 = 192.1.2.3;
test_case( "IPv4 address inequality", a1 != a2 );
test_case( "IPv4 address equality", a1 == 0.0.0.0 );
test_case( "IPv4 address comparison", a1 < a2 );
@ -22,16 +35,7 @@ event zeek_init()
test_case( "size of IPv4 address", |a1| == 32 );
test_case( "IPv4 address type inference", type_name(a4) == "addr" );
# IPv6 addresses
local b1: addr = [::];
local b2: addr = [::255.255.255.255];
local b3: addr = [::ffff:ffff];
local b4: addr = [ffff::ffff];
local b5: addr = [0000:0000:0000:0000:0000:0000:0000:0000];
local b6: addr = [aaaa:bbbb:cccc:dddd:eeee:ffff:1111:2222];
local b7: addr = [AAAA:BBBB:CCCC:DDDD:EEEE:FFFF:1111:2222];
local b8 = [a::b];
local b9 = [2001:db8:0:0:0:FFFF:192.168.0.5];
test_case( "IPv6 address inequality", b1 != b2 );
test_case( "IPv6 address equality", b1 == b5 );
@ -44,9 +48,6 @@ event zeek_init()
test_case( "IPv4 and IPv6 address inequality", a1 != b1 );
# IPv4-mapped-IPv6 (internally treated as IPv4)
local c1: addr = [::ffff:1.2.3.4];
test_case( "IPv4-mapped-IPv6 equality to IPv4", c1 == 1.2.3.4 );
test_case( "IPv4-mapped-IPv6 is IPv4", is_v4_addr(c1) == T );
}

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -11,12 +12,12 @@ function anyarg(arg1: any, arg1type: string)
test_case( arg1type, type_name(arg1) == arg1type );
}
global any1: any = 5;
global any2: any = "bar";
global any3: any = /bar/;
event zeek_init()
{
local any1: any = 5;
local any2: any = "bar";
local any3: any = /bar/;
# Test using variable of type "any"
anyarg( any1, "count" );

View file

@ -1,5 +1,7 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
# Check if @if can be used to alternative function/event definitions
@if ( 1==1 )

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -10,11 +11,10 @@ function foo(c: count): bool
{ return c == 42 ? T : F; }
global TRUE_CONDITION = T;
global xyz = 0;
event zeek_init()
{
local xyz = 0;
# Test "if" without "else"
@if ( F )

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -7,11 +8,10 @@ function test_case(msg: string, expect: bool)
}
global thisisdefined = 123;
global xyz = 0;
event zeek_init()
{
local xyz = 0;
# Test "ifdef" without "else"
@ifdef ( notdefined )

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -7,11 +8,10 @@ function test_case(msg: string, expect: bool)
}
global thisisdefined = 123;
global xyz = 0;
event zeek_init()
{
local xyz = 0;
# Test "ifndef" without "else"
@ifndef ( notdefined )

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
# In this script, we try to access each object defined in a "@load"ed script

View file

@ -1,20 +1,20 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global b1: bool = T;
global b2: bool = F;
global b3: bool = T;
global b4 = T;
global b5 = F;
event zeek_init()
{
local b1: bool = T;
local b2: bool = F;
local b3: bool = T;
local b4 = T;
local b5 = F;
test_case( "equality operator", b1 == b3 );
test_case( "inequality operator", b1 != b2 );
test_case( "logical or operator", b1 || b2 );

View file

@ -1,9 +1,10 @@
# A companion to language/common-mistakes.zeek. Split off because we skip
# this test when using ZAM, since it employs a type-checking violation via
# vector-of-any, which doesn't seem worth going out of our way to support
# in ZAM (and it isn't dead simple to do so).
# this test when using script optimization, since it employs a type-checking
# violation via vector-of-any, which doesn't seem worth going out of our way
# to support for script optimization.
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -b %INPUT >out 2>err
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -25,13 +26,17 @@ function f2(): bool
# value is constant.
global false = F;
global a: count;
global b: count;
global res: count;
global res2: bool;
global s: set[string] = { "one", "two", "three" };
global t: table[count] of string = { [1] = "one", [2] = "two", [3] = "three" };
global v: vector of string = { "one", "two", "three" };
event zeek_init()
{
local a: count;
local b: count;
local res: count;
local res2: bool;
# Test that the correct operand is evaluated
a = b = 0;
@ -67,21 +72,18 @@ event zeek_init()
test_case( "associativity", ct == 2 );
# Test for unspecified set coercion
local s: set[string] = { "one", "two", "three" };
local sT = T ? set() : s;
local sF = F ? s : set();
print |sT|, type_name(sT);
print |sF|, type_name(sF);
# Test for unspecified table coercion
local t: table[count] of string = { [1] = "one", [2] = "two", [3] = "three" };
local tT = T ? table() : t;
local tF = F ? t : table();
print |tT|, type_name(tT);
print |tF|, type_name(tF);
# Test for unspecified vector coercion
local v: vector of string = { "one", "two", "three" };
local vT = T ? vector() : v;
local vF = F ? v : vector();
print |vT|, type_name(vT);

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,27 +1,25 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global c1: count = 0;
global c2: count = 5;
global c3: count = 0xFF;
global c4: count = 255;
global c5: count = 18446744073709551615; # maximum allowed value
global c6: count = 0xffffffffffffffff; # maximum allowed value
global c7 = 1;
event zeek_init()
{
local c1: count = 0;
local c2: count = 5;
local c3: count = 0xFF;
local c4: count = 255;
local c5: count = 18446744073709551615; # maximum allowed value
local c6: count = 0xffffffffffffffff; # maximum allowed value
local c7 = 1;
# Type inference test
test_case( "type inference", type_name(c7) == "count" );
# Test various constant representations
test_case( "hexadecimal", c3 == c4 );
@ -60,6 +58,5 @@ event zeek_init()
test_case( str1, str1 == "max count value = 18446744073709551615" );
local str2 = fmt("max count value = %d", c6);
test_case( str2, str2 == "max count value = 18446744073709551615" );
}

View file

@ -1,37 +1,37 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global d1: double = 3;
global d2: double = +3;
global d3: double = 3.;
global d4: double = 3.0;
global d5: double = +3.0;
global d6: double = 3e0;
global d7: double = 3E0;
global d8: double = 3e+0;
global d9: double = 3e-0;
global d10: double = 3.0e0;
global d11: double = +3.0e0;
global d12: double = +3.0e+0;
global d13: double = +3.0E+0;
global d14: double = +3.0E-0;
global d15: double = .03E+2;
global d16: double = .03E2;
global d17: double = 3.0001;
global d18: double = -3.0001;
global d19: double = 1.7976931348623157e308; # maximum allowed value
global d20 = 7.0;
global d21 = 7e0;
global d22 = 7e+1;
event zeek_init()
{
local d1: double = 3;
local d2: double = +3;
local d3: double = 3.;
local d4: double = 3.0;
local d5: double = +3.0;
local d6: double = 3e0;
local d7: double = 3E0;
local d8: double = 3e+0;
local d9: double = 3e-0;
local d10: double = 3.0e0;
local d11: double = +3.0e0;
local d12: double = +3.0e+0;
local d13: double = +3.0E+0;
local d14: double = +3.0E-0;
local d15: double = .03E+2;
local d16: double = .03E2;
local d17: double = 3.0001;
local d18: double = -3.0001;
local d19: double = 1.7976931348623157e308; # maximum allowed value
local d20 = 7.0;
local d21 = 7e0;
local d22 = 7e+1;
# Type inference tests
test_case( "type inference", type_name(d20) == "double" );

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -13,20 +14,19 @@ type color: enum { Red, White, Blue, };
# enum without optional comma
type city: enum { Rome, Paris };
global e1: color = Blue;
global e2: color = White;
global e3: color = Blue;
global e4: city = Rome;
global x = Blue;
event zeek_init()
{
local e1: color = Blue;
local e2: color = White;
local e3: color = Blue;
local e4: city = Rome;
test_case( "enum equality comparison", e1 != e2 );
test_case( "enum equality comparison", e1 == e3 );
test_case( "enum equality comparison", e1 != e4 );
# type inference
local x = Blue;
test_case( "type inference", x == e1 );
}

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,30 +1,30 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global i1: int = 3;
global i2: int = +3;
global i3: int = -3;
global i4: int = +0;
global i5: int = -0;
global i6: int = 12;
global i7: int = +0xc;
global i8: int = 0xC;
global i9: int = -0xC;
global i10: int = -12;
global i11: int = 9223372036854775807; # max. allowed value
global i12: int = -9223372036854775808; # min. allowed value
global i13: int = 0x7fffffffffffffff; # max. allowed value
global i14: int = -0x8000000000000000; # min. allowed value
global i15 = +3;
event zeek_init()
{
local i1: int = 3;
local i2: int = +3;
local i3: int = -3;
local i4: int = +0;
local i5: int = -0;
local i6: int = 12;
local i7: int = +0xc;
local i8: int = 0xC;
local i9: int = -0xC;
local i10: int = -12;
local i11: int = 9223372036854775807; # max. allowed value
local i12: int = -9223372036854775808; # min. allowed value
local i13: int = 0x7fffffffffffffff; # max. allowed value
local i14: int = -0x8000000000000000; # min. allowed value
local i15 = +3;
# Type inference test
test_case( "type inference", type_name(i15) == "int" );
@ -67,5 +67,4 @@ event zeek_init()
test_case( str3, str3 == "max int value = 9223372036854775807" );
local str4 = fmt("min int value = %d", i14);
test_case( str4, str4 == "min int value = -9223372036854775808" );
}

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -12,41 +13,39 @@ function approx_equal(x: double, y: double): bool
return |(x - y)/x| < 1e-6 ? T : F;
}
# Constants without space and no letter "s"
global in11: interval = 2usec;
global in12: interval = 2msec;
global in13: interval = 120sec;
global in14: interval = 2min;
global in15: interval = -2hr;
global in16: interval = 2.5day;
# Constants with space and no letter "s"
global in21: interval = 2 usec;
global in22: interval = 2 msec;
global in23: interval = 120 sec;
global in24: interval = 2 min;
global in25: interval = -2 hr;
global in26: interval = 2.5 day;
# Constants with space and letter "s"
global in31: interval = 2 usecs;
global in32: interval = 2 msecs;
global in33: interval = 1.2e2 secs;
global in34: interval = 2 mins;
global in35: interval = -2 hrs;
global in36: interval = 2.5 days;
# Type inference
global in41 = 2 usec;
global in42 = 2.1usec;
global in43 = 3usecs;
event zeek_init()
{
# Constants without space and no letter "s"
local in11: interval = 2usec;
local in12: interval = 2msec;
local in13: interval = 120sec;
local in14: interval = 2min;
local in15: interval = -2hr;
local in16: interval = 2.5day;
# Constants with space and no letter "s"
local in21: interval = 2 usec;
local in22: interval = 2 msec;
local in23: interval = 120 sec;
local in24: interval = 2 min;
local in25: interval = -2 hr;
local in26: interval = 2.5 day;
# Constants with space and letter "s"
local in31: interval = 2 usecs;
local in32: interval = 2 msecs;
local in33: interval = 1.2e2 secs;
local in34: interval = 2 mins;
local in35: interval = -2 hrs;
local in36: interval = 2.5 days;
# Type inference
local in41 = 2 usec;
local in42 = 2.1usec;
local in43 = 3usecs;
# Type inference tests
test_case( "type inference", type_name(in41) == "interval" );

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT secondtestfile >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
# In this source file, we define a module and export some objects

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT secondtestfile >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
# This is the same test as "module.zeek", but here we omit the module definition

View file

@ -1,19 +1,19 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global p1: pattern = /foo|bar/;
global p2: pattern = /oob/;
global p3: pattern = /^oob/;
global p4 = /foo/;
event zeek_init()
{
local p1: pattern = /foo|bar/;
local p2: pattern = /oob/;
local p3: pattern = /^oob/;
local p4 = /foo/;
# Type inference tests
test_case( "type inference", type_name(p4) == "pattern" );

View file

@ -1,26 +1,26 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global p1: port = 1/icmp;
global p2: port = 2/udp;
global p3: port = 3/tcp;
global p4: port = 4/unknown;
global p5 = 123/tcp;
# maximum allowed values for each port type
global p6: port = 255/icmp;
global p7: port = 65535/udp;
global p8: port = 65535/tcp;
global p9: port = 255/unknown;
event zeek_init()
{
local p1: port = 1/icmp;
local p2: port = 2/udp;
local p3: port = 3/tcp;
local p4: port = 4/unknown;
local p5 = 123/tcp;
# maximum allowed values for each port type
local p6: port = 255/icmp;
local p7: port = 65535/udp;
local p8: port = 65535/tcp;
local p9: port = 255/unknown;
# Type inference test
test_case( "type inference", type_name(p5) == "port" );

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -9,12 +10,16 @@ function test_case(msg: string, expect: bool)
# This is an incomplete set of tests to demonstrate the order of precedence
# of zeek script operators
global n1: int;
global n2: int;
global n3: int;
global r1: bool;
global r2: bool;
global r3: bool;
event zeek_init()
{
local n1: int;
local n2: int;
local n3: int;
# Tests that show "++" has higher precedence than "*"
n1 = n2 = 5;
@ -70,10 +75,6 @@ event zeek_init()
test_case( "+= and +", n2 == 3 );
test_case( "+= and +", n3 == 1 );
local r1: bool;
local r2: bool;
local r3: bool;
# Tests that show "&&" has higher precedence than "||"
r1 = F && F || T;

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,36 +1,36 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
global s1: string = "a\ty"; # tab
global s2: string = "a\nb"; # newline
global s3: string = "a\"b"; # double quote
global s4: string = "a\\b"; # backslash
global s5: string = "a\x9y"; # 1-digit hex value (tab character)
global s6: string = "a\x0ab"; # 2-digit hex value (newline character)
global s7: string = "a\x22b"; # 2-digit hex value (double quote)
global s8: string = "a\x00b"; # 2-digit hex value (null character)
global s9: string = "a\011y"; # 3-digit octal value (tab character)
global s10: string = "a\12b"; # 2-digit octal value (newline character)
global s11: string = "a\0b"; # 1-digit octal value (null character)
global s20: string = "";
global s21: string = "x";
global s22: string = s21 + s11;
global s23: string = "test";
global s24: string = "this is a very long string" +
"which continues on the next line" +
"the end";
global s25: string = "on";
global s26 = "x";
event zeek_init()
{
local s1: string = "a\ty"; # tab
local s2: string = "a\nb"; # newline
local s3: string = "a\"b"; # double quote
local s4: string = "a\\b"; # backslash
local s5: string = "a\x9y"; # 1-digit hex value (tab character)
local s6: string = "a\x0ab"; # 2-digit hex value (newline character)
local s7: string = "a\x22b"; # 2-digit hex value (double quote)
local s8: string = "a\x00b"; # 2-digit hex value (null character)
local s9: string = "a\011y"; # 3-digit octal value (tab character)
local s10: string = "a\12b"; # 2-digit octal value (newline character)
local s11: string = "a\0b"; # 1-digit octal value (null character)
local s20: string = "";
local s21: string = "x";
local s22: string = s21 + s11;
local s23: string = "test";
local s24: string = "this is a very long string" +
"which continues on the next line" +
"the end";
local s25: string = "on";
local s26 = "x";
# Type inference test
test_case( "type inference", type_name(s26) == "string" );

View file

@ -1,39 +1,42 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
# IPv4 addr
global a1: addr = 192.1.2.3;
# IPv4 subnets
global s1: subnet = 0.0.0.0/0;
global s2: subnet = 192.0.0.0/8;
global s3: subnet = 255.255.255.255/32;
global s4 = 10.0.0.0/16;
# IPv6 addrs
global b1: addr = [ffff::];
global b2: addr = [ffff::1];
global b3: addr = [ffff:1::1];
# IPv6 subnets
global t1: subnet = [::]/0;
global t2: subnet = [ffff::]/64;
global t3 = [a::]/32;
# IPv4-mapped-IPv6 subnets
global u1: subnet = [::ffff:0:0]/96;
event zeek_init()
{
# IPv4 addr
local a1: addr = 192.1.2.3;
# IPv4 subnets
local s1: subnet = 0.0.0.0/0;
local s2: subnet = 192.0.0.0/8;
local s3: subnet = 255.255.255.255/32;
local s4 = 10.0.0.0/16;
test_case( "IPv4 subnet equality", a1/8 == s2 );
test_case( "IPv4 subnet inequality", a1/4 != s2 );
test_case( "IPv4 subnet in operator", a1 in s2 );
test_case( "IPv4 subnet !in operator", a1 !in s3 );
test_case( "IPv4 subnet type inference", type_name(s4) == "subnet" );
# IPv6 addrs
local b1: addr = [ffff::];
local b2: addr = [ffff::1];
local b3: addr = [ffff:1::1];
# IPv6 subnets
local t1: subnet = [::]/0;
local t2: subnet = [ffff::]/64;
local t3 = [a::]/32;
test_case( "IPv6 subnet equality", b1/64 == t2 );
test_case( "IPv6 subnet inequality", b3/64 != t2 );
test_case( "IPv6 subnet in operator", b2 in t2 );
@ -43,9 +46,6 @@ event zeek_init()
test_case( "IPv4 and IPv6 subnet inequality", s1 != t1 );
test_case( "IPv4 address and IPv6 subnet", a1 !in t2 );
# IPv4-mapped-IPv6 subnets
local u1: subnet = [::ffff:0:0]/96;
test_case( "IPv4 in IPv4-mapped-IPv6 subnet", 1.2.3.4 in u1 );
test_case( "IPv6 !in IPv4-mapped-IPv6 subnet", [fe80::1] !in u1 );
test_case( "IPv4-mapped-IPv6 in IPv4-mapped-IPv6 subnet",

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{

View file

@ -1,3 +1,6 @@
# Don't run for C++ scripts, they don't do this analysis at run-time.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: ZEEK_USAGE_ISSUES=1 zeek -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
# @TEST-DOC: The "-u" flag should warn about unused assignments and &is_used suppresses it.

View file

@ -0,0 +1,27 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
event zeek_init()
{
local v6 = vector( 10, 20, 30 );
local v16 = v6;
v16 += 40;
local vs1 = vector( "foo", "bar" );
local vss2 = vs1 + "@";
test_case( "+ operator [string]", vss2[0] == "foo@" && vss2[1] == "bar@" );
local vss4 = (vs1 == "bar");
test_case( "== operator [string]", vss4[0] == F && vss4[1] == T );
local vss5 = ("bar" == vs1);
test_case( "== operator [string]", vss5[0] == F && vss5[1] == T );
# !=, <, >, <=, >= are handled the same as ==, skipping tests
}

View file

@ -1,5 +1,6 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
# @TEST-EXEC: btest-diff .stderr
function test_case(msg: string, expect: bool)
{
@ -169,19 +170,9 @@ event zeek_init()
local vss = vs1 + vs2;
test_case( "+ operator [string]", vss[0] == "fooxxx" && vss[1] == "baryyy" );
local vss2 = vs1 + "@";
test_case( "+ operator [string]", vss2[0] == "foo@" && vss2[1] == "bar@" );
local vss3 = (vs1 == vs3);
test_case( "== operator [string]", vss3[0] == F && vss3[1] == T );
local vss4 = (vs1 == "bar");
test_case( "== operator [string]", vss4[0] == F && vss4[1] == T );
local vss5 = ("bar" == vs1);
test_case( "== operator [string]", vss5[0] == F && vss5[1] == T );
# !=, <, >, <=, >= are handled the same as ==, skipping tests
# Test &&,|| of two vectors
test_case( "&& operator", v14[0] == F && v14[1] == F && v14[2] == T );
@ -227,8 +218,9 @@ event zeek_init()
print "hole in vector of managed types after replacing slice", |v21|, v21;
# Test << and >> operators.
local v22 = v6 << 1;
local v23 = v6 >> 1;
test_case( "left shift", all_set(v22 == vector(20, 40, 60)) );
test_case( "right shift", all_set(v23 == vector(5, 10, 15)) );
local four_ones = vector(1, 1, 1, 1);
local v22 = v6 << four_ones;
local v23 = v6 >> four_ones;
test_case( "left shift", all_set(v22 == vector(20, 40, 60, 80)) );
test_case( "right shift", all_set(v23 == vector(5, 10, 15, 20)) );
}

View file

@ -1,7 +1,7 @@
# @TEST-EXEC: zeek -b -O ZAM --optimize-func='my_test' %INPUT >output
# @TEST-EXEC: btest-diff output
# Tests that we can selectively a given function.
# Tests that we can selectively pick a given function.
function my_test()
{

View file

@ -1,7 +1,7 @@
# @TEST-EXEC: zeek -b -O ZAM --optimize-func='another_test' %INPUT >output
# @TEST-EXEC: btest-diff output
# Tests that we can selectively a bunch of functions (event handlers),
# Tests that we can selectively pick a bunch of functions (event handlers),
# but not every function.
function my_test()

View file

@ -1,7 +1,7 @@
# @TEST-EXEC: zeek -b -O ZAM --optimize-func='my_test' --optimize-func='another_test' %INPUT >output
# @TEST-EXEC: btest-diff output
# Tests that we can selectively a bunch of functions (event handlers),
# Tests that we can selectively pick a bunch of functions (event handlers),
# and also call out an additional function.
function my_test()

View file

@ -1,4 +1,7 @@
#
# Don't run for C++ scripts because the multiple invocations lead to
# some runs having complaints that there are no scripts.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -b -r ${TRACES}/ssh/ssh-on-port-80.trace %INPUT dpd_buffer_size=0 base/protocols/conn base/protocols/ssh base/frameworks/dpd
# @TEST-EXEC: cat conn.log | zeek-cut service | grep -q ssh
#

View file

@ -1,3 +1,7 @@
# Don't run for C++ scripts because the multiple invocations lead to
# some runs having complaints that there are no scripts.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -b -C -r $TRACES/http/multipart.trace base/protocols/http
# @TEST-EXEC: btest-diff http.log
# @TEST-EXEC: zeek -b -C -r $TRACES/http/multipart.trace base/protocols/http %INPUT >out-limited

View file

@ -1,3 +1,6 @@
# Don't run for C++ scripts because there's no script to compile.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -C -r $TRACES/smb/smb2.delete-on-close-perms-delete-existing.pcap policy/protocols/smb/log-cmds
# @TEST-EXEC: btest-diff smb_files.log
# @TEST-EXEC: btest-diff smb_cmd.log

View file

@ -1,5 +1,8 @@
# A basic test of the known-hosts script's logging and asset_tracking options
# Don't run for C++ scripts because there's no script to compile.
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
# @TEST-EXEC: zeek -b -r $TRACES/wikipedia.trace %INPUT Known::host_tracking=LOCAL_HOSTS
# @TEST-EXEC: mv known_hosts.log knownhosts-local.log
# @TEST-EXEC: btest-diff knownhosts-local.log

Some files were not shown because too many files have changed in this diff Show more