From 98b162c76386f865b54f9b6d3a7e893d1e876073 Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:12:35 +0200 Subject: [PATCH 1/7] Create .clang-format --- .clang-format | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..0e49e25 --- /dev/null +++ b/.clang-format @@ -0,0 +1,61 @@ +--- +Language: C +BasedOnStyle: LLVM + +# Indentation +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +ContinuationIndentWidth: 4 + +# Line length — keep short for embedded readability +ColumnLimit: 100 + +# Braces +BreakBeforeBraces: Allman +InsertBraces: false + +# Spaces +SpaceAfterCStyleCast: false +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false + +# Alignment +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 + +# Pointers — ptr goes with the type +PointerAlignment: Right +ReferenceAlignment: Right + +# Short constructs — keep them on separate lines for readability +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false + +# Function parameters +BinPackArguments: false +BinPackParameters: false +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +PenaltyReturnTypeOnItsOwnLine: 10000 + +# Includes +SortIncludes: CaseInsensitive +IncludeBlocks: Regroup + +# Preprocessor +IndentPPDirectives: AfterHash + +# Misc +MaxEmptyLinesToKeep: 1 +KeepEmptyLinesAtTheStartOfBlocks: false + +# Do not indent extern "C" blocks +IndentExternBlock: NoIndent From abda68b1f8449dfa18d29a22636c781580506852 Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:13:15 +0200 Subject: [PATCH 2/7] Delete scripts directory --- scripts/coverage_html.sh | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 scripts/coverage_html.sh diff --git a/scripts/coverage_html.sh b/scripts/coverage_html.sh deleted file mode 100644 index af3d4ad..0000000 --- a/scripts/coverage_html.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -OUT_FILE="${1:-${ROOT_DIR}/build/coverage/index.html}" - -if [[ "${OUT_FILE}" != /* ]]; then - OUT_FILE="${ROOT_DIR}/${OUT_FILE}" -fi - -COVERAGE_CFLAGS='-O0 -g --coverage -Iinclude -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wcast-align -Wcast-qual -Wpointer-arith -Wformat=2 -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wundef -std=c11' - -cd "${ROOT_DIR}" - -if ! command -v gcovr >/dev/null 2>&1; then - echo "Error: gcovr is not installed." - echo "Install with: pip install gcovr" - exit 1 -fi - -make clean >/dev/null -make unit-tests CFLAGS="${COVERAGE_CFLAGS}" >/dev/null -./build/bin/unit_tests >/dev/null - -mkdir -p "$(dirname "${OUT_FILE}")" -gcovr -r "${ROOT_DIR}" \ - --filter "${ROOT_DIR}/src" \ - --html \ - --html-details \ - --output "${OUT_FILE}" - -echo "Coverage HTML report written to: ${OUT_FILE}" \ No newline at end of file From 528fc23e5f828f7e6ecce46f165f307f40f9b074 Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:13:33 +0200 Subject: [PATCH 3/7] Create coverage_html.sh --- tools/coverage_html.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tools/coverage_html.sh diff --git a/tools/coverage_html.sh b/tools/coverage_html.sh new file mode 100644 index 0000000..9fbbe06 --- /dev/null +++ b/tools/coverage_html.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +OUT_FILE="${1:-${ROOT_DIR}/build/coverage/index.html}" + +if [[ "${OUT_FILE}" != /* ]]; then + OUT_FILE="${ROOT_DIR}/${OUT_FILE}" +fi + +COVERAGE_CFLAGS='-O0 -g --coverage -Iinclude -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wcast-align -Wcast-qual -Wpointer-arith -Wformat=2 -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wundef -std=c11' + +cd "${ROOT_DIR}" + +if ! command -v gcovr >/dev/null 2>&1; then + echo "Error: gcovr is not installed." + echo "Install with: pip install gcovr" + exit 1 +fi + +make clean >/dev/null +make unit-tests CFLAGS="${COVERAGE_CFLAGS}" >/dev/null +./build/bin/unit_tests >/dev/null + +mkdir -p "$(dirname "${OUT_FILE}")" +gcovr -r "${ROOT_DIR}" \ + --filter "${ROOT_DIR}/src" \ + --html \ + --html-details \ + --output "${OUT_FILE}" + +echo "Coverage HTML report written to: ${OUT_FILE}" From f70a38fe2b3afe0342738677beef413c44851f00 Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:13:47 +0200 Subject: [PATCH 4/7] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 77b866a..16d8762 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ clean: rm -rf $(BUILD_DIR) obj bin libsdlp.a coverage-html: - bash scripts/coverage_html.sh + bash tools/coverage_html.sh test: unit-tests @echo "Running unit tests..." From 3adbbf85a6d0b60e539050be33ec9fe38b04ba33 Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:14:08 +0200 Subject: [PATCH 5/7] Update cunit.h --- tests/cunit.h | 79 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/tests/cunit.h b/tests/cunit.h index 89a89c4..76fcac3 100644 --- a/tests/cunit.h +++ b/tests/cunit.h @@ -9,42 +9,55 @@ #include static int cunit_overall_failures = 0; +static int cunit_total_tests = 0; -#define ASSERT_EQ_INT(expected, actual) \ - do { \ - if ((int)(expected) != (int)(actual)) { \ - printf("ASSERT_EQ_INT failed: %s:%d: expected %d got %d\n", __FILE__, \ - __LINE__, (int)(expected), (int)(actual)); \ - return 1; \ - } \ - } while (0) +#define ASSERT_EQ_INT(expected, actual) \ + do \ + { \ + if ((int)(expected) != (int)(actual)) \ + { \ + printf("ASSERT_EQ_INT failed: %s:%d: expected %d got %d\n", \ + __FILE__, \ + __LINE__, \ + (int)(expected), \ + (int)(actual)); \ + return 1; \ + } \ + } while (0) -#define ASSERT_EQ_MEM(a, b, len) \ - do { \ - if (memcmp((a), (b), (len)) != 0) { \ - printf("ASSERT_EQ_MEM failed: %s:%d\n", __FILE__, __LINE__); \ - return 1; \ - } \ - } while (0) +#define ASSERT_EQ_MEM(a, b, len) \ + do \ + { \ + if (memcmp((a), (b), (len)) != 0) \ + { \ + printf("ASSERT_EQ_MEM failed: %s:%d\n", __FILE__, __LINE__); \ + return 1; \ + } \ + } while (0) -#define ASSERT_TRUE(cond) \ - do { \ - if (!(cond)) { \ - printf("ASSERT_TRUE failed: %s:%d\n", __FILE__, __LINE__); \ - return 1; \ - } \ - } while (0) +#define ASSERT_TRUE(cond) \ + do \ + { \ + if (!(cond)) \ + { \ + printf("ASSERT_TRUE failed: %s:%d\n", __FILE__, __LINE__); \ + return 1; \ + } \ + } while (0) -#define RUN_TEST(fn) \ - do { \ - printf("RUN %s\n", #fn); \ - int r = fn(); \ - if (r == 0) \ - printf("PASS %s\n", #fn); \ - else { \ - printf("FAIL %s\n", #fn); \ - cunit_overall_failures++; \ - } \ - } while (0) +#define RUN_TEST(fn) \ + do \ + { \ + printf("RUN %s\n", #fn); \ + cunit_total_tests++; \ + int r = fn(); \ + if (r == 0) \ + printf("PASS %s\n", #fn); \ + else \ + { \ + printf("FAIL %s\n", #fn); \ + cunit_overall_failures++; \ + } \ + } while (0) #endif /* CUNIT_H */ From 5e31f85a1ee0d10ad8ac991a19d14d574c8a9fd7 Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:14:31 +0200 Subject: [PATCH 6/7] Create test_runners.h --- tests/test_runners.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/test_runners.h diff --git a/tests/test_runners.h b/tests/test_runners.h new file mode 100644 index 0000000..c2b648a --- /dev/null +++ b/tests/test_runners.h @@ -0,0 +1,10 @@ +#ifndef TEST_RUNNERS_H +#define TEST_RUNNERS_H + +typedef struct +{ + int passed; + int total; +} pus_test_result_t; + +#endif /* TEST_RUNNERS_H */ From 18ff2b20ed3326602ddbf14bcfcbd06a643cdada Mon Sep 17 00:00:00 2001 From: Michal Pogorzelec <80826463+Michal-Pogorzelec@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:15:50 +0200 Subject: [PATCH 7/7] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a0a9120..4748466 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,5 @@ dkms.conf build/ obj/ bin/ -_codeql_detected_source_root +.github/ +.vscode/