Small testing framework

Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
Balazs Toldi 2023-05-29 20:04:52 +02:00
parent 79487c849e
commit 43a6108f89
Signed by: Bazsalanszky
GPG key ID: 6C7D440036F99D58
3 changed files with 25 additions and 0 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
build/
parser
parser_test
*.caff
*.jpg
*.jpeg

View file

@ -3,6 +3,8 @@ CFLAGS = -Wall -O2 -Werror -g
LDFLAGS = -ljpeg
TARGET = parser
SRC = main.c caff.c ciff.c
TEST_SRC = test.c
TEST_TARGET = parser_test
all: $(TARGET)
@ -11,3 +13,6 @@ $(TARGET): $(SRC)
clean:
rm -f $(TARGET)
test:
$(CC) $(CFLAGS) $(TEST_SRC) -o $(TEST_TARGET)

19
test.c Normal file
View file

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#define TEST_COUNT 3
#define COMMAND_SIZE 128
int main(void)
{
int failure = 0;
for (size_t i = 1; i <= TEST_COUNT; i++)
{
char command[COMMAND_SIZE];
sprintf(command,"valgrind --track-origins=yes -s ./parser -caff %ld.caff",i);
int res = system(command);
printf("Test %ld result: %d (%s)\n",i, res, (res == 0) ? "SUCCESS" : "FAIL");
failure += (res != 0) ? 1 : 0;
}
}