-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
format: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install valgrind | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y valgrind | ||
- name: Compile Tests | ||
run: | | ||
make test | ||
- name: Run Tests | ||
run: | | ||
for test in test/bin/*; do | ||
valgrind --leak-check=full --error-exitcode=1 --show-leak-kinds=all --errors-for-leak-kinds=all $test | ||
if [ $? -ne 0 ]; then | ||
exit 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.vscode/ | ||
.bin/ | ||
bin/ | ||
test/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
TARGET := ../edgerunner | ||
DEBUG := ../edgerunner_dbg | ||
|
||
TEST := ../test | ||
TEST_DBG := ../test_dbg | ||
|
||
CC := gcc | ||
|
||
DEBUG_FLAGS := -g -fsanitize=address -fsanitize=object-size -fno-optimize-sibling-calls -fsanitize=undefined -fsanitize=leak -fsanitize=alignment | ||
CFLAGS := -Og -std=gnu17 -Wall -Wextra -Wpedantic -Wno-unused-parameter | ||
|
||
SRCS := $(wildcard src/*.c) | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(SRCS) main.c | ||
$(CC) $(CFLAGS) $^ -o $(TARGET) | ||
$(DEBUG) : $(SRCS) main.c | ||
$(CC) $(CFLAGS) $(DEBUG_FLAGS) $^ -o $(DEBUG) | ||
|
||
|
||
test: $(TEST) | ||
$(TEST): $(SRCS) $(wildcard test/*.c) | ||
$(CC) $(SRCS) $(CFLAGS) $^ -o test/bin/$(basename $(notdir $^)) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main() { | ||
int* thing = (int*)malloc(sizeof(int)); | ||
*thing = 5; | ||
printf("thing = %d\n", *thing); | ||
return 0; | ||
} |