Check in a clang-tidy
This should've been done when we first created the repo, but better late
than never.
Signed-off-by: Ed Tanous <edtanous@google.com>
Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: I68da1d13167ec94f9d008dea307c9f23a991d42c
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..b5f7462
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,300 @@
+Checks: '
+-*,
+boost-use-to-string,
+bugprone-argument-comment,
+bugprone-assert-side-effect,
+bugprone-bad-signal-to-kill-thread,
+bugprone-bool-pointer-implicit-conversion,
+bugprone-branch-clone,
+bugprone-copy-constructor-init,
+bugprone-dangling-handle,
+bugprone-dynamic-static-initializers,
+bugprone-exception-escape,
+bugprone-fold-init-type,
+bugprone-forward-declaration-namespace,
+bugprone-forwarding-reference-overload,
+bugprone-implicit-widening-of-multiplication-result,
+bugprone-inaccurate-erase,
+bugprone-incorrect-roundings,
+bugprone-infinite-loop,
+bugprone-integer-division,
+bugprone-lambda-function-name,
+bugprone-macro-parentheses,
+bugprone-macro-repeated-side-effects,
+bugprone-misplaced-operator-in-strlen-in-alloc,
+bugprone-misplaced-pointer-arithmetic-in-alloc,
+bugprone-misplaced-widening-cast,
+bugprone-move-forwarding-reference,
+bugprone-multiple-statement-macro,
+bugprone-narrowing-conversions,
+bugprone-no-escape,
+bugprone-not-null-terminated-result,
+bugprone-parent-virtual-call,
+bugprone-posix-return,
+bugprone-redundant-branch-condition,
+bugprone-reserved-identifier,
+bugprone-signal-handler,
+bugprone-signed-char-misuse,
+bugprone-sizeof-container,
+bugprone-sizeof-expression,
+bugprone-spuriously-wake-up-functions,
+bugprone-string-constructor,
+bugprone-string-integer-assignment,
+bugprone-string-literal-with-embedded-nul,
+bugprone-suspicious-enum-usage,
+bugprone-suspicious-include,
+bugprone-suspicious-memset-usage,
+bugprone-suspicious-missing-comma,
+bugprone-suspicious-semicolon,
+bugprone-suspicious-string-compare,
+bugprone-swapped-arguments,
+bugprone-terminating-continue,
+bugprone-throw-keyword-missing,
+bugprone-too-small-loop-variable,
+bugprone-undefined-memory-manipulation,
+bugprone-undelegated-constructor,
+bugprone-unhandled-exception-at-new,
+bugprone-unhandled-self-assignment,
+bugprone-unused-raii,
+bugprone-unused-return-value,
+bugprone-use-after-move,
+bugprone-virtual-near-miss,
+cert-con36-c,
+cert-con54-cpp,
+cert-dcl03-c,
+cert-dcl16-c,
+cert-dcl21-cpp,
+cert-dcl37-c,
+cert-dcl50-cpp,
+cert-dcl51-cpp,
+cert-dcl54-cpp,
+cert-dcl58-cpp,
+cert-dcl59-cpp,
+cert-env33-c,
+cert-err09-cpp,
+cert-err34-c,
+cert-err52-cpp,
+cert-err60-cpp,
+cert-err61-cpp,
+cert-fio38-c,
+cert-flp30-c,
+cert-mem57-cpp,
+cert-msc30-c,
+cert-msc32-c,
+cert-msc50-cpp,
+cert-msc51-cpp,
+cert-oop11-cpp,
+cert-oop54-cpp,
+cert-oop57-cpp,
+cert-oop58-cpp,
+cert-pos44-c,
+cert-pos47-c,
+cert-sig30-c,
+cert-str34-c,
+clang-analyzer-apiModeling.StdCLibraryFunctions,
+clang-analyzer-apiModeling.TrustNonnull,
+clang-analyzer-apiModeling.google.GTest,
+clang-analyzer-apiModeling.llvm.CastValue,
+clang-analyzer-apiModeling.llvm.ReturnValue,
+clang-analyzer-core.CallAndMessage,
+clang-analyzer-core.CallAndMessageModeling,
+clang-analyzer-core.DivideZero,
+clang-analyzer-core.DynamicTypePropagation,
+clang-analyzer-core.NonNullParamChecker,
+clang-analyzer-core.NonnilStringConstants,
+clang-analyzer-core.NullDereference,
+clang-analyzer-core.StackAddrEscapeBase,
+clang-analyzer-core.StackAddressEscape,
+clang-analyzer-core.UndefinedBinaryOperatorResult,
+clang-analyzer-core.VLASize,
+clang-analyzer-core.builtin.BuiltinFunctions,
+clang-analyzer-core.builtin.NoReturnFunctions,
+clang-analyzer-core.uninitialized.ArraySubscript,
+clang-analyzer-core.uninitialized.Assign,
+clang-analyzer-core.uninitialized.Branch,
+clang-analyzer-core.uninitialized.CapturedBlockVariable,
+clang-analyzer-core.uninitialized.UndefReturn,
+clang-analyzer-cplusplus.InnerPointer,
+clang-analyzer-cplusplus.Move,
+clang-analyzer-cplusplus.NewDelete,
+clang-analyzer-cplusplus.NewDeleteLeaks,
+clang-analyzer-cplusplus.PlacementNew,
+clang-analyzer-cplusplus.PureVirtualCall,
+clang-analyzer-cplusplus.SelfAssignment,
+clang-analyzer-cplusplus.SmartPtrModeling,
+clang-analyzer-cplusplus.VirtualCallModeling,
+clang-analyzer-deadcode.DeadStores,
+clang-analyzer-fuchsia.HandleChecker,
+clang-analyzer-nullability.NullPassedToNonnull,
+clang-analyzer-nullability.NullReturnedFromNonnull,
+clang-analyzer-nullability.NullabilityBase,
+clang-analyzer-nullability.NullableDereferenced,
+clang-analyzer-nullability.NullablePassedToNonnull,
+clang-analyzer-nullability.NullableReturnedFromNonnull,
+clang-analyzer-optin.cplusplus.UninitializedObject,
+clang-analyzer-optin.cplusplus.VirtualCall,
+clang-analyzer-optin.mpi.MPI-Checker,
+clang-analyzer-optin.osx.OSObjectCStyleCast,
+clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
+clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,
+clang-analyzer-optin.performance.GCDAntipattern,
+clang-analyzer-optin.performance.Padding,
+clang-analyzer-optin.portability.UnixAPI,
+clang-analyzer-osx.API,
+clang-analyzer-osx.MIG,
+clang-analyzer-osx.NSOrCFErrorDerefChecker,
+clang-analyzer-osx.NumberObjectConversion,
+clang-analyzer-osx.OSObjectRetainCount,
+clang-analyzer-osx.ObjCProperty,
+clang-analyzer-osx.SecKeychainAPI,
+clang-analyzer-osx.cocoa.AtSync,
+clang-analyzer-osx.cocoa.AutoreleaseWrite,
+clang-analyzer-osx.cocoa.ClassRelease,
+clang-analyzer-osx.cocoa.Dealloc,
+clang-analyzer-osx.cocoa.IncompatibleMethodTypes,
+clang-analyzer-osx.cocoa.Loops,
+clang-analyzer-osx.cocoa.MissingSuperCall,
+clang-analyzer-osx.cocoa.NSAutoreleasePool,
+clang-analyzer-osx.cocoa.NSError,
+clang-analyzer-osx.cocoa.NilArg,
+clang-analyzer-osx.cocoa.NonNilReturnValue,
+clang-analyzer-osx.cocoa.ObjCGenerics,
+clang-analyzer-osx.cocoa.RetainCount,
+clang-analyzer-osx.cocoa.RetainCountBase,
+clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,
+clang-analyzer-osx.cocoa.SelfInit,
+clang-analyzer-osx.cocoa.SuperDealloc,
+clang-analyzer-osx.cocoa.UnusedIvars,
+clang-analyzer-osx.cocoa.VariadicMethodTypes,
+clang-analyzer-osx.coreFoundation.CFError,
+clang-analyzer-osx.coreFoundation.CFNumber,
+clang-analyzer-osx.coreFoundation.CFRetainRelease,
+clang-analyzer-osx.coreFoundation.containers.OutOfBounds,
+clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,
+clang-analyzer-security.FloatLoopCounter,
+clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
+clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
+clang-analyzer-security.insecureAPI.UncheckedReturn,
+clang-analyzer-security.insecureAPI.bcmp,
+clang-analyzer-security.insecureAPI.bcopy,
+clang-analyzer-security.insecureAPI.bzero,
+clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
+clang-analyzer-security.insecureAPI.getpw,
+clang-analyzer-security.insecureAPI.gets,
+clang-analyzer-security.insecureAPI.mkstemp,
+clang-analyzer-security.insecureAPI.mktemp,
+clang-analyzer-security.insecureAPI.rand,
+clang-analyzer-security.insecureAPI.strcpy,
+clang-analyzer-security.insecureAPI.vfork,
+clang-analyzer-unix.API,
+clang-analyzer-unix.DynamicMemoryModeling,
+clang-analyzer-unix.Malloc,
+clang-analyzer-unix.MallocSizeof,
+clang-analyzer-unix.MismatchedDeallocator,
+clang-analyzer-unix.Vfork,
+clang-analyzer-unix.cstring.BadSizeArg,
+clang-analyzer-unix.cstring.CStringModeling,
+clang-analyzer-unix.cstring.NullArg,
+clang-analyzer-valist.CopyToSelf,
+clang-analyzer-valist.Uninitialized,
+clang-analyzer-valist.Unterminated,
+clang-analyzer-valist.ValistBase,
+clang-analyzer-webkit.NoUncountedMemberChecker,
+clang-analyzer-webkit.RefCntblBaseVirtualDtor,
+cppcoreguidelines-avoid-c-arrays,
+cppcoreguidelines-c-copy-assignment-signature,
+cppcoreguidelines-explicit-virtual-functions,
+cppcoreguidelines-init-variables,
+cppcoreguidelines-interfaces-global-init,
+cppcoreguidelines-macro-usage,
+cppcoreguidelines-narrowing-conversions,
+cppcoreguidelines-no-malloc,
+cppcoreguidelines-prefer-member-initializer,
+cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+cppcoreguidelines-pro-bounds-pointer-arithmetic,
+cppcoreguidelines-pro-type-const-cast,
+cppcoreguidelines-pro-type-cstyle-cast,
+cppcoreguidelines-pro-type-member-init,
+cppcoreguidelines-pro-type-static-cast-downcast,
+cppcoreguidelines-pro-type-union-access,
+cppcoreguidelines-pro-type-vararg,
+cppcoreguidelines-slicing,
+cppcoreguidelines-special-member-functions,
+misc-misplaced-const,
+#misc-no-recursion,
+misc-redundant-expression,
+misc-static-assert,
+misc-throw-by-value-catch-by-reference,
+misc-unconventional-assign-operator,
+misc-uniqueptr-reset-release,
+misc-unused-using-decls,
+modernize-avoid-bind,
+modernize-deprecated-headers,
+modernize-deprecated-ios-base-aliases,
+modernize-loop-convert,
+modernize-make-shared,
+modernize-make-unique,
+modernize-raw-string-literal,
+modernize-replace-auto-ptr,
+modernize-replace-random-shuffle,
+modernize-return-braced-init-list,
+modernize-shrink-to-fit,
+modernize-unary-static-assert,
+modernize-use-bool-literals,
+modernize-use-default-member-init,
+modernize-use-emplace,
+modernize-use-equals-default,
+modernize-use-equals-delete,
+modernize-use-noexcept,
+modernize-use-nullptr,
+modernize-use-override,
+modernize-use-transparent-functors,
+modernize-use-uncaught-exceptions,
+modernize-use-using,
+performance-faster-string-find,
+performance-for-range-copy,
+performance-implicit-conversion-in-loop,
+performance-inefficient-algorithm,
+performance-inefficient-string-concatenation,
+performance-inefficient-vector-operation,
+performance-move-const-arg,
+performance-move-constructor-init,
+performance-no-automatic-move,
+performance-no-int-to-ptr,
+performance-noexcept-move-constructor,
+performance-trivially-destructible,
+performance-type-promotion-in-math-fn,
+performance-unnecessary-copy-initialization,
+performance-unnecessary-value-param,
+readability-avoid-const-params-in-decls,
+readability-braces-around-statements,
+readability-const-return-type,
+readability-container-size-empty,
+readability-delete-null-pointer,
+readability-deleted-default,
+readability-else-after-return,
+readability-implicit-bool-conversion,
+readability-named-parameter,
+readability-redundant-control-flow,
+readability-redundant-declaration,
+readability-redundant-function-ptr-dereference,
+readability-redundant-member-init,
+readability-redundant-preprocessor,
+readability-redundant-smartptr-get,
+readability-redundant-string-cstr,
+readability-redundant-string-init,
+readability-static-accessed-through-instance,
+readability-identifier-naming,
+readability-uppercase-literal-suffix'
+
+WarningsAsErrors: '*'
+HeaderFilterRegex: '.*'
+CheckOptions:
+ - { key: readability-identifier-naming.ClassCase, value: CamelCase }
+ - { key: readability-identifier-naming.VariableCase, value: camelBack }
+ - { key: readability-identifier-naming.FunctionCase, value: camelBack }
+ - { key: readability-identifier-naming.ParameterCase, value: camelBack }
+ - { key: readability-identifier-naming.NamespaceCase, value: lower_case }
+ - { key: readability-identifier-naming.StructCase, value: CamelCase }
+ - { key: cppcoreguidelines-macro-usage.AllowedRegexp, value: ((ERASE_MIN_GEOMETRY)|(ERASE_MAX_GEOMETRY)) }
+
diff --git a/include/cryptsetupInterface.hpp b/include/cryptsetupInterface.hpp
index 8cc0469..49076dd 100644
--- a/include/cryptsetupInterface.hpp
+++ b/include/cryptsetupInterface.hpp
@@ -15,7 +15,12 @@
{
public:
virtual ~CryptsetupInterface() = default;
+ CryptsetupInterface() = default;
+ CryptsetupInterface(const CryptsetupInterface&) = delete;
+ CryptsetupInterface& operator=(const CryptsetupInterface&) = delete;
+ CryptsetupInterface(CryptsetupInterface&&) = delete;
+ CryptsetupInterface& operator=(CryptsetupInterface&&) = delete;
/** @brief Wrapper around crypt_format.
* @details Used for mocking purposes.
*
@@ -105,8 +110,7 @@
*
* @returns 0 on success or negative errno value otherwise.
*/
- virtual int cryptKeyslotDestroy(struct crypt_device* cd,
- const int keyslot) = 0;
+ virtual int cryptKeyslotDestroy(struct crypt_device* cd, int keyslot) = 0;
/** @breif Wapper around crypt_keyslot_max
* @details Used for mocking purposes.
@@ -138,8 +142,14 @@
class Cryptsetup : public CryptsetupInterface
{
public:
- ~Cryptsetup() = default;
+ ~Cryptsetup() override = default;
+ Cryptsetup() = default;
+ Cryptsetup(const Cryptsetup&) = delete;
+ Cryptsetup& operator=(const Cryptsetup&) = delete;
+
+ Cryptsetup(Cryptsetup&&) = delete;
+ Cryptsetup& operator=(Cryptsetup&&) = delete;
int cryptFormat(struct crypt_device* cd, const char* type,
const char* cipher, const char* cipherMode,
const char* uuid, const char* volumeKey,
@@ -222,7 +232,7 @@
*/
struct crypt_device* init(const char* device)
{
- struct crypt_device* cryptDev;
+ struct crypt_device* cryptDev = nullptr;
int retval = crypt_init(&cryptDev, device);
if (retval < 0)
{
diff --git a/include/erase.hpp b/include/erase.hpp
index 8224003..33489ea 100644
--- a/include/erase.hpp
+++ b/include/erase.hpp
@@ -14,7 +14,6 @@
*/
Erase(std::string_view inDevPath) : devPath(inDevPath)
{}
- virtual ~Erase() = default;
/** @brief finds the size of the linux block device in bytes
* @return size of a block device using the devPath
diff --git a/include/estoraged.hpp b/include/estoraged.hpp
index d77c7f9..791134d 100644
--- a/include/estoraged.hpp
+++ b/include/estoraged.hpp
@@ -26,7 +26,7 @@
/** @class eStoraged
* @brief eStoraged object to manage a LUKS encrypted storage device.
*/
-class eStoraged : eStoragedInherit
+class EStoraged : eStoragedInherit
{
public:
/** @brief Constructor for eStoraged
@@ -40,7 +40,7 @@
* @param[in] fsInterface - (optional) pointer to FilesystemInterface
* object
*/
- eStoraged(sdbusplus::bus::bus& bus, const char* path,
+ EStoraged(sdbusplus::bus::bus& bus, const char* path,
const std::string& devPath, const std::string& luksName,
std::unique_ptr<CryptsetupInterface> cryptInterface =
std::make_unique<Cryptsetup>(),
diff --git a/include/filesystemInterface.hpp b/include/filesystemInterface.hpp
index 0f276a7..12495cd 100644
--- a/include/filesystemInterface.hpp
+++ b/include/filesystemInterface.hpp
@@ -17,6 +17,13 @@
public:
virtual ~FilesystemInterface() = default;
+ FilesystemInterface() = default;
+ FilesystemInterface(const FilesystemInterface&) = delete;
+ FilesystemInterface& operator=(const FilesystemInterface&) = delete;
+
+ FilesystemInterface(FilesystemInterface&&) = delete;
+ FilesystemInterface& operator=(FilesystemInterface&&) = delete;
+
/** @brief Runs the mkfs command to create the filesystem.
* @details Used for mocking purposes.
*
@@ -86,11 +93,18 @@
class Filesystem : public FilesystemInterface
{
public:
- ~Filesystem() = default;
+ ~Filesystem() override = default;
+ Filesystem() = default;
+ Filesystem(const Filesystem&) = delete;
+ Filesystem& operator=(const Filesystem&) = delete;
+
+ Filesystem(Filesystem&&) = delete;
+ Filesystem& operator=(Filesystem&&) = delete;
int runMkfs(const std::string& logicalVolume) override
{
std::string mkfsCommand("mkfs.ext4 /dev/mapper/" + logicalVolume);
+ // calling 'system' uses a command processor //NOLINTNEXTLINE
return system(mkfsCommand.c_str());
}
diff --git a/src/erase/cryptoErase.cpp b/src/erase/cryptoErase.cpp
index d99f6bf..edc71d9 100644
--- a/src/erase/cryptoErase.cpp
+++ b/src/erase/cryptoErase.cpp
@@ -34,8 +34,7 @@
throw ResourceNotFound();
}
/* cryptLoad */
- if (cryptIface.get()->cryptLoad(cryptHandle.get(), CRYPT_LUKS2, nullptr) !=
- 0)
+ if (cryptIface->cryptLoad(cryptHandle.get(), CRYPT_LUKS2, nullptr) != 0)
{
lg2::error("Failed to load the key slots for destruction",
"REDFISH_MESSAGE_ID",
@@ -44,7 +43,7 @@
}
/* find key slots */
- int nKeySlots = cryptIface.get()->cryptKeySlotMax(CRYPT_LUKS2);
+ int nKeySlots = cryptIface->cryptKeySlotMax(CRYPT_LUKS2);
if (nKeySlots < 0)
{
lg2::error("Failed to find the max keyslots", "REDFISH_MESSAGE_ID",
@@ -64,12 +63,11 @@
for (int i = 0; i < nKeySlots; i++)
{
crypt_keyslot_info ki =
- cryptIface.get()->cryptKeySlotStatus(cryptHandle.get(), i);
+ cryptIface->cryptKeySlotStatus(cryptHandle.get(), i);
if (ki == CRYPT_SLOT_ACTIVE || ki == CRYPT_SLOT_ACTIVE_LAST)
{
- if (cryptIface.get()->cryptKeyslotDestroy(cryptHandle.get(), i) !=
- 0)
+ if (cryptIface->cryptKeyslotDestroy(cryptHandle.get(), i) != 0)
{
lg2::error(
"Estoraged erase failed to destroy keyslot, continuing",
diff --git a/src/erase/erase.cpp b/src/erase/erase.cpp
index 6cd45f2..40a954e 100644
--- a/src/erase/erase.cpp
+++ b/src/erase/erase.cpp
@@ -17,7 +17,7 @@
uint64_t Erase::findSizeOfBlockDevice()
{
ManagedFd fd;
- uint64_t bytes;
+ uint64_t bytes = 0;
try
{
// open block dev
diff --git a/src/erase/pattern.cpp b/src/erase/pattern.cpp
index 0e510a0..5563661 100644
--- a/src/erase/pattern.cpp
+++ b/src/erase/pattern.cpp
@@ -30,8 +30,11 @@
// static seed defines a fixed prng sequnce so it can be verified later,
// and validated for entropy
uint64_t currentIndex = 0;
+
+ // random number generator seeded with a constant value will
+ // generate a predictable sequence of values NOLINTNEXTLINE
std::minstd_rand0 generator(seed);
- std::array<std::byte, blockSize> randArr;
+ std::array<std::byte, blockSize> randArr{};
ManagedFd fd =
stdplus::fd::open(devPath, stdplus::fd::OpenAccess::WriteOnly);
@@ -65,9 +68,11 @@
{
uint64_t currentIndex = 0;
+ // random number generator seeded with a constant value will
+ // generate a predictable sequence of values NOLINTNEXTLINE
std::minstd_rand0 generator(seed);
- std::array<std::byte, blockSize> randArr;
- std::array<std::byte, blockSize> readArr;
+ std::array<std::byte, blockSize> randArr{};
+ std::array<std::byte, blockSize> readArr{};
ManagedFd fd =
stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
diff --git a/src/erase/verifyDriveGeometry.cpp b/src/erase/verifyDriveGeometry.cpp
index 2d223a7..446bee9 100644
--- a/src/erase/verifyDriveGeometry.cpp
+++ b/src/erase/verifyDriveGeometry.cpp
@@ -22,7 +22,7 @@
std::to_string(ERASE_MAX_GEOMETRY));
throw InternalFailure();
}
- else if (bytes < ERASE_MIN_GEOMETRY)
+ if (bytes < ERASE_MIN_GEOMETRY)
{
lg2::error(
"eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
@@ -31,12 +31,9 @@
std::to_string(bytes) + "<" + std::to_string(ERASE_MIN_GEOMETRY));
throw InternalFailure();
}
- else
- {
- lg2::info("eStorageD erase verify Geometry in range",
- "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.0.1.DriveEraseSuccess"));
- }
+
+ lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.0.1.DriveEraseSuccess"));
}
} // namespace estoraged
diff --git a/src/erase/zero.cpp b/src/erase/zero.cpp
index 2c0d615..2c5a6f5 100644
--- a/src/erase/zero.cpp
+++ b/src/erase/zero.cpp
@@ -51,7 +51,7 @@
stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
uint64_t currentIndex = 0;
- std::array<std::byte, blockSize> readArr;
+ std::array<std::byte, blockSize> readArr{};
const std::array<const std::byte, blockSize> blockOfZeros{};
while (currentIndex < driveSize)
@@ -70,7 +70,7 @@
std::string("eStorageD.1.0.EraseFailure"));
throw InternalFailure();
}
- if (memcmp(readArr.data(), blockOfZeros.data(), readSize))
+ if (memcmp(readArr.data(), blockOfZeros.data(), readSize) != 0)
{
lg2::error("Estoraged erase zeros block is not zero",
"REDFISH_MESSAGE_ID",
diff --git a/src/estoraged.cpp b/src/estoraged.cpp
index 4f7fc40..b52a5f4 100644
--- a/src/estoraged.cpp
+++ b/src/estoraged.cpp
@@ -9,11 +9,11 @@
#include <libcryptsetup.h>
#include <openssl/rand.h>
-#include <stdlib.h>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <string_view>
@@ -26,7 +26,7 @@
using sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound;
using sdbusplus::xyz::openbmc_project::Common::Error::UnsupportedRequest;
-void eStoraged::formatLuks(std::vector<uint8_t> password, FilesystemType type)
+void EStoraged::formatLuks(std::vector<uint8_t> password, FilesystemType type)
{
std::string msg = "OpenBMC.0.1.DriveFormat";
lg2::info("Starting format", "REDFISH_MESSAGE_ID", msg);
@@ -53,7 +53,7 @@
mountFilesystem();
}
-void eStoraged::erase(EraseMethod inEraseMethod)
+void EStoraged::erase(EraseMethod inEraseMethod)
{
std::cerr << "Erasing encrypted eMMC" << std::endl;
lg2::info("Starting erase", "REDFISH_MESSAGE_ID",
@@ -115,7 +115,7 @@
}
}
-void eStoraged::lock()
+void EStoraged::lock()
{
std::string msg = "OpenBMC.0.1.DriveLock";
lg2::info("Starting lock", "REDFISH_MESSAGE_ID", msg);
@@ -124,7 +124,7 @@
deactivateLuksDev();
}
-void eStoraged::unlock(std::vector<uint8_t> password)
+void EStoraged::unlock(std::vector<uint8_t> password)
{
std::string msg = "OpenBMC.0.1.DriveUnlock";
lg2::info("Starting unlock", "REDFISH_MESSAGE_ID", msg);
@@ -141,24 +141,25 @@
mountFilesystem();
}
-void eStoraged::changePassword(std::vector<uint8_t>, std::vector<uint8_t>)
+void EStoraged::changePassword(std::vector<uint8_t> /*oldPassword*/,
+ std::vector<uint8_t> /*newPassword*/)
{
std::cerr << "Changing password for encrypted eMMC" << std::endl;
lg2::info("Starting change password", "REDFISH_MESSAGE_ID",
std::string("OpenBMC.0.1.DrivePasswordChanged"));
}
-bool eStoraged::isLocked() const
+bool EStoraged::isLocked() const
{
return locked();
}
-std::string_view eStoraged::getMountPoint() const
+std::string_view EStoraged::getMountPoint() const
{
return mountPoint;
}
-void eStoraged::formatLuksDev(struct crypt_device* cd,
+void EStoraged::formatLuksDev(struct crypt_device* cd,
std::vector<uint8_t> password)
{
lg2::info("Formatting device {DEV}", "DEV", devPath, "REDFISH_MESSAGE_ID",
@@ -206,7 +207,7 @@
std::string("OpenBMC.0.1.FormatLuksDevSuccess"));
}
-void eStoraged::activateLuksDev(struct crypt_device* cd,
+void EStoraged::activateLuksDev(struct crypt_device* cd,
std::vector<uint8_t> password)
{
lg2::info("Activating LUKS dev {DEV}", "DEV", devPath, "REDFISH_MESSAGE_ID",
@@ -241,11 +242,11 @@
std::string("OpenBMC.0.1.ActivateLuksDevSuccess"));
}
-void eStoraged::createFilesystem()
+void EStoraged::createFilesystem()
{
/* Run the command to create the filesystem. */
int retval = fsIface->runMkfs(containerName);
- if (retval)
+ if (retval != 0)
{
lg2::error("Failed to create filesystem: {RETVAL}", "RETVAL", retval,
"REDFISH_MESSAGE_ID",
@@ -257,7 +258,7 @@
std::string("OpenBMC.0.1.CreateFilesystemSuccess"));
}
-void eStoraged::mountFilesystem()
+void EStoraged::mountFilesystem()
{
/*
* Create directory for the filesystem, if it's not already present. It
@@ -281,7 +282,7 @@
std::string luksContainer("/dev/mapper/" + containerName);
int retval = fsIface->doMount(luksContainer.c_str(), mountPoint.c_str(),
"ext4", 0, nullptr);
- if (retval)
+ if (retval != 0)
{
lg2::error("Failed to mount filesystem: {RETVAL}", "RETVAL", retval,
"REDFISH_MESSAGE_ID",
@@ -302,10 +303,10 @@
std::string("OpenBMC.0.1.MountFilesystemSuccess"));
}
-void eStoraged::unmountFilesystem()
+void EStoraged::unmountFilesystem()
{
int retval = fsIface->doUnmount(mountPoint.c_str());
- if (retval)
+ if (retval != 0)
{
lg2::error("Failed to unmount filesystem: {RETVAL}", "RETVAL", retval,
"REDFISH_MESSAGE_ID",
@@ -328,7 +329,7 @@
std::string("OpenBMC.0.1.MountFilesystemSuccess"));
}
-void eStoraged::deactivateLuksDev()
+void EStoraged::deactivateLuksDev()
{
lg2::info("Deactivating LUKS device {DEV}", "DEV", devPath,
"REDFISH_MESSAGE_ID",
diff --git a/src/main.cpp b/src/main.cpp
index c23ff19..1f50a25 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,7 +26,7 @@
std::string physicalBlockDev = "/dev/mmcblk0";
std::string containerBlockDev;
- int opt;
+ int opt = 0;
while ((opt = getopt(argc, argv, "b:c:")) != -1)
{
switch (opt)
@@ -38,46 +38,54 @@
containerBlockDev = optarg;
break;
default:
- usage(argv[0]);
+ usage(*argv);
exit(EXIT_FAILURE);
}
}
-
- /* Get the filename of the device (without "/dev/"). */
- auto deviceName =
- std::filesystem::path(physicalBlockDev).filename().string();
-
- /* If containerName arg wasn't provided, create one based on deviceName. */
- if (containerBlockDev.empty())
+ try
{
- containerBlockDev = "luks-" + deviceName;
+ /* Get the filename of the device (without "/dev/"). */
+ std::string deviceName =
+ std::filesystem::path(physicalBlockDev).filename().string();
+ /* If containerName arg wasn't provided, create one based on deviceName.
+ */
+ if (containerBlockDev.empty())
+ {
+ containerBlockDev = "luks-" + deviceName;
+ }
+
+ /* DBus path location to place the object. */
+ std::string path = "/xyz/openbmc_project/storage/" + deviceName;
+
+ /*
+ * Create a new bus and affix an object manager for the subtree path we
+ * intend to place objects at.
+ */
+ auto b = sdbusplus::bus::new_default();
+ sdbusplus::server::manager_t m{b, path.c_str()};
+
+ /* Reserve the dbus service name. */
+ std::string busName = "xyz.openbmc_project.eStoraged." + deviceName;
+ b.request_name(busName.c_str());
+
+ /* Create an eStoraged object. */
+ estoraged::EStoraged esObject{b, path.c_str(), physicalBlockDev,
+ containerBlockDev};
+ lg2::info("Storage management service is running", "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.1.0.ServiceStarted"));
+
+ while (true)
+ {
+ b.wait();
+ b.process_discard();
+ }
}
-
- /* DBus path location to place the object. */
- std::string path = "/xyz/openbmc_project/storage/" + deviceName;
-
- /*
- * Create a new bus and affix an object manager for the subtree path we
- * intend to place objects at.
- */
- auto b = sdbusplus::bus::new_default();
- sdbusplus::server::manager_t m{b, path.c_str()};
-
- /* Reserve the dbus service name. */
- std::string busName = "xyz.openbmc_project.eStoraged." + deviceName;
- b.request_name(busName.c_str());
-
- /* Create an eStoraged object. */
- estoraged::eStoraged esObject{b, path.c_str(), physicalBlockDev,
- containerBlockDev};
- lg2::info("Storage management service is running", "REDFISH_MESSAGE_ID",
- std::string("OpenBMC.1.0.ServiceStarted"));
-
- while (true)
+ catch (const std::exception& e)
{
- b.wait();
- b.process_discard();
- }
+ lg2::error(e.what(), "REDFISH_MESSAGE_ID",
+ std::string("OpenBMC.1.0.ServiceException"));
+ return 2;
+ }
return 1;
}
diff --git a/src/test/erase/crypto_test.cpp b/src/test/erase/crypto_test.cpp
index 917b23b..9eefa9d 100644
--- a/src/test/erase/crypto_test.cpp
+++ b/src/test/erase/crypto_test.cpp
@@ -20,25 +20,23 @@
{
using estoraged::CryptErase;
-using estoraged::Cryptsetup;
-using estoraged::CryptsetupInterface;
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
using sdbusplus::xyz::openbmc_project::Common::Error::ResourceNotFound;
-using sdbusplus::xyz::openbmc_project::Inventory::Item::server::Volume;
using ::testing::_;
using ::testing::Return;
using ::testing::StrEq;
-class cryptoEraseTest : public testing::Test
+const std::string testFileName = "testFile";
+
+class CryptoEraseTest : public testing::Test
{
public:
- static constexpr char testFileName[] = "testfile";
std::ofstream testFile;
void SetUp() override
{
/* Create an empty file that we'll pretend is a 'storage device'. */
- testFile.open(testFileName,
+ testFile.open(testFileName.c_str(),
std::ios::out | std::ios::binary | std::ios::trunc);
testFile.close();
if (testFile.fail())
@@ -49,7 +47,7 @@
}
};
-TEST_F(cryptoEraseTest, EraseCryptPass)
+TEST_F(CryptoEraseTest, EraseCryptPass)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -66,11 +64,11 @@
EXPECT_CALL(*mockCryptIface, cryptKeyslotDestroy(_, 0)).Times(1);
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
-TEST_F(cryptoEraseTest, EraseCrypMaxSlotFails)
+TEST_F(CryptoEraseTest, EraseCrypMaxSlotFails)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -82,11 +80,11 @@
.WillOnce(Return(-1));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), ResourceNotFound);
}
-TEST_F(cryptoEraseTest, EraseCrypMaxSlotZero)
+TEST_F(CryptoEraseTest, EraseCrypMaxSlotZero)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -98,11 +96,11 @@
.WillOnce(Return(0));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), ResourceNotFound);
}
-TEST_F(cryptoEraseTest, EraseCrypOnlyInvalid)
+TEST_F(CryptoEraseTest, EraseCrypOnlyInvalid)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -117,11 +115,11 @@
.WillRepeatedly(Return(CRYPT_SLOT_INVALID));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_NO_THROW(myCryptErase.doErase());
}
-TEST_F(cryptoEraseTest, EraseCrypDestoryFails)
+TEST_F(CryptoEraseTest, EraseCrypDestoryFails)
{
std::unique_ptr<MockCryptsetupInterface> mockCryptIface =
std::make_unique<MockCryptsetupInterface>();
@@ -139,7 +137,7 @@
.WillOnce(Return(-1));
CryptErase myCryptErase =
- CryptErase(testFileName, std::move(mockCryptIface));
+ CryptErase(testFileName.c_str(), std::move(mockCryptIface));
EXPECT_THROW(myCryptErase.doErase(), InternalFailure);
}
diff --git a/src/test/erase/pattern_test.cpp b/src/test/erase/pattern_test.cpp
index 98eb374..e0192a0 100644
--- a/src/test/erase/pattern_test.cpp
+++ b/src/test/erase/pattern_test.cpp
@@ -63,7 +63,8 @@
int dummyValue = 88;
testFile.open(testFileName, std::ios::binary | std::ios::out);
- testFile.write((const char*)&dummyValue, sizeof(dummyValue));
+ testFile.write((reinterpret_cast<const char*>(&dummyValue)),
+ sizeof(dummyValue));
testFile.close();
EXPECT_NO_THROW(pass.writePattern(size - sizeof(dummyValue)));
diff --git a/src/test/erase/zero_test.cpp b/src/test/erase/zero_test.cpp
index 70a62e2..846059d 100644
--- a/src/test/erase/zero_test.cpp
+++ b/src/test/erase/zero_test.cpp
@@ -17,7 +17,6 @@
using estoraged::Zero;
using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-using stdplus::fd::ManagedFd;
namespace estoraged_test
{
@@ -61,9 +60,10 @@
std::ofstream testFile;
// open the file and write none zero to it
- int dummyValue = 0x88776655;
+ uint32_t dummyValue = 0x88776655;
testFile.open(testFileName, std::ios::binary | std::ios::out);
- testFile.write((const char*)&dummyValue, sizeof(dummyValue));
+ testFile.write((reinterpret_cast<const char*>(&dummyValue)),
+ sizeof(dummyValue));
testFile.close();
uint64_t size = 4096;
Zero pass(testFileName);
@@ -88,7 +88,7 @@
uint64_t size = 4096;
Zero pass(testFileName);
- int dummyValue = 88;
+ uint32_t dummyValue = 88;
EXPECT_NO_THROW(pass.writeZero(size - sizeof(dummyValue)));
// open the file and write none zero to it
diff --git a/src/test/estoraged_test.cpp b/src/test/estoraged_test.cpp
index 10357fe..7a3286c 100644
--- a/src/test/estoraged_test.cpp
+++ b/src/test/estoraged_test.cpp
@@ -38,23 +38,23 @@
*/
sdbusplus::SdBusMock sdbusMock;
-class eStoragedTest : public testing::Test
+class EStoragedTest : public testing::Test
{
public:
- static constexpr char testFileName[] = "testfile";
- static constexpr char testLuksDevName[] = "testfile_luksDev";
+ const char* testFileName = "testfile";
+ const char* testLuksDevName = "testfile_luksDev";
std::ofstream testFile;
- std::unique_ptr<estoraged::eStoraged> esObject;
- static constexpr auto TEST_PATH = "/test/openbmc_project/storage/test_dev";
- static constexpr auto ESTORAGED_INTERFACE =
+ std::unique_ptr<estoraged::EStoraged> esObject;
+ const char* testPath = "/test/openbmc_project/storage/test_dev";
+ const char* estoragedInterface =
"xyz.openbmc_project.Inventory.Item.Volume";
sdbusplus::bus::bus bus;
std::string passwordString;
std::vector<uint8_t> password;
- MockCryptsetupInterface* mockCryptIface;
- MockFilesystemInterface* mockFsIface;
+ MockCryptsetupInterface* mockCryptIface{};
+ MockFilesystemInterface* mockFsIface{};
- eStoragedTest() :
+ EStoragedTest() :
bus(sdbusplus::get_mocked_new(&sdbusMock)), passwordString("password"),
password(passwordString.begin(), passwordString.end())
{}
@@ -71,16 +71,16 @@
}
EXPECT_CALL(sdbusMock,
- sd_bus_add_object_vtable(IsNull(), _, StrEq(TEST_PATH),
- StrEq(ESTORAGED_INTERFACE), _, _))
+ sd_bus_add_object_vtable(IsNull(), _, StrEq(testPath),
+ StrEq(estoragedInterface), _, _))
.WillRepeatedly(Return(0));
EXPECT_CALL(sdbusMock,
- sd_bus_emit_object_added(IsNull(), StrEq(TEST_PATH)))
+ sd_bus_emit_object_added(IsNull(), StrEq(testPath)))
.WillRepeatedly(Return(0));
EXPECT_CALL(sdbusMock,
- sd_bus_emit_object_removed(IsNull(), StrEq(TEST_PATH)))
+ sd_bus_emit_object_removed(IsNull(), StrEq(testPath)))
.WillRepeatedly(Return(0));
std::unique_ptr<MockCryptsetupInterface> cryptIface =
@@ -90,9 +90,8 @@
std::make_unique<MockFilesystemInterface>();
mockFsIface = fsIface.get();
- esObject = std::make_unique<estoraged::eStoraged>(
- bus, TEST_PATH, std::string(testFileName),
- std::string(testLuksDevName), std::move(cryptIface),
+ esObject = std::make_unique<estoraged::EStoraged>(
+ bus, testPath, testFileName, testLuksDevName, std::move(cryptIface),
std::move(fsIface));
}
@@ -103,11 +102,11 @@
};
/* Test case to format and then lock the LUKS device. */
-TEST_F(eStoragedTest, FormatPass)
+TEST_F(EStoragedTest, FormatPass)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -153,11 +152,11 @@
* Test case where the mount point directory already exists, so it shouldn't
* try to create it.
*/
-TEST_F(eStoragedTest, MountPointExistsPass)
+TEST_F(EStoragedTest, MountPointExistsPass)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -200,7 +199,7 @@
}
/* Test case where the device/file doesn't exist. */
-TEST_F(eStoragedTest, FormatNoDeviceFail)
+TEST_F(EStoragedTest, FormatNoDeviceFail)
{
/* Delete the test file. */
EXPECT_EQ(0, unlink(testFileName));
@@ -216,7 +215,7 @@
}
/* Test case where we fail to format the LUKS device. */
-TEST_F(eStoragedTest, FormatFail)
+TEST_F(EStoragedTest, FormatFail)
{
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _))
.WillOnce(Return(-1));
@@ -227,11 +226,11 @@
}
/* Test case where we fail to set the password for the LUKS device. */
-TEST_F(eStoragedTest, AddKeyslotFail)
+TEST_F(EStoragedTest, AddKeyslotFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -245,11 +244,11 @@
}
/* Test case where we fail to load the LUKS header. */
-TEST_F(eStoragedTest, LoadLuksHeaderFail)
+TEST_F(EStoragedTest, LoadLuksHeaderFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -265,11 +264,11 @@
}
/* Test case where we fail to activate the LUKS device. */
-TEST_F(eStoragedTest, ActivateFail)
+TEST_F(EStoragedTest, ActivateFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -288,11 +287,11 @@
}
/* Test case where we fail to create the filesystem. */
-TEST_F(eStoragedTest, CreateFilesystemFail)
+TEST_F(EStoragedTest, CreateFilesystemFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -313,11 +312,11 @@
}
/* Test case where we fail to create the mount point. */
-TEST_F(eStoragedTest, CreateMountPointFail)
+TEST_F(EStoragedTest, CreateMountPointFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -344,11 +343,11 @@
}
/* Test case where we fail to mount the filesystem. */
-TEST_F(eStoragedTest, MountFail)
+TEST_F(EStoragedTest, MountFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -383,11 +382,11 @@
}
/* Test case where we fail to unmount the filesystem. */
-TEST_F(eStoragedTest, UnmountFail)
+TEST_F(EStoragedTest, UnmountFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -424,11 +423,11 @@
}
/* Test case where we fail to remove the mount point. */
-TEST_F(eStoragedTest, RemoveMountPointFail)
+TEST_F(EStoragedTest, RemoveMountPointFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);
@@ -469,11 +468,11 @@
}
/* Test case where we fail to deactivate the LUKS device. */
-TEST_F(eStoragedTest, DeactivateFail)
+TEST_F(EStoragedTest, DeactivateFail)
{
EXPECT_CALL(sdbusMock,
sd_bus_emit_properties_changed_strv(
- IsNull(), StrEq(TEST_PATH), StrEq(ESTORAGED_INTERFACE), _))
+ IsNull(), StrEq(testPath), StrEq(estoragedInterface), _))
.WillRepeatedly(Return(0));
EXPECT_CALL(*mockCryptIface, cryptFormat(_, _, _, _, _, _, _, _)).Times(1);