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