summaryrefslogtreecommitdiffstats
path: root/libs/nanopb/tests/io_errors_pointers
diff options
context:
space:
mode:
Diffstat (limited to 'libs/nanopb/tests/io_errors_pointers')
-rw-r--r--libs/nanopb/tests/io_errors_pointers/SConscript26
-rw-r--r--libs/nanopb/tests/io_errors_pointers/alltypes.options3
2 files changed, 29 insertions, 0 deletions
diff --git a/libs/nanopb/tests/io_errors_pointers/SConscript b/libs/nanopb/tests/io_errors_pointers/SConscript
new file mode 100644
index 00000000..03727df9
--- /dev/null
+++ b/libs/nanopb/tests/io_errors_pointers/SConscript
@@ -0,0 +1,26 @@
+# Simulate io errors when encoding and decoding
+
+Import("env", "malloc_env")
+
+c = Copy("$TARGET", "$SOURCE")
+env.Command("alltypes.proto", "#alltypes/alltypes.proto", c)
+env.Command("io_errors.c", "#io_errors/io_errors.c", c)
+
+env.NanopbProto(["alltypes", "alltypes.options"])
+
+ioerr = env.Program(["io_errors.c", "alltypes.pb.c",
+ "$COMMON/pb_encode_with_malloc.o",
+ "$COMMON/pb_decode_with_malloc.o",
+ "$COMMON/pb_common_with_malloc.o",
+ "$COMMON/malloc_wrappers.o"])
+
+# Run tests under valgrind if available
+valgrind = env.WhereIs('valgrind')
+kwargs = {}
+if valgrind:
+ kwargs['COMMAND'] = valgrind
+ kwargs['ARGS'] = ["-q", "--error-exitcode=99", ioerr[0].abspath]
+
+env.RunTest("io_errors.output", [ioerr, "$BUILD/alltypes/encode_alltypes.output"], **kwargs)
+
+
diff --git a/libs/nanopb/tests/io_errors_pointers/alltypes.options b/libs/nanopb/tests/io_errors_pointers/alltypes.options
new file mode 100644
index 00000000..7e3ad1e5
--- /dev/null
+++ b/libs/nanopb/tests/io_errors_pointers/alltypes.options
@@ -0,0 +1,3 @@
+# Generate all fields as pointers.
+* type:FT_POINTER
+*.*fbytes fixed_length:true max_size:4