test-rconfig-043.cc

Go to the documentation of this file.
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 // #define ERR_OUT(e)
00024 
00025 void test(void)
00026 {
00027         char *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-7.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().groupname == "group-A");
00048         assert(config.default_job().hostname == "host-A");
00049         assert(config.default_job().rsync_behavior.default_value()
00050                 == rsync_behavior::fail);
00051         assert(config.default_job().rsync_behavior.map_value().size() == 1);
00052         assert(config.default_job().rsync_behavior[5] == rsync_behavior::ok);
00053         assert(config.default_job().rsync_connection == job::connection_server);
00054         assert(config.default_job().rsync_hardlink == false);
00055         assert(config.default_job().rsync_options == "--some -options for-rsync");
00056         assert(config.default_job().rsync_remote_user == "alice");
00057         assert(config.default_job().rsync_remote_port == 4338);
00058         assert(config.jobs().size() == 2);
00059         assert(config.jobs()[0].jobname == "job-A");
00060         assert(config.jobs()[0].groupname == "group-A");
00061         assert(config.jobs()[0].hostname == "host-A");
00062         assert(config.jobs()[0].rsync_behavior.default_value()
00063                 == rsync_behavior::retry);
00064         assert(config.jobs()[0].rsync_behavior.map_value().size() == 9);
00065         assert(config.jobs()[0].rsync_behavior[0] == rsync_behavior::ok);
00066         assert(config.jobs()[0].rsync_behavior[1] == rsync_behavior::fail);
00067         assert(config.jobs()[0].rsync_behavior[2] == rsync_behavior::fail);
00068         assert(config.jobs()[0].rsync_behavior[4] == rsync_behavior::fail);
00069         assert(config.jobs()[0].rsync_behavior[23]
00070                 == rsync_behavior::retry_without_hardlinks);
00071         assert(config.jobs()[0].rsync_behavior[124] == rsync_behavior::fail);
00072         assert(config.jobs()[0].rsync_behavior[125] == rsync_behavior::fail);
00073         assert(config.jobs()[0].rsync_behavior[126] == rsync_behavior::fail);
00074         assert(config.jobs()[0].rsync_behavior[127] == rsync_behavior::fail);
00075         assert(config.jobs()[0].rsync_connection == job::connection_local);
00076         assert(config.jobs()[0].rsync_hardlink == true);
00077         assert(config.jobs()[0].rsync_options == "--some -options for-rsync some more options for rsync");
00078         assert(config.jobs()[0].rsync_remote_user == "");
00079         assert(config.jobs()[0].rsync_remote_port == 0);
00080         assert(config.jobs()[1].jobname.size() == 0);
00081         assert(config.jobs()[1].groupname == "group-A");
00082         assert(config.jobs()[1].hostname == "host-B");
00083         assert(config.jobs()[1].rsync_behavior.default_value()
00084                 == rsync_behavior::fail);
00085         assert(config.jobs()[1].rsync_behavior.map_value().size() == 1);
00086         assert(config.jobs()[1].rsync_behavior.map_value().find(5)->second
00087                 == rsync_behavior::ok);
00088         assert(config.jobs()[1].rsync_connection == job::connection_server);
00089         assert(config.jobs()[1].rsync_hardlink == false);
00090         assert(config.jobs()[1].rsync_remote_user == "alice");
00091         assert(config.jobs()[1].rsync_remote_port == 4338);
00092 }
00093 
00094 int main(int argc, char *argv[])
00095 {
00096         cleanup();
00097         setup();
00098         try {
00099                 test();
00100         }
00101         catch(error e) {
00102                 std::cerr << e;
00103                 assert(0);
00104         }
00105         catch(...) {
00106                 std::cerr << err_unknown;
00107                 assert(0);
00108         }
00109         cleanup();
00110         return(0);
00111 }
00112 

Generated on Fri Jun 23 16:46:31 2006 for rvm by  doxygen 1.4.2