summaryrefslogtreecommitdiffstats
path: root/CAN-binder/libs/nanopb/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'CAN-binder/libs/nanopb/tests/common')
-rw-r--r--CAN-binder/libs/nanopb/tests/common/SConscript48
-rw-r--r--CAN-binder/libs/nanopb/tests/common/malloc_wrappers.c54
-rw-r--r--CAN-binder/libs/nanopb/tests/common/malloc_wrappers.h7
-rw-r--r--CAN-binder/libs/nanopb/tests/common/malloc_wrappers_syshdr.h15
-rw-r--r--CAN-binder/libs/nanopb/tests/common/person.proto22
-rw-r--r--CAN-binder/libs/nanopb/tests/common/test_helpers.h17
-rw-r--r--CAN-binder/libs/nanopb/tests/common/unittestproto.proto43
-rw-r--r--CAN-binder/libs/nanopb/tests/common/unittests.h14
8 files changed, 0 insertions, 220 deletions
diff --git a/CAN-binder/libs/nanopb/tests/common/SConscript b/CAN-binder/libs/nanopb/tests/common/SConscript
deleted file mode 100644
index 05e2f85..0000000
--- a/CAN-binder/libs/nanopb/tests/common/SConscript
+++ /dev/null
@@ -1,48 +0,0 @@
-# Build the common files needed by multiple test cases
-
-Import('env')
-
-# Protocol definitions for the encode/decode_unittests
-env.NanopbProto("unittestproto")
-
-# Protocol definitions for basic_buffer/stream tests
-env.NanopbProto("person")
-
-#--------------------------------------------
-# Binaries of the pb_decode.c and pb_encode.c
-# These are built using more strict warning flags.
-strict = env.Clone()
-strict.Append(CFLAGS = strict['CORECFLAGS'])
-strict.Object("pb_decode.o", "$NANOPB/pb_decode.c")
-strict.Object("pb_encode.o", "$NANOPB/pb_encode.c")
-strict.Object("pb_common.o", "$NANOPB/pb_common.c")
-
-#-----------------------------------------------
-# Binaries of pb_decode etc. with malloc support
-# Uses malloc_wrappers.c to count allocations.
-malloc_env = env.Clone()
-malloc_env.Append(CPPDEFINES = {'PB_ENABLE_MALLOC': 1,
- 'PB_SYSTEM_HEADER': '\\"malloc_wrappers_syshdr.h\\"'})
-malloc_env.Append(CPPPATH = ["$COMMON"])
-
-if 'SYSHDR' in malloc_env:
- malloc_env.Append(CPPDEFINES = {'PB_OLD_SYSHDR': malloc_env['SYSHDR']})
-
-# Disable libmudflap, because it will confuse valgrind
-# and other memory leak detection tools.
-if '-fmudflap' in env["CCFLAGS"]:
- malloc_env["CCFLAGS"].remove("-fmudflap")
- malloc_env["LINKFLAGS"].remove("-fmudflap")
- malloc_env["LIBS"].remove("mudflap")
-
-malloc_strict = malloc_env.Clone()
-malloc_strict.Append(CFLAGS = malloc_strict['CORECFLAGS'])
-malloc_strict.Object("pb_decode_with_malloc.o", "$NANOPB/pb_decode.c")
-malloc_strict.Object("pb_encode_with_malloc.o", "$NANOPB/pb_encode.c")
-malloc_strict.Object("pb_common_with_malloc.o", "$NANOPB/pb_common.c")
-
-malloc_env.Object("malloc_wrappers.o", "malloc_wrappers.c")
-malloc_env.Depends("$NANOPB/pb.h", ["malloc_wrappers_syshdr.h", "malloc_wrappers.h"])
-
-Export("malloc_env")
-
diff --git a/CAN-binder/libs/nanopb/tests/common/malloc_wrappers.c b/CAN-binder/libs/nanopb/tests/common/malloc_wrappers.c
deleted file mode 100644
index ad69f1c..0000000
--- a/CAN-binder/libs/nanopb/tests/common/malloc_wrappers.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "malloc_wrappers.h"
-#include <stdint.h>
-#include <assert.h>
-#include <string.h>
-
-static size_t alloc_count = 0;
-
-/* Allocate memory and place check values before and after. */
-void* malloc_with_check(size_t size)
-{
- size_t size32 = (size + 3) / 4 + 3;
- uint32_t *buf = malloc(size32 * sizeof(uint32_t));
- buf[0] = size32;
- buf[1] = 0xDEADBEEF;
- buf[size32 - 1] = 0xBADBAD;
- return buf + 2;
-}
-
-/* Free memory allocated with malloc_with_check() and do the checks. */
-void free_with_check(void *mem)
-{
- uint32_t *buf = (uint32_t*)mem - 2;
- assert(buf[1] == 0xDEADBEEF);
- assert(buf[buf[0] - 1] == 0xBADBAD);
- free(buf);
-}
-
-/* Track memory usage */
-void* counting_realloc(void *ptr, size_t size)
-{
- /* Don't allocate crazy amounts of RAM when fuzzing */
- if (size > 1000000)
- return NULL;
-
- if (!ptr && size)
- alloc_count++;
-
- return realloc(ptr, size);
-}
-
-void counting_free(void *ptr)
-{
- if (ptr)
- {
- assert(alloc_count > 0);
- alloc_count--;
- free(ptr);
- }
-}
-
-size_t get_alloc_count()
-{
- return alloc_count;
-}
diff --git a/CAN-binder/libs/nanopb/tests/common/malloc_wrappers.h b/CAN-binder/libs/nanopb/tests/common/malloc_wrappers.h
deleted file mode 100644
index 7eec795..0000000
--- a/CAN-binder/libs/nanopb/tests/common/malloc_wrappers.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdlib.h>
-
-void* malloc_with_check(size_t size);
-void free_with_check(void *mem);
-void* counting_realloc(void *ptr, size_t size);
-void counting_free(void *ptr);
-size_t get_alloc_count();
diff --git a/CAN-binder/libs/nanopb/tests/common/malloc_wrappers_syshdr.h b/CAN-binder/libs/nanopb/tests/common/malloc_wrappers_syshdr.h
deleted file mode 100644
index d295d9e..0000000
--- a/CAN-binder/libs/nanopb/tests/common/malloc_wrappers_syshdr.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* This is just a wrapper in order to get our own malloc wrappers into nanopb core. */
-
-#define pb_realloc(ptr,size) counting_realloc(ptr,size)
-#define pb_free(ptr) counting_free(ptr)
-
-#ifdef PB_OLD_SYSHDR
-#include PB_OLD_SYSHDR
-#else
-#include <stdint.h>
-#include <stddef.h>
-#include <stdbool.h>
-#include <string.h>
-#endif
-
-#include <malloc_wrappers.h>
diff --git a/CAN-binder/libs/nanopb/tests/common/person.proto b/CAN-binder/libs/nanopb/tests/common/person.proto
deleted file mode 100644
index becefdf..0000000
--- a/CAN-binder/libs/nanopb/tests/common/person.proto
+++ /dev/null
@@ -1,22 +0,0 @@
-syntax = "proto2";
-
-import "nanopb.proto";
-
-message Person {
- required string name = 1 [(nanopb).max_size = 40];
- required int32 id = 2;
- optional string email = 3 [(nanopb).max_size = 40];
-
- enum PhoneType {
- MOBILE = 0;
- HOME = 1;
- WORK = 2;
- }
-
- message PhoneNumber {
- required string number = 1 [(nanopb).max_size = 40];
- optional PhoneType type = 2 [default = HOME];
- }
-
- repeated PhoneNumber phone = 4 [(nanopb).max_count = 5];
-}
diff --git a/CAN-binder/libs/nanopb/tests/common/test_helpers.h b/CAN-binder/libs/nanopb/tests/common/test_helpers.h
deleted file mode 100644
index f77760a..0000000
--- a/CAN-binder/libs/nanopb/tests/common/test_helpers.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Compatibility helpers for the test programs. */
-
-#ifndef _TEST_HELPERS_H_
-#define _TEST_HELPERS_H_
-
-#ifdef _WIN32
-#include <io.h>
-#include <fcntl.h>
-#define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
-
-#else
-#define SET_BINARY_MODE(file)
-
-#endif
-
-
-#endif
diff --git a/CAN-binder/libs/nanopb/tests/common/unittestproto.proto b/CAN-binder/libs/nanopb/tests/common/unittestproto.proto
deleted file mode 100644
index 23b5b97..0000000
--- a/CAN-binder/libs/nanopb/tests/common/unittestproto.proto
+++ /dev/null
@@ -1,43 +0,0 @@
-syntax = "proto2";
-
-import 'nanopb.proto';
-
-message IntegerArray {
- repeated int32 data = 1 [(nanopb).max_count = 10];
-}
-
-message FloatArray {
- repeated float data = 1 [(nanopb).max_count = 10];
-}
-
-message StringMessage {
- required string data = 1 [(nanopb).max_size = 10];
-}
-
-message BytesMessage {
- required bytes data = 1 [(nanopb).max_size = 16];
-}
-
-message CallbackArray {
- // We cheat a bit and use this message for testing other types, too.
- // Nanopb does not care about the actual defined data type for callback
- // fields.
- repeated int32 data = 1;
-}
-
-message IntegerContainer {
- required IntegerArray submsg = 1;
-}
-
-message CallbackContainer {
- required CallbackArray submsg = 1;
-}
-
-message CallbackContainerContainer {
- required CallbackContainer submsg = 1;
-}
-
-message StringPointerContainer {
- repeated string rep_str = 1 [(nanopb).type = FT_POINTER];
-}
-
diff --git a/CAN-binder/libs/nanopb/tests/common/unittests.h b/CAN-binder/libs/nanopb/tests/common/unittests.h
deleted file mode 100644
index c2b470a..0000000
--- a/CAN-binder/libs/nanopb/tests/common/unittests.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdio.h>
-
-#define COMMENT(x) printf("\n----" x "----\n");
-#define STR(x) #x
-#define STR2(x) STR(x)
-#define TEST(x) \
- if (!(x)) { \
- fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \
- status = 1; \
- } else { \
- printf("\033[32;1mOK:\033[22;39m " #x "\n"); \
- }
-
-