rvm 1.08
|
00001 #include "config.h" 00002 00003 #ifdef HAVE_UNISTD_H 00004 #include <unistd.h> 00005 #endif 00006 00007 #include <iostream> 00008 #include <string> 00009 #include <fstream> 00010 #include <iomanip> 00011 #include <string> 00012 #include <cassert> 00013 #include <algorithm> 00014 00015 #include "asserts.h" 00016 #include "error.h" 00017 #include "fs.h" 00018 #include "rconfig.h" 00019 #include "logger.h" 00020 #include "vaulter.h" 00021 #include "archiver.h" 00022 #include "cataloger.h" 00023 #include "reporter.h" 00024 #include "test-fs-cwd.h" 00025 00026 #define ERR_OUT(e) std::cerr << e 00027 // #define ERR_OUT(e) 00028 00029 bool make_dir(const std::string& path) 00030 { 00031 bool thrown; 00032 bool value; 00033 00034 thrown = false; 00035 try { 00036 mk_dir(path); 00037 } 00038 catch(...) { 00039 thrown = true; 00040 } 00041 00042 value = (thrown == false); 00043 00044 return(value); 00045 } 00046 00047 void setup(void) 00048 { 00049 std::ofstream out; 00050 00051 assert(make_dir("./test-rvm.dir")); 00052 assert(make_dir("./test-rvm.dir/vault-1")); 00053 assert(make_dir("./test-rvm.dir/vault-2")); 00054 assert(make_dir("./test-rvm.dir/vault-3")); 00055 assert(make_dir("./test-rvm.dir/log.dir")); 00056 assert(make_dir("./test-rvm.dir/catalog.dir")); 00057 00058 out.open("./test-rvm.dir/file-1.conf"); 00059 assert(out.is_open()); 00060 out << "link-catalog-dir ./test-rvm.dir/catalog.dir" << std::endl; 00061 out << "log-dir ./test-rvm.dir/log.dir" << std::endl; 00062 out << "logging-level rsync" << std::endl; 00063 out << "rsync-local-path " << LOCAL_RSYNC << std::endl; 00064 out << "rsync-parallel 1" << std::endl; 00065 out << "timestamp-resolution second" << std::endl; 00066 out << "vault ./test-rvm.dir/vault-*" << std::endl; 00067 out << "vault-overflow-behavior quit" << std::endl; 00068 out << "vault-overflow-blocks 0" << std::endl; 00069 out << "vault-overflow-inodes 0" << std::endl; 00070 out << "vault-selection-behavior round-robin" << std::endl; 00071 out << "<job>" << std::endl; 00072 out << " jobname test-job" << std::endl; 00073 out << " archive-path jobname/permutation" << std::endl; 00074 out << " path " << check_cwd << "/" << std::endl; 00075 out << " rsync-connection-type local" << std::endl; 00076 out << " rsync-hardlink true" << std::endl; 00077 out << " <rsync-options>" << std::endl; 00078 out << " -a -v --progress --stats" << std::endl; 00079 out << " --exclude '/.svn/'" << std::endl; 00080 out << " --exclude '/.deps/'" << std::endl; 00081 out << " --exclude '/autom4te.cache/'" << std::endl; 00082 out << " --exclude '/test-rvm.dir/'" << std::endl; 00083 out << " </rsync-options>" << std::endl; 00084 out << " rsync-retry-count 3" << std::endl; 00085 out << "</job>" << std::endl; 00086 out.close(); 00087 } 00088 00089 void cleanup(void) 00090 { 00091 assert(system("rm -fr ./test-rvm.dir") == 0); 00092 } 00093 00094 bool test_inodes( 00095 const std::string& path1, 00096 const std::string& path2, 00097 const std::string& file 00098 ) 00099 { 00100 estring p1, p2; 00101 filestatus f1, f2; 00102 bool r; 00103 00104 p1 = path1; 00105 p1 += "/"; 00106 p1 += file; 00107 p1 = reform_path(p1); 00108 f1.path(p1); 00109 00110 p2 = path2; 00111 p2 += "/"; 00112 p2 += file; 00113 p2 = reform_path(p2); 00114 f2.path(p2); 00115 00116 r = (f1.inode() == f2.inode()); 00117 00118 return(r); 00119 } 00120 00121 void test_rvm(void) 00122 { 00123 std::string local_rsync; 00124 estring adir[4]; 00125 int adirc = 0; 00126 00127 local_rsync = LOCAL_RSYNC; 00128 if (local_rsync.size() == 0) { 00129 char const * text[] = { 00130 "", 00131 "NOTICE: Skipping this test", 00132 "", 00133 "This test cannot be run because no local rsync binary was found during", 00134 "configuration. This also means that RVM will be compiled with no", 00135 "default value for the rsync-local-path command.", 00136 "", 00137 "To change this, run the configure script with --with-rsync=<path>,", 00138 "where <path> is the absolute path to the rsync binary.", 00139 "", 00140 0 00141 }; 00142 int c; 00143 00144 for (c = 0; text[c] != 0; ++c) { 00145 std::cerr << text[c] << std::endl; 00146 } 00147 return; 00148 } 00149 00150 { 00151 char const * argv[256] = { 0 }; 00152 int argc = 0; 00153 bool thrown = false; 00154 subdirectory subdir; 00155 estring dir; 00156 00157 argv[argc++] = "<program>"; 00158 argv[argc++] = "--archive"; 00159 00160 cataloger.clear(); 00161 archiver.clear(); 00162 reporter.clear(); 00163 vaulter.clear(); 00164 logger.clear(); 00165 config.clear(); 00166 00167 config.default_file("./test-rvm.dir/file-1.conf"); 00168 try { 00169 timer t; 00170 00171 t.start(); 00172 00173 config.init(argc, argv); 00174 logger.init(); 00175 vaulter.init(); 00176 reporter.init(); 00177 archiver.init(); 00178 archiver.archive(); 00179 cataloger.init(); 00180 cataloger.catalog(); 00181 00182 t.stop(); 00183 reporter.set_total_time(t); 00184 00185 // reporter.print_report(); 00186 reporter.file_report(); 00187 logger.clear(); 00188 00189 // std::cerr << "vaulter.vault() == " << vaulter.vault() << std::endl; 00190 assert(vaulter.vault() == "./test-rvm.dir/vault-1"); 00191 00192 dir = vaulter.vault(); 00193 dir += "/"; 00194 dir += config.timestamp().str(); 00195 dir += "/"; 00196 dir += config.jobs()[0].generate_archive_path(check_cwd); 00197 adir[adirc++] = dir; 00198 00199 // std::cout << "dir = " << dir << std::endl; 00200 00201 assert( 00202 exists( 00203 config.log_dir() 00204 + static_cast<std::string>("/") 00205 + config.timestamp().str() 00206 + static_cast<std::string>(".log") 00207 ) 00208 ); 00209 assert( 00210 exists( 00211 config.log_dir() 00212 + static_cast<std::string>("/") 00213 + config.timestamp().str() 00214 + static_cast<std::string>(".report") 00215 ) 00216 ); 00217 00218 subdir.path(dir); 00219 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end()); 00220 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end()); 00221 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end()); 00222 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end()); 00223 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end()); 00224 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end()); 00225 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end()); 00226 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end()); 00227 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end()); 00228 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end()); 00229 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end()); 00230 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end()); 00231 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end()); 00232 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end()); 00233 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end()); 00234 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end()); 00235 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end()); 00236 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end()); 00237 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end()); 00238 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end()); 00239 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end()); 00240 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end()); 00241 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end()); 00242 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end()); 00243 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end()); 00244 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end()); 00245 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end()); 00246 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end()); 00247 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end()); 00248 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end()); 00249 assert(find(subdir.begin(), subdir.end(), "test-rvm-001.cc") != subdir.end()); 00250 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end()); 00251 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end()); 00252 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end()); 00253 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end()); 00254 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end()); 00255 // assert(find(subdir.begin(), subdir.end(), "test-job.cc") != subdir.end()); 00256 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end()); 00257 // assert(find(subdir.begin(), subdir.end(), "test-rconfig.cc") != subdir.end()); 00258 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end()); 00259 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end()); 00260 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end()); 00261 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end()); 00262 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end()); 00263 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end()); 00264 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end()); 00265 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end()); 00266 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end()); 00267 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end()); 00268 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end()); 00269 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end()); 00270 } 00271 catch(error e) { 00272 ERR_OUT(e); 00273 thrown = true; 00274 } 00275 catch(...) { 00276 ERR_OUT(err_unknown); 00277 assert(0); 00278 } 00279 assert(!thrown); 00280 } 00281 00282 sleep(2); 00283 00284 { 00285 char const * argv[256] = { 0 }; 00286 int argc = 0; 00287 bool thrown = false; 00288 subdirectory subdir; 00289 estring dir; 00290 00291 argv[argc++] = "<program>"; 00292 argv[argc++] = "--archive"; 00293 00294 cataloger.clear(); 00295 archiver.clear(); 00296 reporter.clear(); 00297 vaulter.clear(); 00298 logger.clear(); 00299 config.clear(); 00300 00301 config.default_file("./test-rvm.dir/file-1.conf"); 00302 try { 00303 timer t; 00304 00305 t.start(); 00306 00307 config.init(argc, argv); 00308 logger.init(); 00309 vaulter.init(); 00310 reporter.init(); 00311 archiver.init(); 00312 archiver.archive(); 00313 cataloger.init(); 00314 cataloger.catalog(); 00315 00316 t.stop(); 00317 reporter.set_total_time(t); 00318 00319 // reporter.print_report(); 00320 reporter.file_report(); 00321 logger.clear(); 00322 00323 // std::cerr << "vaulter.vault() == " << vaulter.vault() << std::endl; 00324 assert(vaulter.vault() == "./test-rvm.dir/vault-2"); 00325 00326 dir = vaulter.vault(); 00327 dir += "/"; 00328 dir += config.timestamp().str(); 00329 dir += "/"; 00330 dir += config.jobs()[0].generate_archive_path(check_cwd); 00331 adir[adirc++] = dir; 00332 00333 // std::cout << "dir = " << dir << std::endl; 00334 00335 subdir.path(dir); 00336 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end()); 00337 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end()); 00338 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end()); 00339 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end()); 00340 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end()); 00341 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end()); 00342 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end()); 00343 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end()); 00344 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end()); 00345 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end()); 00346 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end()); 00347 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end()); 00348 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end()); 00349 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end()); 00350 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end()); 00351 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end()); 00352 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end()); 00353 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end()); 00354 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end()); 00355 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end()); 00356 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end()); 00357 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end()); 00358 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end()); 00359 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end()); 00360 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end()); 00361 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end()); 00362 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end()); 00363 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end()); 00364 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end()); 00365 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end()); 00366 assert(find(subdir.begin(), subdir.end(), "test-rvm-001.cc") != subdir.end()); 00367 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end()); 00368 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end()); 00369 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end()); 00370 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end()); 00371 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end()); 00372 // assert(find(subdir.begin(), subdir.end(), "test-job.cc") != subdir.end()); 00373 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end()); 00374 // assert(find(subdir.begin(), subdir.end(), "test-rconfig.cc") != subdir.end()); 00375 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end()); 00376 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end()); 00377 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end()); 00378 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end()); 00379 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end()); 00380 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end()); 00381 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end()); 00382 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end()); 00383 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end()); 00384 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end()); 00385 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end()); 00386 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end()); 00387 } 00388 catch(error e) { 00389 ERR_OUT(e); 00390 thrown = true; 00391 } 00392 catch(...) { 00393 ERR_OUT(err_unknown); 00394 assert(0); 00395 } 00396 assert(!thrown); 00397 } 00398 00399 sleep(2); 00400 00401 { 00402 char const * argv[256] = { 0 }; 00403 int argc = 0; 00404 bool thrown = false; 00405 subdirectory subdir; 00406 estring dir; 00407 00408 argv[argc++] = "<program>"; 00409 argv[argc++] = "--archive"; 00410 00411 cataloger.clear(); 00412 archiver.clear(); 00413 reporter.clear(); 00414 vaulter.clear(); 00415 logger.clear(); 00416 config.clear(); 00417 00418 config.default_file("./test-rvm.dir/file-1.conf"); 00419 try { 00420 timer t; 00421 00422 t.start(); 00423 00424 config.init(argc, argv); 00425 logger.init(); 00426 vaulter.init(); 00427 reporter.init(); 00428 archiver.init(); 00429 archiver.archive(); 00430 cataloger.init(); 00431 cataloger.catalog(); 00432 00433 t.stop(); 00434 reporter.set_total_time(t); 00435 00436 // reporter.print_report(); 00437 reporter.file_report(); 00438 logger.clear(); 00439 00440 // std::cerr << "vaulter.vault() == " << vaulter.vault() << std::endl; 00441 assert(vaulter.vault() == "./test-rvm.dir/vault-3"); 00442 00443 dir = vaulter.vault(); 00444 dir += "/"; 00445 dir += config.timestamp().str(); 00446 dir += "/"; 00447 dir += config.jobs()[0].generate_archive_path(check_cwd); 00448 adir[adirc++] = dir; 00449 00450 // std::cout << "dir = " << dir << std::endl; 00451 00452 subdir.path(dir); 00453 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end()); 00454 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end()); 00455 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end()); 00456 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end()); 00457 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end()); 00458 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end()); 00459 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end()); 00460 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end()); 00461 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end()); 00462 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end()); 00463 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end()); 00464 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end()); 00465 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end()); 00466 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end()); 00467 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end()); 00468 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end()); 00469 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end()); 00470 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end()); 00471 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end()); 00472 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end()); 00473 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end()); 00474 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end()); 00475 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end()); 00476 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end()); 00477 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end()); 00478 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end()); 00479 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end()); 00480 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end()); 00481 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end()); 00482 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end()); 00483 assert(find(subdir.begin(), subdir.end(), "test-rvm-001.cc") != subdir.end()); 00484 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end()); 00485 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end()); 00486 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end()); 00487 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end()); 00488 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end()); 00489 // assert(find(subdir.begin(), subdir.end(), "test-job.cc") != subdir.end()); 00490 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end()); 00491 // assert(find(subdir.begin(), subdir.end(), "test-rconfig.cc") != subdir.end()); 00492 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end()); 00493 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end()); 00494 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end()); 00495 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end()); 00496 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end()); 00497 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end()); 00498 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end()); 00499 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end()); 00500 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end()); 00501 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end()); 00502 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end()); 00503 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end()); 00504 } 00505 catch(error e) { 00506 ERR_OUT(e); 00507 thrown = true; 00508 } 00509 catch(...) { 00510 ERR_OUT(err_unknown); 00511 assert(0); 00512 } 00513 assert(!thrown); 00514 } 00515 00516 sleep(2); 00517 00518 { 00519 char const * argv[256] = { 0 }; 00520 int argc = 0; 00521 bool thrown = false; 00522 subdirectory subdir; 00523 estring dir; 00524 00525 argv[argc++] = "<program>"; 00526 argv[argc++] = "--archive"; 00527 00528 cataloger.clear(); 00529 archiver.clear(); 00530 reporter.clear(); 00531 vaulter.clear(); 00532 logger.clear(); 00533 config.clear(); 00534 00535 config.default_file("./test-rvm.dir/file-1.conf"); 00536 try { 00537 timer t; 00538 00539 t.start(); 00540 00541 config.init(argc, argv); 00542 logger.init(); 00543 vaulter.init(); 00544 reporter.init(); 00545 archiver.init(); 00546 archiver.archive(); 00547 estring path; 00548 filestatus fstat1, fstat2; 00549 cataloger.init(); 00550 cataloger.catalog(); 00551 00552 t.stop(); 00553 reporter.set_total_time(t); 00554 00555 // reporter.print_report(); 00556 reporter.file_report(); 00557 logger.clear(); 00558 00559 // std::cerr << "vaulter.vault() == " << vaulter.vault() << std::endl; 00560 assert(vaulter.vault() == "./test-rvm.dir/vault-1"); 00561 00562 dir = vaulter.vault(); 00563 dir += "/"; 00564 dir += config.timestamp().str(); 00565 dir += "/"; 00566 dir += config.jobs()[0].generate_archive_path(check_cwd); 00567 adir[adirc++] = dir; 00568 00569 // std::cout << "dir = " << dir << std::endl; 00570 00571 subdir.path(dir); 00572 if (subdir.size() == 0) { 00573 std::string filename; 00574 std::string line; 00575 std::ifstream in; 00576 bool found_usage_error = false; 00577 char line_cstr[2048] = { 0 }; 00578 int c; 00579 00580 filename = "./test-rvm.dir/log.dir/"; 00581 filename += config.timestamp().str(); 00582 filename += ".log"; 00583 in.open(filename.c_str()); 00584 assert(in.is_open()); 00585 while (in.getline(line_cstr,2048)) { 00586 line = line_cstr; 00587 if (line.find("Rsync exit code: [1]") != std::string::npos) 00588 found_usage_error = true; 00589 for (c = 0; c < 2048; line_cstr[c++] = 0); 00590 } 00591 in.close(); 00592 00593 if (found_usage_error) { 00594 std::cerr 00595 << "*** NOTICE: One test has failed, the test that uses rsync with" 00596 << std::endl 00597 << " the --hard-links and --link-dest command line" 00598 << std::endl 00599 << " options. Rsync reported a syntax or usage error," 00600 << std::endl 00601 << " which may indicate that this version of rsync is" 00602 << std::endl 00603 << " old enough to not have these options." 00604 << std::endl 00605 << std::endl 00606 << " In order to be able to hard-link files that have" 00607 << std::endl 00608 << " not changed from one archive to the next, you" 00609 << std::endl 00610 << " will have to upgrade rsync." 00611 << std::endl 00612 ; 00613 } 00614 assert(found_usage_error); 00615 } 00616 else { 00617 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end()); 00618 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end()); 00619 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end()); 00620 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end()); 00621 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end()); 00622 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end()); 00623 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end()); 00624 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end()); 00625 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end()); 00626 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end()); 00627 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end()); 00628 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end()); 00629 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end()); 00630 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end()); 00631 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end()); 00632 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end()); 00633 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end()); 00634 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end()); 00635 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end()); 00636 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end()); 00637 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end()); 00638 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end()); 00639 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end()); 00640 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end()); 00641 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end()); 00642 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end()); 00643 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end()); 00644 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end()); 00645 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end()); 00646 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end()); 00647 assert(find(subdir.begin(), subdir.end(), "test-rvm-001.cc") != subdir.end()); 00648 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end()); 00649 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end()); 00650 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end()); 00651 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end()); 00652 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end()); 00653 // assert(find(subdir.begin(), subdir.end(), "test-job.cc") != subdir.end()); 00654 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end()); 00655 // assert(find(subdir.begin(), subdir.end(), "test-rconfig.cc") != subdir.end()); 00656 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end()); 00657 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end()); 00658 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end()); 00659 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end()); 00660 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end()); 00661 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end()); 00662 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end()); 00663 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end()); 00664 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end()); 00665 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end()); 00666 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end()); 00667 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end()); 00668 00669 assert(test_inodes(adir[0], adir[3], "AUTHORS")); 00670 } 00671 00672 // TODO: Check output 00673 assert( 00674 exists( 00675 static_cast<std::string>("./test-rvm.dir/catalog.dir/") 00676 + config.timestamp().str() 00677 ) 00678 ); 00679 } 00680 catch(error e) { 00681 ERR_OUT(e); 00682 thrown = true; 00683 } 00684 catch(...) { 00685 ERR_OUT(err_unknown); 00686 assert(0); 00687 } 00688 assert(!thrown); 00689 } 00690 } 00691 00692 int main(int argc, char const * argv[]) 00693 { 00694 cleanup(); 00695 setup(); 00696 try { 00697 test_rvm(); 00698 } 00699 catch(error e) { 00700 std::cerr << e; 00701 assert(0); 00702 } 00703 catch(...) { 00704 std::cerr << err_unknown; 00705 assert(0); 00706 } 00707 cleanup(); 00708 return(0); 00709 } 00710