Skip to content

Commit

Permalink
Resolved build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwangmu Lee authored and Madeeks committed Sep 4, 2024
1 parent 49cbcf2 commit 71f4a97
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/cli/CommandRun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class CommandRun : public Command {
auto parser = libsarus::DeviceParser{conf->getRootfsDirectory(), conf->userIdentity};
auto siteDevices = conf->commandRun.deviceMounts;
for (const auto& requestString : deviceMounts) {
auto deviceMount = std::move(parser.parseDeviceRequest(requestString));
auto deviceMount = parser.parseDeviceRequest(requestString);
auto previousSiteDevice = findMatchingSiteDevice(deviceMount, siteDevices);
if (previousSiteDevice) {
auto message = boost::format("Device %s already added by the system administrator at container path %s with access %s. "
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/mpi/MpiHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void MpiHook::injectHostLibraries(const std::vector<SharedLibrary>& hostLibs,

AbiCheckerFactory checkerFactory;
for(const auto& lib : hostLibs) {
injectHostLibrary(lib, hostToContainerLibs, std::move(checkerFactory.create(checkerType)));
injectHostLibrary(lib, hostToContainerLibs, checkerFactory.create(checkerType));
}

log("Successfully injected host's shared libs", libsarus::LogLevel::INFO);
Expand Down
26 changes: 13 additions & 13 deletions src/hooks/mpi/test/test_SharedLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,51 +117,51 @@ TEST(SharedLibraryTestGroup, bestAbiMatch) {
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.1"}, SharedLibrary{"/lib/libfoo.so"}, SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.3"}};
auto best = sl2.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2");
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2"));
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.2.4"}, SharedLibrary{"/lib/libfoo.so.2.3.4"}, SharedLibrary{"/lib/libfoo.so.2.3"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.4");
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.4"));
}

// newest older
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.2.3.3"}, SharedLibrary{"/lib/libfoo.so.2.3.2"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.3");
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.3"));
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2.1"}, SharedLibrary{"/lib/libfoo.so.2.2"}, SharedLibrary{"/lib/libfoo.so.2.4"}};
auto best = sl23.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.2");
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.2"));
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2.1.7"}, SharedLibrary{"/lib/libfoo.so.2.2.3"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.2.3"); // minor is more important than patch
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.2.3")); // minor is more important than patch
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2.3.3"}, SharedLibrary{"/lib/libfoo.so.2.3.6"}, SharedLibrary{"/lib/libfoo.so.2.3.5"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.6"); // don't downgrade patch
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.6")); // don't downgrade patch
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.2.3.7"}, SharedLibrary{"/lib/libfoo.so.3"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.7"); // newer patch is ok
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.7")); // newer patch is ok
}

// oldest newer
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.3"}, SharedLibrary{"/lib/libfoo.so.2.4"}, SharedLibrary{"/lib/libfoo.so.2.4.6"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.4.6");
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.4.6"));
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.5"}, SharedLibrary{"/lib/libfoo.so.4"}, SharedLibrary{"/lib/libfoo.so.3.7"}};
auto best = sl234.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.3.7");
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.3.7"));
}

