diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 876b40b..7f8357e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Build - run: make all - name: Run tests run: make test - name: Create Release diff --git a/Makefile b/Makefile index 3876f5b..b0f024a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,23 @@ -CC=cc -CFLAGS=-O2 -pipe -Wshadow -Werror -I./include +CC ?= cc +CFLAGS ?= -O2 -pipe -Wall -Wextra -Wshadow -Werror -std=c99 -I./include + +SRC = src/main.c src/validation_utils.c +TEST_SRC = tests/unit/test_validation.c src/validation_utils.c +TEST_BIN = tests/unit/test_validation all: checkrc -checkrc: - $(CC) $(CFLAGS) src/main.c src/validation_utils.c -o checkrc +checkrc: $(SRC) + $(CC) $(CFLAGS) $^ -o $@ + +$(TEST_BIN): $(TEST_SRC) + $(CC) $(CFLAGS) $^ -o $@ -test: checkrc - $(CC) $(CFLAGS) -o tests/unit/test_validation tests/unit/test_validation.c src/validation_utils.c - ./tests/unit/test_validation +test: checkrc $(TEST_BIN) + ./$(TEST_BIN) sh tests/integration/test_checkrc.sh clean: - rm -f checkrc tests/unit/test_validation + rm -f checkrc $(TEST_BIN) .PHONY: all test clean diff --git a/README.md b/README.md index 5e7e2bc..dd0b1ca 100644 --- a/README.md +++ b/README.md @@ -76,4 +76,4 @@ This command compiles and builds the entire project using FreeBSD `make`. Don't worry if you're new to this or even if you’re facing some issues along the way; we're here to help! If you have any questions or need a bit of guidance, feel free to reach out by creating an issue in the repository or dropping us a message. Let’s make `checkrc` even better, together! -Thanks for being a part of our community! \ No newline at end of file +Thanks for being a part of our community! diff --git a/src/validation_utils.c b/src/validation_utils.c index e9bee07..ba4cdc7 100644 --- a/src/validation_utils.c +++ b/src/validation_utils.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "validation_utils.h" #include diff --git a/tests/integration/test_checkrc.sh b/tests/integration/test_checkrc.sh index 49be550..049b6cd 100644 --- a/tests/integration/test_checkrc.sh +++ b/tests/integration/test_checkrc.sh @@ -17,4 +17,4 @@ if [ $? -eq 0 ]; then fi echo "All integration tests passed successfully" -exit 0 \ No newline at end of file +exit 0 diff --git a/tests/integration/test_files/invalid_rc.conf b/tests/integration/test_files/invalid_rc.conf index d1d0ad2..9f163fa 100644 --- a/tests/integration/test_files/invalid_rc.conf +++ b/tests/integration/test_files/invalid_rc.conf @@ -4,4 +4,4 @@ defaultrouter="bad host!" # Invalid hostname ipv6_defaultrouter="2001:db8::g" # Invalid IPv6 sshd_enable="enabled" # Invalid boolean ntpd_enable="1" # Invalid boolean -rcshutdown_timeout="fast" # Invalid integer \ No newline at end of file +rcshutdown_timeout="fast" # Invalid integer diff --git a/tests/integration/test_files/valid_rc.conf b/tests/integration/test_files/valid_rc.conf index c0429df..69dbed6 100644 --- a/tests/integration/test_files/valid_rc.conf +++ b/tests/integration/test_files/valid_rc.conf @@ -4,4 +4,4 @@ defaultrouter="router.example.com" ipv6_defaultrouter="fe80::1%em0" sshd_enable="YES" ntpd_enable="NO" -rcshutdown_timeout="30" \ No newline at end of file +rcshutdown_timeout="30" diff --git a/tests/unit/minunit.h b/tests/unit/minunit.h index 288c085..189c7f2 100644 --- a/tests/unit/minunit.h +++ b/tests/unit/minunit.h @@ -35,4 +35,4 @@ static int tests_failed = 0; printf("Tests failed: %d\n", tests_failed), \ tests_failed ? EXIT_FAILURE : EXIT_SUCCESS) -#endif \ No newline at end of file +#endif diff --git a/tests/unit/test_validation.c b/tests/unit/test_validation.c index 9109730..28876e9 100644 --- a/tests/unit/test_validation.c +++ b/tests/unit/test_validation.c @@ -89,6 +89,7 @@ MU_TEST_SUITE(test_suite) { MU_RUN_TEST(test_boolean_validation); MU_RUN_TEST(test_integer_validation); MU_RUN_TEST(test_string_validation); + return NULL; } int main() {