aura  0.1
 All Data Structures Functions Variables Modules Pages
test-susb-stability-io.c
1 #include <aura/aura.h>
2 #include <unistd.h>
3 
4 int main() {
5  int ret;
6  int i;
7  int passed = 0;
8  int failed = 0;
9  slog_init(NULL, 0);
10  struct aura_node *n = aura_open("simpleusb", "../simpleusbconfigs/susb-test.conf");
11 
12  if (!n) {
13  printf("err\n");
14  return -1;
15  }
16 
17  i = 100;
18 
19  while (i--) {
20  struct aura_buffer *retbuf;
21  uint32_t a = rand();
22  uint32_t b = rand();
23  aura_wait_status(n, AURA_STATUS_ONLINE);
24 
25  ret = aura_call(n, "write", &retbuf, 0xa, 0xb, a, b);
26  if (0 != ret) {
27  failed++;
28  continue;
29  }
30 
31  aura_buffer_release(retbuf);
32  ret = aura_call(n, "read", &retbuf, 0x0, 0x0);
33  if (0 != ret) {
34  failed++;
35  continue;
36  }
37 
38  uint32_t tmp = aura_buffer_get_u32(retbuf);
39  if (a != tmp) {
40  slog(0, SLOG_ERROR, "%x != %x", tmp, a);
41  failed++;
42  aura_buffer_release(retbuf);
43  continue;
44  }
45 
46  tmp = aura_buffer_get_u32(retbuf);
47  if (b != tmp) {
48  slog(0, SLOG_ERROR, "%x != %x", tmp, b);
49  failed++;
50  aura_buffer_release(retbuf);
51  continue;
52  }
53 
54  aura_buffer_release(retbuf);
55  passed++;
56  }
57 
58  aura_close(n);
59 
60  printf("Stability test (data io): %d succeeded, %d failed total %d\n",
61  passed, failed, passed + failed);
62 
63  return failed;
64 }
void aura_wait_status(struct aura_node *node, int status)
Definition: aura.c:607
uint32_t aura_buffer_get_u32(struct aura_buffer *buf)
Get an unsigned 32 bit integer from aura buffer.
int aura_call(struct aura_node *node, const char *name, struct aura_buffer **retbuf,...)
Definition: aura.c:666
struct aura_node * aura_open(const char *name, const char *opts)
Definition: aura.c:34
void aura_buffer_release(struct aura_buffer *buf)
Definition: buffer.c:80
void aura_close(struct aura_node *node)
Definition: aura.c:102