Skip to content

Commit

Permalink
GH-458: Extend search for DDS.cfg path
Browse files Browse the repository at this point in the history
Added: $DDS_CONFIG and "/etc/dds/DDS.cfg" are added to the DDS config search paths. (GH-458)
  • Loading branch information
AnarManafov committed Aug 30, 2022
1 parent 4d45466 commit d1cc0ca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Added: every DDS module logs now its pid, group id and parent pid. (GH-403)
Added: Support for Task Assets. (GH-406)
Added: Cancel running and pending SLURM jobs on DDS shutdown. (GH-429)
Added: Support for Apple's arm64 architecture. (GH-393)
Added: $DDS_CONFIG and "/etc/dds/DDS.cfg" are added to the DDS config search paths. (GH-458)

### dds-agent
Fixed: Address potential crash in the external process termination routines.
Expand Down
2 changes: 1 addition & 1 deletion dds-misc-lib/src/SSHConfigFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
//=============================================================================
// std
#include <fstream>
#include <iomanip>
#include <iostream>
#include <fstream>
// boost
#include <boost/tokenizer.hpp>
// Misc
Expand Down
3 changes: 2 additions & 1 deletion dds-user-defaults/src/UserDefaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ const SDDSUserDefaultsOptions_t CUserDefaults::getOptions() const
string CUserDefaults::currentUDFile()
{
CFindCfgFile<string> cfg;
cfg.SetOrder("$HOME/.DDS/DDS.cfg")("$DDS_LOCATION/etc/DDS.cfg")("$DDS_LOCATION/DDS.cfg");
cfg.SetOrder("$DDS_CONFIG")("$HOME/.DDS/DDS.cfg")("$DDS_LOCATION/etc/DDS.cfg")("$DDS_LOCATION/DDS.cfg")(
"/etc/dds/DDS.cfg");
string val;
cfg.GetCfg(&val);

Expand Down
22 changes: 22 additions & 0 deletions dds-user-defaults/tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
// STD
#include <fstream>
// BOOST
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
// DDS
#include "MiscUtils.h"
#include "UserDefaults.h"

using namespace std;
using namespace dds::user_defaults_api;
namespace fs = boost::filesystem;

BOOST_AUTO_TEST_SUITE(Test_UserDefaults);

Expand Down Expand Up @@ -59,4 +62,23 @@ BOOST_AUTO_TEST_CASE(Test_UserDefaults_DefaultSID_FromSIDFile)
}*/
}

BOOST_AUTO_TEST_CASE(Test_UserDefaults_CustomCfgPath)
{
fs::path pathCfg{ fs::temp_directory_path() / fs::unique_path() };
fs::create_directories(pathCfg);
pathCfg /= "dds_test.cfg";

ofstream f(pathCfg.string());
BOOST_TEST(f.is_open());
f << "[server]\n"
<< "idle_time=10\n";
f.close();

dds::misc::auto_setenv env1("DDS_CONFIG", pathCfg.string());
CUserDefaults::instance().reinit(boost::uuids::string_generator()(CUserDefaults::instance().getDefaultSID()),
CUserDefaults::instance().currentUDFile());
fs::remove(pathCfg);
BOOST_TEST(CUserDefaults::instance().getValueForKey("server.idle_time") == "10");
}

BOOST_AUTO_TEST_SUITE_END();

0 comments on commit d1cc0ca

Please sign in to comment.