Home | History | Annotate | Download | only in alltypes
      1 # Build and run a test that encodes and decodes a message that contains
      2 # all of the Protocol Buffers data types.
      3 
      4 Import("env")
      5 
      6 env.NanopbProto(["alltypes", "alltypes.options"])
      7 enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o"])
      8 dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o"])
      9 
     10 # Test the round-trip from nanopb encoder to nanopb decoder
     11 env.RunTest(enc)
     12 env.RunTest([dec, "encode_alltypes.output"])
     13 
     14 # Re-encode the data using protoc, and check that the results from nanopb
     15 # match byte-per-byte to the protoc output.
     16 env.Decode("encode_alltypes.output.decoded",
     17            ["encode_alltypes.output", "alltypes.proto"],
     18            MESSAGE='AllTypes')
     19 env.Encode("encode_alltypes.output.recoded",
     20            ["encode_alltypes.output.decoded", "alltypes.proto"],
     21            MESSAGE='AllTypes')
     22 env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"])
     23 
     24 # Do the same checks with the optional fields present.
     25 env.RunTest("optionals.output", enc, ARGS = ['1'])
     26 env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
     27 env.Decode("optionals.output.decoded",
     28            ["optionals.output", "alltypes.proto"],
     29            MESSAGE='AllTypes')
     30 env.Encode("optionals.output.recoded",
     31            ["optionals.output.decoded", "alltypes.proto"],
     32            MESSAGE='AllTypes')
     33 env.Compare(["optionals.output", "optionals.output.recoded"])
     34 
     35 
     36