00001 #include "config.h"
00002
00003 #include <iostream>
00004 #include <string>
00005 #include <cassert>
00006
00007 #ifdef HAVE_UNISTD_H
00008 #include <unistd.h>
00009 #endif
00010
00011 #include <errno.h>
00012
00013 #include "asserts.h"
00014 #include "types.h"
00015 #include "error.h"
00016 #include "estring.h"
00017 #include "fs.h"
00018 #include "tstamp.h"
00019 #include "rconfig.h"
00020 #include "test-rconfig-setup.h"
00021
00022 #define ERR_OUT(e) std::cerr << e;
00023
00024
00025 void test(void)
00026 {
00027 char const * argv[256] = { 0 };
00028 int argc = 0;
00029 bool thrown = false;
00030
00031 argv[argc++] = "<program>";
00032 argv[argc++] = "--archive";
00033
00034 config.default_file("./test-rconfig.dir/job.dir/file-6.conf");
00035 config.default_logdir("./test-rconfig.dir/log.dir");
00036 try {
00037 config.init(argc, argv);
00038 }
00039 catch(error e) {
00040 ERR_OUT(e);
00041 thrown = true;
00042 }
00043 catch(...) {
00044 assert(0);
00045 }
00046 assert(!thrown);
00047 assert(config.default_job().excludes.size() == 1);
00048 assert(config.default_job().excludes[0] ==
00049 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-B.file-1");
00050 assert(config.jobs().size() == 2);
00051 assert(config.jobs()[0].excludes.size() == 4);
00052 assert(config.jobs()[0].excludes[0] ==
00053 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-A.file-1");
00054 assert(config.jobs()[0].excludes[1] ==
00055 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-A.file-2");
00056 assert(config.jobs()[0].excludes[2] ==
00057 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-A.file-3");
00058 assert(config.jobs()[0].excludes[3] ==
00059 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-B.file-2");
00060 assert(config.jobs()[1].excludes.size() == 2);
00061 assert(config.jobs()[1].excludes[0] ==
00062 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-B.file-1");
00063 assert(config.jobs()[1].excludes[1] ==
00064 "./test-rconfig.dir/job.dir/../excludes.dir/excludes.group-A.file-3");
00065 }
00066
00067 int main(int argc, char const * argv[])
00068 {
00069 cleanup();
00070 setup();
00071 try {
00072 test();
00073 }
00074 catch(error e) {
00075 std::cerr << e;
00076 assert(0);
00077 }
00078 catch(...) {
00079 std::cerr << err_unknown;
00080 assert(0);
00081 }
00082 cleanup();
00083 return(0);
00084 }
00085