zeek/testing/btest/broker/store/invalid-handle.zeek
Jon Siwek a9f853efcd Improve Broker store API's handling of invalid arguments
* Some methods mistakenly returned a bool instead of QueryResult
  when passed an invalid `opaque of Broker::Store` handle.

* Now generates a runtime exception for store_name() and is_closed()
  calls that pass an invalid `opaque of Broker::Store` handle as any
  returned value can't be reasonably used in any subsequent logic.

* Descriptions of any invalid arguments are now given in the error
  message.
2020-06-24 22:56:14 -07:00

34 lines
541 B
Text

# @TEST-EXEC: zeek -b %INPUT >out 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
function print_keys(a: any)
{
when ( local s = Broker::keys(a) )
{
print "keys", s;
}
timeout 2sec
{
print fmt("<timeout for print keys>");
}
}
function checkit(a: any)
{
if ( Broker::is_closed(a) )
print "this shouldn't get printed";
else
print "this shouldn't get printed either";
}
global a: int = 0;
event zeek_init() &priority=10
{
checkit(a);
}
event zeek_init()
{
print_keys(a);
}