Extended ZAM validation to include macros

This commit is contained in:
Vern Paxson 2025-01-02 15:32:30 -08:00
parent 9e85a0d27d
commit 7a908a2876
5 changed files with 21 additions and 8 deletions

@ -1 +1 @@
Subproject commit 517bf6a5c8dc6afdee2b854d575dbdd15736afc5 Subproject commit e780bb6c17f55ef5a4a739c14f49b3f454991dea

View file

@ -13,9 +13,11 @@ using std::string;
namespace zeek::detail { namespace zeek::detail {
std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc = { std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc = {
#include "ZAM-OpDesc.h"
};
#include "ZAM-Desc.h" std::vector<std::pair<string, string>> zam_macro_desc = {
#include "ZAM-MacroDesc.h"
}; };
// While the following has commonalities that could be factored out, // While the following has commonalities that could be factored out,
@ -107,7 +109,15 @@ void validate_ZAM_insts() {
for ( auto& zid : zam_inst_desc ) for ( auto& zid : zam_inst_desc )
analyze_ZAM_inst(ZOP_name(zid.first), zid.second); analyze_ZAM_inst(ZOP_name(zid.first), zid.second);
printf("%d valid, %d tested, %d skipped\n", num_valid, num_tested, num_skipped); int num_valid_macros = 0;
for ( auto& md : zam_macro_desc ) {
if ( std::regex_search(md.second, std::regex("\\$[0-9$]")) )
reporter->InternalError("macro %s contains dollar parameter: %s", md.first.c_str(), md.second.c_str());
++num_valid_macros;
}
printf("%d valid ops, %d tested, %d skipped, %d valid macros\n", num_valid, num_tested, num_skipped,
num_valid_macros);
} }
} // namespace zeek::detail } // namespace zeek::detail

View file

@ -72,6 +72,10 @@ struct ZAMInstDesc {
// Provides access to the validation description of each operation. // Provides access to the validation description of each operation.
extern std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc; extern std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc;
// Same, for the associated macros. First field is macro name, second is
// definition (including "#define" etc.).
extern std::vector<std::pair<std::string, std::string>> zam_macro_desc;
// Maps an operand to its flavor. // Maps an operand to its flavor.
extern ZAMOp1Flavor op1_flavor[]; extern ZAMOp1Flavor op1_flavor[];

View file

@ -1,2 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
1255 valid, 1908 tested, 440 skipped

View file

@ -1,4 +1,5 @@
# @TEST-DOC: ZAM maintenance script for validating synthesized operations. # @TEST-DOC: ZAM maintenance script for validating synthesized operations.
# #
# @TEST-EXEC: zeek -b -O validate-ZAM %INPUT >output # We don't check the output, since it varies for benign reasons as ZAM
# @TEST-EXEC: btest-diff output # operations are modified. What matters is the exit status of success.
# @TEST-EXEC: zeek -b -O validate-ZAM %INPUT