This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathtestmod_jni.c
71 lines (57 loc) · 1.66 KB
/
testmod_jni.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
63
64
65
66
67
68
69
70
71
/**
* @file
*
* @brief tests for jni module
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#ifdef HAVE_KDBCONFIG_H
#include "kdbconfig.h"
#endif
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <testmod_jni.h>
#include <tests_plugin.h>
static void test_helloWorld (void)
{
Key * parentKey = keyNew ("user:/tests/jni", KEY_VALUE, "", KEY_END);
KeySet * conf;
if (access (CLASSPATH, F_OK) == 0)
{
printf ("Using classpath '%s'.\n", CLASSPATH);
conf = ksNew (20, keyNew ("system:/classpath", KEY_VALUE, CLASSPATH, KEY_END),
keyNew ("system:/print", KEY_VALUE, "ON", KEY_END),
keyNew ("system:/classname", KEY_VALUE, "org/libelektra/plugin/Return", KEY_END), KS_END);
}
else
{
fprintf (stderr, "Build JNA binding jar '%s' not found.\n", CLASSPATH);
exit (-1);
}
PLUGIN_OPEN ("jni");
KeySet * ks = ksNew (20, KS_END);
succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 10, "call to kdbGet was not successful");
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 20, "call to kdbSet was not successful");
succeed_if (plugin->kdbError (plugin, ks, parentKey) == 30, "call to kdbError was not successful");
succeed_if (output_error (parentKey), "error in kdbGet/kdbSet/kdbError");
succeed_if (output_warnings (parentKey), "warnings in kdbGet/kdbSet/kdbError");
PLUGIN_CLOSE ();
ksDel (ks);
keyDel (parentKey);
}
int main (int argc, char ** argv)
{
printf ("JNI TESTS\n");
printf ("==================\n\n");
init (argc, argv);
test_helloWorld ();
print_result ("test_jni");
return nbError;
}