mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-09-06 09:51:27 +00:00
Collective fix (#4413)
* Fix vector growth check and typos in core (#9) * Fix resource cleanup in memory and running modes tests (#10) * Add end of file empty line in wasm_running_modes_test.cc
This commit is contained in:
parent
5b32130955
commit
23799a2cb6
|
@ -4,7 +4,6 @@
|
|||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
import argparse
|
||||
import re
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shlex
|
||||
|
@ -39,7 +38,7 @@ INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)"
|
|||
|
||||
def locate_command(command: str) -> bool:
|
||||
if not shutil.which(command):
|
||||
print(f"Command '{command}'' not found")
|
||||
print(f"Command '{command}' not found")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
@ -3999,7 +3999,7 @@ aot_get_func_from_table(const AOTCompContext *comp_ctx, LLVMValueRef base,
|
|||
|
||||
if (!(func =
|
||||
LLVMBuildBitCast(comp_ctx->builder, func, func_type, "func"))) {
|
||||
aot_set_last_error("cast function fialed.");
|
||||
aot_set_last_error("cast function failed.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -4068,7 +4068,7 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
|
|||
|
||||
if (!(const_addr = LLVMBuildBitCast(comp_ctx->builder, const_addr,
|
||||
const_ptr_type, "const_addr"))) {
|
||||
aot_set_last_error("cast const fialed.");
|
||||
aot_set_last_error("cast const failed.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -2668,7 +2668,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
|
|||
}
|
||||
STORE_PTR((void **)global_data, func_obj);
|
||||
global_data += sizeof(void *);
|
||||
/* Also update the inital_value since other globals may
|
||||
/* Also update the initial_value since other globals may
|
||||
* refer to this */
|
||||
global->initial_value.gc_obj = (wasm_obj_t)func_obj;
|
||||
break;
|
||||
|
|
|
@ -194,12 +194,12 @@ bh_vector_append(Vector *vector, const void *elem_buf)
|
|||
goto just_return;
|
||||
}
|
||||
|
||||
/* make sure one more slot is used by the thread who allocas it */
|
||||
/* make sure one more slot is used by the thread who allocates it */
|
||||
if (vector->lock)
|
||||
os_mutex_lock(vector->lock);
|
||||
|
||||
if (!extend_vector(vector, vector->num_elems + 1)) {
|
||||
LOG_ERROR("Append ector elem failed: extend vector failed.\n");
|
||||
LOG_ERROR("Append vector elem failed: extend vector failed.\n");
|
||||
goto unlock_return;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ def to_json(inst, cls):
|
|||
|
||||
|
||||
class Fuzzing(db.Model):
|
||||
__tablename__ = 'fazzing_task'
|
||||
__tablename__ = 'fuzzing_task'
|
||||
id = db.Column(db.Integer, autoincrement=True,
|
||||
primary_key=True, nullable=False)
|
||||
repo = db.Column(db.String(200), nullable=False, default='')
|
||||
|
@ -96,7 +96,7 @@ class TaskError(db.Model):
|
|||
__tablename__ = 'task_error'
|
||||
id = db.Column(db.Integer, autoincrement=True,
|
||||
primary_key=True, nullable=False)
|
||||
fazzing_id = db.Column(db.Integer, db.ForeignKey("fazzing_task.id"))
|
||||
fuzzing_id = db.Column(db.Integer, db.ForeignKey("fuzzing_task.id"))
|
||||
name = db.Column(db.String(200), nullable=False, default='')
|
||||
std_out = db.Column(db.Text, default='')
|
||||
data = db.Column(db.JSON)
|
||||
|
@ -119,9 +119,9 @@ def to_data(data):
|
|||
|
||||
def error_count(data):
|
||||
error = len(TaskError.query.filter(
|
||||
TaskError.fazzing_id == data.get('id'), TaskError.status.in_([1, 2])).all())
|
||||
TaskError.fuzzing_id == data.get('id'), TaskError.status.in_([1, 2])).all())
|
||||
end_error = len(TaskError.query.filter(
|
||||
TaskError.fazzing_id == data.get('id'), TaskError.status == 0).all())
|
||||
TaskError.fuzzing_id == data.get('id'), TaskError.status == 0).all())
|
||||
data['error'] = error
|
||||
data['end_error'] = end_error
|
||||
return data
|
||||
|
@ -159,11 +159,11 @@ def show_fuzz_list():
|
|||
id = data.get('id')
|
||||
if id:
|
||||
all_error = TaskError.query.filter(
|
||||
TaskError.fazzing_id == id).with_entities(TaskError.id, TaskError.fazzing_id,
|
||||
TaskError.fuzzing_id == id).with_entities(TaskError.id, TaskError.fuzzing_id,
|
||||
TaskError.create_time, TaskError.data,
|
||||
TaskError.name, TaskError.status,
|
||||
TaskError.update_time, TaskError.comment).order_by(TaskError.status.desc(), TaskError.update_time.desc(), TaskError.id.desc()).all()
|
||||
data_message = [{'id': error['id'], "fuzzing_id": error['fazzing_id'],
|
||||
data_message = [{'id': error['id'], "fuzzing_id": error['fuzzing_id'],
|
||||
"name": error['name'], "data": error['data'],
|
||||
'create_time': error['create_time'].strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'update_time': error['update_time'].strftime('%Y-%m-%d %H:%M:%S'),
|
||||
|
@ -204,7 +204,7 @@ def New_fuzzing():
|
|||
# curd.set_error_status_to(list(map(lambda x: x.id, error_list)), db)
|
||||
# Fuzzing.query.filter_by(id=fuzz.id).delete()
|
||||
fuzz.data = {'error': "Clone repo Error"}
|
||||
db.commit()
|
||||
db.session.commit()
|
||||
return jsonify({"status": 0, "result": "", "msg": "Clone repo Error"})
|
||||
|
||||
wamr_path_parent = fuzz_dir.parent.parent
|
||||
|
@ -277,7 +277,7 @@ def scheduler_run_task():
|
|||
|
||||
for fuzz in fuzz_query:
|
||||
all_error = TaskError.query.filter(
|
||||
TaskError.fazzing_id == fuzz.id).with_entities(TaskError.name).all()
|
||||
TaskError.fuzzing_id == fuzz.id).with_entities(TaskError.name).all()
|
||||
fuzz_cmd = wasm_mutator_dir / \
|
||||
'workspace' / f'build_{fuzz.id}'
|
||||
dir_list = filter(lambda x: x.startswith(
|
||||
|
@ -287,7 +287,7 @@ def scheduler_run_task():
|
|||
for dir in dir_list:
|
||||
cmd = f'cd {fuzz_cmd} && ./wasm_mutator_fuzz {dir}'
|
||||
status, resp = getstatusoutput(cmd)
|
||||
task_error = TaskError(name=dir, std_out=resp, fazzing_id=fuzz.id,
|
||||
task_error = TaskError(name=dir, std_out=resp, fuzzing_id=fuzz.id,
|
||||
create_time=datetime.utcnow() + timedelta(hours=8))
|
||||
db.session.add(task_error)
|
||||
db.session.commit()
|
||||
|
@ -312,7 +312,7 @@ def get_error_txt():
|
|||
return jsonify({"status": 0, "results": [], 'msg': "Error"})
|
||||
error = TaskError.query.get(id)
|
||||
fuzz_cmd = wasm_mutator_dir / \
|
||||
'workspace' / f'build_{error.fazzing_id}'
|
||||
'workspace' / f'build_{error.fuzzing_id}'
|
||||
file_cmd = fuzz_cmd / error.name
|
||||
|
||||
response = send_file(file_cmd, as_attachment=True,
|
||||
|
@ -351,7 +351,7 @@ def get_cases_zip():
|
|||
with ZipFile(memory_file, "w", ZIP_DEFLATED) as zf:
|
||||
for task_error in task_query:
|
||||
fuzz_cmd = wasm_mutator_dir / \
|
||||
'workspace' / f'build_{task_error.fazzing_id}'
|
||||
'workspace' / f'build_{task_error.fuzzing_id}'
|
||||
file_cmd = fuzz_cmd / task_error.name
|
||||
zf.write(str(file_cmd), arcname=task_error.name)
|
||||
memory_file.seek(0)
|
||||
|
@ -399,7 +399,7 @@ def error_restart():
|
|||
if run_status:
|
||||
return jsonify({"status": 0, "results": [], 'msg': "There are already tasks in progress"})
|
||||
task_query = TaskError.query.filter(TaskError.id.in_(id_list)).all()
|
||||
fuzzing_id = task_query[0].fazzing_id
|
||||
fuzzing_id = task_query[0].fuzzing_id
|
||||
fuzz_cmd = wasm_mutator_dir / \
|
||||
'workspace' / f'build_{fuzzing_id}'
|
||||
restart_cmd = wasm_mutator_dir / \
|
||||
|
@ -412,7 +412,7 @@ def error_restart():
|
|||
if not Path(restart_cmd / 'wamr').exists():
|
||||
print('------ error: clone repo not folder exists ------')
|
||||
# fuzz.data = {'error': "Clone repo Error"}
|
||||
db.commit()
|
||||
db.session.commit()
|
||||
return jsonify({"status": 0, "result": "", "msg": "Clone repo Error"})
|
||||
wamr_path_parent = fuzz_dir.parent.parent
|
||||
wamr_path = wamr_path_parent / 'wamr'
|
||||
|
|
|
@ -17,7 +17,7 @@ git apply ../../../wamr-test-suites/spec-test-script/gc_ignore_cases.patch
|
|||
# Set OCaml compiler environment
|
||||
eval $(opam config env)
|
||||
|
||||
echo "compile the reference intepreter"
|
||||
echo "compile the reference interpreter"
|
||||
pushd interpreter
|
||||
make
|
||||
popd
|
||||
popd
|
||||
|
|
|
@ -9,7 +9,7 @@ import os
|
|||
from collections import OrderedDict
|
||||
|
||||
|
||||
def CLI_ARGS_GENREATOR(running_modes_supported: list[str]) -> list[str]:
|
||||
def CLI_ARGS_GENERATOR(running_modes_supported: list[str]) -> list[str]:
|
||||
res = []
|
||||
list_2d = [["--default-running-mode={} --module-running-mode={}".format(i, j)
|
||||
for i in running_modes_supported] for j in running_modes_supported]
|
||||
|
@ -35,16 +35,16 @@ def main():
|
|||
]
|
||||
|
||||
# Python 3.7+: Dictionary iteration order is guaranteed to be in order of insertion.
|
||||
# just to be safe, using orderreddict
|
||||
# just to be safe, using OrderedDict
|
||||
# key: value -> compile mode, {"compile_flag": CMake compile flag, "iwasm_cli_args": array of CLI args tested}
|
||||
test_options = OrderedDict({
|
||||
"INTERP": {"compile_flag": COMPILE_FLAGS[0], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:1])},
|
||||
"FAST_JIT": {"compile_flag": COMPILE_FLAGS[1], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:2])},
|
||||
"INTERP": {"compile_flag": COMPILE_FLAGS[0], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:1])},
|
||||
"FAST_JIT": {"compile_flag": COMPILE_FLAGS[1], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:2])},
|
||||
"LLVM_JIT": {"compile_flag": COMPILE_FLAGS[2],
|
||||
"cli_args": CLI_ARGS_GENREATOR([RUNNING_MODES[0], RUNNING_MODES[2]])},
|
||||
"MULTI_TIER_JIT": {"compile_flag": COMPILE_FLAGS[3], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES)},
|
||||
"cli_args": CLI_ARGS_GENERATOR([RUNNING_MODES[0], RUNNING_MODES[2]])},
|
||||
"MULTI_TIER_JIT": {"compile_flag": COMPILE_FLAGS[3], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES)},
|
||||
"EAGER_JIT_WITH_BOTH_JIT": {"compile_flag": COMPILE_FLAGS[4],
|
||||
"cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:3])}
|
||||
"cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:3])}
|
||||
})
|
||||
|
||||
build_cmd = "./build_c_embed.sh \"{build_flag}\""
|
||||
|
|
|
@ -29,7 +29,7 @@ def main():
|
|||
]
|
||||
|
||||
# Python 3.7+: Dictionary iteration order is guaranteed to be in order of insertion.
|
||||
# just to be safe, using orderreddict
|
||||
# just to be safe, using OrderedDict
|
||||
# key: value -> compile mode, {"compile_flag": CMake compile flag, "iwasm_cli_args": array of CLI args tested}
|
||||
test_options = OrderedDict({
|
||||
"INTERP": {"compile_flag": COMPILE_FLAGS[0], "iwasm_cli_args": IWASM_CLI_ARGS[:1]},
|
||||
|
|
|
@ -31,7 +31,7 @@ class memory64_atomic_test_suite : public testing::TestWithParam<RunningMode>
|
|||
return true;
|
||||
|
||||
fail:
|
||||
if (!module)
|
||||
if (module)
|
||||
wasm_runtime_unload(module);
|
||||
|
||||
return false;
|
||||
|
@ -56,6 +56,8 @@ class memory64_atomic_test_suite : public testing::TestWithParam<RunningMode>
|
|||
if (exec_env)
|
||||
wasm_runtime_destroy_exec_env(exec_env);
|
||||
if (module_inst)
|
||||
wasm_runtime_deinstantiate(module_inst);
|
||||
if (module)
|
||||
wasm_runtime_unload(module);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class memory64_test_suite : public testing::TestWithParam<RunningMode>
|
|||
return true;
|
||||
|
||||
fail:
|
||||
if (!module)
|
||||
if (module)
|
||||
wasm_runtime_unload(module);
|
||||
|
||||
return false;
|
||||
|
@ -56,11 +56,13 @@ class memory64_test_suite : public testing::TestWithParam<RunningMode>
|
|||
if (exec_env)
|
||||
wasm_runtime_destroy_exec_env(exec_env);
|
||||
if (module_inst)
|
||||
wasm_runtime_deinstantiate(module_inst);
|
||||
if (module)
|
||||
wasm_runtime_unload(module);
|
||||
return false;
|
||||
}
|
||||
|
||||
void destory_exec_env()
|
||||
void destroy_exec_env()
|
||||
{
|
||||
wasm_runtime_destroy_exec_env(exec_env);
|
||||
wasm_runtime_deinstantiate(module_inst);
|
||||
|
@ -201,7 +203,7 @@ TEST_P(memory64_test_suite, memory_8GB)
|
|||
i64 = 0xbeefdead;
|
||||
ASSERT_EQ(i64, GET_U64_FROM_ADDR(wasm_argv));
|
||||
|
||||
destory_exec_env();
|
||||
destroy_exec_env();
|
||||
}
|
||||
|
||||
TEST_P(memory64_test_suite, mem64_from_clang)
|
||||
|
@ -228,7 +230,7 @@ TEST_P(memory64_test_suite, mem64_from_clang)
|
|||
i32 = 0x109;
|
||||
ASSERT_EQ(i32, wasm_argv[0]);
|
||||
|
||||
destory_exec_env();
|
||||
destroy_exec_env();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RunningMode, memory64_test_suite,
|
||||
|
|
|
@ -21,7 +21,7 @@ std::string TEST_WASM1 = "/hello.wasm";
|
|||
std::string TEST_WASM2 = "/mytest.wasm";
|
||||
char *WASM_FILE_1;
|
||||
char *WASM_FILE_2;
|
||||
std::vector<RunningMode> running_mode_supportted = { Mode_Interp,
|
||||
std::vector<RunningMode> running_mode_supported = { Mode_Interp,
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
Mode_Fast_JIT,
|
||||
#endif
|
||||
|
@ -76,7 +76,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
|
|||
return true;
|
||||
|
||||
fail:
|
||||
if (!module)
|
||||
if (module)
|
||||
wasm_runtime_unload(module);
|
||||
|
||||
return false;
|
||||
|
@ -101,11 +101,13 @@ class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
|
|||
if (exec_env)
|
||||
wasm_runtime_destroy_exec_env(exec_env);
|
||||
if (module_inst)
|
||||
wasm_runtime_deinstantiate(module_inst);
|
||||
if (module)
|
||||
wasm_runtime_unload(module);
|
||||
return false;
|
||||
}
|
||||
|
||||
void destory_exec_env()
|
||||
void destroy_exec_env()
|
||||
{
|
||||
wasm_runtime_destroy_exec_env(exec_env);
|
||||
wasm_runtime_deinstantiate(module_inst);
|
||||
|
@ -139,7 +141,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
|
|||
ASSERT_TRUE(ret);
|
||||
ASSERT_EQ(10, wasm_argv[0]);
|
||||
|
||||
destory_exec_env();
|
||||
destroy_exec_env();
|
||||
}
|
||||
|
||||
void run_wasm_complex(char *filename1, char *filename2,
|
||||
|
@ -168,7 +170,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
|
|||
ASSERT_TRUE(ret);
|
||||
ASSERT_EQ(10, wasm_argv[0]);
|
||||
|
||||
destory_exec_env();
|
||||
destroy_exec_env();
|
||||
|
||||
/* run wasm file 2 in running_mode */
|
||||
ret = load_wasm_file(filename2);
|
||||
|
@ -184,7 +186,7 @@ class wasm_running_modes_test_suite : public testing::TestWithParam<RunningMode>
|
|||
ret = wasm_runtime_call_wasm(exec_env, main, 2, wasm_argv);
|
||||
ASSERT_TRUE(ret);
|
||||
|
||||
destory_exec_env();
|
||||
destroy_exec_env();
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -246,7 +248,7 @@ TEST_F(wasm_running_modes_test_suite, wasm_runtime_is_running_mode_supported)
|
|||
// normal situation
|
||||
ASSERT_EQ(true, wasm_runtime_is_running_mode_supported(
|
||||
static_cast<RunningMode>(Mode_Default)));
|
||||
for (auto running_mode : running_mode_supportted) {
|
||||
for (auto running_mode : running_mode_supported) {
|
||||
ASSERT_EQ(true, wasm_runtime_is_running_mode_supported(running_mode));
|
||||
}
|
||||
|
||||
|
@ -264,7 +266,7 @@ TEST_F(wasm_running_modes_test_suite, wasm_runtime_set_default_running_mode)
|
|||
// normal situation: only set up
|
||||
ASSERT_EQ(true, wasm_runtime_set_default_running_mode(
|
||||
static_cast<RunningMode>(Mode_Default)));
|
||||
for (auto running_mode : running_mode_supportted) {
|
||||
for (auto running_mode : running_mode_supported) {
|
||||
ASSERT_EQ(true, wasm_runtime_set_default_running_mode(running_mode));
|
||||
}
|
||||
|
||||
|
@ -296,13 +298,13 @@ TEST_P(wasm_running_modes_test_suite,
|
|||
wasm_runtime_set_and_get_running_mode_complex)
|
||||
{
|
||||
RunningMode default_running_mode = GetParam();
|
||||
for (auto running_mode : running_mode_supportted) {
|
||||
for (auto running_mode : running_mode_supported) {
|
||||
run_wasm_complex(WASM_FILE_1, WASM_FILE_2, default_running_mode,
|
||||
running_mode);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RunningMode, wasm_running_modes_test_suite,
|
||||
testing::ValuesIn(running_mode_supportted));
|
||||
testing::ValuesIn(running_mode_supported));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -414,7 +414,7 @@ function setup_wabt()
|
|||
|
||||
function compile_reference_interpreter()
|
||||
{
|
||||
echo "compile the reference intepreter"
|
||||
echo "compile the reference interpreter"
|
||||
pushd interpreter
|
||||
make
|
||||
if [ $? -ne 0 ]
|
||||
|
|
Loading…
Reference in New Issue
Block a user