rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test-rconfig-049.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-13.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.default_job().rsync_behavior.map_value().size() == 0);
50  assert(config.default_job().paths.size() == 1);
51  assert(config.default_job().paths[0] == "/var/spool");
52  assert(config.jobs().size() == 2);
53  assert(config.jobs()[0].rsync_behavior.map_value().size() == 0);
54  assert(config.jobs()[0].paths.size() == 1);
55  assert(config.jobs()[0].paths[0] == "/var/spool");
56  assert(config.jobs()[1].rsync_behavior.map_value().size() == 0);
57  assert(config.jobs()[1].paths.size() == 1);
58  assert(config.jobs()[1].paths[0] == "/etc");
59 }
60 
61 int main(int argc, char const * argv[])
62 {
63  cleanup();
64  setup();
65  try {
66  test();
67  }
68  catch(error e) {
69  std::cerr << e;
70  assert(0);
71  }
72  catch(...) {
73  std::cerr << err_unknown;
74  assert(0);
75  }
76  cleanup();
77  return(0);
78 }
79 
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
const value_type default_value(void) const
Return the default action.
Definition: rconfig.cc:543
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
class rsync_behavior rsync_behavior
Definition: rconfig.h:174
const map_type & map_value(void) const
Return an std::map of exit codes to actions.
Definition: rconfig.cc:549
void default_logdir(const std::string &a_path)
Return the default log-dir.
Definition: rconfig.cc:1499
#define err_unknown
Definition: error.h:114
void test(void)
An error class.
Definition: error.h:72
#define ERR_OUT(e)
configuration_manager config
The global configuration manager instance.
Definition: rconfig.cc:3364
int main(int argc, char const *argv[])
const job & default_job(void) const
Return the default job configuration.
Definition: rconfig.cc:1658
const jobs_type & jobs(void) const
Return a list of jobs.
Definition: rconfig.cc:1667
paths_type paths
Definition: rconfig.h:173