libubox
C utility functions for OpenWrt.
test-blobmsg-procd-instance.c File Reference
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <libgen.h>
#include "blobmsg.h"
#include "utils.h"

Go to the source code of this file.

Macros

#define BUF_LEN   2048
 

Enumerations

enum  {
  INSTANCE_ATTR_COMMAND , INSTANCE_ATTR_ENV , INSTANCE_ATTR_DATA , INSTANCE_ATTR_NETDEV ,
  INSTANCE_ATTR_FILE , INSTANCE_ATTR_TRIGGER , INSTANCE_ATTR_RESPAWN , INSTANCE_ATTR_NICE ,
  INSTANCE_ATTR_LIMITS , INSTANCE_ATTR_WATCH , INSTANCE_ATTR_ERROR , INSTANCE_ATTR_USER ,
  INSTANCE_ATTR_GROUP , INSTANCE_ATTR_STDOUT , INSTANCE_ATTR_STDERR , INSTANCE_ATTR_NO_NEW_PRIVS ,
  INSTANCE_ATTR_JAIL , INSTANCE_ATTR_TRACE , INSTANCE_ATTR_SECCOMP , INSTANCE_ATTR_PIDFILE ,
  INSTANCE_ATTR_RELOADSIG , INSTANCE_ATTR_TERMTIMEOUT , INSTANCE_ATTR_FACILITY , __INSTANCE_ATTR_MAX
}
 

Functions

static void test_blobmsg_procd_instance (const char *filename)
 
int main (int argc, char *argv[])
 

Variables

static const struct blobmsg_policy instance_attr [__INSTANCE_ATTR_MAX]
 

Macro Definition Documentation

◆ BUF_LEN

#define BUF_LEN   2048

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
INSTANCE_ATTR_COMMAND 
INSTANCE_ATTR_ENV 
INSTANCE_ATTR_DATA 
INSTANCE_ATTR_NETDEV 
INSTANCE_ATTR_FILE 
INSTANCE_ATTR_TRIGGER 
INSTANCE_ATTR_RESPAWN 
INSTANCE_ATTR_NICE 
INSTANCE_ATTR_LIMITS 
INSTANCE_ATTR_WATCH 
INSTANCE_ATTR_ERROR 
INSTANCE_ATTR_USER 
INSTANCE_ATTR_GROUP 
INSTANCE_ATTR_STDOUT 
INSTANCE_ATTR_STDERR 
INSTANCE_ATTR_NO_NEW_PRIVS 
INSTANCE_ATTR_JAIL 
INSTANCE_ATTR_TRACE 
INSTANCE_ATTR_SECCOMP 
INSTANCE_ATTR_PIDFILE 
INSTANCE_ATTR_RELOADSIG 
INSTANCE_ATTR_TERMTIMEOUT 
INSTANCE_ATTR_FACILITY 
__INSTANCE_ATTR_MAX 

Definition at line 9 of file test-blobmsg-procd-instance.c.

9  {
34 };
@ INSTANCE_ATTR_TERMTIMEOUT
@ INSTANCE_ATTR_NO_NEW_PRIVS
@ INSTANCE_ATTR_RELOADSIG
@ INSTANCE_ATTR_FACILITY

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 106 of file test-blobmsg-procd-instance.c.

107 {
108  if (argc != 2) {
109  fprintf(stderr, "Usage: %s <blobmsg.bin>\n", argv[0]);
110  return 3;
111  }
112 
114 
115  return 0;
116 }
static void test_blobmsg_procd_instance(const char *filename)
Here is the call graph for this function:

◆ test_blobmsg_procd_instance()

static void test_blobmsg_procd_instance ( const char *  filename)
static

Definition at line 62 of file test-blobmsg-procd-instance.c.

63 {
64 #define BUF_LEN 2048
65  int r = 0;
66  size_t len = 0;
67  FILE *fd = NULL;
68  char *buf = NULL;
69  struct blob_attr *tb[__INSTANCE_ATTR_MAX];
70  const char *fname = basename((char *) filename);
71 
72  fd = fopen(filename, "r");
73  if (!fd) {
74  fprintf(stderr, "unable to open %s\n", fname);
75  return;
76  }
77 
78  buf = malloc(BUF_LEN+1);
79  if (!buf)
80  return;
81 
82  len = fread(buf, 1, BUF_LEN, fd);
83  fclose(fd);
84 
86  if (r)
87  goto out;
88 
90  goto out;
91 
93  goto out;
94 
95  if (blobmsg_get_u32(tb[INSTANCE_ATTR_NICE]) != 19)
96  goto out;
97 
99  goto out;
100 
101  fprintf(stderr, "%s: OK\n", fname);
102 out:
103  free(buf);
104 }
bool blobmsg_check_attr_list(const struct blob_attr *attr, int type)
Definition: blobmsg.c:130
int blobmsg_parse(const struct blobmsg_policy *policy, int policy_len, struct blob_attr **tb, void *data, unsigned int len)
Definition: blobmsg.c:166
static uint32_t blobmsg_get_u32(struct blob_attr *attr)
Definition: blobmsg.h:293
@ BLOBMSG_TYPE_STRING
Definition: blobmsg.h:29
static bool blobmsg_get_bool(struct blob_attr *attr)
Definition: blobmsg.h:283
Definition: blob.h:52
static const struct blobmsg_policy instance_attr[__INSTANCE_ATTR_MAX]
#define BUF_LEN
FILE(GLOB test_cases "test-*.c") MACRO(ADD_FUZZER_TEST name) ADD_EXECUTABLE($
Definition: CMakeLists.txt:1
int fd
Definition: udebug-priv.h:27
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ instance_attr

const struct blobmsg_policy instance_attr[__INSTANCE_ATTR_MAX]
static
Initial value:
= {
[INSTANCE_ATTR_RELOADSIG] = { "reload_signal", BLOBMSG_TYPE_INT32 },
}
@ BLOBMSG_TYPE_TABLE
Definition: blobmsg.h:28
@ BLOBMSG_TYPE_BOOL
Definition: blobmsg.h:34
@ BLOBMSG_TYPE_ARRAY
Definition: blobmsg.h:27
@ BLOBMSG_TYPE_INT32
Definition: blobmsg.h:31

Definition at line 1 of file test-blobmsg-procd-instance.c.