@@ -177,8 +177,25 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
|
||||
add_test(${TESTNAME} ${TESTNAME})
|
||||
endif()
|
||||
if (${TEST_CATEGORY} MATCHES "perf")
|
||||
message(STATUS "Single threaded test: ${TESTNAME}")
|
||||
set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# On Windows these tests use a lot of memory as it doesn't support
|
||||
# lazy commit.
|
||||
if (${TEST} MATCHES "two_alloc_types")
|
||||
message(STATUS "Single threaded test: ${TESTNAME}")
|
||||
set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4)
|
||||
endif()
|
||||
if (${TEST} MATCHES "fixed_region")
|
||||
message(STATUS "Single threaded test: ${TESTNAME}")
|
||||
set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4)
|
||||
endif()
|
||||
if (${TEST} MATCHES "memory")
|
||||
message(STATUS "Single threaded test: ${TESTNAME}")
|
||||
set_tests_properties(${TESTNAME} PROPERTIES PROCESSORS 4)
|
||||
endif()
|
||||
endif()
|
||||
if (${TEST_CATEGORY} MATCHES "func")
|
||||
target_compile_definitions(${TESTNAME} PRIVATE -DUSE_SNMALLOC_STATS)
|
||||
endif ()
|
||||
|
||||
@@ -3,7 +3,7 @@ trigger:
|
||||
|
||||
pr:
|
||||
- master
|
||||
|
||||
|
||||
jobs:
|
||||
- job:
|
||||
displayName: Linux
|
||||
@@ -130,6 +130,12 @@ jobs:
|
||||
JFlag: '-j 2'
|
||||
|
||||
steps:
|
||||
- script: |
|
||||
bash -c "cat /proc/cpuinfo"
|
||||
bash -c "cat /proc/meminfo"
|
||||
displayName: 'Machine stats'
|
||||
|
||||
|
||||
- task: CMake@1
|
||||
displayName: 'CMake .. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType) -DSNMALLOC_CI_BUILD=On'
|
||||
inputs:
|
||||
|
||||
@@ -170,6 +170,8 @@ namespace snmalloc
|
||||
{
|
||||
error("debug_check_empty: found non-empty allocators");
|
||||
}
|
||||
#else
|
||||
UNUSED(result);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <snmalloc.h>
|
||||
#include <test/opt.h>
|
||||
#include <test/setup.h>
|
||||
#include <test/xoroshiro.h>
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -215,11 +217,14 @@ void test_external_pointer_large()
|
||||
// Pre allocate all the objects
|
||||
size_t* objects[count];
|
||||
|
||||
size_t total_size = 0;
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
size_t b = snmalloc::bits::is64() ? 28 : 26;
|
||||
size_t rand = r.next() & ((1 << b) - 1);
|
||||
size_t size = (1 << 24) + rand;
|
||||
total_size += size;
|
||||
// store object
|
||||
objects[i] = (size_t*)alloc->alloc(size);
|
||||
// Store allocators size for this object
|
||||
@@ -235,6 +240,9 @@ void test_external_pointer_large()
|
||||
check_external_pointer_large(objects[i]);
|
||||
}
|
||||
|
||||
std::cout << "Total size allocated in test_external_pointer_large: "
|
||||
<< total_size << std::endl;
|
||||
|
||||
// Deallocate everything
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
@@ -290,6 +298,8 @@ void test_calloc_16M()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
setup();
|
||||
|
||||
#ifdef USE_SYSTEMATIC_TESTING
|
||||
opt::Opt opt(argc, argv);
|
||||
size_t seed = opt.is<size_t>("--seed", 0);
|
||||
|
||||
@@ -54,7 +54,13 @@ namespace test
|
||||
#ifdef NDEBUG
|
||||
static constexpr size_t iterations = 10000000;
|
||||
#else
|
||||
# ifdef _MSC_VER
|
||||
// Windows Debug build is very slow on this test.
|
||||
// Reduce complexity to balance CI times.
|
||||
static constexpr size_t iterations = 50000;
|
||||
# else
|
||||
static constexpr size_t iterations = 100000;
|
||||
# endif
|
||||
#endif
|
||||
setup(r, alloc);
|
||||
|
||||
|
||||
@@ -1,19 +1,95 @@
|
||||
#if defined(WIN32) && defined(SNMALLOC_CI_BUILD)
|
||||
# include <ds/bits.h>
|
||||
# include <iostream>
|
||||
# include <pal/pal.h>
|
||||
# include <signal.h>
|
||||
# include <stdlib.h>
|
||||
// Has to come after the PAL.
|
||||
# include <DbgHelp.h>
|
||||
# pragma comment(lib, "dbghelp.lib")
|
||||
|
||||
void print_stack_trace()
|
||||
{
|
||||
DWORD error;
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
|
||||
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
|
||||
|
||||
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
pSymbol->MaxNameLen = MAX_SYM_NAME;
|
||||
|
||||
SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS);
|
||||
|
||||
if (!SymInitialize(hProcess, NULL, TRUE))
|
||||
{
|
||||
// SymInitialize failed
|
||||
error = GetLastError();
|
||||
printf("SymInitialize returned error : %d\n", error);
|
||||
return;
|
||||
}
|
||||
|
||||
void* stack[1024];
|
||||
DWORD count = CaptureStackBackTrace(0, 1024, stack, NULL);
|
||||
IMAGEHLP_LINE64 line;
|
||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
|
||||
for (int i = 0; count > 0; count--, i++)
|
||||
{
|
||||
DWORD64 dwDisplacement = 0;
|
||||
DWORD64 dwAddress = (DWORD64)stack[i];
|
||||
|
||||
if (SymFromAddr(hProcess, dwAddress, &dwDisplacement, pSymbol))
|
||||
{
|
||||
DWORD dwDisplacement2 = 0;
|
||||
if (SymGetLineFromAddr64(hProcess, dwAddress, &dwDisplacement2, &line))
|
||||
{
|
||||
std::cerr << "Frame: " << pSymbol->Name << " (" << line.FileName << ": "
|
||||
<< line.LineNumber << ")" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Frame: " << pSymbol->Name << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = GetLastError();
|
||||
std::cerr << "SymFromAddr returned error : " << error << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _cdecl error(int signal)
|
||||
{
|
||||
UNUSED(signal);
|
||||
puts("*****ABORT******");
|
||||
|
||||
print_stack_trace();
|
||||
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
# define CALL_LAST 0
|
||||
LONG WINAPI VectoredHandler(struct _EXCEPTION_POINTERS* ExceptionInfo)
|
||||
{
|
||||
UNUSED(ExceptionInfo);
|
||||
|
||||
puts("*****UNHANDLED EXCEPTION******");
|
||||
|
||||
print_stack_trace();
|
||||
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Disable abort dialog box in CI builds.
|
||||
_set_error_mode(_OUT_TO_STDERR);
|
||||
_set_abort_behavior(0, _WRITE_ABORT_MSG);
|
||||
signal(SIGABRT, error);
|
||||
|
||||
AddVectoredExceptionHandler(CALL_LAST, VectoredHandler);
|
||||
}
|
||||
#else
|
||||
void setup() {}
|
||||
|
||||
Reference in New Issue
Block a user