Add missing permission notice in each source file
[babeltrace.git] / formats / ctf / metadata / ctf-parser-test.c
CommitLineData
c59a87f5
MD
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.
c462e188
MD
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.
c59a87f5
MD
25 */
26
34d3acc4
MD
27#include <stdlib.h>
28#include <stdio.h>
29#include <glib.h>
67905e42 30#include <errno.h>
43e34335 31#include <babeltrace/endian.h>
70bd0a12 32#include <babeltrace/babeltrace-internal.h>
78af2bcd 33#include <babeltrace/ctf/metadata.h>
34d3acc4
MD
34#include "ctf-scanner.h"
35#include "ctf-parser.h"
36#include "ctf-ast.h"
37
a3983482 38int babeltrace_verbose, babeltrace_debug;
34d3acc4
MD
39
40int main(int argc, char **argv)
41{
42 struct ctf_scanner *scanner;
78af2bcd 43 struct ctf_trace *trace;
7de8808c 44 int ret = 0;
34d3acc4 45
a3983482 46 babeltrace_debug = 1;
c8b219a3 47 babeltrace_verbose = 1;
34d3acc4
MD
48 scanner = ctf_scanner_alloc(stdin);
49 if (!scanner) {
3394d22e 50 fprintf(stderr, "Error allocating scanner\n");
67905e42 51 return -ENOMEM;
34d3acc4 52 }
8a4035bc
MD
53 ret = ctf_scanner_append_ast(scanner);
54 if (ret) {
3394d22e 55 fprintf(stderr, "Error creating AST\n");
8a4035bc
MD
56 goto end;
57 }
7de8808c 58
3394d22e 59 ret = ctf_visitor_print_xml(stderr, 0, &scanner->ast->root);
67905e42 60 if (ret) {
3394d22e 61 fprintf(stderr, "Error visiting AST for XML output\n");
67905e42 62 goto end;
7de8808c 63 }
7de8808c 64
3394d22e 65 ret = ctf_visitor_semantic_check(stderr, 0, &scanner->ast->root);
67905e42 66 if (ret) {
3394d22e 67 fprintf(stderr, "Error in CTF semantic validation %d\n", ret);
67905e42
MD
68 goto end;
69 }
78af2bcd 70 trace = malloc(sizeof(*trace));
34e5b91e 71 memset(trace, 0, sizeof(*trace));
3394d22e 72 ret = ctf_visitor_construct_metadata(stderr, 0, &scanner->ast->root,
78af2bcd
MD
73 trace, BYTE_ORDER);
74 if (ret) {
3394d22e 75 fprintf(stderr, "Error in CTF metadata constructor %d\n", ret);
78af2bcd
MD
76 goto free_trace;
77 }
78free_trace:
79 free(trace);
67905e42
MD
80end:
81 ctf_scanner_free(scanner);
7de8808c 82 return ret;
34d3acc4 83}
This page took 0.049887 seconds and 4 git commands to generate.