Move current implementation into separate namespace

We will be moving ietf-hardware implementation from cla-sysrepo to
velia. Veliad daemon will manage not only the "system health" (the
current implementation) but it will also (in later commits) implement
ietf-hardware (RFC8348) [1] (report HW sensors readout to Sysrepo).

This commit prepares the directory structure (i.e., it moves the current
code into a namespace velia::health.
We will be adding new namespace velia::ietf_hardware throughout the next
few commits which will implement the support for ietf-hardware YANG
model.

[1] https://tools.ietf.org/html/rfc8348#appendix-A

Change-Id: I315c2575c5d50036d27cb0a11f5571ce9d615fe5
diff --git a/tests/health_output-led.cpp b/tests/health_output-led.cpp
new file mode 100644
index 0000000..0c15e74
--- /dev/null
+++ b/tests/health_output-led.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
+ *
+ * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
+ *
+*/
+
+#include "trompeloeil_doctest.h"
+#include <filesystem>
+#include <fstream>
+#include "health/outputs/LedSysfsDriver.h"
+#include "test_log_setup.h"
+#include "tests/configure.cmake.h"
+
+namespace {
+
+uint32_t readFile(const std::filesystem::path& path)
+{
+    std::ifstream ifs(path);
+    uint32_t ret;
+    if (!(ifs >> ret)) {
+        throw std::invalid_argument("Failed reading '" + std::string(path) + "'.");
+    }
+    return ret;
+}
+
+/** @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);
+    }
+}
+
+}
+
+TEST_CASE("SysFS LED driver")
+{
+    using namespace std::literals;
+    TEST_INIT_LOGS;
+
+    auto fakeSysfsDir = std::filesystem::path {CMAKE_CURRENT_BINARY_DIR + "/tests/led/"s};
+    auto fakeBrightnessFile = fakeSysfsDir / "brightness";
+    removeDirectoryTreeIfExists(fakeSysfsDir);
+
+    SECTION("Basic usage test")
+    {
+        std::filesystem::copy(std::string(CMAKE_CURRENT_SOURCE_DIR) + "/tests/sysfs/led/1/"s, fakeSysfsDir, std::filesystem::copy_options::recursive);
+        velia::health::LedSysfsDriver led(fakeSysfsDir);
+
+        led.set(0);
+        REQUIRE(readFile(fakeBrightnessFile) == 0);
+
+        led.set(1);
+        REQUIRE(readFile(fakeBrightnessFile) == 1);
+
+        led.set(42);
+        REQUIRE(readFile(fakeBrightnessFile) == 42);
+
+        led.set(0);
+        REQUIRE(readFile(fakeBrightnessFile) == 0);
+    }
+
+    SECTION("Invalid directory")
+    {
+        std::filesystem::copy(std::string(CMAKE_CURRENT_SOURCE_DIR) + "/tests/sysfs/led/2/"s, fakeSysfsDir, std::filesystem::copy_options::recursive);
+        REQUIRE_THROWS_AS(velia::health::LedSysfsDriver(fakeSysfsDir), std::invalid_argument);
+    }
+}