1# Test the AllTypes encoding & decoding using callbacks for all fields. 2 3Import("env", "malloc_env") 4 5c = Copy("$TARGET", "$SOURCE") 6env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) 7 8env.NanopbProto(["alltypes", "alltypes.options"]) 9enc = env.Program(["encode_alltypes_callback.c", "alltypes.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) 10dec = env.Program(["decode_alltypes_callback.c", "alltypes.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) 11 12refdec = "$BUILD/alltypes/decode_alltypes$PROGSUFFIX" 13 14# Encode and compare results 15env.RunTest(enc) 16env.RunTest("decode_alltypes.output", [refdec, "encode_alltypes_callback.output"]) 17env.RunTest("decode_alltypes_callback.output", [dec, "encode_alltypes_callback.output"]) 18 19# Do the same thing with the optional fields present 20env.RunTest("optionals.output", enc, ARGS = ['1']) 21env.RunTest("optionals.refdecout", [refdec, "optionals.output"], ARGS = ['1']) 22env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1']) 23 24# Try with malloc support also 25mallocbin1 = malloc_env.Object("decode_with_malloc.o", "decode_alltypes_callback.c") 26mallocbin2 = malloc_env.Object("alltypes_malloc.pb.o", "alltypes.pb.c") 27mallocdec = malloc_env.Program("decode_with_malloc", [mallocbin1, mallocbin2, "$COMMON/pb_decode_with_malloc.o", "$COMMON/pb_common_with_malloc.o", "$COMMON/malloc_wrappers.o"]) 28env.RunTest("decode_with_malloc.output", [mallocdec, "encode_alltypes_callback.output"]) 29