Update sequence (type specifier -> field ref), fix definition lookup
[babeltrace.git] / formats / ctf / metadata / ctf-parser-test.c
1 /*
2 * ctf-parser-test.c
3 *
4 * Common Trace Format Parser Test
5 *
6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 */
18
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <glib.h>
22 #include <errno.h>
23 #include <endian.h>
24 #include <babeltrace/babeltrace.h>
25 #include <babeltrace/ctf/metadata.h>
26 #include "ctf-scanner.h"
27 #include "ctf-parser.h"
28 #include "ctf-ast.h"
29
30 int babeltrace_verbose, babeltrace_debug;
31
32 int main(int argc, char **argv)
33 {
34 struct ctf_scanner *scanner;
35 struct ctf_trace *trace;
36 int ret = 0;
37
38 babeltrace_debug = 1;
39 babeltrace_verbose = 1;
40 scanner = ctf_scanner_alloc(stdin);
41 if (!scanner) {
42 fprintf(stdout, "Error allocating scanner\n");
43 return -ENOMEM;
44 }
45 ret = ctf_scanner_append_ast(scanner);
46 if (ret) {
47 fprintf(stdout, "Error creating AST\n");
48 goto end;
49 }
50
51 ret = ctf_visitor_print_xml(stdout, 0, &scanner->ast->root);
52 if (ret) {
53 fprintf(stdout, "Error visiting AST for XML output\n");
54 goto end;
55 }
56
57 ret = ctf_visitor_semantic_check(stdout, 0, &scanner->ast->root);
58 if (ret) {
59 fprintf(stdout, "Error in CTF semantic validation %d\n", ret);
60 goto end;
61 }
62 trace = malloc(sizeof(*trace));
63 ret = ctf_visitor_construct_metadata(stdout, 0, &scanner->ast->root,
64 trace, BYTE_ORDER);
65 if (ret) {
66 fprintf(stdout, "Error in CTF metadata constructor %d\n", ret);
67 goto free_trace;
68 }
69 free_trace:
70 free(trace);
71 end:
72 ctf_scanner_free(scanner);
73 return ret;
74 }
This page took 0.031275 seconds and 4 git commands to generate.