Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nanopb
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
le
nanopb
Commits
b850cf9f
Commit
b850cf9f
authored
8 years ago
by
Petteri Aimonen
Browse files
Options
Downloads
Patches
Plain Diff
Only run alltypes_proto3 test case if protoc version is new enough
parent
fb8ced6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/alltypes_proto3/SConscript
+40
-30
40 additions, 30 deletions
tests/alltypes_proto3/SConscript
with
40 additions
and
30 deletions
tests/alltypes_proto3/SConscript
+
40
−
30
View file @
b850cf9f
# 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
"
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment