SConscript revision 7ef855e462b9a18b7d330e4b40f350164a6ad9da
1# Encode the AllTypes message using pointers for all fields, and verify the 2# output against the normal AllTypes test case. 3 4Import("env") 5 6# We need our own pb_decode.o for the malloc support 7env = env.Clone() 8env.Append(CPPDEFINES = {'PB_ENABLE_MALLOC': 1}); 9 10# Disable libmudflap, because it will confuse valgrind 11# and other memory leak detection tools. 12if '-fmudflap' in env["CCFLAGS"]: 13 env["CCFLAGS"].remove("-fmudflap") 14 env["LINKFLAGS"].remove("-fmudflap") 15 env["LIBS"].remove("mudflap") 16 17strict = env.Clone() 18strict.Append(CFLAGS = strict['CORECFLAGS']) 19strict.Object("pb_decode_with_malloc.o", "$NANOPB/pb_decode.c") 20strict.Object("pb_encode_with_malloc.o", "$NANOPB/pb_encode.c") 21 22c = Copy("$TARGET", "$SOURCE") 23env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) 24 25env.NanopbProto(["alltypes", "alltypes.options"]) 26enc = env.Program(["encode_alltypes_pointer.c", "alltypes.pb.c", "pb_encode_with_malloc.o"]) 27dec = env.Program(["decode_alltypes_pointer.c", "alltypes.pb.c", "pb_decode_with_malloc.o"]) 28 29# Encode and compare results to non-pointer alltypes test case 30env.RunTest(enc) 31env.Compare(["encode_alltypes_pointer.output", "$BUILD/alltypes/encode_alltypes.output"]) 32 33# Decode (under valgrind if available) 34valgrind = env.WhereIs('valgrind') 35kwargs = {} 36if valgrind: 37 kwargs['COMMAND'] = valgrind 38 kwargs['ARGS'] = ["-q", dec[0].abspath] 39 40env.RunTest("decode_alltypes.output", [dec, "encode_alltypes_pointer.output"], **kwargs) 41 42# Do the same thing with the optional fields present 43env.RunTest("optionals.output", enc, ARGS = ['1']) 44env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"]) 45 46kwargs['ARGS'] = kwargs.get('ARGS', []) + ['1'] 47env.RunTest("optionals.decout", [dec, "optionals.output"], **kwargs) 48 49