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