From 16b084f5010d49bc83e0d1498009b323f96f7702 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Tue, 13 Aug 2019 15:37:54 +0100 Subject: [PATCH] Changed abort behaviour for Windows CI. --- CMakeLists.txt | 5 +++++ azure-pipelines.yml | 12 +++++------ src/test/func/malloc/malloc.cc | 3 +++ src/test/func/release-rounding/rounding.cc | 3 +++ src/test/func/sizeclass/sizeclass.cc | 3 +++ src/test/func/two_alloc_types/main.cc | 3 +++ src/test/perf/contention/contention.cc | 3 +++ .../perf/external_pointer/externalpointer.cc | 3 +++ src/test/perf/singlethread/singlethread.cc | 3 +++ src/test/setup.h | 20 +++++++++++++++++++ 10 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 src/test/setup.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bd3a275..fe74d39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.8) project(snmalloc C CXX) option(USE_SNMALLOC_STATS "Track allocation stats" OFF) +option(SNMALLOC_CI_BUILD "Disable features not sensible for CI" OFF) option(USE_MEASURE "Measure performance with histograms" OFF) option(EXPOSE_EXTERNAL_PAGEMAP "Expose the global pagemap" OFF) option(EXPOSE_EXTERNAL_RESERVE "Expose an interface to reserve memory using the default memory provider" OFF) @@ -95,6 +96,10 @@ if(USE_MEASURE) target_compile_definitions(snmalloc_lib INTERFACE -DUSE_MEASURE) endif() +if(SNMALLOC_CI_BUILD) + target_compile_definitions(snmalloc_lib INTERFACE -DSNMALLOC_CI_BUILD) +endif() + if(CACHE_FRIENDLY_OFFSET) target_compile_definitions(snmalloc_lib INTERFACE -DCACHE_FRIENDLY_OFFSET=${CACHE_FRIENDLY_OFFSET}) endif() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f7ce06c..2e59630 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -72,9 +72,9 @@ jobs: displayName: 'Install Build Dependencies' - task: CMake@1 - displayName: 'CMake .. $(CMakeArgs) -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"' + displayName: 'CMake .. $(CMakeArgs) -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DSNMALLOC_CI_BUILD=On' inputs: - cmakeArgs: '.. $(CMakeArgs) -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"' + cmakeArgs: '.. $(CMakeArgs) -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DSNMALLOC_CI_BUILD=On' - script: | ninja @@ -131,9 +131,9 @@ jobs: steps: - task: CMake@1 - displayName: 'CMake .. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType)' + displayName: 'CMake .. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType) -DSNMALLOC_CI_BUILD=On' inputs: - cmakeArgs: '.. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType)' + cmakeArgs: '.. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType) -DSNMALLOC_CI_BUILD=On' - task: MSBuild@1 displayName: 'Build solution build/snmalloc.sln' @@ -158,9 +158,9 @@ jobs: steps: - task: CMake@1 - displayName: 'CMake .. -DCMAKE_BUILD_TYPE=$(BuildType)' + displayName: 'CMake .. -DCMAKE_BUILD_TYPE=$(BuildType) -DSNMALLOC_CI_BUILD=On' inputs: - cmakeArgs: '.. -DCMAKE_BUILD_TYPE=$(BuildType)' + cmakeArgs: '.. -DCMAKE_BUILD_TYPE=$(BuildType) -DSNMALLOC_CI_BUILD=On' - script: | make -j 4 diff --git a/src/test/func/malloc/malloc.cc b/src/test/func/malloc/malloc.cc index b3dd268..8df3455 100644 --- a/src/test/func/malloc/malloc.cc +++ b/src/test/func/malloc/malloc.cc @@ -1,4 +1,5 @@ #include +#include #define SNMALLOC_NAME_MANGLE(a) our_##a #include "../../../override/malloc.cc" @@ -76,6 +77,8 @@ int main(int argc, char** argv) UNUSED(argc); UNUSED(argv); + setup(); + constexpr int SUCCESS = 0; test_calloc(0, 0, SUCCESS, false); diff --git a/src/test/func/release-rounding/rounding.cc b/src/test/func/release-rounding/rounding.cc index 8c3a9e8..0836319 100644 --- a/src/test/func/release-rounding/rounding.cc +++ b/src/test/func/release-rounding/rounding.cc @@ -1,4 +1,5 @@ #include +#include using namespace snmalloc; @@ -9,6 +10,8 @@ using namespace snmalloc; int main(int argc, char** argv) { + setup(); + UNUSED(argc); UNUSED(argv); diff --git a/src/test/func/sizeclass/sizeclass.cc b/src/test/func/sizeclass/sizeclass.cc index 6ca6c8d..718b73c 100644 --- a/src/test/func/sizeclass/sizeclass.cc +++ b/src/test/func/sizeclass/sizeclass.cc @@ -1,5 +1,6 @@ #include #include +#include NOINLINE snmalloc::sizeclass_t size_to_sizeclass(size_t size) @@ -9,6 +10,8 @@ snmalloc::sizeclass_t size_to_sizeclass(size_t size) int main(int, char**) { + setup(); + bool failed = false; size_t size_low = 0; diff --git a/src/test/func/two_alloc_types/main.cc b/src/test/func/two_alloc_types/main.cc index c15438b..9802b7c 100644 --- a/src/test/func/two_alloc_types/main.cc +++ b/src/test/func/two_alloc_types/main.cc @@ -3,6 +3,7 @@ #include #include #include +#include void* oe_base; void* oe_end; @@ -40,6 +41,8 @@ host_snmalloc_pagemap_global_get(snmalloc::PagemapConfig const**); using namespace snmalloc; int main() { + setup(); + MemoryProviderStateMixin mp; size_t size = 1ULL << 28; diff --git a/src/test/perf/contention/contention.cc b/src/test/perf/contention/contention.cc index 1858724..b53ec12 100644 --- a/src/test/perf/contention/contention.cc +++ b/src/test/perf/contention/contention.cc @@ -1,5 +1,6 @@ #include "test/measuretime.h" #include "test/opt.h" +#include "test/setup.h" #include "test/usage.h" #include "test/xoroshiro.h" @@ -148,6 +149,8 @@ void test_tasks(size_t num_tasks, size_t count, size_t size) int main(int argc, char** argv) { + setup(); + opt::Opt opt(argc, argv); size_t cores = opt.is("--cores", 8); diff --git a/src/test/perf/external_pointer/externalpointer.cc b/src/test/perf/external_pointer/externalpointer.cc index d87baeb..d4124b3 100644 --- a/src/test/perf/external_pointer/externalpointer.cc +++ b/src/test/perf/external_pointer/externalpointer.cc @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -78,6 +79,8 @@ namespace test int main(int, char**) { + setup(); + xoroshiro::p128r64 r; #if NDEBUG size_t nn = 30; diff --git a/src/test/perf/singlethread/singlethread.cc b/src/test/perf/singlethread/singlethread.cc index 3b3700c..3909521 100644 --- a/src/test/perf/singlethread/singlethread.cc +++ b/src/test/perf/singlethread/singlethread.cc @@ -1,5 +1,6 @@ #include #include +#include #include using namespace snmalloc; @@ -63,6 +64,8 @@ void test_alloc_dealloc(size_t count, size_t size, bool write) int main(int, char**) { + setup(); + for (size_t size = 16; size <= 128; size <<= 1) { test_alloc_dealloc(1 << 15, size, false); diff --git a/src/test/setup.h b/src/test/setup.h new file mode 100644 index 0000000..528d5c0 --- /dev/null +++ b/src/test/setup.h @@ -0,0 +1,20 @@ +#if defined(WIN32) && defined(SNMALLOC_CI_BUILD) +# include +# include +# include +void _cdecl error(int signal) +{ + UNUSED(signal); + puts("*****ABORT******"); + _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); +} +#else +void setup() {} +#endif