Skip to content

Commit 23799a2

Browse files
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
1 parent 5b32130 commit 23799a2

File tree

12 files changed

+52
-47
lines changed

12 files changed

+52
-47
lines changed

ci/coding_guidelines_check.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
#
66
import argparse
7-
import re
87
from pathlib import Path
98
import re
109
import shlex
@@ -39,7 +38,7 @@
3938

4039
def locate_command(command: str) -> bool:
4140
if not shutil.which(command):
42-
print(f"Command '{command}'' not found")
41+
print(f"Command '{command}' not found")
4342
return False
4443

4544
return True

core/iwasm/compilation/aot_llvm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,7 +3999,7 @@ aot_get_func_from_table(const AOTCompContext *comp_ctx, LLVMValueRef base,
39993999

40004000
if (!(func =
40014001
LLVMBuildBitCast(comp_ctx->builder, func, func_type, "func"))) {
4002-
aot_set_last_error("cast function fialed.");
4002+
aot_set_last_error("cast function failed.");
40034003
goto fail;
40044004
}
40054005

@@ -4068,7 +4068,7 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
40684068

40694069
if (!(const_addr = LLVMBuildBitCast(comp_ctx->builder, const_addr,
40704070
const_ptr_type, "const_addr"))) {
4071-
aot_set_last_error("cast const fialed.");
4071+
aot_set_last_error("cast const failed.");
40724072
return NULL;
40734073
}
40744074

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
26682668
}
26692669
STORE_PTR((void **)global_data, func_obj);
26702670
global_data += sizeof(void *);
2671-
/* Also update the inital_value since other globals may
2671+
/* Also update the initial_value since other globals may
26722672
* refer to this */
26732673
global->initial_value.gc_obj = (wasm_obj_t)func_obj;
26742674
break;

core/shared/utils/bh_vector.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ bh_vector_append(Vector *vector, const void *elem_buf)
194194
goto just_return;
195195
}
196196

197-
/* make sure one more slot is used by the thread who allocas it */
197+
/* make sure one more slot is used by the thread who allocates it */
198198
if (vector->lock)
199199
os_mutex_lock(vector->lock);
200200

201201
if (!extend_vector(vector, vector->num_elems + 1)) {
202-
LOG_ERROR("Append ector elem failed: extend vector failed.\n");
202+
LOG_ERROR("Append vector elem failed: extend vector failed.\n");
203203
goto unlock_return;
204204
}
205205

tests/fuzz/wasm-mutator-fuzz/server/app/main.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def to_json(inst, cls):
7272

7373

7474
class Fuzzing(db.Model):
75-
__tablename__ = 'fazzing_task'
75+
__tablename__ = 'fuzzing_task'
7676
id = db.Column(db.Integer, autoincrement=True,
7777
primary_key=True, nullable=False)
7878
repo = db.Column(db.String(200), nullable=False, default='')
@@ -96,7 +96,7 @@ class TaskError(db.Model):
9696
__tablename__ = 'task_error'
9797
id = db.Column(db.Integer, autoincrement=True,
9898
primary_key=True, nullable=False)
99-
fazzing_id = db.Column(db.Integer, db.ForeignKey("fazzing_task.id"))
99+
fuzzing_id = db.Column(db.Integer, db.ForeignKey("fuzzing_task.id"))
100100
name = db.Column(db.String(200), nullable=False, default='')
101101
std_out = db.Column(db.Text, default='')
102102
data = db.Column(db.JSON)
@@ -119,9 +119,9 @@ def to_data(data):
119119

120120
def error_count(data):
121121
error = len(TaskError.query.filter(
122-
TaskError.fazzing_id == data.get('id'), TaskError.status.in_([1, 2])).all())
122+
TaskError.fuzzing_id == data.get('id'), TaskError.status.in_([1, 2])).all())
123123
end_error = len(TaskError.query.filter(
124-
TaskError.fazzing_id == data.get('id'), TaskError.status == 0).all())
124+
TaskError.fuzzing_id == data.get('id'), TaskError.status == 0).all())
125125
data['error'] = error
126126
data['end_error'] = end_error
127127
return data
@@ -159,11 +159,11 @@ def show_fuzz_list():
159159
id = data.get('id')
160160
if id:
161161
all_error = TaskError.query.filter(
162-
TaskError.fazzing_id == id).with_entities(TaskError.id, TaskError.fazzing_id,
162+
TaskError.fuzzing_id == id).with_entities(TaskError.id, TaskError.fuzzing_id,
163163
TaskError.create_time, TaskError.data,
164164
TaskError.name, TaskError.status,
165165
TaskError.update_time, TaskError.comment).order_by(TaskError.status.desc(), TaskError.update_time.desc(), TaskError.id.desc()).all()
166-
data_message = [{'id': error['id'], "fuzzing_id": error['fazzing_id'],
166+
data_message = [{'id': error['id'], "fuzzing_id": error['fuzzing_id'],
167167
"name": error['name'], "data": error['data'],
168168
'create_time': error['create_time'].strftime('%Y-%m-%d %H:%M:%S'),
169169
'update_time': error['update_time'].strftime('%Y-%m-%d %H:%M:%S'),
@@ -204,7 +204,7 @@ def New_fuzzing():
204204
# curd.set_error_status_to(list(map(lambda x: x.id, error_list)), db)
205205
# Fuzzing.query.filter_by(id=fuzz.id).delete()
206206
fuzz.data = {'error': "Clone repo Error"}
207-
db.commit()
207+
db.session.commit()
208208
return jsonify({"status": 0, "result": "", "msg": "Clone repo Error"})
209209

210210
wamr_path_parent = fuzz_dir.parent.parent
@@ -277,7 +277,7 @@ def scheduler_run_task():
277277

278278
for fuzz in fuzz_query:
279279
all_error = TaskError.query.filter(
280-
TaskError.fazzing_id == fuzz.id).with_entities(TaskError.name).all()
280+
TaskError.fuzzing_id == fuzz.id).with_entities(TaskError.name).all()
281281
fuzz_cmd = wasm_mutator_dir / \
282282
'workspace' / f'build_{fuzz.id}'
283283
dir_list = filter(lambda x: x.startswith(
@@ -287,7 +287,7 @@ def scheduler_run_task():
287287
for dir in dir_list:
288288
cmd = f'cd {fuzz_cmd} && ./wasm_mutator_fuzz {dir}'
289289
status, resp = getstatusoutput(cmd)
290-
task_error = TaskError(name=dir, std_out=resp, fazzing_id=fuzz.id,
290+
task_error = TaskError(name=dir, std_out=resp, fuzzing_id=fuzz.id,
291291
create_time=datetime.utcnow() + timedelta(hours=8))
292292
db.session.add(task_error)
293293
db.session.commit()
@@ -312,7 +312,7 @@ def get_error_txt():
312312
return jsonify({"status": 0, "results": [], 'msg': "Error"})
313313
error = TaskError.query.get(id)
314314
fuzz_cmd = wasm_mutator_dir / \
315-
'workspace' / f'build_{error.fazzing_id}'
315+
'workspace' / f'build_{error.fuzzing_id}'
316316
file_cmd = fuzz_cmd / error.name
317317

318318
response = send_file(file_cmd, as_attachment=True,
@@ -351,7 +351,7 @@ def get_cases_zip():
351351
with ZipFile(memory_file, "w", ZIP_DEFLATED) as zf:
352352
for task_error in task_query:
353353
fuzz_cmd = wasm_mutator_dir / \
354-
'workspace' / f'build_{task_error.fazzing_id}'
354+
'workspace' / f'build_{task_error.fuzzing_id}'
355355
file_cmd = fuzz_cmd / task_error.name
356356
zf.write(str(file_cmd), arcname=task_error.name)
357357
memory_file.seek(0)
@@ -399,7 +399,7 @@ def error_restart():
399399
if run_status:
400400
return jsonify({"status": 0, "results": [], 'msg': "There are already tasks in progress"})
401401
task_query = TaskError.query.filter(TaskError.id.in_(id_list)).all()
402-
fuzzing_id = task_query[0].fazzing_id
402+
fuzzing_id = task_query[0].fuzzing_id
403403
fuzz_cmd = wasm_mutator_dir / \
404404
'workspace' / f'build_{fuzzing_id}'
405405
restart_cmd = wasm_mutator_dir / \
@@ -412,7 +412,7 @@ def error_restart():
412412
if not Path(restart_cmd / 'wamr').exists():
413413
print('------ error: clone repo not folder exists ------')
414414
# fuzz.data = {'error': "Clone repo Error"}
415-
db.commit()
415+
db.session.commit()
416416
return jsonify({"status": 0, "result": "", "msg": "Clone repo Error"})
417417
wamr_path_parent = fuzz_dir.parent.parent
418418
wamr_path = wamr_path_parent / 'wamr'

tests/requirement-engineering/gc-aot/build_spec_interpreter.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ git apply ../../../wamr-test-suites/spec-test-script/gc_ignore_cases.patch
1717
# Set OCaml compiler environment
1818
eval $(opam config env)
1919

20-
echo "compile the reference intepreter"
20+
echo "compile the reference interpreter"
2121
pushd interpreter
2222
make
23-
popd
23+
popd

tests/standalone/test-running-modes/test_c_embed_api_thoroughly.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from collections import OrderedDict
1010

1111

12-
def CLI_ARGS_GENREATOR(running_modes_supported: list[str]) -> list[str]:
12+
def CLI_ARGS_GENERATOR(running_modes_supported: list[str]) -> list[str]:
1313
res = []
1414
list_2d = [["--default-running-mode={} --module-running-mode={}".format(i, j)
1515
for i in running_modes_supported] for j in running_modes_supported]
@@ -35,16 +35,16 @@ def main():
3535
]
3636

3737
# Python 3.7+: Dictionary iteration order is guaranteed to be in order of insertion.
38-
# just to be safe, using orderreddict
38+
# just to be safe, using OrderedDict
3939
# key: value -> compile mode, {"compile_flag": CMake compile flag, "iwasm_cli_args": array of CLI args tested}
4040
test_options = OrderedDict({
41-
"INTERP": {"compile_flag": COMPILE_FLAGS[0], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:1])},
42-
"FAST_JIT": {"compile_flag": COMPILE_FLAGS[1], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:2])},
41+
"INTERP": {"compile_flag": COMPILE_FLAGS[0], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:1])},
42+
"FAST_JIT": {"compile_flag": COMPILE_FLAGS[1], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:2])},
4343
"LLVM_JIT": {"compile_flag": COMPILE_FLAGS[2],
44-
"cli_args": CLI_ARGS_GENREATOR([RUNNING_MODES[0], RUNNING_MODES[2]])},
45-
"MULTI_TIER_JIT": {"compile_flag": COMPILE_FLAGS[3], "cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES)},
44+
"cli_args": CLI_ARGS_GENERATOR([RUNNING_MODES[0], RUNNING_MODES[2]])},
45+
"MULTI_TIER_JIT": {"compile_flag": COMPILE_FLAGS[3], "cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES)},
4646
"EAGER_JIT_WITH_BOTH_JIT": {"compile_flag": COMPILE_FLAGS[4],
47-
"cli_args": CLI_ARGS_GENREATOR(RUNNING_MODES[:3])}
47+
"cli_args": CLI_ARGS_GENERATOR(RUNNING_MODES[:3])}
4848
})
4949