// corner cases
Expand All @@ -170,22 +170,22 @@ TEST(SharedLibraryTestGroup, bestAbiMatch) {
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2"}};
auto best = sl2.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2"); // exact match with just major
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2")); // exact match with just major
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.4"}};
auto best = sl2.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.4"); // only candidate non compatible still "best"
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.4")); // only candidate non compatible still "best"
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.1"}, SharedLibrary{"/lib/libfoo.so.3"}};
auto best = sl2.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.1"); // though incompatible, still newest older
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.1")); // though incompatible, still newest older
}
{
auto candidates = std::vector<SharedLibrary>{SharedLibrary{"/lib/libfoo.so.2.10"}, SharedLibrary{"/lib/libfoo.so.2.2"}};
auto best = SharedLibrary{"/lib/libfoo.so.2.20"}.pickNewestAbiCompatibleLibrary(candidates);
CHECK_EQUAL(best.getRealName(), "libfoo.so.2.10"); // check for typical string-comparison pitfalls
CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.10")); // check for typical string-comparison pitfalls
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/hooks/ssh/test/test_SSHHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

#include <chrono>
#include <memory>
#include <signal.h>
#include <thread>
#include <sys/mount.h>
#include <sys/types.h>

#include <boost/algorithm/string.hpp>
#include <boost/filesystem/fstream.hpp>
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/signal.h>
#include <boost/regex.hpp>

#include "common/Config.hpp"
Expand Down
5 changes: 3 additions & 2 deletions src/libsarus/test/test_Flock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ TEST(FlockTestGroup, convert_write_to_read) {
TEST(FlockTestGroup, timeout_time_is_respected) {
libsarus::Flock lock{fileToLock, libsarus::Flock::Type::writeLock};

for (auto &timeout : {10, 100, 500, 1000, 2000}) {
for (auto &timeout : {100, 500, 1000, 2000}) {
auto start = std::chrono::system_clock::now();
try {
libsarus::Flock{fileToLock, libsarus::Flock::Type::writeLock, std::chrono::milliseconds{timeout}};
} catch (const libsarus::Error &) {
}
auto end = std::chrono::system_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start;
CHECK(timeout <= elapsed.count() <= 2 * timeout);
CHECK(timeout <= elapsed.count());
CHECK(elapsed.count() <= 2 * timeout);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/libsarus/test/test_HookUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ TEST(HooksUtilityTestGroup, parseStateOfContainerFromStdin) {
libsarus::filesystem::createFoldersIfNecessary(expectedBundleDir.getPath());

auto returnedBundleDir = boost::filesystem::path();
pid_t returnedPid;

aux::hook::writeOCIContainerStateToStdin(expectedBundleDir.getPath());
auto containerState = parseStateOfContainerFromStdin();
Expand Down
4 changes: 2 additions & 2 deletions src/libsarus/test/test_Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ TEST(UtilityTestGroup, setFilesystemUid) {
CHECK_EQUAL(getgid(), rootIdentity.gid);
CHECK_EQUAL(geteuid(), rootIdentity.uid);
CHECK_EQUAL(getegid(), rootIdentity.gid);
CHECK_EQUAL(setfsuid(-1), unprivilegedIdentity.uid);
CHECK_EQUAL((uid_t)setfsuid(-1), unprivilegedIdentity.uid);

// switch back to privileged fsuid
libsarus::process::setFilesystemUid(rootIdentity);
Expand All @@ -172,7 +172,7 @@ TEST(UtilityTestGroup, setFilesystemUid) {
CHECK_EQUAL(getgid(), rootIdentity.gid);
CHECK_EQUAL(geteuid(), rootIdentity.uid);
CHECK_EQUAL(getegid(), rootIdentity.gid);
CHECK_EQUAL(setfsuid(-1), rootIdentity.uid);
CHECK_EQUAL((uid_t)setfsuid(-1), rootIdentity.uid);
}

TEST(UtilityTestGroup, executeCommand) {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ std::vector<std::unique_ptr<libsarus::Mount>> generatePMIxMounts(std::shared_ptr
auto slurmJobUid = hostEnvironment.at("SLURM_JOB_UID");
auto slurmStepId = hostEnvironment.at("SLURM_STEP_ID");

if (boost::regex_match(slurmConfig, matches, boost::regex{"SlurmdSpoolDir\s*=\s(.*)"})) {
if (boost::regex_match(slurmConfig, matches, boost::regex{"SlurmdSpoolDir\\s*=\\s(.*)"})) {
utility::logMessage(boost::format("Found SlurmdSpoolDir=%s") % matches[1], libsarus::LogLevel::DEBUG);
auto slurmSpoolPath = boost::filesystem::path(matches[1]);
auto slurmPmixPath = slurmSpoolPath / (boost::format("pmix.%s.%s") % slurmJobId % slurmStepId).str();
Expand All @@ -158,7 +158,7 @@ std::vector<std::unique_ptr<libsarus::Mount>> generatePMIxMounts(std::shared_ptr
}
}

if (boost::regex_match(slurmConfig, matches, boost::regex{"TmpFS\s*=\s(.*)"})) {
if (boost::regex_match(slurmConfig, matches, boost::regex{"TmpFS\\s*=\\s(.*)"})) {
utility::logMessage(boost::format("Found Slurm TmpFS=%s") % matches[1], libsarus::LogLevel::DEBUG);
auto slurmTmpFS = boost::filesystem::path(matches[1]);
auto mountPath = slurmTmpFS / (boost::format("spmix_appdir_%s_%s.%s") % slurmJobUid % slurmJobId % slurmStepId).str();
Expand Down

0 comments on commit 71f4a97

Please sign in to comment.