Add --debug-info-target-prefix
[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 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <glib.h>
30 #include <errno.h>
31 #include <babeltrace/endian.h>
32 #include <babeltrace/babeltrace-internal.h>
33 #include <babeltrace/ctf/metadata.h>
34 #include "ctf-scanner.h"
35 #include "ctf-parser.h"
36 #include "ctf-ast.h"
37
38 int babeltrace_verbose, babeltrace_debug;
39
40 int main(int argc, char **argv)
41 {
42 struct ctf_scanner *scanner;
43 struct ctf_trace *trace;
44 int ret = 0;
45
46 babeltrace_debug = 1;
47 babeltrace_verbose = 1;
48 scanner = ctf_scanner_alloc();
49 if (!scanner) {
50 fprintf(stderr, "Error allocating scanner\n");
51 return -ENOMEM;
52 }
53 ret = ctf_scanner_append_ast(scanner, stdin);
54 if (ret) {
55 fprintf(stderr, "Error creating AST\n");
56 goto end;
57 }
58
59 ret = ctf_visitor_print_xml(stderr, 0, &scanner->ast->root);
60 if (ret) {
61 fprintf(stderr, "Error visiting AST for XML output\n");
62 goto end;
63 }
64
65 ret = ctf_visitor_semantic_check(stderr, 0, &scanner->ast->root);
66 if (ret) {
67 fprintf(stderr, "Error in CTF semantic validation %d\n", ret);
68 goto end;
69 }
70 trace = malloc(sizeof(*trace));
71 memset(trace, 0, sizeof(*trace));
72 ret = ctf_visitor_construct_metadata(stderr, 0, &scanner->ast->root,
73 trace, BYTE_ORDER);
74 if (ret) {
75 fprintf(stderr, "Error in CTF metadata constructor %d\n", ret);
76 goto free_trace;
77 }
78 free_trace:
79 free(trace);
80 end:
81 ctf_scanner_free(scanner);
82 return ret;
83 }
This page took 0.030591 seconds and 4 git commands to generate.