HardwareState: HWMon data reader

Ported HWMon driver from
cla-sysrepo@19163e50ab062a8b5b75f754b30c22fdbd62b03a.

In cla-sysrepo, these drivers provided a property-based API, i.e., you
asked for a specific property (i.e., a filename) and the contents of the
file was returned.

In velia, we do not need this one-by-one property access. We provide all
attributes with a single call.

Change-Id: Ife783f21d4552e3b8bc69436d2f8fa53eb6745b7
diff --git a/tests/fs-helpers/FileInjector.cpp b/tests/fs-helpers/FileInjector.cpp
new file mode 100644
index 0000000..a3a80f2
--- /dev/null
+++ b/tests/fs-helpers/FileInjector.cpp
@@ -0,0 +1,26 @@
+#include <fstream>
+#include "FileInjector.h"
+
+/** @short Creates a file with specific permissions and content */
+FileInjector::FileInjector(const std::filesystem::path& path, const std::filesystem::perms permissions, const std::string& content)
+    : path(path)
+{
+    auto fileStream = std::ofstream(path, std::ios_base::out | std::ios_base::trunc);
+    if (!fileStream.is_open()) {
+        throw std::invalid_argument("FileInjector could not open file " + std::string(path) + " for writing");
+    }
+    fileStream << content;
+    std::filesystem::permissions(path, permissions);
+}
+
+/** @short Removes file associated with this FileInjector instance (if exists) */
+FileInjector::~FileInjector() noexcept(false)
+{
+    std::filesystem::remove(path);
+}
+
+/** @short Sets file permissions */
+void FileInjector::setPermissions(const std::filesystem::perms permissions)
+{
+    std::filesystem::permissions(path, permissions);
+}
diff --git a/tests/fs-helpers/FileInjector.h b/tests/fs-helpers/FileInjector.h
new file mode 100644
index 0000000..873d3b6
--- /dev/null
+++ b/tests/fs-helpers/FileInjector.h
@@ -0,0 +1,14 @@
+#pragma once
+#include <filesystem>
+#include <string>
+
+/** @short Represents a temporary file whose lifetime is bound by lifetime of the FileInjector instance */
+class FileInjector {
+private:
+    const std::string path;
+
+public:
+    FileInjector(const std::filesystem::path& path, const std::filesystem::perms permissions, const std::string& content);
+    ~FileInjector() noexcept(false);
+    void setPermissions(const std::filesystem::perms permissions);
+};
diff --git a/tests/fs-helpers/utils.cpp b/tests/fs-helpers/utils.cpp
new file mode 100644
index 0000000..1fc018a
--- /dev/null
+++ b/tests/fs-helpers/utils.cpp
@@ -0,0 +1,9 @@
+#include "utils.h"
+
+/** @short Remove directory tree at 'rootDir' path (if exists) */
+void removeDirectoryTreeIfExists(const std::filesystem::path& rootDir)
+{
+    if (std::filesystem::exists(rootDir)) {
+        std::filesystem::remove_all(rootDir);
+    }
+}
diff --git a/tests/fs-helpers/utils.h b/tests/fs-helpers/utils.h
new file mode 100644
index 0000000..93196f2
--- /dev/null
+++ b/tests/fs-helpers/utils.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <filesystem>
+
+void removeDirectoryTreeIfExists(const std::filesystem::path& rootDir);