5050
build_cmd = "./build_c_embed.sh \"{build_flag}\""

tests/standalone/test-running-modes/test_iwasm_thoroughly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main():
2929
]
3030

3131
# Python 3.7+: Dictionary iteration order is guaranteed to be in order of insertion.
32-
# just to be safe, using orderreddict
32+
# just to be safe, using OrderedDict
3333
# key: value -> compile mode, {"compile_flag": CMake compile flag, "iwasm_cli_args": array of CLI args tested}
3434
test_options = OrderedDict({
3535
"INTERP": {"compile_flag": COMPILE_FLAGS[0], "iwasm_cli_args": IWASM_CLI_ARGS[:1]},

tests/unit/memory64/memory64_atomic_test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class memory64_atomic_test_suite : public testing::TestWithParam<RunningMode>
3131
return true;
3232

3333
fail:
34-
if (!module)
34+
if (module)
3535
wasm_runtime_unload(module);
3636

3737
return false;
@@ -56,6 +56,8 @@ class memory64_atomic_test_suite : public testing::TestWithParam<RunningMode>
5656
if (exec_env)
5757
wasm_runtime_destroy_exec_env(exec_env);
5858
if (module_inst)
59+
wasm_runtime_deinstantiate(module_inst);
60+
if (module)
5961
wasm_runtime_unload(module);
6062
return false;
6163
}

tests/unit/memory64/memory64_test.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class memory64_test_suite : public testing::TestWithParam<RunningMode>
3131
return true;
3232

3333
fail:
34-
if (!module)
34+
if (module)
3535
wasm_runtime_unload(module);
3636

3737
return false;
@@ -56,11 +56,13 @@ class memory64_test_suite : public testing::TestWithParam<RunningMode>
5656
if (exec_env)
5757
wasm_runtime_destroy_exec_env(exec_env);
5858
if (module_inst)
59+
wasm_runtime_deinstantiate(module_inst);
60+
if (module)
5961
wasm_runtime_unload(module);
6062
return false;
6163
}
6264

63-
void destory_exec_env()
65+
void destroy_exec_env()
6466
{
6567
wasm_runtime_destroy_exec_env(exec_env);
6668
wasm_runtime_deinstantiate(module_inst);
@@ -201,7 +203,7 @@ TEST_P(memory64_test_suite, memory_8GB)
201203
i64 = 0xbeefdead;
202204
ASSERT_EQ(i64, GET_U64_FROM_ADDR(wasm_argv));
203205

204-
destory_exec_env();
206+
destroy_exec_env();
205207
}
206208

207209
TEST_P(memory64_test_suite, mem64_from_clang)
@@ -228,7 +230,7 @@ TEST_P(memory64_test_suite, mem64_from_clang)
228230
i32 = 0x109;
229231
ASSERT_EQ(i32, wasm_argv[0]);
230232

231-
destory_exec_env();
233+
destroy_exec_env();
232234
}
233235

234236
INSTANTIATE_TEST_CASE_P(RunningMode, memory64_test_suite,

0 commit comments

Comments
 (0)