rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test-rconfig-050.cc
Go to the documentation of this file.
1 #include "config.h"
2 
3 #include <iostream>
4 #include <string>
5 #include <cassert>
6 
7 #ifdef HAVE_UNISTD_H
8 #include <unistd.h>
9 #endif
10 
11 #include <errno.h>
12 
13 #include "asserts.h"
14 #include "types.h"
15 #include "error.h"
16 #include "estring.h"
17 #include "fs.h"
18 #include "tstamp.h"
19 #include "rconfig.h"
20 #include "test-rconfig-setup.h"
21 
22 #define ERR_OUT(e) std::cerr << e;
23 // #define ERR_OUT(e)
24 
25 void test(void)
26 {
27  char const * argv[256] = { 0 };
28  int argc = 0;
29  bool thrown = false;
30 
31  argv[argc++] = "<program>";
32  argv[argc++] = "--archive";
33 
34  config.default_file("./test-rconfig.dir/job.dir/file-14.conf");
35  config.default_logdir("./test-rconfig.dir/log.dir");
36  try {
37  config.init(argc, argv);
38  }
39  catch(error e) {
40  ERR_OUT(e);
41  thrown = true;
42  }
43  catch(...) {
44  assert(0);
45  }
46  assert(!thrown);
47  assert(config.jobs().size() == 6);
48  assert(config.jobs()[0].generate_source_path("/var/spool/") == "/var/spool/");
49  assert(config.jobs()[1].generate_source_path("/var/spool/") == "/var/spool/");
50  assert(config.jobs()[2].generate_source_path("/var/spool/") == "remote-default:/var/spool/");
51  assert(config.jobs()[3].generate_source_path("/var/spool/") == "remote-port:/var/spool/");
52  assert(config.jobs()[4].generate_source_path("/var/spool/") == "rsync://server-default/var/spool/");
53  assert(config.jobs()[5].generate_source_path("/var/spool/") == "rsync://server-port:1234/var/spool/");
54 }
55 
56 int main(int argc, char const * argv[])
57 {
58  cleanup();
59  setup();
60  try {
61  test();
62  }
63  catch(error e) {
64  std::cerr << e;
65  assert(0);
66  }
67  catch(...) {
68  std::cerr << err_unknown;
69  assert(0);
70  }
71  cleanup();
72  return(0);
73 }
74 
void init(int argc, char const *argv[])
Initialize the configuration manager from rvm's command line options.
Definition: rconfig.cc:1218
Basic types definitions and templates.
void setup(void)
Definition: test-logger.cc:62
void test(void)
void default_file(const std::string &a_path)
Set the default configuration filename.
Definition: rconfig.cc:1484
void cleanup(void)
Definition: test-fs.cc:63
void default_logdir(const std::string &a_path)
Return the default log-dir.
Definition: rconfig.cc:1499
#define err_unknown
Definition: error.h:114
An error class.
Definition: error.h:72
int main(int argc, char const *argv[])
configuration_manager config
The global configuration manager instance.
Definition: rconfig.cc:3364
const jobs_type & jobs(void) const
Return a list of jobs.
Definition: rconfig.cc:1667
#define ERR_OUT(e)