Debian Codegraph @

tests/API/OVAL/test_api_oval.c

raw symbols SCIP
1 /*
2 * test_driver.c
3 *
4 * Created on: Mar 4, 2009
5 * Author: david.niemoller
6 */
7
8 #ifdef HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include <oval_agent_api.h>
16 #include <oscap.h>
17 #include "oscap_source.h"
18 #include "oscap_error.h"
19
20 static int _test_error(void)
21 {
22 if (oscap_err ()) {
23 oscap_errfamily_t f;
24 const char *d;
25
26 fprintf (stderr, "GOT error: %d, %s.\n",
27 f = oscap_err_family (),
28 d = oscap_err_desc ());
29 }
30
31 return 0;
32 }
33
34 int main(int argc, char **argv)
35 {
36 struct oscap_source *source = oscap_source_new_from_file(argv[1]);
37 struct oval_definition_model *model = oval_definition_model_import_source(source);
38 oscap_source_free(source);
39 if (model == NULL)
40 _test_error();
41
42 struct oval_definition_iterator *definitions = oval_definition_model_get_definitions(model);
43 if (!oval_definition_iterator_has_more(definitions)) {
44 printf("NO DEFINITIONS FOUND\n");
45 return 1;
46 }
47 while(oval_definition_iterator_has_more(definitions)) {
48 oval_definition_iterator_next(definitions);
49 /* output is not needed for pusrpuse of this test, is it? */
50 }
51 oval_definition_iterator_free(definitions);
52
53 oval_definition_model_free(model);
54 oscap_cleanup();
55
56 return 0;
57 }