mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
ensure that language tests pay attention to .stderr
This commit is contained in:
parent
8d3265d540
commit
5569d81953
58 changed files with 243 additions and 201 deletions
1
testing/btest/Baseline/language.addr/.stderr
Normal file
1
testing/btest/Baseline/language.addr/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.any/.stderr
Normal file
1
testing/btest/Baseline/language.any/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.at-if-event/.stderr
Normal file
1
testing/btest/Baseline/language.at-if-event/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.at-if/.stderr
Normal file
1
testing/btest/Baseline/language.at-if/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.at-ifdef/.stderr
Normal file
1
testing/btest/Baseline/language.at-ifdef/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.at-ifndef/.stderr
Normal file
1
testing/btest/Baseline/language.at-ifndef/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.at-load/.stderr
Normal file
1
testing/btest/Baseline/language.at-load/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.bool/.stderr
Normal file
1
testing/btest/Baseline/language.bool/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.copy/.stderr
Normal file
1
testing/btest/Baseline/language.copy/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.count/.stderr
Normal file
1
testing/btest/Baseline/language.count/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.double/.stderr
Normal file
1
testing/btest/Baseline/language.double/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.enum/.stderr
Normal file
1
testing/btest/Baseline/language.enum/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.for/.stderr
Normal file
1
testing/btest/Baseline/language.for/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.function/.stderr
Normal file
1
testing/btest/Baseline/language.function/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.if/.stderr
Normal file
1
testing/btest/Baseline/language.if/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.int/.stderr
Normal file
1
testing/btest/Baseline/language.int/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.interval/.stderr
Normal file
1
testing/btest/Baseline/language.interval/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.module/.stderr
Normal file
1
testing/btest/Baseline/language.module/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.no-module/.stderr
Normal file
1
testing/btest/Baseline/language.no-module/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.pattern/.stderr
Normal file
1
testing/btest/Baseline/language.pattern/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.port/.stderr
Normal file
1
testing/btest/Baseline/language.port/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.precedence/.stderr
Normal file
1
testing/btest/Baseline/language.precedence/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.set/.stderr
Normal file
1
testing/btest/Baseline/language.set/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.short-circuit/.stderr
Normal file
1
testing/btest/Baseline/language.short-circuit/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.string/.stderr
Normal file
1
testing/btest/Baseline/language.string/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.subnet/.stderr
Normal file
1
testing/btest/Baseline/language.subnet/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.table/.stderr
Normal file
1
testing/btest/Baseline/language.table/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
1
testing/btest/Baseline/language.time/.stderr
Normal file
1
testing/btest/Baseline/language.time/.stderr
Normal file
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
|
@ -1,20 +1,33 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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 inequality", a1 != a2 );
|
||||||
test_case( "IPv4 address equality", a1 == 0.0.0.0 );
|
test_case( "IPv4 address equality", a1 == 0.0.0.0 );
|
||||||
test_case( "IPv4 address comparison", a1 < a2 );
|
test_case( "IPv4 address comparison", a1 < a2 );
|
||||||
|
@ -22,16 +35,7 @@ event zeek_init()
|
||||||
test_case( "size of IPv4 address", |a1| == 32 );
|
test_case( "size of IPv4 address", |a1| == 32 );
|
||||||
test_case( "IPv4 address type inference", type_name(a4) == "addr" );
|
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 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 inequality", b1 != b2 );
|
||||||
test_case( "IPv6 address equality", b1 == b5 );
|
test_case( "IPv6 address equality", b1 == b5 );
|
||||||
|
@ -44,9 +48,6 @@ event zeek_init()
|
||||||
|
|
||||||
test_case( "IPv4 and IPv6 address inequality", a1 != b1 );
|
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 equality to IPv4", c1 == 1.2.3.4 );
|
||||||
test_case( "IPv4-mapped-IPv6 is IPv4", is_v4_addr(c1) == T );
|
test_case( "IPv4-mapped-IPv6 is IPv4", is_v4_addr(c1) == T );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
@ -11,12 +12,12 @@ function anyarg(arg1: any, arg1type: string)
|
||||||
test_case( arg1type, type_name(arg1) == arg1type );
|
test_case( arg1type, type_name(arg1) == arg1type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global any1: any = 5;
|
||||||
|
global any2: any = "bar";
|
||||||
|
global any3: any = /bar/;
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local any1: any = 5;
|
|
||||||
local any2: any = "bar";
|
|
||||||
local any3: any = /bar/;
|
|
||||||
|
|
||||||
# Test using variable of type "any"
|
# Test using variable of type "any"
|
||||||
|
|
||||||
anyarg( any1, "count" );
|
anyarg( any1, "count" );
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
# Check if @if can be used to alternative function/event definitions
|
# Check if @if can be used to alternative function/event definitions
|
||||||
|
|
||||||
@if ( 1==1 )
|
@if ( 1==1 )
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
@ -10,11 +11,10 @@ function foo(c: count): bool
|
||||||
{ return c == 42 ? T : F; }
|
{ return c == 42 ? T : F; }
|
||||||
|
|
||||||
global TRUE_CONDITION = T;
|
global TRUE_CONDITION = T;
|
||||||
|
global xyz = 0;
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local xyz = 0;
|
|
||||||
|
|
||||||
# Test "if" without "else"
|
# Test "if" without "else"
|
||||||
|
|
||||||
@if ( F )
|
@if ( F )
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
@ -7,11 +8,10 @@ function test_case(msg: string, expect: bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
global thisisdefined = 123;
|
global thisisdefined = 123;
|
||||||
|
global xyz = 0;
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local xyz = 0;
|
|
||||||
|
|
||||||
# Test "ifdef" without "else"
|
# Test "ifdef" without "else"
|
||||||
|
|
||||||
@ifdef ( notdefined )
|
@ifdef ( notdefined )
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
@ -7,11 +8,10 @@ function test_case(msg: string, expect: bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
global thisisdefined = 123;
|
global thisisdefined = 123;
|
||||||
|
global xyz = 0;
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local xyz = 0;
|
|
||||||
|
|
||||||
# Test "ifndef" without "else"
|
# Test "ifndef" without "else"
|
||||||
|
|
||||||
@ifndef ( notdefined )
|
@ifndef ( notdefined )
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff 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
|
# In this script, we try to access each object defined in a "@load"ed script
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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( "equality operator", b1 == b3 );
|
||||||
test_case( "inequality operator", b1 != b2 );
|
test_case( "inequality operator", b1 != b2 );
|
||||||
test_case( "logical or operator", b1 || b2 );
|
test_case( "logical or operator", b1 || b2 );
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
@ -25,13 +26,17 @@ function f2(): bool
|
||||||
# value is constant.
|
# value is constant.
|
||||||
global false = F;
|
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()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local a: count;
|
|
||||||
local b: count;
|
|
||||||
local res: count;
|
|
||||||
local res2: bool;
|
|
||||||
|
|
||||||
# Test that the correct operand is evaluated
|
# Test that the correct operand is evaluated
|
||||||
|
|
||||||
a = b = 0;
|
a = b = 0;
|
||||||
|
@ -67,21 +72,18 @@ event zeek_init()
|
||||||
test_case( "associativity", ct == 2 );
|
test_case( "associativity", ct == 2 );
|
||||||
|
|
||||||
# Test for unspecified set coercion
|
# Test for unspecified set coercion
|
||||||
local s: set[string] = { "one", "two", "three" };
|
|
||||||
local sT = T ? set() : s;
|
local sT = T ? set() : s;
|
||||||
local sF = F ? s : set();
|
local sF = F ? s : set();
|
||||||
print |sT|, type_name(sT);
|
print |sT|, type_name(sT);
|
||||||
print |sF|, type_name(sF);
|
print |sF|, type_name(sF);
|
||||||
|
|
||||||
# Test for unspecified table coercion
|
# Test for unspecified table coercion
|
||||||
local t: table[count] of string = { [1] = "one", [2] = "two", [3] = "three" };
|
|
||||||
local tT = T ? table() : t;
|
local tT = T ? table() : t;
|
||||||
local tF = F ? t : table();
|
local tF = F ? t : table();
|
||||||
print |tT|, type_name(tT);
|
print |tT|, type_name(tT);
|
||||||
print |tF|, type_name(tF);
|
print |tF|, type_name(tF);
|
||||||
|
|
||||||
# Test for unspecified vector coercion
|
# Test for unspecified vector coercion
|
||||||
local v: vector of string = { "one", "two", "three" };
|
|
||||||
local vT = T ? vector() : v;
|
local vT = T ? vector() : v;
|
||||||
local vF = F ? v : vector();
|
local vF = F ? v : vector();
|
||||||
print |vT|, type_name(vT);
|
print |vT|, type_name(vT);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,27 +1,25 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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
|
# Type inference test
|
||||||
|
|
||||||
test_case( "type inference", type_name(c7) == "count" );
|
test_case( "type inference", type_name(c7) == "count" );
|
||||||
|
|
||||||
|
|
||||||
# Test various constant representations
|
# Test various constant representations
|
||||||
|
|
||||||
test_case( "hexadecimal", c3 == c4 );
|
test_case( "hexadecimal", c3 == c4 );
|
||||||
|
@ -60,6 +58,5 @@ event zeek_init()
|
||||||
test_case( str1, str1 == "max count value = 18446744073709551615" );
|
test_case( str1, str1 == "max count value = 18446744073709551615" );
|
||||||
local str2 = fmt("max count value = %d", c6);
|
local str2 = fmt("max count value = %d", c6);
|
||||||
test_case( str2, str2 == "max count value = 18446744073709551615" );
|
test_case( str2, str2 == "max count value = 18446744073709551615" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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
|
# Type inference tests
|
||||||
|
|
||||||
test_case( "type inference", type_name(d20) == "double" );
|
test_case( "type inference", type_name(d20) == "double" );
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
@ -13,20 +14,19 @@ type color: enum { Red, White, Blue, };
|
||||||
# enum without optional comma
|
# enum without optional comma
|
||||||
type city: enum { Rome, Paris };
|
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()
|
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 != e2 );
|
||||||
test_case( "enum equality comparison", e1 == e3 );
|
test_case( "enum equality comparison", e1 == e3 );
|
||||||
test_case( "enum equality comparison", e1 != e4 );
|
test_case( "enum equality comparison", e1 != e4 );
|
||||||
|
|
||||||
# type inference
|
# type inference
|
||||||
local x = Blue;
|
|
||||||
test_case( "type inference", x == e1 );
|
test_case( "type inference", x == e1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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
|
# Type inference test
|
||||||
|
|
||||||
test_case( "type inference", type_name(i15) == "int" );
|
test_case( "type inference", type_name(i15) == "int" );
|
||||||
|
@ -67,5 +67,4 @@ event zeek_init()
|
||||||
test_case( str3, str3 == "max int value = 9223372036854775807" );
|
test_case( str3, str3 == "max int value = 9223372036854775807" );
|
||||||
local str4 = fmt("min int value = %d", i14);
|
local str4 = fmt("min int value = %d", i14);
|
||||||
test_case( str4, str4 == "min int value = -9223372036854775808" );
|
test_case( str4, str4 == "min int value = -9223372036854775808" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
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;
|
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()
|
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
|
# Type inference tests
|
||||||
|
|
||||||
test_case( "type inference", type_name(in41) == "interval" );
|
test_case( "type inference", type_name(in41) == "interval" );
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT secondtestfile >out
|
# @TEST-EXEC: zeek -b %INPUT secondtestfile >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
# In this source file, we define a module and export some objects
|
# In this source file, we define a module and export some objects
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT secondtestfile >out
|
# @TEST-EXEC: zeek -b %INPUT secondtestfile >out
|
||||||
# @TEST-EXEC: btest-diff 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
|
# This is the same test as "module.zeek", but here we omit the module definition
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local p1: pattern = /foo|bar/;
|
|
||||||
local p2: pattern = /oob/;
|
|
||||||
local p3: pattern = /^oob/;
|
|
||||||
local p4 = /foo/;
|
|
||||||
|
|
||||||
# Type inference tests
|
# Type inference tests
|
||||||
|
|
||||||
test_case( "type inference", type_name(p4) == "pattern" );
|
test_case( "type inference", type_name(p4) == "pattern" );
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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
|
# Type inference test
|
||||||
|
|
||||||
test_case( "type inference", type_name(p5) == "port" );
|
test_case( "type inference", type_name(p5) == "port" );
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
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
|
# This is an incomplete set of tests to demonstrate the order of precedence
|
||||||
# of zeek script operators
|
# 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()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local n1: int;
|
|
||||||
local n2: int;
|
|
||||||
local n3: int;
|
|
||||||
|
|
||||||
# Tests that show "++" has higher precedence than "*"
|
# Tests that show "++" has higher precedence than "*"
|
||||||
|
|
||||||
n1 = n2 = 5;
|
n1 = n2 = 5;
|
||||||
|
@ -70,10 +75,6 @@ event zeek_init()
|
||||||
test_case( "+= and +", n2 == 3 );
|
test_case( "+= and +", n2 == 3 );
|
||||||
test_case( "+= and +", n3 == 1 );
|
test_case( "+= and +", n3 == 1 );
|
||||||
|
|
||||||
local r1: bool;
|
|
||||||
local r2: bool;
|
|
||||||
local r3: bool;
|
|
||||||
|
|
||||||
# Tests that show "&&" has higher precedence than "||"
|
# Tests that show "&&" has higher precedence than "||"
|
||||||
|
|
||||||
r1 = F && F || T;
|
r1 = F && F || T;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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
|
# Type inference test
|
||||||
|
|
||||||
test_case( "type inference", type_name(s26) == "string" );
|
test_case( "type inference", type_name(s26) == "string" );
|
||||||
|
|
|
@ -1,39 +1,42 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
|
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()
|
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 equality", a1/8 == s2 );
|
||||||
test_case( "IPv4 subnet inequality", a1/4 != 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 s2 );
|
||||||
test_case( "IPv4 subnet !in operator", a1 !in s3 );
|
test_case( "IPv4 subnet !in operator", a1 !in s3 );
|
||||||
test_case( "IPv4 subnet type inference", type_name(s4) == "subnet" );
|
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 equality", b1/64 == t2 );
|
||||||
test_case( "IPv6 subnet inequality", b3/64 != t2 );
|
test_case( "IPv6 subnet inequality", b3/64 != t2 );
|
||||||
test_case( "IPv6 subnet in operator", b2 in 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 and IPv6 subnet inequality", s1 != t1 );
|
||||||
test_case( "IPv4 address and IPv6 subnet", a1 !in t2 );
|
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( "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( "IPv6 !in IPv4-mapped-IPv6 subnet", [fe80::1] !in u1 );
|
||||||
test_case( "IPv4-mapped-IPv6 in IPv4-mapped-IPv6 subnet",
|
test_case( "IPv4-mapped-IPv6 in IPv4-mapped-IPv6 subnet",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# @TEST-EXEC: zeek -b %INPUT >out
|
# @TEST-EXEC: zeek -b %INPUT >out
|
||||||
# @TEST-EXEC: btest-diff out
|
# @TEST-EXEC: btest-diff out
|
||||||
|
# @TEST-EXEC: btest-diff .stderr
|
||||||
|
|
||||||
function test_case(msg: string, expect: bool)
|
function test_case(msg: string, expect: bool)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue