Get rid of string type and replace with a bool type
[fidl.git] / main.c
blob91137d7f2dddfe83b3efa0b2326e1fabf2662c84
1 /*
2 * QEMU Marshalling Framework
3 * Test driver
5 * Copyright IBM, Corp. 2010
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
10 * This work is licensed under the terms of the GNU GPL, version 2. See
11 * the COPYING file in the top-level directory.
14 #include <string.h>
16 #include "test-marshal.h"
17 #include "xml-writer.h"
18 #include "xml-reader.h"
20 int main(int argc, char **argv)
22 TestDevice test = {};
23 Marshaller *m;
24 FILE *f;
25 Error *err = NULL;
26 int i;
28 test.mem_len = 32;
29 test.mem = malloc(test.mem_len);
30 for (i = 0; i < test.mem_len; i++) {
31 test.mem[i] = i * 3;
34 test.bank2.bank2_enabled = true;
35 test.bank2.mem_len = 0;
36 test.bank2.mem = NULL;
38 test.bank2.bank3.bank3_enabled = true;
39 memset(test.bank2.bank3.mem, 0, sizeof(test.bank2.bank3.mem));
41 f = fopen("test.xml", "w");
42 m = xml_writer_open(f);
43 marshal_TestDevice(m, &test, "test", NULL);
44 xml_writer_close(m);
45 fclose(f);
47 memset(test.mem, 0, test.mem_len);
49 f = fopen("test.xml", "r");
50 m = xml_reader_open(f);
51 marshal_TestDevice(m, &test, "test", &err);
52 xml_reader_close(m);
53 fclose(f);
55 if (err) {
56 fprintf(stderr, "FAIL: %s\n", err->message);
57 error_free(err);
58 return 1;
61 m = xml_writer_open(stdout);
62 marshal_TestDevice(m, &test, "test", NULL);
63 xml_writer_close(m);
65 free(test.mem);
67 return 0;