From: Rafael Antognolli Date: Tue, 16 Jul 2019 21:26:47 +0000 (-0700) Subject: intel/genxml: Add new test for subgroups. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1f4cbc9a060b456a7423be52b8eefa9268a184e5;p=mesa.git intel/genxml: Add new test for subgroups. Make sure that a tag within another tag work just fine. v2: rename 'halfbyte' to 'byte' to match the size (Lionel). Reviewed-by: Lionel Landwerlin --- 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 @@ + + + + + + + + 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; }