unittests, change to PB_LTYPE_BYTES data size
[apps/agl-service-can-low-level.git] / tests / Makefile
1 CFLAGS=-ansi -Wall -Werror -I .. -g -O0 --coverage
2 LDFLAGS=--coverage
3 DEPS=../pb_decode.h ../pb_encode.h ../pb.h person.h unittests.h
4 TESTS=test_decode1 test_encode1 decode_unittests encode_unittests
5
6 all: $(TESTS) run_unittests breakpoints
7
8 clean:
9         rm -f $(TESTS) *.o *.gcda *.gcno
10
11 %.o: %.c $(DEPS)
12         $(CC) $(CFLAGS) -c -o $@ $<
13
14 test_decode1: test_decode1.o ../pb_decode.o person.o
15 test_encode1: test_encode1.o ../pb_encode.o person.o
16 decode_unittests: decode_unittests.o ../pb_decode.o person.o
17 encode_unittests: encode_unittests.o ../pb_encode.o person.o
18
19 person.c person.h: person.proto
20         protoc -I. -I../generator -I/usr/include -operson.pb $<
21         python ../generator/nanopb_generator.py person.pb
22
23 breakpoints: ../*.c *.c
24         grep -n 'return false;' $^ | cut -d: -f-2 | xargs -n 1 echo b > $@
25
26 coverage:
27         gcov -o .. ../pb_encode.c
28         gcov -o .. ../pb_decode.c
29
30 run_unittests: decode_unittests encode_unittests test_encode1 test_decode1
31         ./decode_unittests > /dev/null
32         ./encode_unittests > /dev/null
33         
34         [ "`./test_encode1 | ./test_decode1`" = \
35         "`./test_encode1 | protoc --decode=Person -I. -I../generator -I/usr/include person.proto`" ]
36
37 run_fuzztest: test_decode1
38         bash -c 'I=1; while cat /dev/urandom | ./test_decode1 > /dev/null; do I=$$(($$I+1)); echo -en "\r$$I"; done'