| 34 | } |
| 35 | |
| 36 | TEST(DescriptionTest, LoadImportDesc) { |
| 37 | std::vector<uint8_t> Vec; |
| 38 | |
| 39 | Conf.setWASMStandard(WasmEdge::Standard::WASM_1); |
| 40 | Conf.removeProposal(WasmEdge::Proposal::ImportExportMutGlobals); |
| 41 | WasmEdge::Loader::Loader LdrNoImpMutGlob(Conf); |
| 42 | |
| 43 | // 1. Test load import description. |
| 44 | // |
| 45 | // 1. Load invalid empty import description. |
| 46 | // 2. Load import description with empty module and external name. |
| 47 | // 3. Load import description with module and external names. |
| 48 | // 4. Load import description with invalid external type. |
| 49 | // 5. Load import description of table type. |
| 50 | // 6. Load import description of memory type. |
| 51 | // 7. Load import description of global type. |
| 52 | // 8. Load invalid import description of global type without Mut-Globals |
| 53 | // proposal. |
| 54 | |
| 55 | Vec = { |
| 56 | 0x02U, // Import section |
| 57 | 0x01U, // Content size = 1 |
| 58 | 0x01U // Vector length = 1 |
| 59 | }; |
| 60 | EXPECT_FALSE(Ldr.parseModule(prefixedVec(Vec))); |
| 61 | |
| 62 | Vec = { |
| 63 | 0x02U, // Import section |
| 64 | 0x05U, // Content size = 5 |
| 65 | 0x01U, // Vector length = 1 |
| 66 | 0x00U, // Empty module name |
| 67 | 0x00U, // Empty external name |
| 68 | 0x00U, 0x00U // function type and index |
| 69 | }; |
| 70 | EXPECT_TRUE(Ldr.parseModule(prefixedVec(Vec))); |
| 71 | |
| 72 | Vec = { |
| 73 | 0x02U, // Import section |
| 74 | 0x0FU, // Content size = 15 |
| 75 | 0x01U, // Vector length = 1 |
| 76 | 0x04U, 0x74U, 0x65U, 0x73U, 0x74U, // Module name: test |
| 77 | 0x06U, 0x4CU, 0x6FU, 0x61U, 0x64U, 0x65U, 0x72U, // External name: Loader |
| 78 | 0x00U, 0x00U // function type and index |
| 79 | }; |
| 80 | EXPECT_TRUE(Ldr.parseModule(prefixedVec(Vec))); |
| 81 | |
| 82 | Vec = { |
| 83 | 0x02U, // Import section |
| 84 | 0x0EU, // Content size = 14 |
| 85 | 0x01U, // Vector length = 1 |
| 86 | 0x04U, 0x74U, 0x65U, 0x73U, 0x74U, // Module name: test |
| 87 | 0x06U, 0x4CU, 0x6FU, 0x61U, 0x64U, 0x65U, 0x72U, // External name: Loader |
| 88 | 0x04U, 0x00U // Invalid external type |
| 89 | }; |
| 90 | EXPECT_FALSE(Ldr.parseModule(prefixedVec(Vec))); |
| 91 | |
| 92 | Vec = { |
| 93 | 0x02U, // Import section |
nothing calls this directly
no test coverage detected