Skip to content

Conversation

@kylo5aby
Copy link
Contributor

Summary

To quickly improve WAMR's software quality, this PR uses LLM to generate unit test cases for the interpreter module.

Changes

  • Add 15 new unit test cases for iwasm/interpreter module
  • Improve iwasm/interpreter coverage:
    • Lines coverage: 33.7% → 35.0% (+1.3%)
    • Functions coverage: 55.4% → 56.2% (+0.8%)

Testing

All new test cases pass successfully.

Welcome any feedback or suggestions on these AI-generated test cases. Please let me know if you have ideas for improvement.

Signed-off-by: zhenweijin <[email protected]>

Co-authored-by: Gong, Pu <[email protected]>

target_link_libraries (interpreter_test gtest_main )

# Copy WASM files to build directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably store all those test cases in a separate directory, such as smart-tests or digit-suite.

please co-sign with ai-assistant in the git comment. https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line

# Copy WASM files to build directory
add_custom_command(TARGET interpreter_test POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps/*.wasm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps/*.wasm
${CMAKE_CURRENT_LIST_DIR}/wasm-apps/*.wasm

wasm_argv[0] = 42; // input value

bool success = wasm_runtime_call_wasm(exec_env, func, 1, wasm_argv);
ASSERT_FALSE(success);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally, wasm_runtime_get_exception() should return a non-empty infomation.

* Target: core/iwasm/interpreter/wasm_runtime.c:wasm_call_indirect()
* Expected Coverage: ~12 lines (success path)
*/
TEST_F(FunctionInvocationTest, WasmCallIndirect_Success_ExecutesCorrectly)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication with CallIndirect_ValidFunction_ReturnsCorrectResult

wasm_argv[0] = 100; // input value

bool success = wasm_runtime_call_wasm(exec_env, func, 1, wasm_argv);
ASSERT_FALSE(success);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally, wasm_runtime_get_exception() should return a non-empty information.

bool success = wasm_runtime_call_wasm(exec_env, func, 1, wasm_argv);
// This might succeed or fail depending on implementation
// The important thing is that it doesn't crash
if (success) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if() should be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returned value should be checked by an assertion unconditionally. like

ASSERT_TRUE(success);
ASSERT_EQ(wasm_arv[0], 0);


// Complex calculation with overflow handling
// The exact result depends on implementation but should not crash
ASSERT_TRUE(true); // Test passes if no crash occurs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid assertion.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd suggest that anyone who wants to submit an AI-generated thing should review it by himself extensively before making it be publicly reviewed.
reviewing AI-generated logic is tiresome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants