summaryrefslogtreecommitdiffstats
path: root/src/intel/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel/common')
-rw-r--r--src/intel/common/tests/gentest.xml8
-rw-r--r--src/intel/common/tests/genxml_test.c36
2 files changed, 44 insertions, 0 deletions
diff --git a/src/intel/common/tests/gentest.xml b/src/intel/common/tests/gentest.xml
index 249ebad612b..75a944365a3 100644
--- a/src/intel/common/tests/gentest.xml
+++ b/src/intel/common/tests/gentest.xml
@@ -9,4 +9,12 @@
</group>
</struct>
+ <struct name="STRUCT_TWO_LEVELS" length="8">
+ <group count="4" start="0" size="64">
+ <group count="8" start="0" size="8">
+ <field name="byte" start="0" end="7" type="uint"/>
+ </group>
+ </group>
+ </struct>
+
</genxml>
diff --git a/src/intel/common/tests/genxml_test.c b/src/intel/common/tests/genxml_test.c
index 85002929fca..4bcc3129003 100644
--- a/src/intel/common/tests/genxml_test.c
+++ b/src/intel/common/tests/genxml_test.c
@@ -90,6 +90,41 @@ test_struct(struct gen_spec *spec) {
}
}
+static void
+test_two_levels(struct gen_spec *spec) {
+ struct GEN9_STRUCT_TWO_LEVELS test;
+
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 8; j++) {
+ test.byte[i][j] = (i * 10 + j) % 256;
+ }
+ }
+
+ uint32_t dw[GEN9_STRUCT_TWO_LEVELS_length];
+ GEN9_STRUCT_TWO_LEVELS_pack(NULL, dw, &test);
+
+ struct gen_group *group;
+ group = gen_spec_find_struct(spec, "STRUCT_TWO_LEVELS");
+
+ assert(group != NULL);
+
+ if (!quiet) {
+ printf("\nSTRUCT_TWO_LEVELS\n");
+ gen_print_group(stdout, group, 0, dw, 0, false);
+ }
+
+ struct gen_field_iterator iter;
+ gen_field_iterator_init(&iter, group, dw, 0, false);
+
+ while (gen_field_iterator_next(&iter)) {
+ int i, j;
+
+ assert(sscanf(iter.name, "byte[%d][%d]", &i, &j) == 2);
+ uint8_t number = iter.raw_value;
+ assert(number == test.byte[i][j]);
+ }
+}
+
int main(int argc, char **argv)
{
struct gen_spec *spec = gen_spec_load_filename(GENXML_PATH);
@@ -98,6 +133,7 @@ int main(int argc, char **argv)
quiet = true;
test_struct(spec);
+ test_two_levels(spec);
return 0;
}