00001 #include "config.h" 00002 00003 #include <iostream> 00004 #include <fstream> 00005 #include <iomanip> 00006 #include <string> 00007 #include <cassert> 00008 00009 #include "asserts.h" 00010 #include "error.h" 00011 #include "fs.h" 00012 #include "vaulter.h" 00013 00014 bool make_dir(const std::string& path) 00015 { 00016 bool thrown; 00017 00018 thrown = false; 00019 try { 00020 mk_dir(path); 00021 } 00022 catch(...) { 00023 thrown = true; 00024 } 00025 00026 return(thrown == false); 00027 } 00028 00029 void setup(void) 00030 { 00031 std::ofstream out; 00032 00033 assert(make_dir("./test-vaulter.dir")); 00034 assert(make_dir("./test-vaulter.dir/group-1")); 00035 assert(make_dir("./test-vaulter.dir/group-1/vault-1")); 00036 assert(make_dir("./test-vaulter.dir/group-1/vault-2")); 00037 assert(make_dir("./test-vaulter.dir/group-1/vault-3")); 00038 assert(make_dir("./test-vaulter.dir/group-1/vault-1/2003-09-15")); 00039 assert(make_dir("./test-vaulter.dir/group-1/vault-2/2003-09-16")); 00040 assert(make_dir("./test-vaulter.dir/group-1/vault-3/2003-09-17")); 00041 assert(make_dir("./test-vaulter.dir/group-1/vault-1/2003-09-18.incomplete")); 00042 assert(make_dir("./test-vaulter.dir/group-1/vault-1/2003-09-18.corrupt")); 00043 assert(make_dir("./test-vaulter.dir/group-1/vault-2/2003-09-19")); 00044 assert(make_dir("./test-vaulter.dir/group-1/vault-3/2003-09-20")); 00045 assert(make_dir("./test-vaulter.dir/group-1/vault-1/2003-09-21")); 00046 assert(make_dir("./test-vaulter.dir/group-1/vault-2/2003-09-22")); 00047 assert(make_dir("./test-vaulter.dir/group-2")); 00048 assert(make_dir("./test-vaulter.dir/group-2/vault-1")); 00049 assert(make_dir("./test-vaulter.dir/group-2/vault-2")); 00050 assert(make_dir("./test-vaulter.dir/group-2/vault-3")); 00051 assert(make_dir("./test-vaulter.dir/group-2/vault-1/2003-09-15")); 00052 assert(make_dir("./test-vaulter.dir/group-2/vault-2/2003-09-16")); 00053 assert(make_dir("./test-vaulter.dir/group-2/vault-3/2003-09-17")); 00054 assert(make_dir("./test-vaulter.dir/group-2/vault-1/2003-09-18")); 00055 assert(make_dir("./test-vaulter.dir/group-2/vault-2/2003-09-19")); 00056 assert(make_dir("./test-vaulter.dir/group-2/vault-3/2003-09-20")); 00057 assert(make_dir("./test-vaulter.dir/group-2/vault-1/2003-09-21")); 00058 assert(make_dir("./test-vaulter.dir/log.dir")); 00059 assert(make_dir("./test-vaulter.dir/log.dir/log-1.dir")); 00060 assert(make_dir("./test-vaulter.dir/log.dir/log-2.dir")); 00061 00062 out.open("./test-vaulter.dir/file-1.conf"); 00063 assert(out.is_open()); 00064 out << "log-dir ./test-vaulter.dir/log.dir/log-1.dir" << std::endl; 00065 out << "vault ./test-vaulter.dir/group-1/*" << std::endl; 00066 out << "vault-selection-behavior round-robin" << std::endl; 00067 out.close(); 00068 } 00069 00070 void cleanup(void) 00071 { 00072 assert(system("rm -fr ./test-vaulter.dir") == 0); 00073 } 00074