add all crash printer tests

This commit is contained in:
otavepto 2024-06-15 20:20:31 +03:00
parent 7b810764fa
commit fa59283f1c
7 changed files with 369 additions and 300 deletions

View File

@ -1,33 +0,0 @@
#!/usr/bin/env bash
my_dir="$(cd "$(dirname "$0")" && pwd)"
pushd "$my_dir" > /dev/null
clang++ -x c++ -rdynamic -std=c++17 -fvisibility=hidden -fexceptions -fno-jump-tables -Og -g3 -fPIE -I../ ../linux.cpp ../common.cpp test_linux_sa_handler.cpp -otest_linux_sa_handler && {
./test_linux_sa_handler ;
echo "exit code = $?" ;
rm -f ./test_linux_sa_handler ;
}
clang++ -x c++ -rdynamic -std=c++17 -fvisibility=hidden -fexceptions -fno-jump-tables -Og -g3 -fPIE -I../ ../linux.cpp ../common.cpp test_linux_sa_sigaction.cpp -otest_linux_sa_sigaction && {
./test_linux_sa_sigaction ;
echo "exit code = $?" ;
rm -f ./test_linux_sa_sigaction ;
}
clang++ -m32 -x c++ -rdynamic -std=c++17 -fvisibility=hidden -fexceptions -fno-jump-tables -Og -g3 -fPIE -I../ ../linux.cpp ../common.cpp test_linux_sa_handler.cpp -otest_linux_sa_handler && {
./test_linux_sa_handler ;
echo "exit code = $?" ;
rm -f ./test_linux_sa_handler ;
}
clang++ -m32 -x c++ -rdynamic -std=c++17 -fvisibility=hidden -fexceptions -fno-jump-tables -Og -g3 -fPIE -I../ ../linux.cpp ../common.cpp test_linux_sa_sigaction.cpp -otest_linux_sa_sigaction && {
./test_linux_sa_sigaction ;
echo "exit code = $?" ;
rm -f ./test_linux_sa_sigaction ;
}
rm -f -r ./crash_test
popd > /dev/null

View File

@ -1,47 +0,0 @@
@echo off
pushd "%~dp0"
call :cleanup
setlocal
call ..\..\build_win_set_env.bat 64
cl.exe /DEBUG:FULL /Z7 /Od /std:c++17 /DYNAMICBASE /errorReport:none /nologo /utf-8 /EHsc /GF /GL- /GS /MT /I../ ../win.cpp ../common.cpp test_win.cpp kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib Iphlpapi.lib Wldap32.lib Winmm.lib Bcrypt.lib Dbghelp.lib /link /DYNAMICBASE /ERRORREPORT:NONE /NOLOGO /OUT:test_win.exe && (
call test_win.exe
setlocal enableDelayedExpansion
echo exit code = !errorlevel!
endlocal
call :cleanup
)
endlocal
setlocal
call ..\..\build_win_set_env.bat 32
cl.exe /DEBUG:FULL /Z7 /Od /std:c++17 /DYNAMICBASE /errorReport:none /nologo /utf-8 /EHsc /GF /GL- /GS /MT /I../ ../win.cpp ../common.cpp test_win.cpp kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib Iphlpapi.lib Wldap32.lib Winmm.lib Bcrypt.lib Dbghelp.lib /link /DYNAMICBASE /ERRORREPORT:NONE /NOLOGO /OUT:test_win.exe && (
call test_win.exe
setlocal enableDelayedExpansion
echo exit code = !errorlevel!
endlocal
call :cleanup
)
endlocal
rmdir /s /q crash_test
popd
exit /b 0
:cleanup
del /f /q test_win.exe >nul 2>&1
del /f /q test_win.ilk >nul 2>&1
del /f /q test_win.obj >nul 2>&1
del /f /q test_win.pdb >nul 2>&1
del /f /q win.obj >nul 2>&1
del /f /q common.obj >nul 2>&1
exit /b

View File

@ -7,7 +7,7 @@
static inline bool remove_file(const std::string &file)
{
const std::filesystem::u8path p_file(std::filesystem::u8path(file));
const std::filesystem::path p_file(std::filesystem::u8path(file));
if (!std::filesystem::exists(p_file)) {
return true;
}

View File

@ -29,6 +29,10 @@ static LONG WINAPI exception_handler(LPEXCEPTION_POINTERS ex_pointers)
exit(1);
}
int* get_ptr()
{
return nullptr;
}
int main()
{
@ -46,7 +50,7 @@ int main()
}
// simulate a crash
volatile int * volatile ptr = nullptr;
volatile int * volatile ptr = get_ptr();
*ptr = 42;
return 0;

View File

@ -1441,6 +1441,60 @@ project "tool_file_dos_stub_changer"
}
-- End tool_file_dos_stub_changer
-- Project test_crash_printer
---------
project "test_crash_printer"
kind "ConsoleApp"
location "%{wks.location}/%{prj.name}"
targetdir("build/" .. os_iden .. "/%{_ACTION}/%{cfg.buildcfg}/tests/crash_printer")
targetname "test_crash_printer_%{cfg.platform}"
-- include dir
---------
-- common include dir
filter {} -- reset the filter and remove all active keywords
includedirs {
'crash_printer',
'helpers',
}
-- common source & header files
---------
filter {} -- reset the filter and remove all active keywords
files { -- added to all filters, later defines will be appended
'crash_printer/' .. os_iden .. '.cpp', 'crash_printer/crash_printer/' .. os_iden .. '.hpp',
'crash_printer/tests/test_helper.hpp',
-- helpers
'helpers/common_helpers.cpp', 'helpers/common_helpers/**',
-- test files
'crash_printer/tests/test_win.cpp',
}
removefiles {
'post_build/**',
'build/deps/**',
}
-- libs to link
---------
filter {} -- reset the filter and remove all active keywords
-- Windows libs
links {
'Dbghelp',
}
-- post build
---------
filter {} -- reset the filter and remove all active keywords
postbuildcommands {
'%[%{!cfg.buildtarget.abspath}]',
}
-- End test_crash_printer
end
-- End WINDOWS ONLY TARGETS
@ -1518,6 +1572,97 @@ project "steamclient_regular"
}
-- End steamclient_regular
-- Project test_crash_printer_sa_handler
---------
project "test_crash_printer_sa_handler"
kind "ConsoleApp"
location "%{wks.location}/%{prj.name}"
targetdir("build/" .. os_iden .. "/%{_ACTION}/%{cfg.buildcfg}/tests/crash_printer")
targetname "test_crash_printer_sa_handler_%{cfg.platform}"
-- include dir
---------
-- common include dir
filter {} -- reset the filter and remove all active keywords
includedirs {
'crash_printer',
'helpers',
}
-- common source & header files
---------
filter {} -- reset the filter and remove all active keywords
files { -- added to all filters, later defines will be appended
'crash_printer/' .. os_iden .. '.cpp', 'crash_printer/crash_printer/' .. os_iden .. '.hpp',
'crash_printer/tests/test_helper.hpp',
-- helpers
'helpers/common_helpers.cpp', 'helpers/common_helpers/**',
-- test files
'crash_printer/tests/test_linux_sa_handler.cpp',
}
removefiles {
'post_build/**',
'build/deps/**',
}
-- post build
---------
filter {} -- reset the filter and remove all active keywords
postbuildcommands {
'%[%{!cfg.buildtarget.abspath}]',
}
-- End test_crash_printer_sa_handler
-- Project test_crash_printer_sa_sigaction
---------
project "test_crash_printer_sa_sigaction"
kind "ConsoleApp"
location "%{wks.location}/%{prj.name}"
targetdir("build/" .. os_iden .. "/%{_ACTION}/%{cfg.buildcfg}/tests/crash_printer")
targetname "test_crash_printer_sa_sigaction_%{cfg.platform}"
-- include dir
---------
-- common include dir
filter {} -- reset the filter and remove all active keywords
includedirs {
'crash_printer',
'helpers',
}
-- common source & header files
---------
filter {} -- reset the filter and remove all active keywords
files { -- added to all filters, later defines will be appended
'crash_printer/' .. os_iden .. '.cpp', 'crash_printer/crash_printer/' .. os_iden .. '.hpp',
'crash_printer/tests/test_helper.hpp',
-- helpers
'helpers/common_helpers.cpp', 'helpers/common_helpers/**',
-- test files
'crash_printer/tests/test_linux_sa_sigaction.cpp',
}
removefiles {
'post_build/**',
'build/deps/**',
}
-- post build
---------
filter {} -- reset the filter and remove all active keywords
postbuildcommands {
'%[%{!cfg.buildtarget.abspath}]',
}
-- End test_crash_printer_sa_sigaction
end
-- End LINUX ONLY TARGETS