Fix error attribute naming for Linux 5.0

There was a slight change to one of the error attributes as part of the
OCC driver upstreaming process. This commit also adds unit tests for the
error attributes. This required some refactoring to support the unit
tests.

Resolves openbmc/openbmc#3505

Signed-off-by: Eddie James <eajames@us.ibm.com>
Change-Id: I665b46e44b18befc8a728f7246bcda82f1f1a71c
diff --git a/occ_device.cpp b/occ_device.cpp
index b05dc09..6cd6a1f 100644
--- a/occ_device.cpp
+++ b/occ_device.cpp
@@ -12,10 +12,31 @@
 fs::path Device::bindPath = fs::path(OCC_HWMON_PATH) / "bind";
 fs::path Device::unBindPath = fs::path(OCC_HWMON_PATH) / "unbind";
 
+std::string Device::getPathBack(const fs::path& path)
+{
+    if (path.empty())
+        return std::string();
+
+    // Points to the last element in the path
+    auto conf = --path.end();
+
+    // The last element will be '.' if the path ends in '/'
+    // This behavior differs between filesystem and experimental::filesystem
+    // Verify there is an element before too
+    if (!conf->compare(".") && conf != path.begin())
+    {
+        return *(--conf);
+    }
+    else
+    {
+        return *conf;
+    }
+}
+
 bool Device::master() const
 {
     int master;
-    auto masterFile = fs::path(DEV_PATH) / config / "occ_master";
+    auto masterFile = devPath / "occ_master";
     std::ifstream file(masterFile, std::ios::in);
 
     if (!file)