Skip to content

Commit 9ba8c80

Browse files
authored
samples/multi-module: Examine module registration a bit (#1595)
1 parent 00ae8cd commit 9ba8c80

File tree

1 file changed

+28
-0
lines changed
  • samples/multi-module/src

1 file changed

+28
-0
lines changed

samples/multi-module/src/main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ main()
6666
uint8 *file_buf = NULL;
6767
uint32 file_buf_size = 0;
6868
wasm_module_t module = NULL;
69+
wasm_module_t module1;
6970
wasm_module_inst_t module_inst = NULL;
7071

7172
/* all malloc() only from the given buffer */
@@ -122,6 +123,33 @@ main()
122123
"call \"C5\", it will be failed since it is a export function, ===> ");
123124
wasm_application_execute_func(module_inst, "C5", 0, args);
124125

126+
/* examine module registration a bit */
127+
module1 = wasm_runtime_find_module_registered("mC");
128+
if (module1 != NULL) {
129+
printf("unexpected module mC %p != NULL\n", module1);
130+
goto UNLOAD_MODULE;
131+
}
132+
module1 = wasm_runtime_find_module_registered("mA");
133+
if (module1 == NULL) {
134+
printf("unexpected module mA\n");
135+
goto UNLOAD_MODULE;
136+
}
137+
module1 = wasm_runtime_find_module_registered("mB");
138+
if (module1 == NULL) {
139+
printf("unexpected module mB\n");
140+
goto UNLOAD_MODULE;
141+
}
142+
if (!wasm_runtime_register_module("mC", module, error_buf,
143+
sizeof(error_buf))) {
144+
printf("%s\n", error_buf);
145+
goto UNLOAD_MODULE;
146+
}
147+
module1 = wasm_runtime_find_module_registered("mC");
148+
if (module1 != module) {
149+
printf("unexpected module mC %p != %p\n", module1, module);
150+
goto UNLOAD_MODULE;
151+
}
152+
125153
ret = true;
126154

127155
printf("- wasm_runtime_deinstantiate\n");

0 commit comments

Comments
 (0)