From da36fefe923547b61c463f20654482a2a8702bd5 Mon Sep 17 00:00:00 2001 From: Herve_eruam Date: Mon, 6 May 2024 14:39:22 +0200 Subject: [PATCH] Skipped tests that are not revelent without .parms.db --- test/libcommonserver/log/testlog.cpp | 29 ++++++++++++++++++++++++++++ test/libcommonserver/log/testlog.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/test/libcommonserver/log/testlog.cpp b/test/libcommonserver/log/testlog.cpp index f8a5b39a5..a8510c7ea 100644 --- a/test/libcommonserver/log/testlog.cpp +++ b/test/libcommonserver/log/testlog.cpp @@ -132,6 +132,12 @@ void TestLog::testCopyLogsTo(void) { void TestLog::testCopyParmsDbTo(void) { { + if (!_parmsDbFileExist()) { + std::cout << std::endl << "No .parms.db file, this test will not be relevant (skipped)." << std::endl; + LOG_WARN(_logger, "No .parms.db file, this test will not be relevant (skipped)."); + return; + } + TemporaryDirectory tempDir; const SyncPath parmsDbName = ".parms.db"; const SyncPath parmsDbPath = CommonUtility::getAppSupportDir() / parmsDbName; @@ -139,6 +145,9 @@ void TestLog::testCopyParmsDbTo(void) { uint64_t parmsDbSize = 0; IoError err = IoErrorSuccess; IoHelper::getFileSize(parmsDbPath, parmsDbSize, err); + + + CPPUNIT_ASSERT_EQUAL(IoErrorSuccess, err); CPPUNIT_ASSERT(parmsDbSize >= 0); @@ -255,6 +264,12 @@ void TestLog::testGenerateUserDescriptionFile(void) { } void TestLog::testGenerateLogsSupportArchive(void) { + if (!_parmsDbFileExist()) { + std::cout << std::endl << "No .parms.db file, this test will not be relevant (skipped)." << std::endl; + LOG_WARN(_logger, "No .parms.db file, this test will not be relevant (skipped)."); + return; + } + { TemporaryDirectory tempDir; const SyncPath archiveFile = tempDir.path / "logs_support.tar.gz"; @@ -272,4 +287,18 @@ void TestLog::testGenerateLogsSupportArchive(void) { } } +bool TestLog::_parmsDbFileExist() { + const SyncPath parmsDbName = ".parms.db"; + const SyncPath parmsDbPath = CommonUtility::getAppSupportDir() / parmsDbName; + + IoError err = IoErrorSuccess; + bool exists = false; + + if (!IoHelper::checkIfPathExists(parmsDbPath, exists, err)) { + return false; + } + + return exists; +} + } // namespace KDC diff --git a/test/libcommonserver/log/testlog.h b/test/libcommonserver/log/testlog.h index 70994650b..d03e74221 100644 --- a/test/libcommonserver/log/testlog.h +++ b/test/libcommonserver/log/testlog.h @@ -47,6 +47,9 @@ class TestLog : public CppUnit::TestFixture { void testCompressLogs(void); void testGenerateUserDescriptionFile(void); void testGenerateLogsSupportArchive(void); + + private: + bool _parmsDbFileExist(); }; } // namespace KDC