Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #ifdef HAVE_KDBCONFIG_H
10 : #include "kdbconfig.h"
11 : #endif
12 :
13 : #include <stdio.h>
14 : #ifdef HAVE_STDLIB_H
15 : #include <stdlib.h>
16 : #endif
17 : #ifdef HAVE_STRING_H
18 : #include <string.h>
19 : #endif
20 :
21 : #include <tests_plugin.h>
22 :
23 2 : void test_structure (void)
24 : {
25 2 : printf ("Test structure of keys returned from uname plugin");
26 :
27 2 : Key * parentKey = keyNew ("user/test/key", KEY_END);
28 2 : KeySet * keys = ksNew (0, KS_END);
29 2 : KeySet * conf = 0;
30 :
31 2 : PLUGIN_OPEN ("uname");
32 :
33 2 : succeed_if (plugin->kdbGet (plugin, keys, parentKey) == 1, "could not call kdbGet");
34 :
35 2 : succeed_if (ksGetSize (keys) == 6, "size not correct");
36 2 : succeed_if (ksLookupByName (keys, "user/test/key", 0), "parentkey not found");
37 2 : succeed_if (ksLookupByName (keys, "user/test/key/sysname", 0), "sysname key not found");
38 2 : succeed_if (ksLookupByName (keys, "user/test/key/nodename", 0), "nodename key not found");
39 2 : succeed_if (ksLookupByName (keys, "user/test/key/release", 0), "release key not found");
40 2 : succeed_if (ksLookupByName (keys, "user/test/key/version", 0), "version key not found");
41 2 : succeed_if (ksLookupByName (keys, "user/test/key/machine", 0), "machine key not found");
42 :
43 2 : ksDel (keys);
44 2 : keyDel (parentKey);
45 :
46 2 : PLUGIN_CLOSE ();
47 2 : }
48 :
49 :
50 2 : int main (int argc, char ** argv)
51 : {
52 2 : printf ("UNAME TESTS\n");
53 2 : printf ("==================\n\n");
54 :
55 2 : init (argc, argv);
56 :
57 2 : test_structure ();
58 :
59 2 : print_result ("testmod_uname");
60 :
61 2 : return nbError;
62 : }
|