1 #include "config.h"
2 
3 #include <iostream>
4 #include <string>
5 #include <cassert>
6 
7 #ifdef HAVE_UNISTD_H
8 #include <unistd.h>
9 #endif
10 
11 #include <errno.h>
12 
13 #include "asserts.h"
14 #include "types.h"
15 #include "error.h"
16 #include "estring.h"
17 #include "fs.h"
18 #include "tstamp.h"
19 #include "rconfig.h"
20 #include "test-rconfig-setup.h"
21 
22 // #define ERR_OUT(e) std::cerr << e;
23 #define ERR_OUT(e)
24 
test(void)25 void test(void)
26 {
27 	char const * argv[256] = { 0 };
28 	int argc = 0;
29 	bool thrown = false;
30 
31 	argv[argc++] = "<program>";
32 	argv[argc++] = "--archive";
33 
34 	config.default_file("./test-rconfig.dir/global-vault-selection-behavior.dir/file-1.conf");
35 	config.default_logdir("./test-rconfig.dir/log.dir");
36 	try {
37 		config.init(argc, argv);
38 	}
39 	catch(error e) {
40 		ERR_OUT(e);
41 		assert(e.num() == 0);
42 		assert(!e.internal());
43 		assert(e.size() == 2);
44 		assert(e[0].what() == "Invalid vault-selection-behavior value: \"lolksjdf\"");
45 		assert(e[1].what() == "At ./test-rconfig.dir/global-vault-selection-behavior.dir/file-1.conf[3]");
46 		thrown = true;
47 	}
48 	catch(...) {
49 		assert(0);
50 	}
51 	assert(thrown);
52 	assert(config.vault_selection_behavior()
53 		== configuration_manager::selection_round_robin);
54 }
55 
main(int argc,char const * argv[])56 int main(int argc, char const * argv[])
57 {
58 	cleanup();
59 	setup();
60 	try {
61 		test();
62 	}
63 	catch(error e) {
64 		std::cerr << e;
65 		assert(0);
66 	}
67 	catch(...) {
68 		std::cerr << err_unknown;
69 		assert(0);
70 	}
71 	cleanup();
72 	return(0);
73 }
74 
75