mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/vern/script-opt-keep-asserts'
* origin/topic/vern/script-opt-keep-asserts: ZAM documentation updates for asserts and event handler run-time errors BTest updates for ZAM support of (optionally) keeping "assert" statements command-line options for controlling script optimization: keeping asserts, avoiding event handler coalescence ZAM support for option to not coalesce event handlers ZAM support for keeping "assert" statements internal support for script optimization options for keeping asserts, not consolidating event handlers ZAM operations to support asserts simplified "assert" by not trying to catch messages that themselves have errors Fixed some TEST-REQUIRES "${ZEEK_ZAM}" == "1" to use "=" instead to be /bin/sh compatible.
This commit is contained in:
commit
93a3a11d36
63 changed files with 312 additions and 75 deletions
22
CHANGES
22
CHANGES
|
@ -1,3 +1,25 @@
|
|||
7.1.0-dev.687 | 2024-12-05 21:43:49 +0100
|
||||
|
||||
* ZAM documentation updates for asserts and event handler run-time errors (Vern Paxson, Corelight)
|
||||
|
||||
* BTest updates for ZAM support of (optionally) keeping "assert" statements (Vern Paxson, Corelight)
|
||||
|
||||
* command-line options for controlling script optimization: keeping asserts, (Vern Paxson, Corelight)
|
||||
avoiding event handler coalescence
|
||||
|
||||
* ZAM support for option to not coalesce event handlers (Vern Paxson, Corelight)
|
||||
|
||||
* ZAM support for keeping "assert" statements (Vern Paxson, Corelight)
|
||||
|
||||
* internal support for script optimization options for keeping asserts, not (Vern Paxson, Corelight)
|
||||
consolidating event handlers
|
||||
|
||||
* ZAM operations to support asserts (Vern Paxson, Corelight)
|
||||
|
||||
* simplified "assert" by not trying to catch messages that themselves have errors (Vern Paxson, Corelight)
|
||||
|
||||
* ZAM optimization now removes hook calls to hooks without any bodies (Vern Paxson, Corelight)
|
||||
|
||||
7.1.0-dev.676 | 2024-12-05 11:08:55 -0700
|
||||
|
||||
* update of BTest that tracks number of (and validates) ZAM operations (Vern Paxson, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
7.1.0-dev.676
|
||||
7.1.0-dev.687
|
||||
|
|
|
@ -192,7 +192,9 @@ static void print_analysis_help() {
|
|||
fprintf(stderr, " dump-final-ZAM dump final generated ZAM code; implies gen-ZAM-code\n");
|
||||
fprintf(stderr, " gen-ZAM-code generate ZAM code (without turning on additional optimizations)\n");
|
||||
fprintf(stderr, " inline inline function calls\n");
|
||||
fprintf(stderr, " keep-asserts do not optimize away \"assert\" statements\n");
|
||||
fprintf(stderr, " no-inline turn off inlining\n");
|
||||
fprintf(stderr, " no-event-handler-coalescence when inlining, do not coalescence event handlers\n");
|
||||
fprintf(stderr, " no-ZAM-opt omit low-level ZAM optimization\n");
|
||||
fprintf(stderr, " optimize-all optimize all scripts, even inlined ones\n");
|
||||
fprintf(stderr, " optimize-AST optimize the (transformed) AST; implies xform\n");
|
||||
|
@ -243,8 +245,12 @@ static void set_analysis_option(const char* opt, Options& opts) {
|
|||
a_o.activate = a_o.gen_ZAM_code = true;
|
||||
else if ( util::streq(opt, "inline") )
|
||||
a_o.inliner = true;
|
||||
else if ( util::streq(opt, "keep-asserts") )
|
||||
a_o.keep_asserts = true;
|
||||
else if ( util::streq(opt, "no-inline") )
|
||||
a_o.no_inliner = true;
|
||||
else if ( util::streq(opt, "no-event-handler-coalescence") )
|
||||
a_o.no_eh_coalescence = true;
|
||||
else if ( util::streq(opt, "no-ZAM-opt") )
|
||||
a_o.activate = a_o.no_ZAM_opt = true;
|
||||
else if ( util::streq(opt, "optimize-all") )
|
||||
|
|
49
src/Stmt.cc
49
src/Stmt.cc
|
@ -1570,10 +1570,10 @@ TraversalCode NullStmt::Traverse(TraversalCallback* cb) const {
|
|||
HANDLE_TC_STMT_POST(tc);
|
||||
}
|
||||
|
||||
AssertStmt::AssertStmt(ExprPtr arg_cond, ExprPtr arg_msg)
|
||||
: Stmt(STMT_ASSERT), cond(std::move(arg_cond)), msg(std::move(arg_msg)) {
|
||||
if ( ! IsBool(cond->GetType()->Tag()) )
|
||||
cond->Error("conditional must be boolean");
|
||||
AssertStmt::AssertStmt(ExprPtr cond, ExprPtr arg_msg)
|
||||
: ExprStmt(STMT_ASSERT, std::move(cond)), msg(std::move(arg_msg)) {
|
||||
if ( ! IsBool(e->GetType()->Tag()) )
|
||||
e->Error("conditional must be boolean");
|
||||
|
||||
if ( msg && ! IsString(msg->GetType()->Tag()) )
|
||||
msg->Error("message must be string");
|
||||
|
@ -1581,7 +1581,7 @@ AssertStmt::AssertStmt(ExprPtr arg_cond, ExprPtr arg_msg)
|
|||
zeek::ODesc desc;
|
||||
desc.SetShort(true);
|
||||
desc.SetQuotes(true);
|
||||
cond->Describe(&desc);
|
||||
e->Describe(&desc);
|
||||
|
||||
cond_desc = desc.Description();
|
||||
}
|
||||
|
@ -1592,28 +1592,16 @@ ValPtr AssertStmt::Exec(Frame* f, StmtFlowType& flow) {
|
|||
|
||||
static auto assertion_result_hook = id::find_func("assertion_result");
|
||||
bool run_result_hook = assertion_result_hook && assertion_result_hook->HasEnabledBodies();
|
||||
auto assert_result = cond->Eval(f)->AsBool();
|
||||
auto assert_result = e->Eval(f)->AsBool();
|
||||
|
||||
if ( ! assert_result || run_result_hook ) {
|
||||
zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString();
|
||||
|
||||
if ( msg ) {
|
||||
// Eval() may fail if expression assumes assert
|
||||
// condition is F, but we still try to get it for
|
||||
// the assertion_result hook.
|
||||
try {
|
||||
msg_val = cast_intrusive<zeek::StringVal>(msg->Eval(f));
|
||||
} catch ( InterpreterException& e ) {
|
||||
static ODesc desc;
|
||||
desc.Clear();
|
||||
desc.SetShort(true);
|
||||
desc.SetQuotes(true);
|
||||
desc.Add("<error eval ");
|
||||
msg->Describe(&desc);
|
||||
desc.Add(">");
|
||||
msg_val = zeek::make_intrusive<zeek::StringVal>(desc.Len(), (const char*)desc.Bytes());
|
||||
}
|
||||
}
|
||||
if ( msg )
|
||||
// It's up to the script writing to assure that the expression
|
||||
// works regardless of the state of the condition. If they
|
||||
// fail to do so, they can get an exception at this point.
|
||||
msg_val = cast_intrusive<zeek::StringVal>(msg->Eval(f));
|
||||
|
||||
report_assert(assert_result, cond_desc, msg_val, GetLocationInfo());
|
||||
}
|
||||
|
@ -1631,7 +1619,13 @@ void AssertStmt::StmtDescribe(ODesc* d) const {
|
|||
auto orig_quotes = d->WantQuotes();
|
||||
d->SetQuotes(true);
|
||||
|
||||
cond->Describe(d);
|
||||
e->Describe(d);
|
||||
|
||||
if ( msg_setup_stmt ) {
|
||||
d->Add("{ ");
|
||||
msg_setup_stmt->Describe(d);
|
||||
d->Add(" }");
|
||||
}
|
||||
|
||||
if ( msg ) {
|
||||
d->Add(",");
|
||||
|
@ -1648,9 +1642,14 @@ TraversalCode AssertStmt::Traverse(TraversalCallback* cb) const {
|
|||
TraversalCode tc = cb->PreStmt(this);
|
||||
HANDLE_TC_STMT_PRE(tc);
|
||||
|
||||
tc = cond->Traverse(cb);
|
||||
tc = e->Traverse(cb);
|
||||
HANDLE_TC_STMT_PRE(tc);
|
||||
if ( msg ) {
|
||||
if ( msg_setup_stmt ) {
|
||||
tc = msg_setup_stmt->Traverse(cb);
|
||||
HANDLE_TC_STMT_PRE(tc);
|
||||
}
|
||||
|
||||
tc = msg->Traverse(cb);
|
||||
HANDLE_TC_STMT_PRE(tc);
|
||||
}
|
||||
|
|
|
@ -495,15 +495,15 @@ private:
|
|||
bool is_directive;
|
||||
};
|
||||
|
||||
class AssertStmt final : public Stmt {
|
||||
class AssertStmt final : public ExprStmt {
|
||||
public:
|
||||
explicit AssertStmt(ExprPtr cond, ExprPtr msg = nullptr);
|
||||
|
||||
ValPtr Exec(Frame* f, StmtFlowType& flow) override;
|
||||
|
||||
const auto& Cond() const { return cond; }
|
||||
const auto& CondDesc() const { return cond_desc; }
|
||||
const auto& Msg() const { return msg; }
|
||||
const auto& MsgSetupStmt() const { return msg_setup_stmt; }
|
||||
|
||||
void StmtDescribe(ODesc* d) const override;
|
||||
|
||||
|
@ -516,9 +516,12 @@ public:
|
|||
StmtPtr DoReduce(Reducer* c) override;
|
||||
|
||||
private:
|
||||
ExprPtr cond;
|
||||
std::string cond_desc;
|
||||
ExprPtr msg;
|
||||
|
||||
// Statement to execute before evaluating "msg". Only used for script
|
||||
// optimization.
|
||||
StmtPtr msg_setup_stmt;
|
||||
};
|
||||
|
||||
// Helper function for reporting on asserts that either failed, or should
|
||||
|
|
|
@ -480,7 +480,7 @@ void CPPCompile::GenForOverString(const ExprPtr& str, const IDPList* loop_vars)
|
|||
}
|
||||
|
||||
void CPPCompile::GenAssertStmt(const AssertStmt* a) {
|
||||
auto& cond = a->Cond();
|
||||
auto cond = a->StmtExpr();
|
||||
auto& msg = a->Msg();
|
||||
|
||||
Emit("{ // begin a new scope for internal \"assert\" variables");
|
||||
|
|
|
@ -166,7 +166,8 @@ void Inliner::Analyze() {
|
|||
inline_ables[func] = f.Profile();
|
||||
}
|
||||
|
||||
CoalesceEventHandlers();
|
||||
if ( ! analysis_options.no_eh_coalescence )
|
||||
CoalesceEventHandlers();
|
||||
|
||||
for ( auto& f : funcs )
|
||||
if ( f.ShouldAnalyze() )
|
||||
|
|
|
@ -265,11 +265,13 @@ static void init_options() {
|
|||
check_env_opt("ZEEK_DUMP_UDS", analysis_options.dump_uds);
|
||||
check_env_opt("ZEEK_INLINE", analysis_options.inliner);
|
||||
check_env_opt("ZEEK_NO_INLINE", analysis_options.no_inliner);
|
||||
check_env_opt("ZEEK_NO_EH_COALESCENCE", analysis_options.no_eh_coalescence);
|
||||
check_env_opt("ZEEK_OPT", analysis_options.optimize_AST);
|
||||
check_env_opt("ZEEK_XFORM", analysis_options.activate);
|
||||
check_env_opt("ZEEK_ZAM", analysis_options.gen_ZAM);
|
||||
check_env_opt("ZEEK_COMPILE_ALL", analysis_options.compile_all);
|
||||
check_env_opt("ZEEK_REPORT_UNCOMPILABLE", analysis_options.report_uncompilable);
|
||||
check_env_opt("ZEEK_ZAM_KEEP_ASSERTS", analysis_options.keep_asserts);
|
||||
check_env_opt("ZEEK_ZAM_CODE", analysis_options.gen_ZAM_code);
|
||||
check_env_opt("ZEEK_NO_ZAM_OPT", analysis_options.no_ZAM_opt);
|
||||
check_env_opt("ZEEK_NO_ZAM_CONTROL_FLOW_OPT", analysis_options.no_ZAM_control_flow_opt);
|
||||
|
|
|
@ -57,6 +57,12 @@ struct AnalyOpt {
|
|||
// enabled due to other options.
|
||||
bool no_inliner = false;
|
||||
|
||||
// If true, when inlining skip event handler coalescence.
|
||||
bool no_eh_coalescence = false;
|
||||
|
||||
// Whether to keep or elide "assert" statements.
|
||||
bool keep_asserts = false;
|
||||
|
||||
// If true, report which functions are directly and indirectly
|
||||
// recursive, and exit. Only germane if running the inliner.
|
||||
bool report_recursive = false;
|
||||
|
|
|
@ -1069,11 +1069,36 @@ StmtPtr InitStmt::DoReduce(Reducer* c) {
|
|||
return ThisPtr();
|
||||
}
|
||||
|
||||
StmtPtr AssertStmt::Duplicate() { return SetSucc(new AssertStmt(cond->Duplicate(), msg ? msg->Duplicate() : nullptr)); }
|
||||
StmtPtr AssertStmt::Duplicate() { return SetSucc(new AssertStmt(e->Duplicate(), msg ? msg->Duplicate() : nullptr)); }
|
||||
|
||||
bool AssertStmt::IsReduced(Reducer* c) const { return false; }
|
||||
bool AssertStmt::IsReduced(Reducer* c) const {
|
||||
if ( ! analysis_options.keep_asserts )
|
||||
return false;
|
||||
|
||||
StmtPtr AssertStmt::DoReduce(Reducer* c) { return TransformMe(make_intrusive<NullStmt>(), c); }
|
||||
return e->IsSingleton(c) && (! msg || msg->IsSingleton(c));
|
||||
}
|
||||
|
||||
StmtPtr AssertStmt::DoReduce(Reducer* c) {
|
||||
if ( ! analysis_options.keep_asserts )
|
||||
return TransformMe(make_intrusive<NullStmt>(), c);
|
||||
|
||||
if ( c->Optimizing() ) {
|
||||
e = c->OptExpr(e);
|
||||
if ( msg )
|
||||
msg = c->OptExpr(msg);
|
||||
return ThisPtr();
|
||||
}
|
||||
else if ( IsReduced(c) )
|
||||
return ThisPtr();
|
||||
|
||||
StmtPtr red_stmt;
|
||||
e = e->ReduceToSingleton(c, red_stmt);
|
||||
if ( msg )
|
||||
msg = msg->ReduceToSingleton(c, msg_setup_stmt);
|
||||
|
||||
auto sl = with_location_of(make_intrusive<StmtList>(red_stmt, ThisPtr()), this);
|
||||
return sl->Reduce(c);
|
||||
}
|
||||
|
||||
bool WhenInfo::HasUnreducedIDs(Reducer* c) const {
|
||||
for ( auto& cp : *cl ) {
|
||||
|
|
|
@ -287,6 +287,21 @@ UDs UseDefs::PropagateUDs(const Stmt* s, UDs succ_UDs, const Stmt* succ_stmt, bo
|
|||
return CreateUDs(s, uds);
|
||||
}
|
||||
|
||||
case STMT_ASSERT: {
|
||||
auto a = s->AsAssertStmt();
|
||||
auto e = a->StmtExpr();
|
||||
|
||||
if ( auto msg = a->Msg().get() ) {
|
||||
succ_UDs = UD_Union(succ_UDs, ExprUDs(msg));
|
||||
if ( auto msg_setup_stmt = a->MsgSetupStmt().get() ) {
|
||||
succ_UDs = PropagateUDs(msg_setup_stmt, succ_UDs, succ_stmt, second_pass);
|
||||
succ_stmt = msg_setup_stmt;
|
||||
}
|
||||
}
|
||||
|
||||
return CreateUDs(s, UD_Union(succ_UDs, ExprUDs(e)));
|
||||
}
|
||||
|
||||
case STMT_SWITCH: {
|
||||
auto sw_UDs = std::make_shared<UseDefSet>();
|
||||
|
||||
|
|
|
@ -337,3 +337,33 @@ macro BuildWhen(zf, timeout)
|
|||
local_aggrs.push_back(v);
|
||||
}
|
||||
(void)make_intrusive<trigger::Trigger>(wi, wi->WhenExprGlobals(), local_aggrs, timeout, Z_FRAME, Z_LOC->Loc());
|
||||
|
||||
# Helper instruction that loads into $$ a boolean indicating whether an
|
||||
# upcoming assertion should be reported.
|
||||
op Should-Report-Assert
|
||||
classes VV
|
||||
op-types I I
|
||||
eval static auto assertion_result_hook = id::find_func("assertion_result");
|
||||
bool run_result_hook = assertion_result_hook && assertion_result_hook->HasEnabledBodies();
|
||||
$$ = ! $1 || run_result_hook;
|
||||
|
||||
op Report-Assert
|
||||
# Operands are (1) result from Should-Report-Assert, (2) assertion value,
|
||||
# (3) description of the condition (always a constant).
|
||||
op1-read
|
||||
classes VVC
|
||||
op-types I I S
|
||||
eval if ( $$ )
|
||||
{
|
||||
zeek::StringValPtr msg_val = zeek::val_mgr->EmptyString();
|
||||
report_assert($1, $2->ToStdString(), msg_val, Z_LOC->Loc());
|
||||
}
|
||||
|
||||
op Report-Assert-With-Message
|
||||
# The same, but with an additional operand being the associated message
|
||||
# (as a variable, so it comes in $2 rather than $3).
|
||||
op1-read
|
||||
classes VVVC
|
||||
op-types I I S S
|
||||
eval if ( $$ )
|
||||
report_assert($1, $3->ToStdString(), {NewRef{}, $2}, Z_LOC->Loc());
|
||||
|
|
|
@ -70,7 +70,14 @@ variables.
|
|||
|
||||
### Incompatibilities:
|
||||
|
||||
* ZAM ignores `assert` statements.
|
||||
* By default, ZAM removes `assert` statements (including any side effects
|
||||
present in their elements). To keep these, specify `-O keep-asserts`.
|
||||
|
||||
* For event handlers with multiple bodies, if one of the bodies encounters
|
||||
a run-time error, the later (lower priority) bodies won't run, because ZAM
|
||||
inlines all of the bodies together to facilitate cross-body optimization.
|
||||
If you need full isolation between event handler bodies, you can specify
|
||||
`-O no-event-handler-coalescence` to turning off the inlining.
|
||||
|
||||
* The `same_object()` BiF will always deem two non-container values as
|
||||
different.
|
||||
|
@ -94,7 +101,9 @@ issues:
|
|||
|`gen-ZAM-code` | Generate ZAM without additional optimizations.|
|
||||
|`help` | Print this list.|
|
||||
|`inline` | Inline function calls.|
|
||||
|`keep-asserts` | Don't optimize away `assert` statements.|
|
||||
|`no-inline` | Suppress inlining even if another option implies it.|
|
||||
|`no-event-handler-coalescence` | When inlining, do not coalescence event handlers.|
|
||||
|`no-ZAM-opt` | Turn off low-level ZAM optimization.|
|
||||
|`optimize-all` | Optimize all scripts, even inlined ones. You need to separately specify which optimizations you want to apply, e.g., `-O inline -O xform`.|
|
||||
|`optimize-AST` | Optimize the (transform) AST; implies `xform`.|
|
||||
|
|
|
@ -48,6 +48,8 @@ const ZAMStmt ZAMCompiler::CompileStmt(const Stmt* s) {
|
|||
|
||||
case STMT_WHEN: return CompileWhen(static_cast<const WhenStmt*>(s));
|
||||
|
||||
case STMT_ASSERT: return CompileAssert(static_cast<const AssertStmt*>(s));
|
||||
|
||||
case STMT_NULL: return EmptyStmt();
|
||||
|
||||
case STMT_CHECK_ANY_LEN: {
|
||||
|
@ -1047,6 +1049,45 @@ const ZAMStmt ZAMCompiler::CompileWhen(const WhenStmt* ws) {
|
|||
return AddInst(z);
|
||||
}
|
||||
|
||||
const ZAMStmt ZAMCompiler::CompileAssert(const AssertStmt* as) {
|
||||
auto cond = as->StmtExpr();
|
||||
|
||||
int cond_slot;
|
||||
if ( cond->Tag() == EXPR_CONST )
|
||||
cond_slot = TempForConst(cond->AsConstExpr());
|
||||
else
|
||||
cond_slot = FrameSlot(cond->AsNameExpr());
|
||||
|
||||
auto decision_slot = NewSlot(false);
|
||||
|
||||
(void)AddInst(ZInstI(OP_SHOULD_REPORT_ASSERT_VV, decision_slot, cond_slot));
|
||||
|
||||
ZInstI z;
|
||||
|
||||
// We don't have a convenient way of directly introducing a std::string
|
||||
// constant, so we build one to hold it.
|
||||
auto cond_desc = make_intrusive<StringVal>(new String(as->CondDesc()));
|
||||
auto cond_desc_e = make_intrusive<ConstExpr>(cond_desc);
|
||||
|
||||
if ( auto msg = as->Msg() ) {
|
||||
auto& msg_setup_stmt = as->MsgSetupStmt();
|
||||
if ( msg_setup_stmt )
|
||||
(void)CompileStmt(msg_setup_stmt);
|
||||
|
||||
int msg_slot;
|
||||
if ( msg->Tag() == EXPR_CONST )
|
||||
msg_slot = TempForConst(msg->AsConstExpr());
|
||||
else
|
||||
msg_slot = FrameSlot(msg->AsNameExpr());
|
||||
|
||||
z = ZInstI(OP_REPORT_ASSERT_WITH_MESSAGE_VVVC, decision_slot, cond_slot, msg_slot, cond_desc_e.get());
|
||||
}
|
||||
else
|
||||
z = ZInstI(OP_REPORT_ASSERT_VVC, decision_slot, cond_slot, cond_desc_e.get());
|
||||
|
||||
return AddInst(z);
|
||||
}
|
||||
|
||||
const ZAMStmt ZAMCompiler::InitRecord(IDPtr id, RecordType* rt) {
|
||||
auto z = ZInstI(OP_INIT_RECORD_V, FrameSlot(id));
|
||||
z.SetType({NewRef{}, rt});
|
||||
|
|
|
@ -20,6 +20,7 @@ const ZAMStmt CompileCatchReturn(const CatchReturnStmt* cr);
|
|||
const ZAMStmt CompileStmts(const StmtList* sl);
|
||||
const ZAMStmt CompileInit(const InitStmt* is);
|
||||
const ZAMStmt CompileWhen(const WhenStmt* ws);
|
||||
const ZAMStmt CompileAssert(const AssertStmt* ws);
|
||||
|
||||
const ZAMStmt CompileNext() { return GenGoTo(nexts.back()); }
|
||||
const ZAMStmt CompileBreak() { return GenGoTo(breaks.back()); }
|
||||
|
|
|
@ -25,8 +25,8 @@ int FrameSlotIfName(const Expr* e) {
|
|||
return n ? FrameSlot(n->Id()) : -1;
|
||||
}
|
||||
|
||||
int FrameSlot(const NameExpr* id) { return FrameSlot(id->AsNameExpr()->Id()); }
|
||||
int Frame1Slot(const NameExpr* id, ZOp op) { return Frame1Slot(id->AsNameExpr()->Id(), op); }
|
||||
int FrameSlot(const NameExpr* n) { return FrameSlot(n->Id()); }
|
||||
int Frame1Slot(const NameExpr* n, ZOp op) { return Frame1Slot(n->Id(), op); }
|
||||
|
||||
int Frame1Slot(const ID* id, ZOp op) { return Frame1Slot(id, op1_flavor[op]); }
|
||||
int Frame1Slot(const NameExpr* n, ZAMOp1Flavor fl) { return Frame1Slot(n->Id(), fl); }
|
||||
|
|
3
testing/btest/Baseline.zam/language.assert-2/out
Normal file
3
testing/btest/Baseline.zam/language.assert-2/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 3: assertion failure: fmt("%s", 1) == "2" ("1" != "2")
|
||||
fatal error: errors occurred while initializing
|
3
testing/btest/Baseline.zam/language.assert-3/out
Normal file
3
testing/btest/Baseline.zam/language.assert-3/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 3: assertion failure: (coerce to_count("42") to double) == 42.5 (always failing)
|
||||
fatal error: errors occurred while initializing
|
3
testing/btest/Baseline.zam/language.assert-4/out
Normal file
3
testing/btest/Baseline.zam/language.assert-4/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 4: assertion failure: 1 == x (Expected x to be 1, have 2)
|
||||
fatal error: errors occurred while initializing
|
6
testing/btest/Baseline.zam/language.assert-5/out
Normal file
6
testing/btest/Baseline.zam/language.assert-5/out
Normal file
|
@ -0,0 +1,6 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 9: assertion failure: "ghi" in tbl ({
|
||||
[abc] = 123,
|
||||
[def] = 456
|
||||
})
|
||||
fatal error: errors occurred while initializing
|
3
testing/btest/Baseline.zam/language.assert-6/out
Normal file
3
testing/btest/Baseline.zam/language.assert-6/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
runtime error in <...>/assert.zeek, line 9: field value missing: $b
|
||||
fatal error: errors occurred while initializing
|
3
testing/btest/Baseline.zam/language.assert-7/out
Normal file
3
testing/btest/Baseline.zam/language.assert-7/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
runtime error in <...>/assert.zeek, line 9: field value missing: $b
|
||||
fatal error: errors occurred while initializing
|
3
testing/btest/Baseline.zam/language.assert-8/out
Normal file
3
testing/btest/Baseline.zam/language.assert-8/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 2: assertion failure: 1 == 2 (always false)
|
||||
fatal error: failed to execute script statements at top-level scope
|
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-error.zeek, line 3: message must be string (1234)
|
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-error.zeek, line 3: syntax error, at or near ";"
|
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-error.zeek, line 3: syntax error, at or near ","
|
2
testing/btest/Baseline.zam/language.assert-error/.stderr
Normal file
2
testing/btest/Baseline.zam/language.assert-error/.stderr
Normal file
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-error.zeek, line 8: conditional must be boolean (1)
|
|
@ -0,0 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
4
testing/btest/Baseline.zam/language.assert-hook-2/out
Normal file
4
testing/btest/Baseline.zam/language.assert-hook-2/out
Normal 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.
|
||||
assertion_failure, to_count("5") == 4, 5 is not 4
|
||||
assert <...>/assert-hook.zeek:21
|
||||
zeek_init <none>:0
|
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-hook.zeek, line 12: assertion failure: F (terminate me!)
|
||||
received termination signal
|
3
testing/btest/Baseline.zam/language.assert-hook-3/out
Normal file
3
testing/btest/Baseline.zam/language.assert-hook-3/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_failure, terminate me!
|
||||
zeek_done()
|
|
@ -0,0 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
2
testing/btest/Baseline.zam/language.assert-hook-4/out
Normal file
2
testing/btest/Baseline.zam/language.assert-hook-4/out
Normal file
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_failure, calling exit!
|
|
@ -0,0 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
8
testing/btest/Baseline.zam/language.assert-hook-5/out
Normal file
8
testing/btest/Baseline.zam/language.assert-hook-5/out
Normal file
|
@ -0,0 +1,8 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_result T at <...>/assert-hook.zeek:25: md5_hash("") == "d41d8cd98f00b204e9800998ecf8427e"
|
||||
assertion_result T at <...>/assert-hook.zeek:30: sha1_hash("") == "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
||||
assertion_result F at <...>/assert-hook.zeek:35: sha1_hash("") == "wrong"
|
||||
assertion_failure at <...>/assert-hook.zeek:35: sha1_hash("") == "wrong"
|
||||
assertion_result F at <...>/assert-hook.zeek:40: md5_hash("") == "wrong"
|
||||
assertion_failure at <...>/assert-hook.zeek:40: md5_hash("") == "wrong"
|
||||
2 of 4 assertions failed
|
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
runtime error in <...>/assert-hook.zeek, line 18: field value missing: $ip
|
||||
error in <...>/assert-hook.zeek, line 24: assertion failure: 2 + 2 == 5 ({"msg":"false and works"})
|
4
testing/btest/Baseline.zam/language.assert-hook-6/out
Normal file
4
testing/btest/Baseline.zam/language.assert-hook-6/out
Normal 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.
|
||||
assertion_result, T, 2 + 2 == 4, {"msg":"true and works"}, <...>/assert-hook.zeek, 15
|
||||
assertion_result, F, 2 + 2 == 5, {"msg":"false and works"}, <...>/assert-hook.zeek, 24
|
||||
assertion_failure, 2 + 2 == 5, {"msg":"false and works"}, <...>/assert-hook.zeek, 24
|
|
@ -0,0 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
5
testing/btest/Baseline.zam/language.assert-hook-7/out
Normal file
5
testing/btest/Baseline.zam/language.assert-hook-7/out
Normal file
|
@ -0,0 +1,5 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_result, T, 2 + 2 == 4, this is true, <...>/assert-hook.zeek, 10
|
||||
assertion_result, T, 2 + 2 == 4, {"msg":"this is also true"}, <...>/assert-hook.zeek, 11
|
||||
assertion_result, F, 2 + 2 == 5, this is false, <...>/assert-hook.zeek, 12
|
||||
assertion_result, F, 2 + 2 == 5, this is false, <...>/assert-hook.zeek, 18
|
|
@ -0,0 +1 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
6
testing/btest/Baseline.zam/language.assert-hook-8/out
Normal file
6
testing/btest/Baseline.zam/language.assert-hook-8/out
Normal file
|
@ -0,0 +1,6 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
zeek_init
|
||||
returning true
|
||||
assertion_result, T, always_true(), always true, <...>/assert-hook.zeek, 23
|
||||
returning false
|
||||
assertion_result, F, always_false(), always false, <...>/assert-hook.zeek, 24
|
2
testing/btest/Baseline.zam/language.assert-hook/.stderr
Normal file
2
testing/btest/Baseline.zam/language.assert-hook/.stderr
Normal file
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-hook.zeek, line 15: assertion failure: 1 != 1
|
2
testing/btest/Baseline.zam/language.assert-hook/out
Normal file
2
testing/btest/Baseline.zam/language.assert-hook/out
Normal file
|
@ -0,0 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_failure, 1 != 1, , <...>/assert-hook.zeek, 15
|
7
testing/btest/Baseline.zam/language.assert-misc/out
Normal file
7
testing/btest/Baseline.zam/language.assert-misc/out
Normal 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.
|
||||
f, lambda_<10820400278317158366>: function() : void
|
||||
ZAM-code lambda_<10820400278317158366>
|
||||
g, lambda_<9730512750166342063>: function() : void
|
||||
ZAM-code lambda_<9730512750166342063>
|
||||
test_function, test_function: function() : void
|
||||
ZAM-code test_function
|
3
testing/btest/Baseline.zam/language.assert/out
Normal file
3
testing/btest/Baseline.zam/language.assert/out
Normal file
|
@ -0,0 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 8: assertion failure: fmt("%s", 1) == "2"
|
||||
fatal error: errors occurred while initializing
|
|
@ -1,2 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
1245 valid, 1883 tested, 437 skipped
|
||||
1248 valid, 1892 tested, 437 skipped
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
expression error in <...>/assert.zeek, line 10: field value missing (r$b)
|
||||
error in <...>/assert.zeek, line 10: assertion failure: r?$b (<error eval fmt("r$b is not set trying anyway: %s", r$b)>)
|
||||
expression error in <...>/assert.zeek, line 12: field value missing (r$b)
|
||||
fatal error: errors occurred while initializing
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
expression error in <...>/assert-hook.zeek, line 15: field value missing (get_current_packet_header()$ip)
|
||||
expression error in <...>/assert-hook.zeek, line 17: field value missing (get_current_packet_header()$ip)
|
||||
error in <...>/assert-hook.zeek, line 17: assertion failure: 2 + 2 == 5 (<error eval cat(get_current_packet_header()$ip)>)
|
||||
error in <...>/assert-hook.zeek, line 22: assertion failure: 2 + 2 == 5 ({"msg":"false and works"})
|
||||
expression error in <...>/assert-hook.zeek, line 18: field value missing (get_current_packet_header()$ip)
|
||||
error in <...>/assert-hook.zeek, line 24: assertion failure: 2 + 2 == 5 ({"msg":"false and works"})
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_result, T, 2 + 2 == 4, <error eval cat(get_current_packet_header()$ip)>, <...>/assert-hook.zeek, 15
|
||||
assertion_result, T, 2 + 2 == 4, {"msg":"true and works"}, <...>/assert-hook.zeek, 16
|
||||
assertion_result, F, 2 + 2 == 5, <error eval cat(get_current_packet_header()$ip)>, <...>/assert-hook.zeek, 17
|
||||
assertion_failure, 2 + 2 == 5, <error eval cat(get_current_packet_header()$ip)>, <...>/assert-hook.zeek, 17
|
||||
assertion_result, F, 2 + 2 == 5, {"msg":"false and works"}, <...>/assert-hook.zeek, 22
|
||||
assertion_failure, 2 + 2 == 5, {"msg":"false and works"}, <...>/assert-hook.zeek, 22
|
||||
assertion_result, T, 2 + 2 == 4, {"msg":"true and works"}, <...>/assert-hook.zeek, 15
|
||||
assertion_result, F, 2 + 2 == 5, {"msg":"false and works"}, <...>/assert-hook.zeek, 24
|
||||
assertion_failure, 2 + 2 == 5, {"msg":"false and works"}, <...>/assert-hook.zeek, 24
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-hook.zeek, line 18: assertion failure: 1 != 1
|
||||
error in <...>/assert-hook.zeek, line 15: assertion failure: 1 != 1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
assertion_failure, 1 != 1, , <...>/assert-hook.zeek, 18
|
||||
assertion_failure, 1 != 1, , <...>/assert-hook.zeek, 15
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert-top-level.zeek, line 7: assertion failure: getpid() == 0 (my pid greater 0? T)
|
||||
error in <...>/assert-top-level.zeek, line 5: assertion failure: getpid() == 0 (my pid greater 0? T)
|
||||
fatal error: failed to execute script statements at top-level scope
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
error in <...>/assert.zeek, line 11: assertion failure: fmt("%s", 1) == "2"
|
||||
error in <...>/assert.zeek, line 8: assertion failure: fmt("%s", 1) == "2"
|
||||
fatal error: errors occurred while initializing
|
||||
|
|
|
@ -99,4 +99,5 @@ BTEST_BASELINE_DIR=%(testbase)s/Baseline.cpp:%(testbase)s/Baseline
|
|||
# (no -j).
|
||||
[environment-zam]
|
||||
ZEEK_ZAM=1
|
||||
ZEEK_ZAM_KEEP_ASSERTS=1
|
||||
BTEST_BASELINE_DIR=%(testbase)s/Baseline.zam:%(testbase)s/Baseline.xform:%(testbase)s/Baseline
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# @TEST-DOC: Assert statement testing with assertion_failure and assertion_result implementation.
|
||||
#
|
||||
# Doesn't make sense for ZAM as it ignores assert's.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||
#
|
||||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: zeek -b -O no-event-handler-coalescence %INPUT >out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||
|
||||
|
@ -164,9 +161,11 @@ hook assertion_result(result: bool, cond: string, msg: string, bt: Backtrace)
|
|||
|
||||
event zeek_init()
|
||||
{
|
||||
assert 2 + 2 == 4, cat(get_current_packet_header()$ip);
|
||||
assert 2 + 2 == 4, to_json([$msg="true and works"]);
|
||||
assert 2 + 2 == 5, cat(get_current_packet_header()$ip);
|
||||
# This next assert will generate a run-time error, exiting the
|
||||
# event handler.
|
||||
assert 2 + 2 == 4, cat(get_current_packet_header()$ip);
|
||||
assert 2 + 2 == 5, "didn't get to here";
|
||||
}
|
||||
|
||||
event zeek_done()
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# @TEST-DOC: Test Describe() of assert statement. Expressions may be canonicalized.
|
||||
#
|
||||
# Doesn't make sense for ZAM as it ignores assert's.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||
#
|
||||
# @TEST-EXEC: zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC: zeek -b -O no-event-handler-coalescence %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
function test_function()
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# Doesn't make sense for ZAM as it ignores assert's.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||
# @TEST-EXEC-FAIL: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# @TEST-DOC: Assert statement behavior testing without an assertion_failure() hook.
|
||||
#
|
||||
# Doesn't make sense for ZAM as it ignores assert's.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" != "1"
|
||||
#
|
||||
# @TEST-EXEC-FAIL: unset ZEEK_ALLOW_INIT_ERRORS; zeek -b %INPUT >out 2>&1
|
||||
# @TEST-EXEC-FAIL: unset ZEEK_ALLOW_INIT_ERRORS; zeek -b -O no-event-handler-coalescence %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
event zeek_init()
|
||||
|
@ -69,6 +66,8 @@ event zeek_init()
|
|||
{
|
||||
local r: MyRecord = [$a=1234];
|
||||
assert ! r?$b, fmt("Unexpected r$b is set to %s", r$b);
|
||||
# This will generate a run-time error, rather than reporting the
|
||||
# failed assertion.
|
||||
assert r?$b, fmt("r$b is not set trying anyway: %s", r$b);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" == "1"
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" = "1"
|
||||
# @TEST-EXEC-FAIL: zeek -b %INPUT >output 2>err
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff err
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# A version of uninitialized-local.zeek suitable for ZAM's behavior.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" == "1"
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" = "1"
|
||||
# @TEST-EXEC-FAIL: zeek -b %INPUT >out 2>&1
|
||||
|
||||
event testit() &priority=10
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# @TEST-DOC: Stress tests for the AST optimizer dealing with side effects.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" == "1"
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" = "1"
|
||||
#
|
||||
# See below for an explanation of this convoluted invocation line.
|
||||
# @TEST-EXEC: zeek -b -O ZAM -O dump-xform --optimize-func='AST_opt_test_.*' %INPUT >output
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# @TEST-DOC: ZAM maintenance script for tracking changes in BiFs.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" == "1"
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" = "1"
|
||||
#
|
||||
# @TEST-EXEC: zeek -b %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# @TEST-DOC: ZAM maintenance script for validating synthesized operations.
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" == "1"
|
||||
# @TEST-REQUIRES: test "${ZEEK_ZAM}" = "1"
|
||||
#
|
||||
# @TEST-EXEC: zeek -b -O validate-ZAM %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue