locitest: run all messages through the validator
The only failures are OF 1.2+ flow mods due to the variable-offset instructions
member.
diff --git a/c_gen/templates/locitest/test_validator.c b/c_gen/templates/locitest/test_validator.c
index db8079e..d7947b9 100644
--- a/c_gen/templates/locitest/test_validator.c
+++ b/c_gen/templates/locitest/test_validator.c
@@ -26,6 +26,9 @@
:: # under the EPL.
::
:: include('_copyright.c')
+:: import of_g
+:: from loxi_utils import loxi_utils
+:: from loxi_front_end import type_maps
/**
* Test message validator
@@ -102,12 +105,45 @@
return TEST_PASS;
}
+/*
+ * Create an instance of every message and run it through the validator.
+ */
+static int
+test_validate_all(void)
+{
+:: for version in of_g.of_version_range:
+:: ver_name = loxi_utils.version_to_name(version)
+::
+:: for cls in reversed(of_g.standard_class_order):
+:: if not loxi_utils.class_in_version(cls, version):
+:: continue
+:: elif cls in type_maps.inheritance_map:
+:: continue
+:: elif not loxi_utils.class_is_message(cls):
+:: continue
+:: #endif
+ {
+ ${cls}_t *obj = ${cls}_new(${ver_name});
+ of_message_t msg;
+ ${cls}_${ver_name}_populate(obj, 1);
+ msg = OF_OBJECT_TO_MESSAGE(obj);
+ TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == 0);
+ ${cls}_delete(obj);
+ }
+
+:: #endfor
+:: #endfor
+
+ return TEST_PASS;
+}
+
int
run_validator_tests(void)
{
RUN_TEST(validate_fixed_length);
RUN_TEST(validate_fixed_length_list);
RUN_TEST(validate_tlv16_list);
+ RUN_TEST(validate_all);
return TEST_PASS;
}