summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-10-23 21:01:11 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-10-23 21:01:11 +0300
commit49bd3f35a0b6db0fa47d2e6e8fe9ddfb1bbcd58b (patch)
tree53be9a0ea9447bc5afae519512f26f36368b4b3d /tests
parent2bfd497eea857d19a09054c5c54f3718b08dc8c9 (diff)
Generate message size #defines also for messages defined in multiple files.
Add testcase for the same.
Diffstat (limited to 'tests')
-rw-r--r--tests/message_sizes/SConscript11
-rw-r--r--tests/message_sizes/dummy.c9
-rw-r--r--tests/message_sizes/messages1.proto27
-rw-r--r--tests/message_sizes/messages2.proto8
4 files changed, 55 insertions, 0 deletions
diff --git a/tests/message_sizes/SConscript b/tests/message_sizes/SConscript
new file mode 100644
index 00000000..e7524e02
--- /dev/null
+++ b/tests/message_sizes/SConscript
@@ -0,0 +1,11 @@
+# Test the generation of message size #defines
+
+Import('env')
+
+incpath = env.Clone()
+incpath.Append(PROTOCPATH = '#message_sizes')
+
+incpath.NanopbProto("messages1")
+incpath.NanopbProto("messages2")
+
+incpath.Program(['dummy.c', 'messages1.pb.c', 'messages2.pb.c'])
diff --git a/tests/message_sizes/dummy.c b/tests/message_sizes/dummy.c
new file mode 100644
index 00000000..767ad463
--- /dev/null
+++ b/tests/message_sizes/dummy.c
@@ -0,0 +1,9 @@
+/* Just test that the file can be compiled successfully. */
+
+#include "messages2.pb.h"
+
+int main()
+{
+ return xmit_size;
+}
+
diff --git a/tests/message_sizes/messages1.proto b/tests/message_sizes/messages1.proto
new file mode 100644
index 00000000..48af55a3
--- /dev/null
+++ b/tests/message_sizes/messages1.proto
@@ -0,0 +1,27 @@
+enum MessageStatus {
+ FAIL = 0;
+ OK = 1;
+};
+
+message MessageInfo {
+ required fixed32 msg_id = 1;
+ optional fixed32 interface_id = 2;
+}
+
+message MessageResponseInfo {
+ required fixed64 interface_id = 1;
+ required fixed32 seq = 2;
+ required fixed32 msg_id = 3;
+}
+
+message MessageHeader {
+ required MessageInfo info = 1;
+ optional MessageResponseInfo response_info = 2;
+ optional MessageResponse response = 3;
+}
+
+message MessageResponse {
+ required MessageStatus status = 1;
+ required fixed32 seq = 2;
+}
+
diff --git a/tests/message_sizes/messages2.proto b/tests/message_sizes/messages2.proto
new file mode 100644
index 00000000..19fc11ef
--- /dev/null
+++ b/tests/message_sizes/messages2.proto
@@ -0,0 +1,8 @@
+import 'nanopb.proto';
+import 'messages1.proto';
+
+message xmit {
+ required MessageHeader header = 1;
+ required bytes data = 2 [(nanopb).max_size = 128];
+}
+