Add pb_release() function
[apps/agl-service-can-low-level.git] / tests / alltypes_pointer / SConscript
1 # Encode the AllTypes message using pointers for all fields, and verify the
2 # output against the normal AllTypes test case.
3
4 Import("env")
5
6 # We need our own pb_decode.o for the malloc support
7 env = env.Clone()
8 env.Append(CPPDEFINES = {'PB_ENABLE_MALLOC': 1});
9
10 # Disable libmudflap, because it will confuse e.g. valgrind
11 # and other memory leak detection tools.
12 if '-fmudflap' in env["CCFLAGS"]:
13     env["CCFLAGS"].remove("-fmudflap")
14     env["LINKFLAGS"].remove("-fmudflap")
15     env["LIBS"].remove("mudflap")
16
17 strict = env.Clone()
18 strict.Append(CFLAGS = strict['CORECFLAGS'])
19 strict.Object("pb_decode_with_malloc.o", "$NANOPB/pb_decode.c")
20 strict.Object("pb_encode_with_malloc.o", "$NANOPB/pb_encode.c")
21
22 c = Copy("$TARGET", "$SOURCE")
23 env.Command("alltypes.proto", "#alltypes/alltypes.proto", c)
24
25 env.NanopbProto(["alltypes", "alltypes.options"])
26 enc = env.Program(["encode_alltypes_pointer.c", "alltypes.pb.c", "pb_encode_with_malloc.o"])
27 dec = env.Program(["decode_alltypes_pointer.c", "alltypes.pb.c", "pb_decode_with_malloc.o"])
28
29 refdec = "$BUILD/alltypes/decode_alltypes$PROGSUFFIX"
30
31 # Encode and compare results
32 env.RunTest(enc)
33 env.RunTest("decode_alltypes.output", [dec, "encode_alltypes_pointer.output"])
34 env.RunTest("decode_alltypes_ref.output", [refdec, "encode_alltypes_pointer.output"])
35 env.Compare(["encode_alltypes_pointer.output", "$BUILD/alltypes/encode_alltypes.output"])
36
37 # Do the same thing with the optional fields present
38 env.RunTest("optionals.output", enc, ARGS = ['1'])
39 env.RunTest("optionals.decout", [refdec, "optionals.output"], ARGS = ['1'])
40 env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"])
41