diff --git a/.gitignore b/.gitignore index effe1a6..b1cdcd9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ build/ parser +parser_test *.caff *.jpg *.jpeg diff --git a/Makefile b/Makefile index 611e153..3c16d02 100644 --- a/Makefile +++ b/Makefile @@ -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) \ No newline at end of file diff --git a/test.c b/test.c new file mode 100644 index 0000000..a953f57 --- /dev/null +++ b/test.c @@ -0,0 +1,19 @@ +#include +#include + +#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; + } +} \ No newline at end of file