diff options
author | Rafael Antognolli <[email protected]> | 2019-07-16 14:26:47 -0700 |
---|---|---|
committer | Rafael Antognolli <[email protected]> | 2019-07-23 17:45:19 +0000 |
commit | 1f4cbc9a060b456a7423be52b8eefa9268a184e5 (patch) | |
tree | 5106133e914eb7b4ae47b97438680c8a50043218 /src/intel | |
parent | fe5ae96d6609f25ef217f6d2e87fca8c6be96d39 (diff) |
intel/genxml: Add new test for subgroups.
Make sure that a <group> tag within another <group> tag work just fine.
v2: rename 'halfbyte' to 'byte' to match the size (Lionel).
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/common/tests/gentest.xml | 8 | ||||
-rw-r--r-- | src/intel/common/tests/genxml_test.c | 36 |
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; } |