diff --git a/ci/loadWin.groovy b/ci/loadWin.groovy index d2860b6fbc..ec6e9c3466 100644 --- a/ci/loadWin.groovy +++ b/ci/loadWin.groovy @@ -289,7 +289,21 @@ def check_tests(){ status = bat(returnStatus: true, script: 'grep " PASSED " win_full_test.log') if (status != 0) { + // Check for segfault/termination only if PASSED is not found + def segfault_status = bat(returnStatus: true, script: 'grep -i "segmentation fault\\|segfault\\|crashed\\|abnormal termination" win_full_test.log') + if (segfault_status == 0) { + // Found segfault, report detailed information + echo "Error: Windows run test failed - SEGFAULT/CRASH DETECTED." + def last_test = bat(returnStatus: false, returnStdout: true, script: 'grep " OK ]" win_full_test.log | tail -1') + echo "Last Successful Test:\n${last_test}" + def failed_test = bat(returnStatus: false, returnStdout: true, script: 'grep -A 10 " RUN " win_full_test.log | tail -20') + echo "Failed Test Context:\n${failed_test}" + def segfault_msg = bat(returnStatus: false, returnStdout: true, script: 'grep -i "segmentation fault\\|segfault\\|crashed\\|abnormal termination" win_full_test.log') + echo "Segfault/Crash Messages:\n${segfault_msg}" + error "Error: Windows run test failed due to segmentation fault. Check win_full_test.log for details." + } else { error "Error: Windows run test failed ${status}. Expecting PASSED at the end of log. Check pipeline.log for details." + } } else { echo "Success: Windows run test finished with success." } diff --git a/src/test/ovmsconfig_test.cpp b/src/test/ovmsconfig_test.cpp index 6b76d0e2fa..04cc1e804c 100644 --- a/src/test/ovmsconfig_test.cpp +++ b/src/test/ovmsconfig_test.cpp @@ -74,7 +74,7 @@ TEST_F(OvmsConfigDeathTest, bufferTest) { std::string input{"Test buffer"}; std::cout << input; std::string check{buffer.str()}; - EXPECT_EQ(input, check); + EXPECT_EQ(input, "ddddd"); } TEST_F(OvmsConfigDeathTest, emptyInput) { diff --git a/windows_install_build_dependencies.bat b/windows_install_build_dependencies.bat index 7f32d6143c..029aa4df8f 100644 --- a/windows_install_build_dependencies.bat +++ b/windows_install_build_dependencies.bat @@ -466,7 +466,7 @@ if !errorlevel! neq 0 exit /b !errorlevel! %python_path%\python.exe -m pip install --upgrade pip if !errorlevel! neq 0 exit /b !errorlevel! :: setuptools<60.0 required for numpy1.23 on python311 to install -%python_path%\python.exe -m pip install "numpy==2.2.5" "Jinja2==3.1.6" "MarkupSafe==3.0.2" +%python_path%\python.exe -m pip install "numpy==2.2.5" "Jinja2==3.1.6" "MarkupSafe==3.0.2" "pytest" if !errorlevel! neq 0 exit /b !errorlevel! echo [INFO] Python %python_version% installed: %python_path% goto install_curl diff --git a/windows_test.bat b/windows_test.bat index dfd1a8c424..c8e33eecea 100644 --- a/windows_test.bat +++ b/windows_test.bat @@ -98,10 +98,12 @@ if !errorlevel! neq 0 exit /b !errorlevel! :: Run install_ovms_service.bat unit tests echo Running install_ovms_service.bat unit tests... -python -m pytest tests\python\test_install_ovms_service_windows.py -v 2>&1 | tee win_install_service_test.log -if !errorlevel! neq 0 ( +python -m pytest tests\python\test_install_ovms_service_windows.py -v > win_install_service_test.log 2>&1 +set "pytestExitCode=!errorlevel!" +type win_install_service_test.log +if !pytestExitCode! neq 0 ( echo [ERROR] install_ovms_service.bat unit tests failed. See win_install_service_test.log. - exit /b !errorlevel! + exit /b !pytestExitCode! ) echo [INFO] install_ovms_service.bat unit tests passed. @@ -113,13 +115,50 @@ echo Running: %runTest% set regex="\[ .* ms" set sed_clean="s/ (.* ms)//g" C:\Windows\System32\tar.exe -a -c -f win_test_log.zip win_full_test.log -grep -a %regex% win_full_test.log | sed %sed_clean% > win_test_summary.log -grep -a %regex% win_full_test.log | sed %sed_clean% | grep -q " FAILED " + +:: Create summary log with filtered results, always create the file even if grep finds no matches +grep -a %regex% win_full_test.log | sed %sed_clean% > win_test_summary.log 2>&1 || ( + echo No matching test results found >> win_test_summary.log +) + +:: Check if tests completed successfully by looking for PASSED marker at the end +grep -q " PASSED " win_full_test.log +if !errorlevel! equ 0 goto :exit_build + +:: Tests did not complete successfully - check for failures and segfaults +:: Check if tests failed by looking for FAILED in the full log +grep -q " FAILED " win_full_test.log +if !errorlevel! equ 0 goto :exit_build_error + +:: Also check for segmentation faults or crashes +grep -q -i "segmentation fault\|segfault\|crashed\|abnormal termination" win_full_test.log if !errorlevel! equ 0 goto :exit_build_error + +:: If we reach here, tests didn't complete but no clear failure found +goto :exit_build_error + :exit_build echo [INFO] Tests finished with no failures. Check the summary in win_test_summary.log. exit /b 0 :exit_build_error +echo. +echo [ERROR] FAILED TESTS OR CRASHES DETECTED: +echo. +echo === Last Successful Test === +grep " OK ]" win_full_test.log | tail -1 +echo. +echo === Last Running Test (likely the one that failed) === +grep " RUN " win_full_test.log | tail -1 +echo. +echo === Output from Last Running Test to End of Log === +:: Find the line number of the last RUN and display everything from that point onwards +for /F "delims=" %%A in ('grep -n " RUN " win_full_test.log ^| tail -1 ^| cut -d: -f1') do ( + sed -n "%%A,$p" win_full_test.log | head -100 +) +echo. +echo === Segfault/Crash Messages (if any) === +grep -i "segmentation fault\|segfault\|crashed\|abnormal termination" win_full_test.log || echo (none found) +echo. echo [ERROR] Check tests summary in 'win_test_summary.log' and tests logs in 'win_full_test.log'. Rerun failed test with: windows_setupvars.bat and %cd%\bazel-bin\src\ovms_test.exe --gtest_filter='*.*' exit /b 1 endlocal