Home | History | Annotate | Download | only in without_64bit
      1 # Run the alltypes test case, but compile with PB_WITHOUT_64BIT.
      2 
      3 Import("env")
      4 
      5 env.NanopbProto(["alltypes", "alltypes.options"])
      6 
      7 # Define the compilation options
      8 opts = env.Clone()
      9 opts.Append(CPPDEFINES = {'PB_WITHOUT_64BIT': 1, 'HAVE_STDINT_H': 0, 'PB_SYSTEM_HEADER': '\\"no_64bit_syshdr.h\\"'})
     10 opts.Append(CPPPATH = "#without_64bit")
     11 
     12 if 'SYSHDR' in opts:
     13     opts.Append(CPPDEFINES = {'PB_OLD_SYSHDR': opts['SYSHDR']})
     14 
     15 # Build new version of core
     16 strict = opts.Clone()
     17 strict.Append(CFLAGS = strict['CORECFLAGS'])
     18 strict.Object("pb_decode_no64bit.o", "$NANOPB/pb_decode.c")
     19 strict.Object("pb_encode_no64bit.o", "$NANOPB/pb_encode.c")
     20 strict.Object("pb_common_no64bit.o", "$NANOPB/pb_common.c")
     21 
     22 # Now build and run the test normally.
     23 enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_no64bit.o", "pb_common_no64bit.o"])
     24 dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_no64bit.o", "pb_common_no64bit.o"])
     25 
     26 env.RunTest(enc)
     27 env.RunTest([dec, "encode_alltypes.output"])
     28 
     29 # Re-encode the data using protoc, and check that the results from nanopb
     30 # match byte-per-byte to the protoc output.
     31 env.Decode("encode_alltypes.output.decoded",
     32            ["encode_alltypes.output", "alltypes.proto"],
     33            MESSAGE='AllTypes')
     34 env.Encode("encode_alltypes.output.recoded",
     35            ["encode_alltypes.output.decoded", "alltypes.proto"],
     36            MESSAGE='AllTypes')
     37 env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"])
     38 
     39 
     40 # Do the same checks with the optional fields present.
     41 env.RunTest("optionals.output", enc, ARGS = ['1'])
     42 env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
     43 env.Decode("optionals.output.decoded",
     44            ["optionals.output", "alltypes.proto"],
     45            MESSAGE='AllTypes')
     46 env.Encode("optionals.output.recoded",
     47            ["optionals.output.decoded", "alltypes.proto"],
     48            MESSAGE='AllTypes')
     49 env.Compare(["optionals.output", "optionals.output.recoded"])
     50