mirror of
https://github.com/google/pebble.git
synced 2025-07-23 07:44:55 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
21
third_party/nanopb/tests/regression/issue_259/SConscript
vendored
Normal file
21
third_party/nanopb/tests/regression/issue_259/SConscript
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Check that callback fields inside malloc()ed messages
|
||||
# are correctly initialized.
|
||||
|
||||
Import('env', 'malloc_env')
|
||||
|
||||
env.NanopbProto('callback_pointer')
|
||||
|
||||
p = malloc_env.Program(["callback_pointer.c",
|
||||
"callback_pointer.pb.c",
|
||||
"$COMMON/pb_decode_with_malloc.o",
|
||||
"$COMMON/pb_common_with_malloc.o",
|
||||
"$COMMON/malloc_wrappers.o"])
|
||||
|
||||
# Run test under valgrind if available
|
||||
kwargs = {}
|
||||
if env.get("VALGRIND"):
|
||||
kwargs['COMMAND'] = env['VALGRIND']
|
||||
kwargs['ARGS'] = ["-q", "--error-exitcode=99", p[0].abspath]
|
||||
|
||||
env.RunTest(p, **kwargs)
|
||||
|
30
third_party/nanopb/tests/regression/issue_259/callback_pointer.c
vendored
Normal file
30
third_party/nanopb/tests/regression/issue_259/callback_pointer.c
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "callback_pointer.pb.h"
|
||||
#include <unittests.h>
|
||||
#include <pb_decode.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int status = 0;
|
||||
const uint8_t msgdata[] = {0x0A, 0x02, 0x08, 0x7F};
|
||||
|
||||
MainMessage msg = MainMessage_init_zero;
|
||||
|
||||
{
|
||||
pb_istream_t stream = pb_istream_from_buffer(msgdata, sizeof(msgdata));
|
||||
COMMENT("Running first decode");
|
||||
TEST(pb_decode(&stream, MainMessage_fields, &msg));
|
||||
pb_release(MainMessage_fields, &msg);
|
||||
}
|
||||
|
||||
{
|
||||
pb_istream_t stream = pb_istream_from_buffer(msgdata, sizeof(msgdata));
|
||||
COMMENT("Running second decode");
|
||||
TEST(pb_decode(&stream, MainMessage_fields, &msg));
|
||||
pb_release(MainMessage_fields, &msg);
|
||||
}
|
||||
|
||||
TEST(get_alloc_count() == 0);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
11
third_party/nanopb/tests/regression/issue_259/callback_pointer.proto
vendored
Normal file
11
third_party/nanopb/tests/regression/issue_259/callback_pointer.proto
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
syntax = "proto2";
|
||||
import 'nanopb.proto';
|
||||
|
||||
message SubMessage {
|
||||
optional int32 foo = 1 [(nanopb).type = FT_CALLBACK];
|
||||
}
|
||||
|
||||
message MainMessage {
|
||||
optional SubMessage bar = 1 [(nanopb).type = FT_POINTER];
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue