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 + std::string("/")
00203 + config.timestamp().str()
00204 + std::string(".log")
00205 )
00206 );
00207 assert(
00208 exists(
00209 config.log_dir()
00210 + std::string("/")
00211 + config.timestamp().str()
00212 + 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(), "ChangeLog") != subdir.end());
00220 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00221 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00222 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00223 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00224 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00225 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00226 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00227 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00228 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00229 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != 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.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
00256 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00257
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 *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
00320 reporter.file_report();
00321 logger.clear();
00322
00323
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
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(), "ChangeLog") != subdir.end());
00339 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00340 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00341 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00342 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00343 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00344 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00345 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00346 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00347 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00348 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != subdir.end());
00349 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end());
00350 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end());
00351 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end());
00352 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end());
00353 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end());
00354 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end());
00355 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end());
00356 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end());
00357 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end());
00358 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end());
00359 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end());
00360 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end());
00361 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end());
00362 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end());
00363 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end());
00364 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end());
00365 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end());
00366 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end());
00367 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end());
00368 assert(find(subdir.begin(), subdir.end(), "test-rvm.cc") != subdir.end());
00369 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end());
00370 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end());
00371 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end());
00372 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end());
00373 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end());
00374
00375 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00376
00377 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end());
00378 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end());
00379 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end());
00380 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end());
00381 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end());
00382 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end());
00383 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end());
00384 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end());
00385 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end());
00386 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end());
00387 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end());
00388 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end());
00389 }
00390 catch(error e) {
00391 ERR_OUT(e);
00392 thrown = true;
00393 }
00394 catch(...) {
00395 ERR_OUT(err_unknown);
00396 assert(0);
00397 }
00398 assert(!thrown);
00399 }
00400
00401 sleep(2);
00402
00403 {
00404 char *argv[256] = { 0 };
00405 int argc = 0;
00406 bool thrown = false;
00407 subdirectory subdir;
00408 estring dir;
00409
00410 argv[argc++] = "<program>";
00411 argv[argc++] = "--archive";
00412
00413 cataloger.clear();
00414 archiver.clear();
00415 reporter.clear();
00416 vaulter.clear();
00417 logger.clear();
00418 config.clear();
00419
00420 config.default_file("./test-rvm.dir/file-1.conf");
00421 try {
00422 timer t;
00423
00424 t.start();
00425
00426 config.init(argc, argv);
00427 logger.init();
00428 vaulter.init();
00429 reporter.init();
00430 archiver.init();
00431 archiver.archive();
00432 cataloger.init();
00433 cataloger.catalog();
00434
00435 t.stop();
00436 reporter.set_total_time(t);
00437
00438
00439 reporter.file_report();
00440 logger.clear();
00441
00442
00443 assert(vaulter.vault() == "./test-rvm.dir/vault-3");
00444
00445 dir = vaulter.vault();
00446 dir += "/";
00447 dir += config.timestamp().str();
00448 dir += "/";
00449 dir += config.jobs()[0].generate_archive_path(check_cwd);
00450 adir[adirc++] = dir;
00451
00452
00453
00454 subdir.path(dir);
00455 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end());
00456 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end());
00457 assert(find(subdir.begin(), subdir.end(), "ChangeLog") != subdir.end());
00458 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00459 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00460 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00461 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00462 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00463 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00464 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00465 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00466 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00467 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != subdir.end());
00468 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end());
00469 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end());
00470 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end());
00471 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end());
00472 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end());
00473 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end());
00474 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end());
00475 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end());
00476 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end());
00477 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end());
00478 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end());
00479 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end());
00480 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end());
00481 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end());
00482 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end());
00483 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end());
00484 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end());
00485 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end());
00486 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end());
00487 assert(find(subdir.begin(), subdir.end(), "test-rvm.cc") != subdir.end());
00488 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end());
00489 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end());
00490 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end());
00491 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end());
00492 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end());
00493
00494 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00495
00496 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end());
00497 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end());
00498 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end());
00499 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end());
00500 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end());
00501 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end());
00502 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end());
00503 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end());
00504 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end());
00505 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end());
00506 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end());
00507 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end());
00508 }
00509 catch(error e) {
00510 ERR_OUT(e);
00511 thrown = true;
00512 }
00513 catch(...) {
00514 ERR_OUT(err_unknown);
00515 assert(0);
00516 }
00517 assert(!thrown);
00518 }
00519
00520 sleep(2);
00521
00522 {
00523 char *argv[256] = { 0 };
00524 int argc = 0;
00525 bool thrown = false;
00526 subdirectory subdir;
00527 estring dir;
00528
00529 argv[argc++] = "<program>";
00530 argv[argc++] = "--archive";
00531
00532 cataloger.clear();
00533 archiver.clear();
00534 reporter.clear();
00535 vaulter.clear();
00536 logger.clear();
00537 config.clear();
00538
00539 config.default_file("./test-rvm.dir/file-1.conf");
00540 try {
00541 timer t;
00542
00543 t.start();
00544
00545 config.init(argc, argv);
00546 logger.init();
00547 vaulter.init();
00548 reporter.init();
00549 archiver.init();
00550 archiver.archive();
00551 estring path;
00552 filestatus fstat1, fstat2;
00553 cataloger.init();
00554 cataloger.catalog();
00555
00556 t.stop();
00557 reporter.set_total_time(t);
00558
00559
00560 reporter.file_report();
00561 logger.clear();
00562
00563
00564 assert(vaulter.vault() == "./test-rvm.dir/vault-1");
00565
00566 dir = vaulter.vault();
00567 dir += "/";
00568 dir += config.timestamp().str();
00569 dir += "/";
00570 dir += config.jobs()[0].generate_archive_path(check_cwd);
00571 adir[adirc++] = dir;
00572
00573
00574
00575 subdir.path(dir);
00576 if (subdir.size() == 0) {
00577 std::string filename;
00578 std::string line;
00579 std::ifstream in;
00580 bool found_usage_error = false;
00581 char line_cstr[2048] = { 0 };
00582 int c;
00583
00584 filename = "./test-rvm.dir/log.dir/";
00585 filename += config.timestamp().str();
00586 filename += ".log";
00587 in.open(filename.c_str());
00588 assert(in.is_open());
00589 while (in.getline(line_cstr,2048)) {
00590 line = line_cstr;
00591 if (line.find("Rsync exit code: [1]") != std::string::npos)
00592 found_usage_error = true;
00593 for (c = 0; c < 2048; line_cstr[c++] = 0);
00594 }
00595 in.close();
00596
00597 if (found_usage_error) {
00598 std::cerr
00599 << "*** NOTICE: One test has failed, the test that uses rsync with"
00600 << std::endl
00601 << " the --hard-links and --link-dest command line"
00602 << std::endl
00603 << " options. Rsync reported a syntax or usage error,"
00604 << std::endl
00605 << " which may indicate that this version of rsync is"
00606 << std::endl
00607 << " old enough to not have these options."
00608 << std::endl
00609 << std::endl
00610 << " In order to be able to hard-link files that have"
00611 << std::endl
00612 << " not changed from one archive to the next, you"
00613 << std::endl
00614 << " will have to upgrade rsync."
00615 << std::endl
00616 ;
00617 }
00618 assert(found_usage_error);
00619 }
00620 else {
00621 assert(find(subdir.begin(), subdir.end(), "AUTHORS") != subdir.end());
00622 assert(find(subdir.begin(), subdir.end(), "COPYING") != subdir.end());
00623 assert(find(subdir.begin(), subdir.end(), "ChangeLog") != subdir.end());
00624 assert(find(subdir.begin(), subdir.end(), "INSTALL") != subdir.end());
00625 assert(find(subdir.begin(), subdir.end(), "Makefile") != subdir.end());
00626 assert(find(subdir.begin(), subdir.end(), "Makefile.in") != subdir.end());
00627 assert(find(subdir.begin(), subdir.end(), "README") != subdir.end());
00628 assert(find(subdir.begin(), subdir.end(), "archiver.cc") != subdir.end());
00629 assert(find(subdir.begin(), subdir.end(), "archiver.h") != subdir.end());
00630 assert(find(subdir.begin(), subdir.end(), "config.h") != subdir.end());
00631 assert(find(subdir.begin(), subdir.end(), "config.h.in") != subdir.end());
00632 assert(find(subdir.begin(), subdir.end(), "configure") != subdir.end());
00633 assert(find(subdir.begin(), subdir.end(), "doxygen.conf") != subdir.end());
00634 assert(find(subdir.begin(), subdir.end(), "error.cc") != subdir.end());
00635 assert(find(subdir.begin(), subdir.end(), "error.h") != subdir.end());
00636 assert(find(subdir.begin(), subdir.end(), "estring.cc") != subdir.end());
00637 assert(find(subdir.begin(), subdir.end(), "estring.h") != subdir.end());
00638 assert(find(subdir.begin(), subdir.end(), "exec.cc") != subdir.end());
00639 assert(find(subdir.begin(), subdir.end(), "exec.h") != subdir.end());
00640 assert(find(subdir.begin(), subdir.end(), "fs.cc") != subdir.end());
00641 assert(find(subdir.begin(), subdir.end(), "fs.h") != subdir.end());
00642 assert(find(subdir.begin(), subdir.end(), "help.cc") != subdir.end());
00643 assert(find(subdir.begin(), subdir.end(), "help.h") != subdir.end());
00644 assert(find(subdir.begin(), subdir.end(), "logger.cc") != subdir.end());
00645 assert(find(subdir.begin(), subdir.end(), "logger.h") != subdir.end());
00646 assert(find(subdir.begin(), subdir.end(), "make-test-fs-cc") != subdir.end());
00647 assert(find(subdir.begin(), subdir.end(), "rconfig.cc") != subdir.end());
00648 assert(find(subdir.begin(), subdir.end(), "rconfig.h") != subdir.end());
00649 assert(find(subdir.begin(), subdir.end(), "rmath.h") != subdir.end());
00650 assert(find(subdir.begin(), subdir.end(), "rvm.cc") != subdir.end());
00651 assert(find(subdir.begin(), subdir.end(), "rvm.1") != subdir.end());
00652 assert(find(subdir.begin(), subdir.end(), "rvm.1.in") != subdir.end());
00653 assert(find(subdir.begin(), subdir.end(), "test-rvm.cc") != subdir.end());
00654 assert(find(subdir.begin(), subdir.end(), "test-error.cc") != subdir.end());
00655 assert(find(subdir.begin(), subdir.end(), "test-estring.cc") != subdir.end());
00656 assert(find(subdir.begin(), subdir.end(), "test-exec.cc") != subdir.end());
00657 assert(find(subdir.begin(), subdir.end(), "test-fs-cwd.cc") != subdir.end());
00658 assert(find(subdir.begin(), subdir.end(), "test-fs.cc") != subdir.end());
00659
00660 assert(find(subdir.begin(), subdir.end(), "test-logger.cc") != subdir.end());
00661
00662 assert(find(subdir.begin(), subdir.end(), "test-rmath.cc") != subdir.end());
00663 assert(find(subdir.begin(), subdir.end(), "test-strfmt.cc") != subdir.end());
00664 assert(find(subdir.begin(), subdir.end(), "test-timer.cc") != subdir.end());
00665 assert(find(subdir.begin(), subdir.end(), "test-tstamp.cc") != subdir.end());
00666 assert(find(subdir.begin(), subdir.end(), "test-types.cc") != subdir.end());
00667 assert(find(subdir.begin(), subdir.end(), "timer.cc") != subdir.end());
00668 assert(find(subdir.begin(), subdir.end(), "timer.h") != subdir.end());
00669 assert(find(subdir.begin(), subdir.end(), "tstamp.cc") != subdir.end());
00670 assert(find(subdir.begin(), subdir.end(), "tstamp.h") != subdir.end());
00671 assert(find(subdir.begin(), subdir.end(), "types.h") != subdir.end());
00672 assert(find(subdir.begin(), subdir.end(), "vaulter.cc") != subdir.end());
00673 assert(find(subdir.begin(), subdir.end(), "vaulter.h") != subdir.end());
00674
00675 assert(test_inodes(adir[0], adir[3], "AUTHORS"));
00676 }
00677
00678
00679 assert(
00680 exists(
00681 std::string("./test-rvm.dir/catalog.dir/")+config.timestamp().str()
00682 )
00683 );
00684 }
00685 catch(error e) {
00686 ERR_OUT(e);
00687 thrown = true;
00688 }
00689 catch(...) {
00690 ERR_OUT(err_unknown);
00691 assert(0);
00692 }
00693 assert(!thrown);
00694 }
00695 }
00696
00697 int main(int argc, char *argv[])
00698 {
00699 cleanup();
00700 setup();
00701 try {
00702 test_rvm();
00703 }
00704 catch(error e) {
00705 std::cerr << e;
00706 assert(0);
00707 }
00708 catch(...) {
00709 std::cerr << err_unknown;
00710 assert(0);
00711 }
00712 cleanup();
00713 return(0);
00714 }
00715