HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
test_scfg.c
Go to the documentation of this file.
1 #include <assert.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 
5 #include <hipc/scfg.h>
6 
7 static void test_hipcScfgInit(void)
8 {
9  struct HIPC_scfg cfg;
10  unsigned char endian;
11 
12  cfg.endian_p = &endian;
13  hipcScfgInit(&cfg);
14  assert(0x6c /* 'l' */ == endian ||
15  0x42 /* 'B' */ == endian ||
16  0x6f /* 'o' */ == endian);
17 
18  return;
19 }
20 
21 static void test_hipcScfgCheckStrusize(void)
22 {
23  struct HIPC_scfg cfg;
24  const size_t sizes1[] = { 0, 1, 8, 255 };
25  const size_t sizes2[] = { 16, 256, 32 };
26 
27  cfg.strusize_p = NULL;
28  assert(HIPC_SUCCESS == hipcScfgCheckStrusize(&cfg));
29 
30  cfg.n_struct = sizeof(sizes1) / sizeof(sizes1[0]);
31  cfg.strusize_p = sizes1;
32  assert(HIPC_SUCCESS == hipcScfgCheckStrusize(&cfg));
33 
34  cfg.n_struct = sizeof(sizes2) / sizeof(sizes2[0]);
35  cfg.strusize_p = sizes2;
37 
38  return;
39 }
40 
41 int main(int argc, char *argv[])
42 {
43  if (2 != argc) {
44  fprintf(stderr, "Usage: %s test_id\n", argv[0]);
45  exit(EXIT_FAILURE);
46  }
47 
48  switch (argv[1][0]) {
49  case 'a':
51  break;
52  case 'b':
54  break;
55  default:
56  fprintf(stderr, "Invalid test_id: %s \n", argv[1]);
57  exit(EXIT_FAILURE);
58  }
59 
60  return 0;
61 }
unsigned char * endian_p
Definition: scfg.h:12
static void test_hipcScfgCheckStrusize(void)
Definition: test_scfg.c:21
int main(int argc, char *argv[])
Definition: test_scfg.c:41
void hipcScfgInit(const struct HIPC_scfg *const cfg_p)
Initializes a server-side configuration.
Definition: scfg.c:8
static void test_hipcScfgInit(void)
Definition: test_scfg.c:7
const size_t * strusize_p
Definition: scfg.h:16
Definition: scfg.h:9
unsigned char n_struct
Definition: scfg.h:15
enum HIPC_errno hipcScfgCheckStrusize(const struct HIPC_scfg *const cfg_p)
Checks structure sizes.
Definition: scfg.c:20