Fixed a bug related to submessage encoding into memory buffer.
[apps/low-level-can-service.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.pb.h callbacks.pb.h unittests.h unittestproto.pb.h
4 TESTS=test_decode1 test_encode1 decode_unittests encode_unittests
5
6 all: breakpoints $(TESTS) run_unittests
7
8 clean:
9         rm -f $(TESTS) person.pb* *.o *.gcda *.gcno
10
11 %.o: %.c
12 %.o: %.c $(DEPS)
13         $(CC) $(CFLAGS) -c -o $@ $<
14
15 pb_encode.o: ../pb_encode.c $(DEPS)
16         $(CC) $(CFLAGS) -c -o $@ $<
17 pb_decode.o: ../pb_decode.c $(DEPS)
18         $(CC) $(CFLAGS) -c -o $@ $<
19
20 test_decode1: test_decode1.o pb_decode.o person.pb.o
21 test_encode1: test_encode1.o pb_encode.o person.pb.o
22 test_encode2: test_encode2.o pb_encode.o person.pb.o
23 test_decode_callbacks: test_decode_callbacks.o pb_decode.o callbacks.pb.o
24 test_encode_callbacks: test_encode_callbacks.o pb_encode.o callbacks.pb.o
25 decode_unittests: decode_unittests.o pb_decode.o unittestproto.pb.o
26 encode_unittests: encode_unittests.o pb_encode.o unittestproto.pb.o
27
28 %.pb: %.proto
29         protoc -I. -I../generator -I/usr/include -o$@ $<
30
31 %.pb.c %.pb.h: %.pb ../generator/nanopb_generator.py
32         python ../generator/nanopb_generator.py $<
33
34 breakpoints: ../*.c *.c
35         grep -n 'return false;' $^ | cut -d: -f-2 | xargs -n 1 echo b > $@
36
37 coverage: run_unittests
38         gcov pb_encode.gcda
39         gcov pb_decode.gcda
40
41 run_unittests: decode_unittests encode_unittests test_encode1 test_encode2 test_decode1 test_encode_callbacks test_decode_callbacks
42         rm -f *.gcda
43         
44         ./decode_unittests > /dev/null
45         ./encode_unittests > /dev/null
46         
47         [ "`./test_encode1 | ./test_decode1`" = \
48         "`./test_encode1 | protoc --decode=Person -I. -I../generator -I/usr/include person.proto`" ]
49
50         [ "`./test_encode2 | ./test_decode1`" = \
51         "`./test_encode2 | protoc --decode=Person -I. -I../generator -I/usr/include person.proto`" ]
52         
53         [ "`./test_encode_callbacks | ./test_decode_callbacks`" = \
54         "`./test_encode_callbacks | protoc --decode=TestMessage callbacks.proto`" ]
55
56 run_fuzztest: test_decode1
57         bash -c 'I=1; while cat /dev/urandom | ./test_decode1 > /dev/null; do I=$$(($$I+1)); echo -en "\r$$I"; done'