mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
update existing test suite usage of "when" statements to include captures
This commit is contained in:
parent
98cd3f2213
commit
b59ee83979
6 changed files with 9 additions and 9 deletions
|
@ -46,7 +46,7 @@ function check_terminate_conditions()
|
||||||
|
|
||||||
function check_it(name: string, s: opaque of Broker::Store)
|
function check_it(name: string, s: opaque of Broker::Store)
|
||||||
{
|
{
|
||||||
when ( local r = Broker::keys(s) )
|
when [name, s] ( local r = Broker::keys(s) )
|
||||||
{
|
{
|
||||||
check_terminate_conditions();
|
check_terminate_conditions();
|
||||||
print fmt("%s keys result: %s", name, r);
|
print fmt("%s keys result: %s", name, r);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
function print_keys(a: any)
|
function print_keys(a: any)
|
||||||
{
|
{
|
||||||
when ( local s = Broker::keys(a) )
|
when [a] ( local s = Broker::keys(a) )
|
||||||
{
|
{
|
||||||
print "keys", s;
|
print "keys", s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ function f(do_exception: bool): bool
|
||||||
local cmd = Exec::Command($cmd=fmt("echo 'f(%s)'",
|
local cmd = Exec::Command($cmd=fmt("echo 'f(%s)'",
|
||||||
do_exception));
|
do_exception));
|
||||||
|
|
||||||
return when ( local result = Exec::run(cmd) )
|
return when [cmd, do_exception] ( local result = Exec::run(cmd) )
|
||||||
{
|
{
|
||||||
print result$stdout;
|
print result$stdout;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ function g(do_exception: bool): bool
|
||||||
{
|
{
|
||||||
local stall = Exec::Command($cmd="sleep 30");
|
local stall = Exec::Command($cmd="sleep 30");
|
||||||
|
|
||||||
return when ( local result = Exec::run(stall) )
|
return when [do_exception, stall] ( local result = Exec::run(stall) )
|
||||||
{
|
{
|
||||||
print "shouldn't get here, g()", do_exception, result;
|
print "shouldn't get here, g()", do_exception, result;
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,14 @@ event zeek_init()
|
||||||
local cmd = Exec::Command($cmd="echo 'zeek_init()'");
|
local cmd = Exec::Command($cmd="echo 'zeek_init()'");
|
||||||
local stall = Exec::Command($cmd="sleep 30");
|
local stall = Exec::Command($cmd="sleep 30");
|
||||||
|
|
||||||
when ( local result = Exec::run(cmd) )
|
when [cmd] ( local result = Exec::run(cmd) )
|
||||||
{
|
{
|
||||||
print result$stdout;
|
print result$stdout;
|
||||||
event termination_check();
|
event termination_check();
|
||||||
print myrecord$notset;
|
print myrecord$notset;
|
||||||
}
|
}
|
||||||
|
|
||||||
when ( local result2 = Exec::run(stall) )
|
when [stall] ( local result2 = Exec::run(stall) )
|
||||||
{
|
{
|
||||||
print "shouldn't get here", result2;
|
print "shouldn't get here", result2;
|
||||||
check_term_condition();
|
check_term_condition();
|
||||||
|
|
|
@ -22,7 +22,7 @@ redef exit_only_after_terminate=T;
|
||||||
event on_demand_key()
|
event on_demand_key()
|
||||||
{
|
{
|
||||||
local host = 1.2.3.4;
|
local host = 1.2.3.4;
|
||||||
when ( local result = SumStats::request_key("test", [$host=host]) )
|
when [host] ( local result = SumStats::request_key("test", [$host=host]) )
|
||||||
{
|
{
|
||||||
print fmt("Key request for %s", host);
|
print fmt("Key request for %s", host);
|
||||||
print fmt(" Host: %s -> %.0f", host, result["test.reducer"]$sum);
|
print fmt(" Host: %s -> %.0f", host, result["test.reducer"]$sum);
|
||||||
|
|
|
@ -23,7 +23,7 @@ function check_exit_condition()
|
||||||
|
|
||||||
function test_request(label: string, req: ActiveHTTP::Request)
|
function test_request(label: string, req: ActiveHTTP::Request)
|
||||||
{
|
{
|
||||||
when ( local response = ActiveHTTP::request(req) )
|
when [label, req] ( local response = ActiveHTTP::request(req) )
|
||||||
{
|
{
|
||||||
print label, response;
|
print label, response;
|
||||||
check_exit_condition();
|
check_exit_condition();
|
||||||
|
|
|
@ -19,7 +19,7 @@ function check_exit_condition()
|
||||||
|
|
||||||
function test_cmd(label: string, cmd: Exec::Command)
|
function test_cmd(label: string, cmd: Exec::Command)
|
||||||
{
|
{
|
||||||
when ( local result = Exec::run(cmd) )
|
when [label, cmd] ( local result = Exec::run(cmd) )
|
||||||
{
|
{
|
||||||
local file_content = "";
|
local file_content = "";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue