diff --git a/.github/workflows/unit_tests_ci_workflow.yml b/.github/workflows/unit_tests_ci_workflow.yml index 19214cf..c929a9a 100644 --- a/.github/workflows/unit_tests_ci_workflow.yml +++ b/.github/workflows/unit_tests_ci_workflow.yml @@ -8,9 +8,14 @@ jobs: run-unit-tests: name: Run Unit Tests runs-on: ubuntu-latest + steps: + - name: Checkout repository uses: actions/checkout@v5 + - name: Check and install GCC version + run: ./ci_scripts/check_gcc_version.sh + - name: Run Unit Tests run: cd tests && ./run_tests.sh diff --git a/Makefile b/Makefile index 05c0828..4fcd42c 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ GIT_DIRTY := $(shell git diff-index --quiet HEAD -- || echo "-dirty") GIT_HASH := $(shell git rev-parse --short HEAD || echo "undef") GIT_C_FLAGS := -DGIT_HASH=\"$(GIT_HASH)\" -DGIT_DIRTY=\"$(GIT_DIRTY)\" -CFLAGS := -g -O3 -Wall -Werror \ +CFLAGS := -g -O3 -Wall -Werror -std=gnu23 \ -mcpu=arm7tdmi -mtune=arm7tdmi \ -ffast-math -fomit-frame-pointer -funroll-loops \ $(ARCH) diff --git a/ci_scripts/check_gcc_version.sh b/ci_scripts/check_gcc_version.sh new file mode 100755 index 0000000..7654bdc --- /dev/null +++ b/ci_scripts/check_gcc_version.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Check GCC version and install GCC 14 if needed +check_gcc_version() { + if command -v gcc &> /dev/null; then + gcc_version=$(gcc -dumpversion | cut -d. -f1) + if [ "$gcc_version" -lt 14 ]; then + echo "GCC version $gcc_version detected. Installing GCC 14..." + sudo apt-get update + sudo apt-get install -y gcc-14 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 + echo "GCC 14 installed and set as default." + fi + fi +} + +check_gcc_version \ No newline at end of file diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..77bbf95 --- /dev/null +++ b/tests/README @@ -0,0 +1,5 @@ +These are tests that run on the repository's CI or can be run locally +to make sure none of the base modules are broken. + +The project uses the gnu23 C standard which is stably supported from GCC 14 and onwards +so this project should be compiled with GCC 14 or later. diff --git a/tests/bitset/Makefile b/tests/bitset/Makefile index 2eed24d..a3eac92 100644 --- a/tests/bitset/Makefile +++ b/tests/bitset/Makefile @@ -1,7 +1,7 @@ CC := gcc CFLAGS := -I../../include -I. \ - -g -O3 -Wall -Werror + -g -O3 -std=gnu23 -Wall -Werror SRC := bitset_test.c \ ../../source/bitset.c OUT := build/bitset_test diff --git a/tests/list/Makefile b/tests/list/Makefile index 0a433b6..3c23e55 100644 --- a/tests/list/Makefile +++ b/tests/list/Makefile @@ -1,7 +1,7 @@ CC := gcc CFLAGS := -I../../include -I. \ - -g -O3 -Wall -Werror -DPOOLS_TEST_ENV=yes + -g -O3 -std=gnu23 -Wall -Werror -DPOOLS_TEST_ENV=yes SRC := list_test.c \ ../../source/list.c \ diff --git a/tests/pool/Makefile b/tests/pool/Makefile index f2f6093..225ee24 100644 --- a/tests/pool/Makefile +++ b/tests/pool/Makefile @@ -1,7 +1,7 @@ CC := gcc CFLAGS := -I../../include -I. \ - -g -O3 -Wall -Werror -DPOOLS_TEST_ENV=yes + -g -O3 -std=gnu23 -Wall -Werror -DPOOLS_TEST_ENV=yes SRC := pool_test.c ../../source/pool.c ../../source/bitset.c OUT := build/pool_test diff --git a/tests/util/Makefile b/tests/util/Makefile index 56bbfc2..fb9a3ad 100644 --- a/tests/util/Makefile +++ b/tests/util/Makefile @@ -1,7 +1,7 @@ CC := gcc CFLAGS := -I../../include -I. \ - -g -O3 -Wall -Werror -Wno-format + -g -O3 -std=gnu23 -Wall -Werror -Wno-format SRC := util_test.c ../../source/util.c OUT := build/util_test