Add analyzer test (#165)

Small step in the right direction for #111
This commit is contained in:
Maurice Heumann
2025-03-19 14:24:48 +01:00
committed by GitHub
5 changed files with 46 additions and 5 deletions

View File

@@ -323,6 +323,7 @@ jobs:
env:
EMULATOR_ROOT: ${{github.workspace}}/build/${{matrix.preset}}/artifacts/root
EMULATOR_VERBOSE: ${{ github.event.inputs.verbose }}
ANALYSIS_SAMPLE: ${{github.workspace}}/build/${{matrix.preset}}/artifacts/dump-apiset.exe
smoke-test-android:
name: Smoke Test Android

View File

@@ -2,6 +2,13 @@ include_guard()
##########################################
set(PYTHON3_EXE "python3")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(PYTHON3_EXE "python")
endif()
##########################################
function(momo_silence_deprecation_warnings)
set(CMAKE_WARN_DEPRECATED_OLD ${CMAKE_WARN_DEPRECATED} PARENT_SCOPE)
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)

View File

@@ -23,3 +23,15 @@ target_link_libraries(analyzer PRIVATE
set_property(GLOBAL PROPERTY VS_STARTUP_PROJECT analyzer)
momo_strip_target(analyzer)
set(ENV_PREFIX "$")
set(ENV_SUFFIX "")
if(WIN)
set(ENV_PREFIX "%")
set(ENV_SUFFIX "%")
endif()
add_test(NAME analyzer-test
COMMAND "${PYTHON3_EXE}" "${CMAKE_CURRENT_LIST_DIR}/test.py"
WORKING_DIRECTORY "$<TARGET_FILE_DIR:analyzer>")

26
src/analyzer/test.py Normal file
View File

@@ -0,0 +1,26 @@
import os
import subprocess
emulator_root = os.getenv('EMULATOR_ROOT')
analysis_sample = os.getenv('ANALYSIS_SAMPLE')
virtual_sample = 'C:/analysis-sample.exe'
application = 'analyzer'
def make_app(app):
if os.name == 'nt':
return app + ".exe"
return app
command = [
os.path.join(os.getcwd(), make_app(application)),
'-c',
'-e', emulator_root,
'-p', virtual_sample, analysis_sample,
virtual_sample
]
result = subprocess.run(command, cwd=os.getcwd())
exit(result.returncode)

View File

@@ -20,11 +20,6 @@ if(WIN32)
add_dependencies(windows-emulator-test test-sample)
endif()
set(PYTHON3_EXE "python3")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(PYTHON3_EXE "python")
endif()
add_test(NAME windows-emulator-test
COMMAND "${PYTHON3_EXE}" "${PROJECT_SOURCE_DIR}/deps/gtest-parallel/gtest_parallel.py" ./windows-emulator-test
WORKING_DIRECTORY "$<TARGET_FILE_DIR:windows-emulator-test>")