summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/alltypes_proto3/SConscript70
1 files changed, 40 insertions, 30 deletions
diff --git a/tests/alltypes_proto3/SConscript b/tests/alltypes_proto3/SConscript
index 6c6238c6..c0b2fc1b 100644
--- a/tests/alltypes_proto3/SConscript
+++ b/tests/alltypes_proto3/SConscript
@@ -1,35 +1,45 @@
-# Build and run a test that encodes and decodes a message that contains
-# all of the Protocol Buffers data types.
+# Version of AllTypes test case for protobuf 3 file format.
Import("env")
-env.NanopbProto(["alltypes", "alltypes.options"])
-enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"])
-dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"])
-
-# Test the round-trip from nanopb encoder to nanopb decoder
-env.RunTest(enc)
-env.RunTest([dec, "encode_alltypes.output"])
-
-# Re-encode the data using protoc, and check that the results from nanopb
-# match byte-per-byte to the protoc output.
-env.Decode("encode_alltypes.output.decoded",
- ["encode_alltypes.output", "alltypes.proto"],
- MESSAGE='AllTypes')
-env.Encode("encode_alltypes.output.recoded",
- ["encode_alltypes.output.decoded", "alltypes.proto"],
- MESSAGE='AllTypes')
-env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"])
-
-# Do the same checks with the optional fields present.
-env.RunTest("optionals.output", enc, ARGS = ['1'])
-env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
-env.Decode("optionals.output.decoded",
- ["optionals.output", "alltypes.proto"],
- MESSAGE='AllTypes')
-env.Encode("optionals.output.recoded",
- ["optionals.output.decoded", "alltypes.proto"],
- MESSAGE='AllTypes')
-env.Compare(["optionals.output", "optionals.output.recoded"])
+import re
+match = None
+if 'PROTOC_VERSION' in env:
+ match = re.search('([0-9]+).([0-9]+).([0-9]+)', env['PROTOC_VERSION'])
+
+if match:
+ version = map(int, match.groups())
+
+# proto3 syntax is supported by protoc >= 3.0.0
+if env.GetOption('clean') or (match and version[0] >= 3):
+
+ env.NanopbProto(["alltypes", "alltypes.options"])
+ enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"])
+ dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"])
+
+ # Test the round-trip from nanopb encoder to nanopb decoder
+ env.RunTest(enc)
+ env.RunTest([dec, "encode_alltypes.output"])
+
+ # Re-encode the data using protoc, and check that the results from nanopb
+ # match byte-per-byte to the protoc output.
+ env.Decode("encode_alltypes.output.decoded",
+ ["encode_alltypes.output", "alltypes.proto"],
+ MESSAGE='AllTypes')
+ env.Encode("encode_alltypes.output.recoded",
+ ["encode_alltypes.output.decoded", "alltypes.proto"],
+ MESSAGE='AllTypes')
+ env.Compare(["encode_alltypes.output", "encode_alltypes.output.recoded"])
+
+ # Do the same checks with the optional fields present.
+ env.RunTest("optionals.output", enc, ARGS = ['1'])
+ env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
+ env.Decode("optionals.output.decoded",
+ ["optionals.output", "alltypes.proto"],
+ MESSAGE='AllTypes')
+ env.Encode("optionals.output.recoded",
+ ["optionals.output.decoded", "alltypes.proto"],
+ MESSAGE='AllTypes')
+ env.Compare(["optionals.output", "optionals.output.recoded"])