Fix support for gold linker: inappropriate dep removal of plugins
[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.
17 */
18
34d3acc4
MD
19#include <stdlib.h>
20#include <stdio.h>
21#include <glib.h>
67905e42 22#include <errno.h>
78af2bcd 23#include <endian.h>
c8b219a3 24#include <babeltrace/babeltrace.h>
78af2bcd 25#include <babeltrace/ctf/metadata.h>
34d3acc4
MD
26#include "ctf-scanner.h"
27#include "ctf-parser.h"
28#include "ctf-ast.h"
29
a3983482 30int babeltrace_verbose, babeltrace_debug;
34d3acc4
MD
31
32int main(int argc, char **argv)
33{
34 struct ctf_scanner *scanner;
78af2bcd 35 struct ctf_trace *trace;
7de8808c 36 int ret = 0;
34d3acc4 37
a3983482 38 babeltrace_debug = 1;
c8b219a3 39 babeltrace_verbose = 1;
34d3acc4
MD
40 scanner = ctf_scanner_alloc(stdin);
41 if (!scanner) {
34f7b02c 42 fprintf(stdout, "Error allocating scanner\n");
67905e42 43 return -ENOMEM;
34d3acc4 44 }
8a4035bc
MD
45 ret = ctf_scanner_append_ast(scanner);
46 if (ret) {
47 fprintf(stdout, "Error creating AST\n");
48 goto end;
49 }
7de8808c 50
67905e42
MD
51 ret = ctf_visitor_print_xml(stdout, 0, &scanner->ast->root);
52 if (ret) {
8a4035bc 53 fprintf(stdout, "Error visiting AST for XML output\n");
67905e42 54 goto end;
7de8808c 55 }
7de8808c 56
67905e42
MD
57 ret = ctf_visitor_semantic_check(stdout, 0, &scanner->ast->root);
58 if (ret) {
8a4035bc 59 fprintf(stdout, "Error in CTF semantic validation %d\n", ret);
67905e42
MD
60 goto end;
61 }
78af2bcd 62 trace = malloc(sizeof(*trace));
34e5b91e 63 memset(trace, 0, sizeof(*trace));
78af2bcd
MD
64 ret = ctf_visitor_construct_metadata(stdout, 0, &scanner->ast->root,
65 trace, BYTE_ORDER);
66 if (ret) {
67 fprintf(stdout, "Error in CTF metadata constructor %d\n", ret);
68 goto free_trace;
69 }
70free_trace:
71 free(trace);
67905e42
MD
72end:
73 ctf_scanner_free(scanner);
7de8808c 74 return ret;
34d3acc4 75}
This page took 0.026924 seconds and 4 git commands to generate.