Skip to content

Commit

Permalink
swap compare()
Browse files Browse the repository at this point in the history
  • Loading branch information
osalyk committed Jul 31, 2024
1 parent b636a12 commit 6a39c19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/tests/ras/utils/inject_manager/inject_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ const std::vector<Dimm> InjectManager::GetDimmsToInject(
}

bool InjectManager::CheckUSCDiff(
const std::vector<DimmNamespace> &dimm_namespaces,
std::function<bool(int, int)> compare) const {
const std::vector<DimmNamespace> &dimm_namespaces) const {
for (const auto &dn : dimm_namespaces) {
for (const auto &d : GetDimmsToInject(dn)) {
int recorded_usc = ReadRecordedUSC(test_dir_ + d.GetUid());
Expand All @@ -118,7 +117,7 @@ bool InjectManager::CheckUSCDiff(
return false;
}

if (!compare(recorded_usc, d.GetShutdownCount())) {
if (recorded_usc != d.GetShutdownCount()) {
std::cerr << "NVDIMM: " << d.GetUid()
<< " (test dir: " << dn.GetTestDir()
<< "). Current USC: " << d.GetShutdownCount()
Expand Down Expand Up @@ -151,7 +150,7 @@ bool InjectManager::IsLastShutdownUnsafe(
return cur > rec;
};

if (!CheckUSCDiff(dimm_namespaces, compare)) {
if (!CheckUSCDiff(dimm_namespaces)) {
std::cerr << "Unexpected safe shutdown of NVDIMM" << std::endl;
return false;
}
Expand All @@ -164,7 +163,7 @@ bool InjectManager::IsLastShutdownSafe(
return cur == rec;
};

if (!CheckUSCDiff(dimm_namespaces, compare)) {
if (!CheckUSCDiff(dimm_namespaces)) {
std::cerr << "Unexpected unsafe shutdown of NVDIMM" << std::endl;
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/tests/ras/utils/inject_manager/inject_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class InjectManager {
private:
std::string test_dir_;
InjectPolicy policy_;
bool CheckUSCDiff(const std::vector<DimmNamespace> &dimm_namespaces,
std::function<bool(int, int)> compare) const;
bool CheckUSCDiff(const std::vector<DimmNamespace> &dimm_namespaces) const;

int ReadRecordedUSC(const std::string &usc_file_path) const;

Expand Down

0 comments on commit 6a39c19

Please sign in to comment.