Git init
[pkgs/e/elektra.git] / tests / tests.h
1 /**Some common functions in use for testing framework*/
2
3 /***************************************************************************
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the BSD License (revised).                      *
7  *                                                                         *
8  ***************************************************************************/
9
10 #ifndef TESTS_H
11 #define TESTS_H
12
13 #ifdef HAVE_CONFIG_H
14 #include "config.h"
15 #endif
16
17 #ifdef HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20
21 #ifdef HAVE_STDIO_H
22 #include <stdio.h>
23 #endif
24
25 #ifdef HAVE_STDLIB_H
26 #include <stdlib.h>
27 #endif
28
29 #ifdef HAVE_STRING_H
30 #include <string.h>
31 #endif
32
33 #ifdef HAVE_TIME_H
34 #include <time.h>
35 #endif
36
37 #ifdef HAVE_LOCALE_H
38 #include <locale.h>
39 #endif
40
41 #define DYN_LINK
42 #include <kdbtools.h>
43 #include <kdbloader.h>
44 #include <kdbbackend.h>
45
46 #define KEY_ROOT "user/tests"
47 #define KEY_LENGTH 1024
48 #define BUFFER_LENGTH 4096
49
50 #define MODE_WRITE 4
51 #define MODE_READ 2
52 #define MODE_DIR 1
53
54 extern int nbError;
55 extern int nbTest;
56 extern int nbStreaming;
57 extern uid_t nbUid;
58 extern gid_t nbGid;
59
60 int init();
61
62 KSFromXMLfile ksFromXMLfile;
63 KSFromXML ksFromXML;
64
65 output ksToStream;
66 output ksOutput;
67 output ksGenerate;
68
69 #define warn_if_fail(x,y) {nbTest++; if (!(x)) { printf("%s:%d: warn in %s: %s\n", __FILE__, __LINE__, __FUNCTION__, y); }}
70 #define succeed_if(x,y) {nbTest++; if (!(x)) { nbError++; printf("%s:%d: error in %s: %s\n", __FILE__, __LINE__, __FUNCTION__, y); }}
71 #define exit_if_fail(x,y) {nbTest++; if (!(x)) { printf("%s:%d: fatal in %s: %s\n", __FILE__, __LINE__, __FUNCTION__, y); exit(1); }}
72
73 int compare_key (Key *k1, Key *k2, KDBCap *cap);
74 int compare_keyset (KeySet *ks, KeySet *ks2, int filter, KDBCap *cap);
75 int compare_files (const char * filename);
76
77 int loadToolsLib(void);
78 char *srcdir_file(const char * fileName);
79
80 Key * create_root_key (const char *backendName);
81 KeySet *create_conf (const char *filename);
82
83 #endif
84