diff options
-rwxr-xr-x | Makefile.am | 3 | ||||
-rwxr-xr-x | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/utest.cpp | 63 |
3 files changed, 2 insertions, 67 deletions
diff --git a/Makefile.am b/Makefile.am index 50681c30f..f8ef52ae9 100755 --- a/Makefile.am +++ b/Makefile.am @@ -24,8 +24,7 @@ generic_ldflags = \ $(SYSTEMD_LIBS) \ $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ $(SDBUSPLUS_LIBS) \ - $(PHOSPHOR_LOGGING_LIBS) \ - -lstdc++fs + $(PHOSPHOR_LOGGING_LIBS) openpower_version_host_software_manager_CXXFLAGS = $(generic_cxxflags) openpower_version_host_software_manager_LDFLAGS = $(generic_ldflags) diff --git a/test/Makefile.am b/test/Makefile.am index cac8e378c..e2caf4ba6 100755 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,7 +10,6 @@ TESTS = $(check_PROGRAMS) utest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) utest_CXXFLAGS = $(PTHREAD_CFLAGS) $(PHOSPHOR_LOGGING_CFLAGS) utest_LDFLAGS = -lgtest_main -lgtest $(PTHREAD_LIBS) $(OESDK_TESTCASE_FLAGS) \ - $(PHOSPHOR_LOGGING_LIBS) -lstdc++fs + $(PHOSPHOR_LOGGING_LIBS) utest_SOURCES = utest.cpp -utest_LDADD = $(top_builddir)/version_host_software_manager.o diff --git a/test/utest.cpp b/test/utest.cpp index 4fd1e78ed..21805333f 100644 --- a/test/utest.cpp +++ b/test/utest.cpp @@ -1,64 +1 @@ -#include "version_host_software_manager.hpp" #include <gtest/gtest.h> -#include <experimental/filesystem> -#include <stdlib.h> -#include <fstream> -#include <iostream> -#include <sstream> -#include <string> - -using namespace openpower::software::manager; -namespace fs = std::experimental::filesystem; - - -class VersionTest : public testing::Test -{ - protected: - - virtual void SetUp() - { - char versionDir[] = "./versionXXXXXX"; - _directory = mkdtemp(versionDir); - - if (_directory.empty()) - { - throw std::bad_alloc(); - } - } - - virtual void TearDown() - { - fs::remove_all(_directory); - } - - std::string _directory; -}; - -/** @brief Make sure we correctly get the version from getVersion()*/ -TEST_F(VersionTest, TestGetVersion) -{ - auto manifestFilePath = _directory + "/" + "MANIFEST"; - auto version = "test-version"; - - std::ofstream file; - file.open(manifestFilePath, std::ofstream::out); - ASSERT_TRUE(file.is_open()); - - file << "version=" << version << std::endl; - file.close(); - - EXPECT_EQ(Version::getVersion(manifestFilePath), version); -} - -/** @brief Make sure we correctly get the Id from getId()*/ -TEST_F(VersionTest, TestGetId) -{ - std::stringstream hexId; - auto version = "test-id"; - - hexId << std::hex << ((std::hash<std::string> {}( - version)) & 0xFFFFFFFF); - - EXPECT_EQ(Version::getId(version), hexId.str()); - -} |