zeek/testing/btest/language/no-module.bro
Johanna Amann 8eddeed78f Allow access to global variables using GLOBAL:: namespace.
Addresses BIT-1758. Patch was contributed by François Pennaneach
<francois.pennaneach@free.fr>.
2016-12-07 15:28:34 -08:00

35 lines
839 B
Text

# @TEST-EXEC: bro -b %INPUT secondtestfile >out
# @TEST-EXEC: btest-diff out
# This is the same test as "module.bro", but here we omit the module definition
global num: count = 123;
const daysperyear: count = 365;
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
event testevent(msg: string)
{
test_case( "event", T );
}
# @TEST-START-FILE secondtestfile
# In this script, we try to access each object defined in the other script
event bro_init()
{
test_case( "function", T );
test_case( "global variable", num == 123 );
test_case( "fully qualified global variable", GLOBAL::num == 123 ); # test for BIT-1758 : GLOBAL scope ID discovery bug
test_case( "const", daysperyear == 365 );
event testevent( "foo" );
}
# @TEST-END-FILE