28 #define TEST(code,test) \
54 return(thrown ==
false);
59 assert(system(
"rm -fr ./test-logger.dir") == 0);
66 assert(
make_dir(
"./test-logger.dir"));
67 assert(
make_dir(
"./test-logger.dir/log.dir"));
68 assert(
make_dir(
"./test-logger.dir/vault.dir"));
70 out.open(
"./test-logger.dir/rvm.conf");
71 assert(out.is_open());
72 out <<
"log-dir ./test-logger.dir/log.dir" << std::endl;
73 out <<
"vault ./test-logger.dir/vault.dir" << std::endl;
74 out <<
"<job>" << std::endl;
75 out <<
" archive-path pathname" << std::endl;
76 out <<
" rsync-connection-type local" << std::endl;
77 out <<
" path /var/spool" << std::endl;
78 out <<
"</job>" << std::endl;
82 const bool same(std::string s1, std::string s2)
84 s1[11] =
'x'; s2[11] =
'x';
85 s1[12] =
'x'; s2[12] =
'x';
86 s1[14] =
'x'; s2[14] =
'x';
87 s1[15] =
'x'; s2[15] =
'x';
88 s1[17] =
'x'; s2[17] =
'x';
89 s1[18] =
'x'; s2[18] =
'x';
99 char const * argv[256] = { 0 };
106 assert(e.num() == 0);
107 assert(!e.internal());
108 assert(e.size() == 1);
109 assert(e[0].what() ==
"Configuration manager is not initialized");
113 argv[argc++] =
"<program>";
114 argv[argc++] =
"--archive";
138 std::string filename;
142 filename =
"./test-logger.dir/log.dir/";
145 in.open(filename.c_str());
146 assert(in.is_open());
150 str +=
"Rsync Vault Manager - ";
152 assert(
same(str,line));
158 str +=
"Testing... 1... 2... 3... ";
159 assert(
same(str,line));
166 assert(
same(str,line));
173 assert(
same(str,line));
180 assert(
same(str,line));
187 assert(
same(str,line));
193 str +=
" Testing...";
194 assert(
same(str,line));
201 assert(
same(str,line));
208 assert(
same(str,line));
215 assert(
same(str,line));
222 str +=
estring(static_cast<unsigned long>(
pid()));
223 assert(
same(str,line));
228 int main(
int argc,
char const * argv[])
void init(int argc, char const *argv[])
Initialize the configuration manager from rvm's command line options.
const pid_t pid(void)
Return the PID of this process.
void mk_dir(const std::string &a_path)
Create a directory.
log_manager logger
The global log manager.
Basic types definitions and templates.
An extended string class.
void default_file(const std::string &a_path)
Set the default configuration filename.
void write(const std::string &a_str, const uint16 a_indention=0, const configuration_manager::logging_type a_logging_level=configuration_manager::logging_manager, const pid_t a_pid=pid())
Write a string to the log file.
const class timestamp & timestamp(void) const
Return the timestamp of this instance of rvm.
std::string stamp(const pid_t a_pid, const int a_indention)
Generate a timstamp string.
void clear(void)
Clear the log manager.
void init(void)
Initialize the log manager.
configuration_manager config
The global configuration manager instance.
const bool same(std::string s1, std::string s2)
int main(int argc, char const *argv[])
bool make_dir(const std::string &path)
const std::string str(void) const
Generate a string.