Port libminijail unit tests to C++.
That way they can be run on Android Platform Continuous Testing,
which requires gtest for parsing of test output.
Fix one issue in free_label_strings(), which was not setting
|labels->count| to 0. Also fix some nits in test files.
Bug: 30973585
Change-Id: I8bdb414329aab82e2180d412b9ecc128beab7227
diff --git a/bpf.h b/bpf.h
index 9e28ede..e4897e2 100644
--- a/bpf.h
+++ b/bpf.h
@@ -16,6 +16,10 @@
#include <stddef.h>
#include <sys/user.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "arch.h"
#if __BITS_PER_LONG == 32 || defined(__ILP32__)
@@ -26,7 +30,7 @@
/* Constants for comparison operators. */
#define MIN_OPERATOR 128
-enum operator {
+enum {
EQ = MIN_OPERATOR,
NE,
LT,
@@ -121,8 +125,8 @@
/* BPF instruction manipulation functions and macros. */
static inline size_t set_bpf_instr(struct sock_filter *instr,
- unsigned short code, unsigned int k,
- unsigned char jt, unsigned char jf)
+ unsigned short code, unsigned int k,
+ unsigned char jt, unsigned char jf)
{
instr->code = code;
instr->k = k;
@@ -189,4 +193,8 @@
void dump_bpf_prog(struct sock_fprog *fprog);
void dump_bpf_filter(struct sock_filter *filter, unsigned short len);
+#ifdef __cplusplus
+}; /* extern "C" */
+#endif
+
#endif /* BPF_H */