Blame src/util/profile/test_parse.c
|
Packit |
fd8b60 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit |
fd8b60 |
#include "prof_int.h"
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include <stdio.h>
|
|
Packit |
fd8b60 |
#include <string.h>
|
|
Packit |
fd8b60 |
#ifdef HAVE_STDLIB_H
|
|
Packit |
fd8b60 |
#include <stdlib.h>
|
|
Packit |
fd8b60 |
#endif
|
|
Packit |
fd8b60 |
#include <errno.h>
|
|
Packit |
fd8b60 |
#include <ctype.h>
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
void dump_profile (struct profile_node *root, int level);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
int main(argc, argv)
|
|
Packit |
fd8b60 |
int argc;
|
|
Packit |
fd8b60 |
char **argv;
|
|
Packit |
fd8b60 |
{
|
|
Packit |
fd8b60 |
struct profile_node *root;
|
|
Packit |
fd8b60 |
unsigned long retval;
|
|
Packit |
fd8b60 |
FILE *f;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
initialize_prof_error_table();
|
|
Packit |
fd8b60 |
if (argc != 2) {
|
|
Packit |
fd8b60 |
fprintf(stderr, "%s: Usage <filename>\n", argv[0]);
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
f = fopen(argv[1], "r");
|
|
Packit |
fd8b60 |
if (!f) {
|
|
Packit |
fd8b60 |
perror(argv[1]);
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
retval = profile_parse_file(f, &root, NULL);
|
|
Packit |
fd8b60 |
if (retval) {
|
|
Packit |
fd8b60 |
printf("profile_parse_file error %s\n",
|
|
Packit |
fd8b60 |
error_message((errcode_t) retval));
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
fclose(f);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
printf("\n\nDebugging dump.\n");
|
|
Packit |
fd8b60 |
profile_write_tree_file(root, stdout);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
retval = profile_verify_node(root);
|
|
Packit |
fd8b60 |
if (retval) {
|
|
Packit |
fd8b60 |
printf("profile_verify_node reported an error: %s\n",
|
|
Packit |
fd8b60 |
error_message((errcode_t) retval));
|
|
Packit |
fd8b60 |
exit(1);
|
|
Packit |
fd8b60 |
}
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
profile_free_node(root);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
return 0;
|
|
Packit |
fd8b60 |
}
|