1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2019-2019 Bareos GmbH & Co. KG
5 
6    This program is Free Software; you can redistribute it and/or
7    modify it under the terms of version three of the GNU Affero General Public
8    License as published by the Free Software Foundation and included
9    in the file LICENSE.
10 
11    This program is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14    Affero General Public License for more details.
15 
16    You should have received a copy of the GNU Affero General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19    02110-1301, USA.
20 */
21 #if defined(HAVE_MINGW)
22 #include "include/bareos.h"
23 #include "gtest/gtest.h"
24 #else
25 #include "gtest/gtest.h"
26 #include "include/bareos.h"
27 #endif
28 
29 #include "lib/parse_conf.h"
30 #include "dird/dird_globals.h"
31 #include "dird/dird_conf.h"
32 
33 namespace directordaemon {
34 
TEST(ConfigParser_Dir,bareos_configparser_tests)35 TEST(ConfigParser_Dir, bareos_configparser_tests)
36 {
37   OSDependentInit();
38   InitMsg(NULL, NULL); /* initialize message handler */
39 
40   std::string path_to_config_file = std::string(
41       RELATIVE_PROJECT_SOURCE_DIR "/configs/bareos-configparser-tests");
42   my_config = InitDirConfig(path_to_config_file.c_str(), M_ERROR_TERM);
43   my_config->ParseConfig();
44 
45   my_config->DumpResources(PrintMessage, NULL);
46 
47   delete my_config;
48 
49   TermMsg();         /* Terminate message handler */
50   CloseMemoryPool(); /* release free memory in pool */
51 }
52 
TEST(ConfigParser_Dir,runscript_test)53 TEST(ConfigParser_Dir, runscript_test)
54 {
55   OSDependentInit();
56   InitMsg(NULL, NULL); /* initialize message handler */
57 
58   std::string path_to_config_file = std::string(
59       RELATIVE_PROJECT_SOURCE_DIR "/configs/runscript-tests/bareos-dir.conf");
60   my_config = InitDirConfig(path_to_config_file.c_str(), M_ERROR_TERM);
61   my_config->ParseConfig();
62 
63   my_config->DumpResources(PrintMessage, NULL);
64 
65   delete my_config;
66 
67   TermMsg();         /* Terminate message handler */
68   CloseMemoryPool(); /* release free memory in pool */
69 }
70 
71 }  // namespace directordaemon
72