mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Spicy: Improve error messages reporting malformed unit names in EVT files.
This commit is contained in:
parent
2d935d9668
commit
d57c125942
5 changed files with 49 additions and 2 deletions
|
@ -1165,7 +1165,7 @@ bool GlueCompiler::PopulateEvents() {
|
||||||
// to a unit now.
|
// to a unit now.
|
||||||
ev.unit = ev.path.namespace_();
|
ev.unit = ev.path.namespace_();
|
||||||
if ( ! ev.unit ) {
|
if ( ! ev.unit ) {
|
||||||
hilti::logger().error(hilti::util::fmt("unit type missing in hook '%s'", ev.path));
|
hilti::logger().error(hilti::util::fmt("namespace missing for '%s'", ev.path), ev.location);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,7 +1174,7 @@ bool GlueCompiler::PopulateEvents() {
|
||||||
ev.hook = ev.path;
|
ev.hook = ev.path;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hilti::logger().error(hilti::util::fmt("unknown unit type '%s'", ev.unit));
|
hilti::logger().error(hilti::util::fmt("no unit type of name '%s'", ev.path), ev.location);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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] <...>/event-unit-type-fail.evt:5: no unit type of name 'TestAssertion::DoesNotExit'
|
||||||
|
[error] <Spicy support for Zeek>: aborting after errors
|
|
@ -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] <...>/event-unit-type-fail.evt:5: no unit type of name 'TestAssertion::E'
|
||||||
|
[error] <Spicy support for Zeek>: aborting after errors
|
3
testing/btest/Baseline/spicy.event-unit-type-fail/output
Normal file
3
testing/btest/Baseline/spicy.event-unit-type-fail/output
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] <...>/event-unit-type-fail.evt:12: namespace missing for 'Data'
|
||||||
|
[error] <Spicy support for Zeek>: aborting after errors
|
38
testing/btest/spicy/event-unit-type-fail.evt
Normal file
38
testing/btest/spicy/event-unit-type-fail.evt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# @TEST-REQUIRES: have-spicy
|
||||||
|
#
|
||||||
|
# @TEST-EXEC-FAIL: spicyz -d -o test.hlto test.spicy %INPUT 2>output
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=diff-remove-abspath btest-diff output
|
||||||
|
#
|
||||||
|
# @TEST-DOC: Check that we catch various cases of invalid unit types in event definitions; regression test for #3988.
|
||||||
|
|
||||||
|
protocol analyzer spicy::Test over TCP:
|
||||||
|
parse with TestAssertion::Data;
|
||||||
|
|
||||||
|
on TestAssertion::Alias -> event Test::my_event(); # works
|
||||||
|
on Data -> event Test::my_event(); # failure: can't find unit due to missing namespace
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
protocol analyzer spicy::Test over TCP:
|
||||||
|
parse with TestAssertion::Data;
|
||||||
|
|
||||||
|
on TestAssertion::DoesNotExit -> event Test::my_event(); # failure: no such type
|
||||||
|
|
||||||
|
@TEST-START-NEXT
|
||||||
|
|
||||||
|
protocol analyzer spicy::Test over TCP:
|
||||||
|
parse with TestAssertion::Data;
|
||||||
|
|
||||||
|
on TestAssertion::E -> event Test::my_event(); # failure: exists, but not a unit type
|
||||||
|
|
||||||
|
@TEST-START-FILE test.spicy
|
||||||
|
module TestAssertion;
|
||||||
|
|
||||||
|
public type Data = unit {
|
||||||
|
: uint8;
|
||||||
|
};
|
||||||
|
|
||||||
|
public type Alias = Data;
|
||||||
|
public type E = enum { One };
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue