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