From e33af907d1f3dfe2e10adc5db909237624da4ef1 Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Tue, 18 May 2021 16:07:30 +0200 Subject: Add gitignore to benchmarks to ignore executables --- benchmarks/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 benchmarks/.gitignore diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore new file mode 100644 index 00000000..b883f1fd --- /dev/null +++ b/benchmarks/.gitignore @@ -0,0 +1 @@ +*.exe -- cgit v1.2.3 From fdcccab327f45bb5cabb232b0e25f06748b7ee80 Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Tue, 18 May 2021 16:07:43 +0200 Subject: Provide initial cmake configuration --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..1787154f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.1) +project(stc) +add_library(stc INTERFACE) +target_include_directories(stc INTERFACE include) + + -- cgit v1.2.3 From e7fbf378f9786c92b9e241767d10685f465876fe Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Tue, 18 May 2021 16:14:14 +0200 Subject: cmake: Add examples as tests --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1787154f..e7510343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,14 @@ project(stc) add_library(stc INTERFACE) target_include_directories(stc INTERFACE include) +include(CTest) +if(BUILD_TESTING) + file(GLOB examples examples/*.c) + foreach(file IN LISTS examples) + get_filename_component(name "${file}" NAME_WE) + add_executable(${name} ${file}) + target_link_libraries(${name} PRIVATE stc m) + add_test(NAME ${name} COMMAND ${name}) + endforeach() +endif() -- cgit v1.2.3 From 2558be51ea2046b05a70e00c05bfbdfcc9064dab Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Tue, 18 May 2021 16:20:32 +0200 Subject: Add github-actions testing --- .github/workflows/workflow.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 00000000..d0cb7f63 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,19 @@ +name: "Main Workflow" +on: + pull_request: + push: + +jobs: + build_and_test: + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + - name: 'Build & Test' + uses: ashutoshvarma/action-cmake-build@master + with: + cc: gcc + cxx: g++ + build-type: Release + configure-options: -DBUILD_TESTING=1 + run-test: true -- cgit v1.2.3 From 4a930f5e5f84d3be80cdd96383ef0525f8012a42 Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Wed, 19 May 2021 05:15:18 +0200 Subject: cmake: Add benchmarks as tests --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7510343..f834aceb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,5 +12,10 @@ if(BUILD_TESTING) target_link_libraries(${name} PRIVATE stc m) add_test(NAME ${name} COMMAND ${name}) endforeach() + foreach(name IN ITEMS cdeq clist cmap csmap cvec) + add_executable(${name} benchmarks/${name}_benchmark.cpp) + target_link_libraries(${name} PRIVATE stc m) + add_test(NAME ${name} COMMAND ${name}) + endforeach() endif() -- cgit v1.2.3 From 153bd3d701f69991e3f03943df1344cd8b65e59b Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Sat, 21 Aug 2021 02:27:43 +0200 Subject: Fix memory leaks --- examples/birthday.c | 3 ++- examples/bits.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/birthday.c b/examples/birthday.c index 0dbb544a..b3800f70 100644 --- a/examples/birthday.c +++ b/examples/birthday.c @@ -23,6 +23,7 @@ static void test_repeats(void) int v = cmap_ic_emplace(&m, k, 0).ref->second += 1; if (v > 1) printf("repeated value %llx (%d) at 2^%d\n", k, v, (int) log2(i)); } + cmap_ic_del(&m); } @@ -56,4 +57,4 @@ int main() seed = time(NULL); test_distribution(); test_repeats(); -} \ No newline at end of file +} diff --git a/examples/bits.c b/examples/bits.c index 84bdbb6b..d8c6f762 100644 --- a/examples/bits.c +++ b/examples/bits.c @@ -9,6 +9,7 @@ int main() char buf[256]; cbits_to_str(s1, buf, 0, -1); printf("buf: %s: %zu\n", buf, cbits_count(s1)); + cbits_del(&s1); cbits_reset(&set, 9); cbits_resize(&set, 43, false); @@ -58,4 +59,4 @@ int main() puts(""); } } -} \ No newline at end of file +} -- cgit v1.2.3 From 9e0df7dbfdd284a74bbbd96f81a512abc3e81136 Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Sat, 21 Aug 2021 02:29:26 +0200 Subject: Add address-sanitizer to CI/CD --- .github/workflows/workflow.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d0cb7f63..e2f745d8 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -6,6 +6,9 @@ on: jobs: build_and_test: runs-on: ubuntu-latest + env: + CFLAGS: -Wall -Wno-unused-function -ggdb3 -fsanitize=address -fsanitize=undefined -fsanitize=pointer-compare -fsanitize=pointer-subtract + CXXFLAGS: -Wall -Wno-unused-function -ggdb3 -fsanitize=address -fsanitize=undefined -fsanitize=pointer-compare -fsanitize=pointer-subtract steps: - name: 'Checkout' uses: actions/checkout@v2 -- cgit v1.2.3 From 57dbfbd8e68a9df26f0902cafbd3059bbd479822 Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Sat, 21 Aug 2021 02:42:35 +0200 Subject: github-actions: print test output on failure --- .github/workflows/workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e2f745d8..5ceacd43 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -19,4 +19,5 @@ jobs: cxx: g++ build-type: Release configure-options: -DBUILD_TESTING=1 + ctest-options: --output-on-failure run-test: true -- cgit v1.2.3