diff options
author | Vladimir Lavor <vlavor@cisco.com> | 2020-12-22 15:35:31 +0100 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2021-02-01 12:31:39 +0000 |
commit | c0c73d34a7f5eae44e7c9230ddccc0cfcb201084 (patch) | |
tree | 206568c2717b45bbc8c71783d37e0bec3a2e2ae6 /binapigen/vppapi | |
parent | 4da29d1fb32a77dd299e84a9ed3a11ddcaa31a3b (diff) |
Rework test for binary API union sizes
The test now generates various unions from union.api.json
and tests correct sizes of generated types.
Change-Id: Ifaf18a8ce650e71a8ca8b2d5cfb9d7eed2d757c6
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
Diffstat (limited to 'binapigen/vppapi')
-rw-r--r-- | binapigen/vppapi/testdata/union.api.json | 231 | ||||
-rw-r--r-- | binapigen/vppapi/vppapi_test.go | 2 |
2 files changed, 232 insertions, 1 deletions
diff --git a/binapigen/vppapi/testdata/union.api.json b/binapigen/vppapi/testdata/union.api.json new file mode 100644 index 0000000..0811f22 --- /dev/null +++ b/binapigen/vppapi/testdata/union.api.json @@ -0,0 +1,231 @@ +{ + "services": [], + "vl_api_version": "0x1db2ece9", + "enums": [ + [ + "enum1", + [ + "ENUM_1_VALUE_1", + 1 + ], + [ + "ENUM_1_VALUE_2", + 2 + ], + { + "enumtype": "u16" + } + ], + [ + "enum2", + [ + "ENUM_2_VALUE_1", + 10 + ], + [ + "ENUM_2_VALUE_2", + 20 + ], + { + "enumtype": "u32" + } + ] + ], + "messages": [], + "types": [ + [ + "type1", + [ + "u8", + "field1", + 16 + ], + [ + "u8", + "field2", + 16 + ] + ], + [ + "type2", + [ + "u16", + "field1" + ], + [ + "u32", + "field2" + ], + [ + "u32", + "field3" + ] + ], + [ + "type3", + [ + "u8", + "field1", + 64 + ] + ], + [ + "type4", + [ + "u8", + "field1" + ], + [ + "u8", + "field2", + 16 + ] + ], + [ + "type5", + [ + "u32", + "field1" + ], + [ + "union5", + "field2" + ] + ], + [ + "type6", + [ + "u16", + "field1" + ], + [ + "u32", + "field2" + ], + [ + "type4", + "field3" + ], + [ + "u16", + "field4" + ], + [ + "u32", + "field5" + ], + [ + "u32", + "field6" + ] + ], + [ + "complex_type", + [ + "u32", + "field1" + ], + [ + "u8", + "field2" + ], + [ + "u8", + "field3" + ], + [ + "u32", + "field4" + ], + [ + "type5", + "field5" + ], + [ + "type6", + "field6" + ] + ] + ], + "unions": [ + [ + "union1", + [ + "vl_api_alias1_t", + "alias1" + ], + [ + "vl_api_alias2_t", + "alias2" + ] + ], + [ + "union2", + [ + "vl_api_enum1_t", + "enum1" + ], + [ + "vl_api_enum2_t", + "enum2" + ] + ], + [ + "union3", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_type2_t", + "type2" + ] + ], + [ + "union4", + [ + "vl_api_union1_t", + "union1" + ], + [ + "vl_api_union2_t", + "union2" + ] + ], + [ + "union5", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_type3_t", + "type3" + ] + ], + [ + "union6", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_complex_type_t", + "type3" + ] + ] + ], + "aliases": { + "alias1": { + "type": "u8", + "length": 4 + }, + "alias2": { + "type": "u8", + "length": 16 + }, + "alias3": { + "type": "u32" + } + } +} diff --git a/binapigen/vppapi/vppapi_test.go b/binapigen/vppapi/vppapi_test.go index 027cc1f..a555d9f 100644 --- a/binapigen/vppapi/vppapi_test.go +++ b/binapigen/vppapi/vppapi_test.go @@ -27,7 +27,7 @@ func TestGetInputFiles(t *testing.T) { result, err := FindFiles("testdata", 1) Expect(err).ShouldNot(HaveOccurred()) - Expect(result).To(HaveLen(5)) + Expect(result).To(HaveLen(6)) for _, file := range result { Expect(file).To(BeAnExistingFile()) } |