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
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 << "rsync-local-path " << LOCAL_RSYNC << std::endl;
00063 out << "rsync-parallel 1" << std::endl;
00064 out << "timestamp-resolution second" << std::endl;
00065 out << "vault ./test-rvm.dir/vault-*" << std::endl;
00066 out << "vault-overflow-behavior quit" << std::endl;
00067 out << "vault-overflow-blocks 0" << std::endl;
00068 out << "vault-overflow-inodes 0" << std::endl;
00069 out << "vault-selection-behavior round-robin" << std::endl;
00070 out << "<job>" << std::endl;
00071 out << " jobname test-job" << std::endl;
00072 out << " archive-path jobname/permutation" << std::endl;
00073 out << " path " << check_cwd << "/" << std::endl;
00074 out << " rsync-connection-type local" << std::endl;
00075 out << " rsync-hardlink true" << std::endl;
00076 out << " <rsync-options>" << std::endl;
00077 out << " -a -v --progress --stats" << std::endl;
00078 out << " --exclude '/doc/'" << std::endl;
00079 out << " --exclude '/.deps/'" << std::endl;
00080 out << " --exclude '/test-rvm.dir/'" << std::endl;
00081 out << " </rsync-options>" << std::endl;
00082 out << " rsync-retry-count 3" << std::endl;
00083 out << "</job>" << std::endl;
00084 out.close();
00085 }
00086
00087 void cleanup(void)
00088 {
00089 assert(system("rm -fr ./test-rvm.dir") == 0);
00090 }
00091
00092 bool test_inodes(
00093 const std::string& path1,
00094 const std::string& path2,
00095 const std::string& file
00096 )
00097 {
00098 estring p1, p2;
00099 filestatus f1, f2;
00100 bool r;
00101
00102 p1 = path1;
00103 p1 += "/";
00104 p1 += file;
00105 p1 = reform_path(p1);
00106 f1.path(p1);
00107
00108 p2 = path2;
00109 p2 += "/";
00110 p2 += file;
00111 p2 = reform_path(p2);
00112 f2.path(p2);
00113
00114 r = (f1.inode() == f2.inode());
00115
00116 return(r);
00117 }
00118
00119 void test_rvm(void)
00120 {
00121 std::string local_rsync;
00122 estring adir[4];
00123 int adirc = 0;
00124
00125 local_rsync = LOCAL_RSYNC;
00126 if (local_rsync.size() == 0) {
00127 char *text[] = {
00128 "",
00129 "NOTICE: Skipping this test",
00130 "",
00131 "This test cannot be run because no local rsync binary was found during",
00132 "configuration. This also means that RVM will be compiled with no",
00133 "default value for the rsync-local-path command.",
00134 "",
00135 "To change this, run the configure script with --with-rsync=<path>,",
00136 "where <path> is the absolute path to the rsync binary.",
00137 "",
00138 0
00139 };
00140 int c;
00141
00142 for (c = 0; text[c] != 0; ++c) {
00143 std::cerr << text[c] << std::endl;
00144 }
00145 return;
00146 }
00147
00148 {
00149 char *argv[256] = { 0 };
00150 int argc = 0;
00151 bool thrown = false;
00152 subdirectory subdir;
00153 estring dir;
00154
00155 argv[argc++] = "<program>";
00156 argv[argc++] = "--archive";
00157
00158 cataloger.clear();
00159 archiver.clear();
00160 reporter.clear();
00161 vaulter.clear();
00162 logger.clear();
00163 config.clear();
00164
00165 config.default_file("./test-rvm.dir/file-1.conf");
00166 try {
00167 timer t;
00168
00169 t.start();
00170
00171 config.init(argc, argv);
00172 logger.init();
00173 vaulter.init();
00174 reporter.init();
00175 archiver.init();
00176 archiver.archive();
00177 cataloger.init();
00178 cataloger.catalog();
00179
00180 t.stop();
00181 reporter.set_total_time(t);
00182
00183
00184 reporter.file_report();
00185 logger.clear();
00186
00187
00188 assert(vaulter.vault() == "./test-rvm.dir/vault-1");
00189
00190 dir = vaulter.vault();
00191 dir += "/";
00192 dir += config.timestamp().str();
00193 dir += "/";
00194 dir += config.jobs()[0].generate_archive_path(check_cwd);
00195 adir[adirc++] = dir;
00196
00197
00198
00199 assert(
00200 exists(
00201 config.log_dir()
00202 + static_cast<std::string>("/")
00203 + config.timestamp().str()
00204 + static_cast<std::string>(".log")
00205 )
00206 );
00207 assert(
00208 exists(
00209 config.log_dir()
00210 + static_cast<std::string>("/")
00211 + config.timestamp().str()
00212 + static_cast<std::string>(".report")
00213 )
00214 );
00215
00216 subdir.path(dir);
00217 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end());
00218 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end());
00219 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00220 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00221 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00222 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00223 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00224 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00225 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00226 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00227 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00228 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != subdir.end());
00229 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end());
00230 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end());
00231 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end());
00232 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end());
00233 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end());
00234 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end());
00235 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end());
00236 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end());
00237 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end());
00238 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end());
00239 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end());
00240 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end());
00241 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end());
00242 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end());
00243 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end());
00244 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end());
00245 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end());
00246 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end());
00247 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end());
00248 assert(find(subdir.begin(), subdir.end(), "test-rvm.cc") != subdir.end());
00249 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end());
00250 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end());
00251 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end());
00252 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end());
00253 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end());
00254
00255 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00256
00257 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end());
00258 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end());
00259 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end());
00260 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end());
00261 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end());
00262 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end());
00263 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end());
00264 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end());
00265 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end());
00266 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end());
00267 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end());
00268 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end());
00269 }
00270 catch(error e) {
00271 ERR_OUT(e);
00272 thrown = true;
00273 }
00274 catch(...) {
00275 ERR_OUT(err_unknown);
00276 assert(0);
00277 }
00278 assert(!thrown);
00279 }
00280
00281 sleep(2);
00282
00283 {
00284 char *argv[256] = { 0 };
00285 int argc = 0;
00286 bool thrown = false;
00287 subdirectory subdir;
00288 estring dir;
00289
00290 argv[argc++] = "<program>";
00291 argv[argc++] = "--archive";
00292
00293 cataloger.clear();
00294 archiver.clear();
00295 reporter.clear();
00296 vaulter.clear();
00297 logger.clear();
00298 config.clear();
00299
00300 config.default_file("./test-rvm.dir/file-1.conf");
00301 try {
00302 timer t;
00303
00304 t.start();
00305
00306 config.init(argc, argv);
00307 logger.init();
00308 vaulter.init();
00309 reporter.init();
00310 archiver.init();
00311 archiver.archive();
00312 cataloger.init();
00313 cataloger.catalog();
00314
00315 t.stop();
00316 reporter.set_total_time(t);
00317
00318
00319 reporter.file_report();
00320 logger.clear();
00321
00322
00323 assert(vaulter.vault() == "./test-rvm.dir/vault-2");
00324
00325 dir = vaulter.vault();
00326 dir += "/";
00327 dir += config.timestamp().str();
00328 dir += "/";
00329 dir += config.jobs()[0].generate_archive_path(check_cwd);
00330 adir[adirc++] = dir;
00331
00332
00333
00334 subdir.path(dir);
00335 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end());
00336 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end());
00337 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00338 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00339 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00340 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00341 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00342 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00343 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00344 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00345 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00346 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != 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.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
00373 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00374
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 *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
00437 reporter.file_report();
00438 logger.clear();
00439
00440
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
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(), "doxygen.conf") != subdir.end());
00465 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end());
00466 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end());
00467 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end());
00468 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end());
00469 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end());
00470 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end());
00471 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end());
00472 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end());
00473 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end());
00474 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end());
00475 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end());
00476 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end());
00477 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end());
00478 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end());
00479 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end());
00480 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end());
00481 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end());
00482 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end());
00483 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end());
00484 assert(find(subdir.begin(), subdir.end(), "test-rvm.cc") != subdir.end());
00485 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end());
00486 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end());
00487 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end());
00488 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end());
00489 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end());
00490
00491 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00492
00493 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end());
00494 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end());
00495 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end());
00496 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end());
00497 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end());
00498 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end());
00499 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end());
00500 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end());
00501 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end());
00502 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end());
00503 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end());
00504 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end());
00505 }
00506 catch(error e) {
00507 ERR_OUT(e);
00508 thrown = true;
00509 }
00510 catch(...) {
00511 ERR_OUT(err_unknown);
00512 assert(0);
00513 }
00514 assert(!thrown);
00515 }
00516
00517 sleep(2);
00518
00519 {
00520 char *argv[256] = { 0 };
00521 int argc = 0;
00522 bool thrown = false;
00523 subdirectory subdir;
00524 estring dir;
00525
00526 argv[argc++] = "<program>";
00527 argv[argc++] = "--archive";
00528
00529 cataloger.clear();
00530 archiver.clear();
00531 reporter.clear();
00532 vaulter.clear();
00533 logger.clear();
00534 config.clear();
00535
00536 config.default_file("./test-rvm.dir/file-1.conf");
00537 try {
00538 timer t;
00539
00540 t.start();
00541
00542 config.init(argc, argv);
00543 logger.init();
00544 vaulter.init();
00545 reporter.init();
00546 archiver.init();
00547 archiver.archive();
00548 estring path;
00549 filestatus fstat1, fstat2;
00550 cataloger.init();
00551 cataloger.catalog();
00552
00553 t.stop();
00554 reporter.set_total_time(t);
00555
00556
00557 reporter.file_report();
00558 logger.clear();
00559
00560
00561 assert(vaulter.vault() == "./test-rvm.dir/vault-1");
00562
00563 dir = vaulter.vault();
00564 dir += "/";
00565 dir += config.timestamp().str();
00566 dir += "/";
00567 dir += config.jobs()[0].generate_archive_path(check_cwd);
00568 adir[adirc++] = dir;
00569
00570
00571
00572 subdir.path(dir);
00573 if (subdir.size() == 0) {
00574 std::string filename;
00575 std::string line;
00576 std::ifstream in;
00577 bool found_usage_error = false;
00578 char line_cstr[2048] = { 0 };
00579 int c;
00580
00581 filename = "./test-rvm.dir/log.dir/";
00582 filename += config.timestamp().str();
00583 filename += ".log";
00584 in.open(filename.c_str());
00585 assert(in.is_open());
00586 while (in.getline(line_cstr,2048)) {
00587 line = line_cstr;
00588 if (line.find("Rsync exit code: [1]") != std::string::npos)
00589 found_usage_error = true;
00590 for (c = 0; c < 2048; line_cstr[c++] = 0);
00591 }
00592 in.close();
00593
00594 if (found_usage_error) {
00595 std::cerr
00596 << "*** NOTICE: One test has failed, the test that uses rsync with"
00597 << std::endl
00598 << " the --hard-links and --link-dest command line"
00599 << std::endl
00600 << " options. Rsync reported a syntax or usage error,"
00601 << std::endl
00602 << " which may indicate that this version of rsync is"
00603 << std::endl
00604 << " old enough to not have these options."
00605 << std::endl
00606 << std::endl
00607 << " In order to be able to hard-link files that have"
00608 << std::endl
00609 << " not changed from one archive to the next, you"
00610 << std::endl
00611 << " will have to upgrade rsync."
00612 << std::endl
00613 ;
00614 }
00615 assert(found_usage_error);
00616 }
00617 else {
00618 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end());
00619 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end());
00620 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00621 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00622 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00623 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00624 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00625 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00626 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00627 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00628 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00629 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != subdir.end());
00630 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end());
00631 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end());
00632 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end());
00633 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end());
00634 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end());
00635 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end());
00636 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end());
00637 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end());
00638 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end());
00639 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end());
00640 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end());
00641 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end());
00642 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end());
00643 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end());
00644 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end());
00645 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end());
00646 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end());
00647 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end());
00648 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end());
00649 assert(find(subdir.begin(), subdir.end(), "test-rvm.cc") != subdir.end());
00650 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end());
00651 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end());
00652 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end());
00653 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end());
00654 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end());
00655
00656 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00657
00658 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end());
00659 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end());
00660 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end());
00661 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end());
00662 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end());
00663 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end());
00664 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end());
00665 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end());
00666 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end());
00667 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end());
00668 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end());
00669 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end());
00670
00671 assert(test_inodes(adir[0], adir[3], "AUTHORS"));
00672 }
00673
00674
00675 assert(
00676 exists(
00677 static_cast<std::string>("./test-rvm.dir/catalog.dir/")
00678 + config.timestamp().str()
00679 )
00680 );
00681 }
00682 catch(error e) {
00683 ERR_OUT(e);
00684 thrown = true;
00685 }
00686 catch(...) {
00687 ERR_OUT(err_unknown);
00688 assert(0);
00689 }
00690 assert(!thrown);
00691 }
00692 }
00693
00694 int main(int argc, char *argv[])
00695 {
00696 cleanup();
00697 setup();
00698 try {
00699 test_rvm();
00700 }
00701 catch(error e) {
00702 std::cerr << e;
00703 assert(0);
00704 }
00705 catch(...) {
00706 std::cerr << err_unknown;
00707 assert(0);
00708 }
00709 cleanup();
00710 return(0);
00711 }
00712