1 # Encode the AllTypes message using pointers for all fields, and verify the
2 # output against the normal AllTypes test case.
6 # We need our own pb_decode.o for the malloc support
8 env.Append(CPPDEFINES = {'PB_ENABLE_MALLOC': 1});
10 # Disable libmudflap, because it will confuse 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")
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 strict.Object("pb_common_with_malloc.o", "$NANOPB/pb_common.c")
23 c = Copy("$TARGET", "$SOURCE")
24 env.Command("alltypes.proto", "#alltypes/alltypes.proto", c)
26 env.NanopbProto(["alltypes", "alltypes.options"])
27 enc = env.Program(["encode_alltypes_pointer.c", "alltypes.pb.c", "pb_encode_with_malloc.o", "pb_common_with_malloc.o"])
28 dec = env.Program(["decode_alltypes_pointer.c", "alltypes.pb.c", "pb_decode_with_malloc.o", "pb_common_with_malloc.o"])
30 # Encode and compare results to non-pointer alltypes test case
32 env.Compare(["encode_alltypes_pointer.output", "$BUILD/alltypes/encode_alltypes.output"])
34 # Decode (under valgrind if available)
35 valgrind = env.WhereIs('valgrind')
38 kwargs['COMMAND'] = valgrind
39 kwargs['ARGS'] = ["-q", dec[0].abspath]
41 env.RunTest("decode_alltypes.output", [dec, "encode_alltypes_pointer.output"], **kwargs)
43 # Do the same thing with the optional fields present
44 env.RunTest("optionals.output", enc, ARGS = ['1'])
45 env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"])
47 kwargs['ARGS'] = kwargs.get('ARGS', []) + ['1']
48 env.RunTest("optionals.decout", [dec, "optionals.output"], **kwargs)