Skip to content

Commit d68d2a5

Browse files
committed
[complication] Add 20 cases for advanced compiler core operations
- Advanced compiler configurations and feature combinations - Memory optimization and profiling settings - Platform-specific compilation options - Resource management and lifecycle testing - Optimization level validation across all supported levels Signed-off-by: Gong Pu <pu.gong@intel.com>
1 parent b124f70 commit d68d2a5

5 files changed

Lines changed: 697 additions & 0 deletions

File tree

tests/unit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ add_subdirectory(aot-stack-frame)
6868
add_subdirectory(linux-perf)
6969
add_subdirectory(gc)
7070
add_subdirectory(tid-allocator)
71+
add_subdirectory(enhanced_unit_test)
7172

7273
if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
7374
# should enable 32-bit llvm when X86_32
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
cmake_minimum_required(VERSION 3.14)
5+
6+
project (test-enhanced-compilation)
7+
8+
add_definitions (-DRUN_ON_LINUX)
9+
10+
add_definitions (-Dattr_container_malloc=malloc)
11+
add_definitions (-Dattr_container_free=free)
12+
add_definitions (-DWASM_ENABLE_WAMR_COMPILER=1)
13+
add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1)
14+
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
15+
16+
set (WAMR_BUILD_LIBC_WASI 0)
17+
set (WAMR_BUILD_APP_FRAMEWORK 0)
18+
set (WAMR_BUILD_THREAD_MGR 1)
19+
set (WAMR_BUILD_AOT 1)
20+
21+
include (../../unit_common.cmake)
22+
23+
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
24+
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
25+
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
26+
endif ()
27+
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
28+
find_package(LLVM REQUIRED CONFIG)
29+
include_directories(${LLVM_INCLUDE_DIRS})
30+
add_definitions(${LLVM_DEFINITIONS})
31+
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
32+
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
33+
34+
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
35+
36+
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
37+
38+
file (GLOB source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
39+
40+
set (UNIT_SOURCE ${source_all})
41+
42+
set (unit_test_sources
43+
${UNIT_SOURCE}
44+
${WAMR_RUNTIME_LIB_SOURCE}
45+
${UNCOMMON_SHARED_SOURCE}
46+
${SRC_LIST}
47+
${PLATFORM_SHARED_SOURCE}
48+
${UTILS_SHARED_SOURCE}
49+
${MEM_ALLOC_SHARED_SOURCE}
50+
${LIB_HOST_AGENT_SOURCE}
51+
${NATIVE_INTERFACE_SOURCE}
52+
${LIBC_BUILTIN_SOURCE}
53+
${IWASM_COMMON_SOURCE}
54+
${IWASM_INTERP_SOURCE}
55+
${IWASM_AOT_SOURCE}
56+
${IWASM_COMPL_SOURCE}
57+
${WASM_APP_LIB_SOURCE_ALL}
58+
)
59+
60+
# Now simply link against gtest or gtest_main as needed. Eg
61+
add_executable (enhanced_compilation_test ${unit_test_sources})
62+
63+
target_link_libraries (enhanced_compilation_test ${LLVM_AVAILABLE_LIBS} gtest_main )
64+
65+
add_custom_command(TARGET enhanced_compilation_test POST_BUILD
66+
COMMAND ${CMAKE_COMMAND} -E copy
67+
${CMAKE_CURRENT_LIST_DIR}/wasm-apps/main.wasm
68+
${CMAKE_CURRENT_BINARY_DIR}
69+
COMMENT "Copy main.wasm to the directory: build/enhanced_compilation."
70+
)
71+
72+
include(GoogleTest)
73+
gtest_discover_tests(enhanced_compilation_test)
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Feature-Comprehensive Test Plan for Compilation Module
2+
3+
## Current Test Analysis
4+
5+
### Existing Test Files (11 files, 45 test cases)
6+
- **aot_compiler_test.cc**: AOT compiler basic functionality
7+
- **aot_emit_aot_file_test.cc**: AOT file emission testing
8+
- **aot_emit_compare_test.cc**: Comparison operations emission
9+
- **aot_emit_control_test.cc**: Control flow emission
10+
- **aot_emit_function_test.cc**: Function emission testing
11+
- **aot_emit_memory_test.cc**: Memory operations emission
12+
- **aot_emit_numberic_test.cc**: Numeric operations emission
13+
- **aot_emit_parametric_test.cc**: Parametric operations emission
14+
- **aot_emit_table_test.cc**: Table operations emission
15+
- **aot_emit_variable_test.cc**: Variable operations emission
16+
- **aot_llvm_test.cc**: LLVM integration testing
17+
18+
### Covered Features
19+
- Basic AOT compilation pipeline (compiler options, file emission)
20+
- LLVM IR generation and object file creation
21+
- Core instruction emission (arithmetic, memory, control flow)
22+
- Basic error handling for compilation failures
23+
- File I/O operations for AOT output
24+
25+
### Identified Gaps (Major Feature Areas Missing)
26+
27+
#### Priority 1: Core Compilation Features (Missing ~65% coverage)
28+
- **Advanced Compiler Options**: Exception handling, GC support, stringref support
29+
- **SIMD Compilation**: 32 SIMD modules completely untested (simd/*.c files)
30+
- **Debug Information**: DWARF debug info extraction and emission
31+
- **Stack Frame Management**: AOT stack frame compilation and optimization
32+
- **Error Recovery**: Comprehensive error handling and validation
33+
34+
#### Priority 2: Advanced Compilation Features (Missing ~70% coverage)
35+
- **LLVM Optimization Passes**: Advanced optimization configurations
36+
- **Target Architecture Support**: Platform-specific code generation
37+
- **Memory Management**: Compilation-time memory optimization
38+
- **Multi-Module Compilation**: Inter-module dependency handling
39+
- **Performance Profiling**: Compilation performance measurement
40+
41+
#### Priority 3: Integration Features (Missing ~80% coverage)
42+
- **Cross-Platform Compilation**: Different target architectures
43+
- **Compilation Pipeline Integration**: End-to-end workflow testing
44+
- **Resource Management**: Memory and file handle management during compilation
45+
- **Concurrent Compilation**: Thread safety and parallel compilation
46+
- **Regression Testing**: Compatibility with different WASM features
47+
48+
## Feature Enhancement Strategy
49+
50+
### Total Source Files Analysis
51+
- **Core Compilation Files**: 66 files (*.c + *.h)
52+
- **Function Coverage Estimate**: ~146 public functions identified
53+
- **Current Test Coverage**: ~35% (basic functionality only)
54+
- **Target Coverage**: 65%+ (comprehensive feature testing)
55+
56+
### Multi-Step Feature Segmentation
57+
58+
#### Step 1: Advanced Compiler Core Operations (≤20 test cases)
59+
**Feature Focus**: Advanced compiler options, error handling, and validation
60+
**Test Categories**: Compiler configuration, advanced options, error recovery
61+
- [ ] test_aot_compiler_advanced_options_configuration
62+
- [ ] test_aot_compiler_exception_handling_support
63+
- [ ] test_aot_compiler_gc_support_compilation
64+
- [ ] test_aot_compiler_stringref_support_compilation
65+
- [ ] test_aot_compiler_memory_optimization_settings
66+
- [ ] test_aot_compiler_target_architecture_selection
67+
- [ ] test_aot_compiler_debug_information_generation
68+
- [ ] test_aot_compiler_error_recovery_mechanisms
69+
- [ ] test_aot_compiler_validation_pipeline
70+
- [ ] test_aot_compiler_resource_management
71+
- [ ] test_aot_compiler_compilation_context_lifecycle
72+
- [ ] test_aot_compiler_module_dependency_resolution
73+
- [ ] test_aot_compiler_optimization_level_validation
74+
- [ ] test_aot_compiler_platform_specific_options
75+
- [ ] test_aot_compiler_feature_flag_combinations
76+
- [ ] test_aot_compiler_invalid_input_handling
77+
- [ ] test_aot_compiler_memory_pressure_scenarios
78+
- [ ] test_aot_compiler_concurrent_compilation_safety
79+
- [ ] test_aot_compiler_temporary_file_management
80+
- [ ] test_aot_compiler_compilation_metadata_generation
81+
82+
**Status**: PENDING
83+
**Coverage Target**: Advanced compiler configuration and validation (~25% of missing coverage)
84+
85+
#### Step 2: SIMD and Advanced Instruction Emission (≤20 test cases)
86+
**Feature Focus**: SIMD instruction compilation and advanced WebAssembly features
87+
**Test Categories**: SIMD operations, advanced instructions, feature-specific compilation
88+
- [ ] test_simd_access_lanes_compilation
89+
- [ ] test_simd_bitmask_extracts_compilation
90+
- [ ] test_simd_bit_shifts_compilation
91+
- [ ] test_simd_bitwise_operations_compilation
92+
- [ ] test_simd_boolean_reductions_compilation
93+
- [ ] test_simd_comparisons_compilation
94+
- [ ] test_simd_conversions_compilation
95+
- [ ] test_simd_construct_values_compilation
96+
- [ ] test_simd_floating_point_compilation
97+
- [ ] test_simd_integer_arithmetic_compilation
98+
- [ ] test_simd_load_store_compilation
99+
- [ ] test_simd_saturated_arithmetic_compilation
100+
- [ ] test_aot_emit_const_advanced_operations
101+
- [ ] test_aot_emit_conversion_comprehensive_types
102+
- [ ] test_aot_emit_exception_handling_compilation
103+
- [ ] test_aot_emit_gc_operations_compilation
104+
- [ ] test_aot_emit_stringref_operations_compilation
105+
- [ ] test_aot_stack_frame_compilation_optimization
106+
- [ ] test_advanced_control_flow_compilation
107+
- [ ] test_complex_memory_operations_compilation
108+
109+
**Status**: PENDING
110+
**Coverage Target**: SIMD and advanced instruction support (~30% of missing coverage)
111+
112+
#### Step 3: LLVM Integration and Optimization (≤20 test cases)
113+
**Feature Focus**: LLVM backend integration, optimization passes, and code generation
114+
**Test Categories**: LLVM optimization, code generation, platform targeting
115+
- [ ] test_llvm_module_creation_and_validation
116+
- [ ] test_llvm_optimization_pass_configuration
117+
- [ ] test_llvm_target_machine_setup
118+
- [ ] test_llvm_code_generation_pipeline
119+
- [ ] test_llvm_debug_information_integration
120+
- [ ] test_llvm_memory_layout_optimization
121+
- [ ] test_llvm_function_inlining_decisions
122+
- [ ] test_llvm_constant_propagation_optimization
123+
- [ ] test_llvm_dead_code_elimination
124+
- [ ] test_llvm_loop_optimization_passes
125+
- [ ] test_llvm_vectorization_opportunities
126+
- [ ] test_llvm_register_allocation_strategies
127+
- [ ] test_llvm_instruction_scheduling_optimization
128+
- [ ] test_llvm_platform_specific_code_generation
129+
- [ ] test_llvm_cross_compilation_support
130+
- [ ] test_llvm_orc_jit_compilation_integration
131+
- [ ] test_llvm_error_handling_and_diagnostics
132+
- [ ] test_llvm_metadata_preservation
133+
- [ ] test_llvm_performance_profiling_integration
134+
- [ ] test_llvm_resource_cleanup_and_management
135+
136+
**Status**: PENDING
137+
**Coverage Target**: LLVM integration and optimization (~25% of missing coverage)
138+
139+
#### Step 4: Integration and Performance Testing (≤20 test cases)
140+
**Feature Focus**: End-to-end compilation workflows, performance validation, edge cases
141+
**Test Categories**: Integration scenarios, performance benchmarks, stress testing
142+
- [ ] test_end_to_end_compilation_workflow
143+
- [ ] test_multi_module_compilation_pipeline
144+
- [ ] test_large_wasm_module_compilation
145+
- [ ] test_compilation_performance_benchmarks
146+
- [ ] test_memory_intensive_compilation_scenarios
147+
- [ ] test_concurrent_compilation_stress_testing
148+
- [ ] test_compilation_error_propagation_chains
149+
- [ ] test_resource_exhaustion_during_compilation
150+
- [ ] test_platform_compatibility_compilation
151+
- [ ] test_backward_compatibility_compilation
152+
- [ ] test_compilation_cache_management
153+
- [ ] test_incremental_compilation_support
154+
- [ ] test_compilation_metadata_validation
155+
- [ ] test_cross_platform_compilation_consistency
156+
- [ ] test_compilation_output_verification
157+
- [ ] test_compilation_regression_detection
158+
- [ ] test_compilation_security_validation
159+
- [ ] test_compilation_deterministic_output
160+
- [ ] test_compilation_profiling_and_metrics
161+
- [ ] test_compilation_cleanup_and_finalization
162+
163+
**Status**: PENDING
164+
**Coverage Target**: Integration workflows and edge cases (~20% of missing coverage)
165+
166+
### Multi-Step Execution Protocol
167+
1. **Feature Analysis**: Focus on comprehensive WAMR compilation feature testing
168+
2. **Step Planning**: Divided into logical segments (Core → SIMD → LLVM → Integration)
169+
3. **Sequential Execution**: Complete Step N before proceeding to Step N+1
170+
4. **Progress Validation**: Verify each step's functionality and coverage improvement
171+
5. **Integration Testing**: Ensure steps work together cohesively
172+
173+
### Step Completion Criteria
174+
Each step must satisfy:
175+
- [ ] All test cases compile and run successfully
176+
- [ ] All assertions provide meaningful validation (no tautologies)
177+
- [ ] Test quality meets WAMR standards
178+
- [ ] Coverage improvement is measurable for target functions
179+
- [ ] No regression in existing functionality
180+
181+
### Multi-Feature Integration Testing
182+
1. **Cross-Feature Interaction**: Test how compilation features interact (SIMD + optimization)
183+
2. **System Integration**: Test complete compilation workflows with all features enabled
184+
3. **Stress Testing**: Test compilation system behavior under resource pressure
185+
4. **Regression Testing**: Ensure new tests don't break existing compilation functionality
186+
5. **Platform Testing**: Validate compilation behavior across different target platforms
187+
188+
## Overall Progress
189+
- Total Feature Areas: 4 major areas
190+
- Completed Feature Areas: 0
191+
- Current Focus: Advanced Compiler Core Operations (PENDING)
192+
- Quality Score: TBD (based on test comprehensiveness and assertion quality)
193+
- Estimated Total Test Cases: 80 comprehensive test cases
194+
- Target Coverage Improvement: From ~35% to 65%+
195+
196+
## Feature Status
197+
- [ ] Step 1: Advanced Compiler Core Operations - PENDING
198+
- [ ] Step 2: SIMD and Advanced Instruction Emission - PENDING
199+
- [ ] Step 3: LLVM Integration and Optimization - PENDING
200+
- [ ] Step 4: Integration and Performance Testing - PENDING
201+
202+
## Implementation Strategy
203+
- **Enhanced Directory**: All tests in `tests/unit/enhanced_unit_test/compilation/`
204+
- **Test File Naming**: `test_[feature_area]_enhanced.cc`
205+
- **WAT File Support**: Generate comprehensive WAT files for advanced feature testing
206+
- **CMake Integration**: Modified CMakeLists.txt for enhanced test compilation
207+
- **Coverage Measurement**: Focus on uncovered functions in compilation module
208+
209+
## Plan Metadata
210+
- **Plan ID**: compilation_20241219_143000
211+
- **Module Name**: compilation
212+
- **Target Coverage**: 65%
213+
- **Total Steps**: 4
214+
- **Current Step**: 1
215+
- **Total Functions Estimated**: 146
216+
- **Uncovered Functions Estimated**: 95
217+
- **Complexity Level**: high
218+
- **Dependencies**: ["test_helper.h", "LLVM libraries", "wamr compiler infrastructure"]
219+
- **Platform Constraints**: ["linux", "LLVM_ENABLE", "AOT_COMPILATION_SUPPORT"]
220+
- **Estimated Duration**: "6-8 hours"

0 commit comments

Comments
 (0)