Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI testing help #88

Merged
merged 6 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
8 changes: 7 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ trigger:

pr:
- master

jobs:
- job:
displayName: Linux
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/mem/globalalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ namespace snmalloc
{
error("debug_check_empty: found non-empty allocators");
}
#else
UNUSED(result);
#endif
}
};
Expand Down
10 changes: 10 additions & 0 deletions src/test/func/memory/memory.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <iostream>
#include <snmalloc.h>
#include <test/opt.h>
#include <test/setup.h>
#include <test/xoroshiro.h>
#include <unordered_set>

Expand Down Expand Up @@ -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
Expand All @@ -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++)
{
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/test/perf/external_pointer/externalpointer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
76 changes: 76 additions & 0 deletions src/test/setup.h
Original file line number Diff line number Diff line change
@@ -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()
mjp41 marked this conversation as resolved.
Show resolved Hide resolved
{
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);
mjp41 marked this conversation as resolved.
Show resolved Hide resolved
}

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() {}
Expand Down