Let iwasm return non-zero value when running failed (#1377)

Let iwasm return non-zero value when running failed
so that the caller (e.g. test framework) can check the
running status according to the return value.
This commit is contained in:
Xu Jun
2022-08-12 18:03:14 +08:00
committed by GitHub
parent 872cc51881
commit bc86674a45
4 changed files with 44 additions and 15 deletions

View File

@ -223,6 +223,7 @@ moudle_destroyer(uint8 *buffer, uint32 size)
int
main(int argc, char *argv[])
{
int32 ret = -1;
char *wasm_file = NULL;
const char *func_name = NULL;
uint8 *wasm_file_buf = NULL;
@ -254,8 +255,7 @@ main(int argc, char *argv[])
if (!strcmp(argv[0], "-f") || !strcmp(argv[0], "--function")) {
argc--, argv++;
if (argc < 2) {
print_help();
return 0;
return print_help();
}
func_name = argv[0];
}
@ -286,7 +286,7 @@ main(int argc, char *argv[])
if (dir_list_size >= sizeof(dir_list) / sizeof(char *)) {
printf("Only allow max dir number %d\n",
(int)(sizeof(dir_list) / sizeof(char *)));
return -1;
return 1;
}
dir_list[dir_list_size++] = argv[0] + 6;
}
@ -298,7 +298,7 @@ main(int argc, char *argv[])
if (env_list_size >= sizeof(env_list) / sizeof(char *)) {
printf("Only allow max env number %d\n",
(int)(sizeof(env_list) / sizeof(char *)));
return -1;
return 1;
}
tmp_env = argv[0] + 6;
if (validate_env_str(tmp_env))
@ -437,6 +437,8 @@ main(int argc, char *argv[])
else
app_instance_main(wasm_module_inst);
ret = 0;
/* destroy the module instance */
wasm_runtime_deinstantiate(wasm_module_inst);
@ -454,5 +456,11 @@ fail2:
fail1:
/* destroy runtime environment */
wasm_runtime_destroy();
#if WASM_ENABLE_SPEC_TEST != 0
(void)ret;
return 0;
#else
return ret;
#endif
}