From 0c488cd7ac70b7a7eb07e26a1ca710e24bab1e2f Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sat, 17 Aug 2024 19:06:55 -0500 Subject: [PATCH] add native_test --- .github/workflows/c.yml | 3 +++ .github/workflows/cplusplus.yml | 3 +++ c/Makefile | 6 +++++- c/src/include/utils.h | 2 +- cplusplus/Makefile | 6 +++++- cplusplus/src/include/utils.hpp | 8 ++++---- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/c.yml b/.github/workflows/c.yml index 28de030e..2d5655a8 100644 --- a/.github/workflows/c.yml +++ b/.github/workflows/c.yml @@ -81,6 +81,9 @@ jobs: NO_OPTIONAL_TESTS: true COMPILER_OVERRIDE: clang + - name: Run tests (native runner) + run: make c_native_test + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: diff --git a/.github/workflows/cplusplus.yml b/.github/workflows/cplusplus.yml index a2f8d67a..d1d3f22e 100644 --- a/.github/workflows/cplusplus.yml +++ b/.github/workflows/cplusplus.yml @@ -76,6 +76,9 @@ jobs: NO_OPTIONAL_TESTS: true COMPILER_OVERRIDE: clang + - name: Run tests (native test runner) + run: make cp_native_test + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: diff --git a/c/Makefile b/c/Makefile index abebe8df..6543ad76 100644 --- a/c/Makefile +++ b/c/Makefile @@ -58,7 +58,11 @@ lint: .PHONY: native native: ../LICENSE Unity/src/unity.c - @$(CC) test.c Unity/src/unity.c -O$(O) -g -lm -lc -Wall -Werror -std=gnu99 -march=native -flto + @$(CC) test.c Unity/src/unity.c -O$(O) -g -lm -lc -Wall -Werror -std=gnu99 -march=native -flto --coverage -o native_test_runner + +.PHONY: native_test +native_test: native + @./native_test_runner .PHONY: clean clean: diff --git a/c/src/include/utils.h b/c/src/include/utils.h index cf2688fe..c8db2b57 100644 --- a/c/src/include/utils.h +++ b/c/src/include/utils.h @@ -135,7 +135,7 @@ Answer get_answer(uint16_t id) { char *linepointer; char *tabpointer; Answer ret = { - id: id, + .id = id, }; char *answers = get_data_file("answers.tsv"); diff --git a/cplusplus/Makefile b/cplusplus/Makefile index 97413cff..c52cbb6f 100644 --- a/cplusplus/Makefile +++ b/cplusplus/Makefile @@ -50,7 +50,11 @@ lint: .PHONY: native native: ../LICENSE Unity/src/unity.c - @$(CXX) test.cpp Unity/src/unity.c -O$(O) -g -lm -lstdc++ -Wall -Werror -std=gnu++11 -march=native -flto + @$(CXX) test.cpp Unity/src/unity.c -O$(O) -g -lm -lstdc++ -Wall -Werror -std=gnu++11 -march=native -flto -Wno-deprecated --coverage -o native_test_runner + +.PHONY: native_test +native_test: native + @./native_test_runner .PHONY: clean clean: diff --git a/cplusplus/src/include/utils.hpp b/cplusplus/src/include/utils.hpp index bc28c12f..1c0039a3 100644 --- a/cplusplus/src/include/utils.hpp +++ b/cplusplus/src/include/utils.hpp @@ -168,7 +168,7 @@ Answer get_answer(const uint16_t id) { break; default: std::cerr << "Error: Unsupported int size " << size << "'\n"; - Answer err = {0}; + Answer err = {{0}}; return err; } break; @@ -191,7 +191,7 @@ Answer get_answer(const uint16_t id) { break; default: std::cerr << "Error: Unsupported uint size " << size << "'\n"; - Answer err = {0}; + Answer err = {{0}}; return err; } break; @@ -202,13 +202,13 @@ Answer get_answer(const uint16_t id) { answer.value.STR[size] = 0; } else { std::cerr << "Error: Memory allocation failed for string\n"; - Answer err = {0}; + Answer err = {{0}}; return err; } break; default: std::cerr << "Error: Unknown type (should be unreachable)\n"; - Answer err = {0}; + Answer err = {{0}}; return err; } }