rvm 1.08
|
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 { 00028 char const * argv[256] = { 0 }; 00029 int argc = 0; 00030 bool thrown = false; 00031 00032 argv[argc++] = "<program>"; 00033 argv[argc++] = "--archive"; 00034 00035 config.default_file("./test-rconfig.dir/global-vault-locking.dir/file-1.conf"); 00036 config.default_logdir("./test-rconfig.dir/log.dir"); 00037 try { 00038 config.init(argc, argv); 00039 } 00040 catch(error e) { 00041 ERR_OUT(e); 00042 thrown = true; 00043 } 00044 catch(...) { 00045 assert(0); 00046 } 00047 assert(!thrown); 00048 assert(config.vault_locking()); 00049 } 00050 00051 { 00052 char const * argv[256] = { 0 }; 00053 int argc = 0; 00054 bool thrown = false; 00055 00056 argv[argc++] = "<program>"; 00057 argv[argc++] = "--archive"; 00058 00059 config.default_file("./test-rconfig.dir/global-vault-locking.dir/file-2.conf"); 00060 config.default_logdir("./test-rconfig.dir/log.dir"); 00061 try { 00062 config.init(argc, argv); 00063 } 00064 catch(error e) { 00065 ERR_OUT(e); 00066 thrown = true; 00067 } 00068 catch(...) { 00069 assert(0); 00070 } 00071 assert(!thrown); 00072 assert(!config.vault_locking()); 00073 } 00074 00075 { 00076 char const * argv[256] = { 0 }; 00077 int argc = 0; 00078 bool thrown = false; 00079 00080 argv[argc++] = "<program>"; 00081 argv[argc++] = "--archive"; 00082 00083 config.default_file("./test-rconfig.dir/global-vault-locking.dir/file-3.conf"); 00084 config.default_logdir("./test-rconfig.dir/log.dir"); 00085 try { 00086 config.init(argc, argv); 00087 } 00088 catch(error e) { 00089 ERR_OUT(e); 00090 thrown = true; 00091 } 00092 catch(...) { 00093 assert(0); 00094 } 00095 assert(!thrown); 00096 assert(config.vault_locking()); 00097 } 00098 } 00099 00100 int main(int argc, char const * argv[]) 00101 { 00102 cleanup(); 00103 setup(); 00104 try { 00105 test(); 00106 } 00107 catch(error e) { 00108 std::cerr << e; 00109 assert(0); 00110 } 00111 catch(...) { 00112 std::cerr << err_unknown; 00113 assert(0); 00114 } 00115 cleanup(); 00116 return(0); 00117 } 00118