Debian Codegraph @

tests/API/XCCDF/unittests/test_xccdf_shall_pass.c

raw symbols SCIP
1 /*
2 * Copyright 2012 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Simon Lukasik <[email protected]>
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdio.h>
28
29 #include <xccdf_benchmark.h>
30 #include <xccdf_policy.h>
31
32 #include "oscap_assert.h"
33 #include "unit_helper.h"
34
35 int main(int argc, char *argv[])
36 {
37 oscap_assert(argc == 2);
38 struct xccdf_policy_model* policy_model = uh_load_xccdf(argv[1]);
39 struct xccdf_policy *policy = uh_get_default_policy(policy_model);
40 uh_register_simple_engines(policy_model);
41
42 struct xccdf_result *ritem = xccdf_policy_evaluate(policy);
43 oscap_assert(ritem != NULL);
44
45 struct xccdf_model_iterator *model_it = xccdf_benchmark_get_models(
46 xccdf_policy_model_get_benchmark(policy_model));
47 while (xccdf_model_iterator_has_more(model_it)) {
48 struct xccdf_model *model = xccdf_model_iterator_next(model_it);
49 struct xccdf_score *score = xccdf_policy_get_score(policy, ritem, xccdf_model_get_system(model));
50 printf("Score was %f\n", (float) xccdf_score_get_score(score));
51 oscap_assert((int)xccdf_score_get_score(score) == 100);
52 }
53 xccdf_policy_model_free(policy_model);
54 return 0;
55 }
56