summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2016-10-23 18:40:50 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2016-10-23 18:40:50 +0300
commitb850cf9fb101e0fe7fd71150210c6ff9877e57c1 (patch)
treea9bf82f6b58062b2e7454c5d6beb20082393543c /tests
parentfb8ced6b3412528442c20aca31e2a21b792eb07e (diff)
Only run alltypes_proto3 test case if protoc version is new enough
Diffstat (limited to 'tests')
-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"])