From ca344fdd47db57610ef9bb67caefbd1d5a3cd0bb Mon Sep 17 00:00:00 2001 From: Djordje Todorovic Date: Tue, 30 Aug 2022 17:31:56 +0200 Subject: [PATCH] model: Add tests for import-db --- .../configuration/revng/for-import-idb.yml | 12 +++ .../model/import/idb/enum-type.c.model.yml | 45 +++++++++++ .../model/import/idb/linked-list.c.model.yml | 32 ++++++++ .../import/idb/nested-struct.c.model.yml | 48 ++++++++++++ .../tests/model/import/idb/qsort.c.model.yml | 75 +++++++++++++++++++ .../tests/model/import/idb/simple.c.model.yml | 48 ++++++++++++ .../idb/struct-as-field-ptr.c.model.yml | 51 +++++++++++++ .../tests/model/import/idb/struct.c.model.yml | 21 ++++++ .../idb/typedef-char-to-uint32.c.model.yml | 28 +++++++ 9 files changed, 360 insertions(+) create mode 100644 share/revng/test/configuration/revng/for-import-idb.yml create mode 100644 share/revng/test/tests/model/import/idb/enum-type.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/linked-list.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/nested-struct.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/qsort.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/simple.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/struct-as-field-ptr.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/struct.c.model.yml create mode 100644 share/revng/test/tests/model/import/idb/typedef-char-to-uint32.c.model.yml diff --git a/share/revng/test/configuration/revng/for-import-idb.yml b/share/revng/test/configuration/revng/for-import-idb.yml new file mode 100644 index 000000000..963761923 --- /dev/null +++ b/share/revng/test/configuration/revng/for-import-idb.yml @@ -0,0 +1,12 @@ + +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +commands: + - type: revng.test-import-idb + from: + - type: revng-qa.idb + command: |- + revng model import idb $INPUT + | revng model compare "${SOURCE}.model.yml" diff --git a/share/revng/test/tests/model/import/idb/enum-type.c.model.yml b/share/revng/test/tests/model/import/idb/enum-type.c.model.yml new file mode 100644 index 000000000..265c3a7a8 --- /dev/null +++ b/share/revng/test/tests/model/import/idb/enum-type.c.model.yml @@ -0,0 +1,45 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: +- ID: 1284 + Kind: PrimitiveType + PrimitiveKind: Unsigned + Size: 4 +- Kind: EnumType + ID: 8119090305649570066 + CustomName: "A" + OriginalName: A + UnderlyingType: + UnqualifiedType: "/Types/PrimitiveType-1284" + Entries: + - Value: 0 + CustomName: "x" + OriginalName: x + - Value: 1 + CustomName: "y" + OriginalName: 'y' +- ID: 256 + Kind: PrimitiveType + PrimitiveKind: Void + Size: 0 +- Kind: TypedefType + ID: 1687222338895130802 + CustomName: "A_" + OriginalName: A + UnderlyingType: + UnqualifiedType: "/Types/EnumType-8119090305649570066" +- Kind: CABIFunctionType + ID: 5232257417303549612 + CustomName: "fn" + OriginalName: fn + ABI: SystemV_x86_64 + ReturnType: + UnqualifiedType: "/Types/PrimitiveType-256" + Arguments: + - Index: 0 + Type: + UnqualifiedType: "/Types/TypedefType-1687222338895130802" + CustomName: "x" + OriginalName: x diff --git a/share/revng/test/tests/model/import/idb/linked-list.c.model.yml b/share/revng/test/tests/model/import/idb/linked-list.c.model.yml new file mode 100644 index 000000000..64c45170f --- /dev/null +++ b/share/revng/test/tests/model/import/idb/linked-list.c.model.yml @@ -0,0 +1,32 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: + - Kind: StructType + ID: 17825711661244524544 + CustomName: "Node" + OriginalName: Node + Fields: + - Offset: 0 + CustomName: "content_uint32" + OriginalName: content_uint32 + Type: + UnqualifiedType: "/Types/TypedefType-16313795245817021241" + - Offset: 4 + CustomName: "prev" + OriginalName: prev + Type: + UnqualifiedType: "/Types/TypedefType-14968854803921815239" + Qualifiers: + - Kind: Pointer + Size: 8 + - Offset: 12 + CustomName: "next" + OriginalName: next + Type: + UnqualifiedType: "/Types/TypedefType-14968854803921815239" + Qualifiers: + - Kind: Pointer + Size: 8 + Size: 20 diff --git a/share/revng/test/tests/model/import/idb/nested-struct.c.model.yml b/share/revng/test/tests/model/import/idb/nested-struct.c.model.yml new file mode 100644 index 000000000..9e4d6c2dc --- /dev/null +++ b/share/revng/test/tests/model/import/idb/nested-struct.c.model.yml @@ -0,0 +1,48 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: + - Kind: StructType + ID: 8153719478940916065 + CustomName: "my_struct" + OriginalName: my_struct + Fields: + - Offset: 0 + CustomName: "second" + OriginalName: second + Type: + UnqualifiedType: "/Types/TypedefType-3436967820219683210" + - Offset: 8 + CustomName: "x" + OriginalName: x + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + - Offset: 12 + CustomName: "y" + OriginalName: 'y' + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + Size: 16 + - Kind: TypedefType + ID: 3436967820219683210 + CustomName: "second_struct_" + OriginalName: second_struct + UnderlyingType: + UnqualifiedType: "/Types/StructType-9993798603444101287" + - Kind: StructType + ID: 9993798603444101287 + CustomName: "second_struct" + OriginalName: second_struct + Fields: + - Offset: 0 + CustomName: "a" + OriginalName: a + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + - Offset: 4 + CustomName: "b" + OriginalName: b + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + Size: 8 diff --git a/share/revng/test/tests/model/import/idb/qsort.c.model.yml b/share/revng/test/tests/model/import/idb/qsort.c.model.yml new file mode 100644 index 000000000..a6242e948 --- /dev/null +++ b/share/revng/test/tests/model/import/idb/qsort.c.model.yml @@ -0,0 +1,75 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +ImportedDynamicFunctions: + - OriginalName: qsort + CustomName: "qsort_" + Prototype: "/Types/CABIFunctionType-3821538295510931842" +Types: + - Kind: CABIFunctionType + ID: 3821538295510931842 + CustomName: "qsort" + OriginalName: qsort + ABI: SystemV_x86_64 + ReturnType: + UnqualifiedType: "/Types/PrimitiveType-256" + Arguments: + - Index: 0 + Type: + UnqualifiedType: "/Types/PrimitiveType-256" + Qualifiers: + - Kind: Pointer + Size: 8 + CustomName: "base" + OriginalName: base + - Index: 1 + Type: + UnqualifiedType: "/Types/TypedefType-855760813070670525" + CustomName: "nmemb" + OriginalName: nmemb + - Index: 2 + Type: + UnqualifiedType: "/Types/TypedefType-855760813070670525" + CustomName: "size" + OriginalName: size + - Index: 3 + Type: + UnqualifiedType: "/Types/TypedefType-7339777181910699325" + CustomName: "compar" + OriginalName: compar + - Kind: TypedefType + ID: 855760813070670525 + CustomName: "size_t" + OriginalName: size_t + UnderlyingType: + UnqualifiedType: "/Types/PrimitiveType-1288" + - Kind: TypedefType + ID: 7339777181910699325 + CustomName: "prefix___compar_fn_t" + OriginalName: __compar_fn_t + UnderlyingType: + UnqualifiedType: "/Types/CABIFunctionType-5090678720539169893" + Qualifiers: + - Kind: Pointer + Size: 8 + - Kind: CABIFunctionType + ID: 5090678720539169893 + ABI: SystemV_x86_64 + ReturnType: + UnqualifiedType: "/Types/PrimitiveType-1028" + Arguments: + - Index: 0 + Type: + UnqualifiedType: "/Types/PrimitiveType-256" + Qualifiers: + - Kind: Pointer + Size: 8 + - Kind: Const + - Index: 1 + Type: + UnqualifiedType: "/Types/PrimitiveType-256" + Qualifiers: + - Kind: Pointer + Size: 8 + - Kind: Const diff --git a/share/revng/test/tests/model/import/idb/simple.c.model.yml b/share/revng/test/tests/model/import/idb/simple.c.model.yml new file mode 100644 index 000000000..4389b41b7 --- /dev/null +++ b/share/revng/test/tests/model/import/idb/simple.c.model.yml @@ -0,0 +1,48 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: +- ID: 1028 + Kind: PrimitiveType + PrimitiveKind: Number + Size: 4 +- ID: 1025 + Kind: PrimitiveType + PrimitiveKind: Number + Size: 1 +- Kind: CABIFunctionType + ID: 9061286636309425384 + CustomName: "main" + OriginalName: main + ABI: SystemV_x86_64 + ReturnType: + UnqualifiedType: "/Types/PrimitiveType-1028" + Arguments: + - Index: 0 + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + CustomName: "argc" + OriginalName: argc + - Index: 1 + Type: + UnqualifiedType: "/Types/PrimitiveType-1025" + Qualifiers: + - Kind: Pointer + Size: 8 + - Kind: Pointer + Size: 8 + - Kind: Const + CustomName: "argv" + OriginalName: argv + - Index: 2 + Type: + UnqualifiedType: "/Types/PrimitiveType-1025" + Qualifiers: + - Kind: Pointer + Size: 8 + - Kind: Pointer + Size: 8 + - Kind: Const + CustomName: "envp" + OriginalName: envp diff --git a/share/revng/test/tests/model/import/idb/struct-as-field-ptr.c.model.yml b/share/revng/test/tests/model/import/idb/struct-as-field-ptr.c.model.yml new file mode 100644 index 000000000..0c85514ea --- /dev/null +++ b/share/revng/test/tests/model/import/idb/struct-as-field-ptr.c.model.yml @@ -0,0 +1,51 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: + - Kind: StructType + ID: 12620553074732431538 + CustomName: "my_struct" + OriginalName: my_struct + Fields: + - Offset: 0 + CustomName: "x" + OriginalName: x + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + - Offset: 4 + CustomName: "y" + OriginalName: 'y' + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + - Offset: 8 + CustomName: "z" + OriginalName: z + Type: + UnqualifiedType: "/Types/TypedefType-626103279023675435" + Qualifiers: + - Kind: Pointer + Size: 8 + Size: 16 + - Kind: TypedefType + ID: 626103279023675435 + CustomName: "second_struct_" + OriginalName: second_struct + UnderlyingType: + UnqualifiedType: "/Types/StructType-2113910595525978593" + - Kind: StructType + ID: 2113910595525978593 + CustomName: "second_struct" + OriginalName: second_struct + Fields: + - Offset: 0 + CustomName: "a" + OriginalName: a + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + - Offset: 4 + CustomName: "b" + OriginalName: b + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + Size: 8 diff --git a/share/revng/test/tests/model/import/idb/struct.c.model.yml b/share/revng/test/tests/model/import/idb/struct.c.model.yml new file mode 100644 index 000000000..7a6dfe1e2 --- /dev/null +++ b/share/revng/test/tests/model/import/idb/struct.c.model.yml @@ -0,0 +1,21 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: + - Kind: StructType + ID: 10354558065911308391 + CustomName: "my_struct" + OriginalName: my_struct + Fields: + - Offset: 0 + CustomName: "x" + OriginalName: x + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + - Offset: 4 + CustomName: "y" + OriginalName: 'y' + Type: + UnqualifiedType: "/Types/PrimitiveType-1028" + Size: 8 diff --git a/share/revng/test/tests/model/import/idb/typedef-char-to-uint32.c.model.yml b/share/revng/test/tests/model/import/idb/typedef-char-to-uint32.c.model.yml new file mode 100644 index 000000000..7a3ad4755 --- /dev/null +++ b/share/revng/test/tests/model/import/idb/typedef-char-to-uint32.c.model.yml @@ -0,0 +1,28 @@ +# +# This file is distributed under the MIT License. See LICENSE.md for details. +# + +Types: + - Kind: PrimitiveType + ID: 1025 + PrimitiveKind: Number + Size: 1 + - Kind: CABIFunctionType + ID: 13950133128659256343 + CustomName: "fn" + OriginalName: fn + ABI: SystemV_x86_64 + ReturnType: + UnqualifiedType: "/Types/TypedefType-11568236181854152965" + Arguments: + - Index: 0 + Type: + UnqualifiedType: "/Types/TypedefType-11568236181854152965" + CustomName: "x" + OriginalName: x + - Kind: TypedefType + ID: 11568236181854152965 + CustomName: "prefix_uint32_t" + OriginalName: uint32_t + UnderlyingType: + UnqualifiedType: "/Types/PrimitiveType-1025"