Small testing framework
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
This commit is contained in:
parent
79487c849e
commit
43a6108f89
3 changed files with 25 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
build/
|
build/
|
||||||
parser
|
parser
|
||||||
|
parser_test
|
||||||
*.caff
|
*.caff
|
||||||
*.jpg
|
*.jpg
|
||||||
*.jpeg
|
*.jpeg
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -3,6 +3,8 @@ CFLAGS = -Wall -O2 -Werror -g
|
||||||
LDFLAGS = -ljpeg
|
LDFLAGS = -ljpeg
|
||||||
TARGET = parser
|
TARGET = parser
|
||||||
SRC = main.c caff.c ciff.c
|
SRC = main.c caff.c ciff.c
|
||||||
|
TEST_SRC = test.c
|
||||||
|
TEST_TARGET = parser_test
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
|
@ -11,3 +13,6 @@ $(TARGET): $(SRC)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGET)
|
rm -f $(TARGET)
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(CC) $(CFLAGS) $(TEST_SRC) -o $(TEST_TARGET)
|
19
test.c
Normal file
19
test.c
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue