Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from bareos/dev/franku/master/show_cmd_resour…
…ces_test dird: show command: add test to compare lists of resources types
- Loading branch information
Showing
4 changed files
with
139 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
BAREOS® - Backup Archiving REcovery Open Sourced | ||
Copyright (C) 2000-2012 Free Software Foundation Europe e.V. | ||
Copyright (C) 2011-2016 Planets Communications B.V. | ||
Copyright (C) 2013-2019 Bareos GmbH & Co. KG | ||
This program is Free Software; you can redistribute it and/or | ||
modify it under the terms of version three of the GNU Affero General Public | ||
License as published by the Free Software Foundation and included | ||
in the file LICENSE. | ||
This program is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
02110-1301, USA. | ||
*/ | ||
|
||
#ifndef BAREOS_SRC_DIRD_SHOW_CMD_AVAILABLE_RESOURCES_H_ | ||
#define BAREOS_SRC_DIRD_SHOW_CMD_AVAILABLE_RESOURCES_H_ | ||
|
||
#include <include/bareos.h> | ||
#include "dird/dird_conf.h" | ||
|
||
namespace directordaemon { | ||
|
||
static struct { | ||
const char* res_name; | ||
int type; | ||
} show_cmd_available_resources[] = {{NT_("directors"), R_DIRECTOR}, | ||
{NT_("clients"), R_CLIENT}, | ||
{NT_("counters"), R_COUNTER}, | ||
{NT_("devices"), R_DEVICE}, | ||
{NT_("jobs"), R_JOB}, | ||
{NT_("jobdefs"), R_JOBDEFS}, | ||
{NT_("storages"), R_STORAGE}, | ||
{NT_("catalogs"), R_CATALOG}, | ||
{NT_("schedules"), R_SCHEDULE}, | ||
{NT_("filesets"), R_FILESET}, | ||
{NT_("pools"), R_POOL}, | ||
{NT_("messages"), R_MSGS}, | ||
{NT_("profiles"), R_PROFILE}, | ||
{NT_("consoles"), R_CONSOLE}, | ||
{NT_("users"), R_USER}, | ||
{NT_("all"), -1}, | ||
{NT_("help"), -2}, | ||
{NULL, 0}}; | ||
|
||
|
||
} // namespace directordaemon | ||
|
||
#endif // BAREOS_SRC_DIRD_SHOW_CMD_AVAILABLE_RESOURCES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/tests/show_cmd_available_resources_equals_config_resources.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
BAREOS® - Backup Archiving REcovery Open Sourced | ||
Copyright (C) 2019-2019 Bareos GmbH & Co. KG | ||
This program is Free Software; you can redistribute it and/or | ||
modify it under the terms of version three of the GNU Affero General Public | ||
License as published by the Free Software Foundation, which is | ||
listed in the file LICENSE. | ||
This program is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
02110-1301, USA. | ||
*/ | ||
|
||
#include "gtest/gtest.h" | ||
#include "include/bareos.h" | ||
#include "lib/parse_conf.h" | ||
#include "dird/dird_globals.h" | ||
#include "dird/dird_conf.h" | ||
#include "dird/ua_output.h" | ||
#include "dird/show_cmd_available_resources.h" | ||
|
||
#include <set> | ||
|
||
using namespace directordaemon; | ||
|
||
TEST(available_resources_equals_config_resources, check_contents) | ||
{ | ||
std::unique_ptr<ConfigurationParser> my_config( | ||
InitDirConfig(nullptr, M_ERROR_TERM)); | ||
|
||
std::set<uint32_t> set_of_config_resources; | ||
|
||
for (int i = 0; my_config->resources_[i].name; i++) { | ||
set_of_config_resources.insert(my_config->resources_[i].rcode); | ||
} | ||
|
||
std::set<uint32_t> set_of_show_cmd_resources; | ||
|
||
for (int i = 0; show_cmd_available_resources[i].res_name; i++) { | ||
if (show_cmd_available_resources[i].type > 0) { | ||
set_of_show_cmd_resources.insert(show_cmd_available_resources[i].type); | ||
} | ||
} | ||
|
||
EXPECT_EQ(set_of_config_resources, set_of_show_cmd_resources) | ||
<< "The list of resources for the show command does not match the list " | ||
"of configured resources in dird_conf.cc."; | ||
} |