Debian Codegraph @

tests/DS/ds_sds_index/test_ds_sds_index.c

raw symbols SCIP
1 /*
2 * Copyright 2012 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * Authors:
6 * Martin Preisler <[email protected]>
7 */
8
9 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`!
10 #include <config.h>cxx . . $ `<file>/build/config.h`/
11 #endif
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include "scap_ds.h"cxx . . $ `<file>/src/DS/public/scap_ds.h`/
18 #include "common/list.h"cxx . . $ `<file>/src/common/list.h`/
19 #include "oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/
20 #include "ds_sds_session.h"cxx . . $ `<file>/src/DS/public/ds_sds_session.h`/
21
22 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv)
23 {
24 if (argc != 2)
25 {
26 printfcxx . . $ printf(581fddd72a8db8fc).("Invalid arguments, usage: ./test_ds_sds_index FILE");
27 return 2;
28 }
29
30 struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(argv[1]);
31 struct ds_sds_sessioncxx . . $ ds_sds_session# *session = ds_sds_session_new_from_sourcecxx . . $ ds_sds_session_new_from_source(84081d5e8394044f).(source);
32 struct ds_sds_indexcxx . . $ ds_sds_index# *idx = ds_sds_session_get_sds_idxcxx . . $ ds_sds_session_get_sds_idx(4257cf9e93799a4d).(session);
33 struct ds_stream_index_iteratorcxx . . $ ds_stream_index_iterator#* streams = ds_sds_index_get_streamscxx . . $ ds_sds_index_get_streams(812311662d5ba693).(idx);
34
35 // number of streams in the collection
36 int nr_streams = 0;
37
38 while (ds_stream_index_iterator_has_morecxx . . $ ds_stream_index_iterator_has_more(c225a27a4fccde78).(streams))
39 {
40 struct ds_stream_indexcxx . . $ ds_stream_index#* stream = ds_stream_index_iterator_nextcxx . . $ ds_stream_index_iterator_next(52812d4c4a7c3217).(streams);
41 nr_streams++;
42
43 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(ds_stream_index_get_idcxx . . $ ds_stream_index_get_id(c92d33fc914bb08c).(stream),
44 "scap_org.open-scap_datastream_from_xccdf_scap-fedora14-xccdf.xml") != 0)
45 {
46 printfcxx . . $ printf(581fddd72a8db8fc).("Failed to read datastream ID correctly. "
47 "Expected 'scap_org.open-scap_datastream_from_xccdf_scap-fedora14-xccdf.xml', "
48 "found '%s'.\n", ds_stream_index_get_idcxx . . $ ds_stream_index_get_id(c92d33fc914bb08c).(stream));
49 ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session);
50 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
51 return 1;
52 }
53 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(ds_stream_index_get_timestampcxx . . $ ds_stream_index_get_timestamp(c92d33fc914bb08c).(stream),
54 "2012-11-01T12:22:58") != 0)
55 {
56 printfcxx . . $ printf(581fddd72a8db8fc).("Failed to read datastream timestamp correctly. "
57 "Expected '2012-11-01T12:22:58', "
58 "found '%s'.\n", ds_stream_index_get_timestampcxx . . $ ds_stream_index_get_timestamp(c92d33fc914bb08c).(stream));
59 ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session);
60 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
61 return 1;
62 }
63 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(ds_stream_index_get_versioncxx . . $ ds_stream_index_get_version(c92d33fc914bb08c).(stream),
64 "1.2") != 0)
65 {
66 printfcxx . . $ printf(581fddd72a8db8fc).("Failed to read datastream scap-version correctly. "
67 "Expected '1.2', "
68 "found '%s'.\n", ds_stream_index_get_versioncxx . . $ ds_stream_index_get_version(c92d33fc914bb08c).(stream));
69 ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session);
70 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
71 return 1;
72 }
73 }
74 ds_stream_index_iterator_freecxx . . $ ds_stream_index_iterator_free(7e4fb91f616c49f4).(streams);
75
76 if (ds_sds_index_get_streamcxx . . $ ds_sds_index_get_stream(5c419e4b1e68b074).(idx, "scap_org.open-scap_datastream_from_xccdf_scap-fedora14-xccdf.xml") == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
77 {
78 printfcxx . . $ printf(581fddd72a8db8fc).("Attempted to retrieve 'scap_org.open-scap_datastream_from_xccdf_scap-fedora14-xccdf.xml' "
79 "by ID but got NULL as a result!\n");
80 ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session);
81 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
82 return 1;
83 }
84 if (ds_sds_index_get_streamcxx . . $ ds_sds_index_get_stream(5c419e4b1e68b074).(idx, "nonexistant_rubbish") != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
85 {
86 printfcxx . . $ printf(581fddd72a8db8fc).("Attempted to retrieve a nonexistant stream by ID but got a non-NULL result!\n");
87 ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session);
88 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
89 return 1;
90 }
91
92 ds_sds_session_freecxx . . $ ds_sds_session_free(41ab223cf3ccc737).(session);
93 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
94
95 if (nr_streams != 1)
96 {
97 printfcxx . . $ printf(581fddd72a8db8fc).("Expected to read 1 data-stream from the source datastream collection, "
98 "instead read %i!\n", nr_streams);
99 return 1;
100 }
101
102 return 0;
103 }