rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test-rconfig-051.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/global-vault-2.dir/file-1.conf");
35  config.default_logdir("./test-rconfig.dir/log.dir");
36  std::cerr << std::endl;
37  std::cerr << " You should see an error message here:" << std::endl;
38  std::cerr << "-----------------------------------------" << std::endl;
39  try {
40  config.init(argc, argv);
41  }
42  catch(error e) {
43  ERR_OUT(e);
44  assert(0);
45  // thrown = true;
46  }
47  catch(...) {
48  assert(0);
49  }
50  std::cerr << "-----------------------------------------" << std::endl;
51  std::cerr << std::endl;
52  // assert(thrown);
53  assert(config.vaults().size() == 3);
54  assert(config.vaults()[0]
55  == "./test-rconfig.dir/global-vault-2.dir/vaults/1");
56  assert(config.vaults()[1]
57  == "./test-rconfig.dir/global-vault-2.dir/vaults/3");
58  assert(config.vaults()[2]
59  == "./test-rconfig.dir/global-vault-2.dir/vaults/4");
60 }
61 
62 int main(int argc, char const * argv[])
63 {
64  cleanup();
65  setup();
66  try {
67  test();
68  }
69  catch(error e) {
70  std::cerr << e;
71  assert(0);
72  }
73  catch(...) {
74  std::cerr << err_unknown;
75  assert(0);
76  }
77  cleanup();
78  return(0);
79 }
80 
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
const vaults_type & vaults(void) const
Return the vaults.
Definition: rconfig.cc:1604
#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
#define ERR_OUT(e)