Add 'CAN-binder/libs/nanopb/' from commit '278ffb890e3d8722e4c7d824baaf221a1e375fc4'
[apps/agl-service-can-low-level.git] / CAN-binder / libs / nanopb / 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", "malloc_env")
5
6 c = Copy("$TARGET", "$SOURCE")
7 env.Command("alltypes.proto", "#alltypes/alltypes.proto", c)
8
9 env.NanopbProto(["alltypes", "alltypes.options"])
10 enc = malloc_env.Program(["encode_alltypes_pointer.c",
11                           "alltypes.pb.c",
12                           "$COMMON/pb_encode_with_malloc.o",
13                           "$COMMON/pb_common_with_malloc.o",
14                           "$COMMON/malloc_wrappers.o"])
15 dec = malloc_env.Program(["decode_alltypes_pointer.c",
16                           "alltypes.pb.c",
17                           "$COMMON/pb_decode_with_malloc.o",
18                           "$COMMON/pb_common_with_malloc.o",
19                           "$COMMON/malloc_wrappers.o"])
20
21 # Encode and compare results to non-pointer alltypes test case
22 env.RunTest(enc)
23 env.Compare(["encode_alltypes_pointer.output", "$BUILD/alltypes/encode_alltypes.output"])
24
25 # Decode (under valgrind if available)
26 valgrind = env.WhereIs('valgrind')
27 kwargs = {}
28 if valgrind:
29     kwargs['COMMAND'] = valgrind
30     kwargs['ARGS'] = ["-q", "--error-exitcode=99", dec[0].abspath]
31
32 env.RunTest("decode_alltypes.output", [dec, "encode_alltypes_pointer.output"], **kwargs)
33
34 # Do the same thing with the optional fields present
35 env.RunTest("optionals.output", enc, ARGS = ['1'])
36 env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"])
37
38 kwargs['ARGS'] = kwargs.get('ARGS', []) + ['1']
39 env.RunTest("optionals.decout", [dec, "optionals.output"], **kwargs)
40