/** * @RDE_HEADER@ * ISM Function Topic test executable * $Id$ * @RDE_HEADER@ * Module Tests for FLM * $Id$ * $HeadURL$ * $Author$ * Created by Iuliana Ojog, SLSE, 2017-04-05 */ #include "flm_tests.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* ---------------------------------------------------------------------------------- * HOW TO RUN THE TESTS (for example) * ---------------------------------------------------------------------------------- * 0. Preconditions: * Start with an empty database (BUILD) * make db * Start services: (SV) * ./bin/svcExerciseManagement -d 74 & * ./bin/svcFileManagement -d 74 & * Test steps (sample): * 1. ./bin/tests/flmTests -d 74 -t 11 -f 11 */ // ------------------------------------------------------------------------------ using namespace FileManagement; FlmTests::FlmTests(QObject *parent) : QObject(parent) , m_testId(-1) , m_folderId(0) , m_fileContentId(-1) , m_operatorId(99) , m_bTestsSuccessful(true) , m_logger(getLogger("Test")) { qRegisterMetaType("Core::FunctionReply"); } // ------------------------------------------------------------------------------ FlmTests::~FlmTests() { } // ------------------------------------------------------------------------------ bool FlmTests::init(int domainId, int testId, int folderId, int fileContentId, int operatorId) { INFO_LOG(m_logger) << "init begin"; m_testId = testId; m_folderId = folderId; m_fileContentId = fileContentId; m_operatorId = operatorId; m_content.clear(); // initialize DDS, always on exercise 0 m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Global)); if (!m_ddsConnector->init()) return false; m_ddsConnector->initPublisherSubscriber(); TRACE_LOG(m_logger) << "create dtc"; m_dtc = FileManagement::Interface::Dtc::create(m_ddsConnector); TRACE_LOG(m_logger) << "init dtc"; bool bRet = m_dtc->enableAll(); TRACE_LOG(m_logger) << "init dtc end - bRet = " << bRet; TRACE_LOG(m_logger) << "create ftc"; m_ftc = FileManagement::Interface::Ftc::create(m_ddsConnector); TRACE_LOG(m_logger) << "init ftc"; bRet &= m_ftc->enableAll(); TRACE_LOG(m_logger) << "init ftc end - bRet = " << bRet; // initialize database m_dbHandler = std::make_shared(); if(!m_dbHandler->init(0, Settings::settings())) { ERROR_LOG(m_logger) << "Initialisation dbHandler failed."; return false; } DEBUG_LOG(m_logger) << "Initialisation dbHandler succesful."; m_db = m_dbHandler->db(); DEBUG_LOG(m_logger) << "########### Domain Id = " << domainId; DEBUG_LOG(m_logger) << "########### Test Id = " << testId; DEBUG_LOG(m_logger) << "########### Folder Id = " << folderId; DEBUG_LOG(m_logger) << "########### File Content Id = " << fileContentId; DEBUG_LOG(m_logger) << "########### Operator Id = " << operatorId; return bRet; } // ------------------------------------------------------------------------------ void FlmTests::startTest() { INFO_LOG(m_logger) << "********* startTest **************"; switch (m_testId) { // folder case 1: tryCreateFolder(); break; case 2: tryModifyFolder(); break; case 3: tryRemoveFolder(); break; // file content case 11: tryCreateFileContent(); break; case 12: tryModifyFileContent(); break; case 13: tryRemoveFileContent(); break; case 14: tryExportFileContent(); break; case 15: tryGetContent(); break; case 16: tryUpdateStatus(); break; case 20: tryGetAllTemplates(); break; case 21: tryGetAllPlans(); break; case 22: tryGetAllFavs(); break; case 23: tryGetAllSymbols(); break; // plans case 31: tryCreatePlan(); break; case 32: tryCreateFav(); break; case 33: tryCreateSymbol(); break; default: ERROR_LOG(m_logger) << "Unknown test case !"; failExit(); break; } INFO_LOG(m_logger) << "********* endTest **************"; QTimer::singleShot(0, qApp, &QCoreApplication::quit); } // ************* FOLDER ********************************************************** // ------------------------------------------------------------------------------ void FlmTests::tryCreateFolder() { INFO_LOG(m_logger) << "trying to send FolderCreateRequest"; int parentFolderId = m_folderId; if (parentFolderId == 0) parentFolderId = 1; DEBUG_LOG(m_logger) << "Creating Folder under folder id = " << parentFolderId; // Creating hidden folder m_folderId = createFolder(parentFolderId, QStringLiteral("Test Folder"), true); QTRY_VERIFY(m_folderId != 0); parentFolderId = m_folderId; m_folderId = 0; DEBUG_LOG(m_logger) << "Creating Subfolder for folder id = " << parentFolderId; m_folderId = createFolder(parentFolderId, QStringLiteral("Test Sub Folder")); QTRY_VERIFY(m_folderId != 0); QTimer::singleShot(0, qApp, &QCoreApplication::quit); } // ------------------------------------------------------------------------------ void FlmTests::tryModifyFolder() { INFO_LOG(m_logger) << "trying to send folder modify request "; DEBUG_LOG(m_logger) << "m_folderId = " << m_folderId; m_dtc->waitForHistoricalDataFolder(); const FileManagement::Folder &fld = m_dtc->folder(m_folderId); FileManagement::FolderModifyRequest data; DEBUG_LOG(m_logger) << "fld.id() = " << fld.id(); if (fld.id() == 0) { ERROR_LOG(m_logger) << "Cannot find Folder Id = " << m_folderId; failExit(); } else { m_folderId = 0; data.id(fld.id()); data.name(fld.name()); data.path(fld.path()); data.isEditable(fld.isEditable()); data.isHidden(fld.isHidden()); data.parentId(fld.parentId()); data.operatorId(m_operatorId); // changing only name data.name("Folder-Updated"); if (!m_ftc->folderModifyRequest(FolderModifyRequest(data), this)) { ERROR_LOG(m_logger) << "Error requesting modify data"; failExit(); } QTRY_VERIFY(m_folderId > 0); } QTimer::singleShot(0, qApp, &QCoreApplication::quit); } // ------------------------------------------------------------------------------ void FlmTests::tryRemoveFolder() { INFO_LOG(m_logger) << "trying to send FolderRemoveRequest "; m_dtc->waitForHistoricalDataFolder(); if (!m_ftc->folderRemoveRequest(FolderRemoveRequest(m_folderId), this)) { ERROR_LOG(m_logger) << "Error requesting delete data"; failExit(); } QTest::qWait(1000); } // ------------------------------------------------------------------------------ int FlmTests::createFolder(int parentFolderId, const QString &folderName, bool isHidden) { FileManagement::Folder parentFolder = m_dtc->folder(parentFolderId); const std::vector &parentPath = parentFolder.path(); FileManagement::FolderModifyRequest req; req.name(folderName.toStdString()); req.path(parentPath); req.isEditable(false); req.isHidden(isHidden); req.parentId(parentFolderId); req.operatorId(m_operatorId); if (!m_ftc->folderModifyRequest(req, this)) { ERROR_LOG(m_logger) << "Error creating folder with parent = " << parentFolderId << " and name = " << folderName ; failExit(); } return m_folderId; } //********************* FILE CONTENT ******************************************** // ------------------------------------------------------------------------------ void FlmTests::tryCreateFileContent() { INFO_LOG(m_logger) << "trying to send file content create request "; m_dtc->waitForHistoricalDataFileContent(); FileContentModifyRequest data; data.name("Test Document"); data.isTemplate(false); data.isUsedBy(false); data.usedBy(0); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::User); // user docs data.fileType(FileManagement::FileType::MSOfficeDocument); // doc data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); QByteArray vmTest; vmTest += "bla-bla-bla"; data.content(LtsUtils::convert>(vmTest)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); data.name("Test PDF"); data.isTemplate(false); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::User); // user docs data.fileType(FileManagement::FileType::Pdf); // pdf data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); vmTest += "\npdf-pdf-pdf"; data.content(LtsUtils::convert>(vmTest)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); data.name("Test JPG"); data.isTemplate(false); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::User); // user docs data.fileType(FileManagement::FileType::Jpg); data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); QString fileName = QLatin1String("/titel_logo_RDE.jpg"); QFile file; file.setFileName(QCoreApplication::applicationDirPath()+fileName); if (!file.open(QFile::ReadOnly)) { ERROR_LOG(m_logger) << "Error opening file " << fileName; failExit(); } QByteArray rawImage = file.readAll(); DEBUG_LOG(m_logger) << "Read file " << fileName; file.close(); data.content(LtsUtils::convert>(rawImage)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); data.name("Test big JPG"); data.isTemplate(false); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::User); // user docs data.fileType(FileManagement::FileType::Jpg); data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); fileName = QLatin1String("/logo_Project.jpg"); file.setFileName(QCoreApplication::applicationDirPath()+fileName); if (!file.open(QFile::ReadOnly)) { ERROR_LOG(m_logger) << "Error opening file " << fileName; failExit(); } rawImage = file.readAll(); DEBUG_LOG(m_logger) << "Read file " << fileName; file.close(); data.content(LtsUtils::convert>(rawImage)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); } // ------------------------------------------------------------------------------ void FlmTests::tryModifyFileContent() { INFO_LOG(m_logger) << "trying to send file content modify request "; DEBUG_LOG(m_logger) << "m_fileContentId = " << m_fileContentId; m_dtc->waitForHistoricalDataFileContent(); const FileManagement::FileContent &flc = m_dtc->fileContent(m_fileContentId); FileManagement::FileContentModifyRequest data; DEBUG_LOG(m_logger) << "flc.id() = " << flc.id(); if (flc.id() == 0) { ERROR_LOG(m_logger) << "Cannot find File Content Id = " << m_fileContentId; failExit(); } else { if (!checkContentSize(m_fileContentId)) { ERROR_LOG(m_logger) << "Content size 0"; failExit(); } DEBUG_LOG(m_logger) << "Content size = " << m_content.size(); data.id(flc.id()); data.name(flc.name()); if (flc.exerciseId().is_set()) { data.exerciseId(flc.exerciseId().get()); if (flc.phaseId().is_set()) data.phaseId(flc.phaseId().get()); } data.fileCategory(flc.fileCategory()); data.fileStatus(flc.fileStatus()); data.fileType(flc.fileType()); data.folderId(flc.folderId()); data.isTemplate(flc.isTemplate()); data.isUsedBy(flc.isUsedBy()); data.usedBy(flc.usedBy()); data.operatorId(flc.operatorId()); data.properties(flc.properties()); data.content(m_content); // changing only name, template, last modified data.name("Test File Content Updated"); data.isTemplate(true); data.lastModified(QDateTime::currentMSecsSinceEpoch()); if (!m_ftc->fileContentModifyRequest(FileContentModifyRequest(data), this)) { ERROR_LOG(m_logger) << "Error requesting modify data"; failExit(); } QTest::qWait(1000); } } // ------------------------------------------------------------------------------ bool FlmTests::checkContentSize(int fileId) { GetFileContentDataRequest request; request.fileContentId(fileId); m_content.clear(); if (!m_ftc->getFileContentDataRequest(request, this)) { ERROR_LOG(m_logger) << "Cannot retrieve file content for id = " << fileId; return false; } QTest::qWait(1000); return (m_content.size() > 0); } // ------------------------------------------------------------------------------ void FlmTests::tryUpdateStatus() { INFO_LOG(m_logger) << "trying update status file content"; DEBUG_LOG(m_logger) << "m_fileContentId = " << m_fileContentId; m_dtc->waitForHistoricalDataFileContent(); const FileManagement::FileContent &flc = m_dtc->fileContent(m_fileContentId); DEBUG_LOG(m_logger) << "flc.id() = " << flc.id(); if (flc.id() == 0) { ERROR_LOG(m_logger) << "Cannot find File Content Id = " << m_fileContentId; failExit(); } else { if (!m_db->updateStatus(m_fileContentId, FileManagement::FileStatus::Deleted, m_operatorId)) { ERROR_LOG(m_logger) << "Cannot update status for File Content Id = " << m_fileContentId; failExit(); } QTest::qWait(1000); if (!checkContentSize(m_fileContentId)) { ERROR_LOG(m_logger) << "Content size 0"; failExit(); } QTest::qWait(1000); } } // ------------------------------------------------------------------------------ void FlmTests::tryRemoveFileContent() { INFO_LOG(m_logger) << "trying to send FileContentRemoveRequest "; m_dtc->waitForHistoricalDataFileContent(); if (!m_ftc->fileContentRemoveRequest(FileContentRemoveRequest(m_fileContentId), this)) { ERROR_LOG(m_logger) << "Error requesting delete data"; failExit(); } QTest::qWait(1000); } // ------------------------------------------------------------------------------ void FlmTests::tryExportFileContent() { INFO_LOG(m_logger) << "trying to send FileContentExportRequest "; m_dtc->waitForHistoricalDataFileContent(); if (!m_ftc->fileContentExportRequest(FileContentExportRequest(m_fileContentId), this)) { ERROR_LOG(m_logger) << "Error requesting export data"; failExit(); } QTest::qWait(1000); if (!checkContentSize(m_fileContentId)) { ERROR_LOG(m_logger) << "Content size 0"; failExit(); } QTest::qWait(1000); } // ------------------------------------------------------------------------------ void FlmTests::tryCreatePlan() { INFO_LOG(m_logger) << "trying to send file content create request "; FileContentModifyRequest data; data.name("Test Plan"); data.isTemplate(false); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::Global); // global data.fileType(FileManagement::FileType::TacticalPlan); // plan data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); QByteArray vmTest; vmTest += "bla-bla-bla"; data.content(LtsUtils::convert>(vmTest)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); } // ------------------------------------------------------------------------------ void FlmTests::tryCreateFav() { INFO_LOG(m_logger) << "trying to send file content create request "; FileContentModifyRequest data; data.name("Test Fav"); data.isTemplate(false); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::User); // user data.fileType(FileManagement::FileType::OperatorFavourite); // fav data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); QByteArray vmTest; vmTest += "bla-bla-bla"; data.content(LtsUtils::convert>(vmTest)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); } // ------------------------------------------------------------------------------ void FlmTests::tryCreateSymbol() { INFO_LOG(m_logger) << "trying to send file content create request "; FileContentModifyRequest data; data.name("Test Symbol"); data.isTemplate(false); data.folderId(m_folderId); data.fileStatus(FileManagement::FileStatus::Valid); data.fileCategory(FileManagement::FileCategory::Global); // global data.fileType(FileManagement::FileType::OperatorDefinedSymbol); data.operatorId(m_operatorId); data.lastModified(QDateTime::currentMSecsSinceEpoch()); QByteArray vmTest; vmTest += "bla-bla-bla"; data.content(LtsUtils::convert>(vmTest)); m_fileContentId = 0; if (!m_ftc->fileContentModifyRequest(data, this)) { ERROR_LOG(m_logger) << "Error requesting create data"; failExit(); } QTRY_VERIFY(m_fileContentId > 0); } // ------------------------------------------------------------------------------ void FlmTests::tryGetContent() { GetFileContentDataRequest request; request.fileContentId(m_fileContentId); INFO_LOG(m_logger) << "trying to send content request for file Id = " << m_fileContentId; if (!m_ftc->getFileContentDataRequest(request, this)) { ERROR_LOG(m_logger) << "Error requesting content for id : " << m_fileContentId; failExit(); } QTRY_VERIFY(m_content.size() > 0); DEBUG_LOG(m_logger) << "Got content size: " << m_content.size(); } // ------------------------------------------------------------------------------ void FlmTests::onGetFileContentDataReply(const GetFileContentDataReply &replyObject) { if (replyObject.errorString().size() > 0) { ERROR_LOG(m_logger) << "Got onGetFileContentDataReply error: " << replyObject.errorString(); failExit(); } INFO_LOG(m_logger) << "Got reply with id " << replyObject.id() << " and errorString " << replyObject.errorString(); m_content = replyObject.content(); DEBUG_LOG(m_logger) << "Content size: " << m_content.size(); // QTimer::singleShot(0, qApp, &QCoreApplication::quit); } // ************* CUSTOM DTC's***************************************************** // ------------------------------------------------------------------------------ void FlmTests::tryGetAllTemplates() { INFO_LOG(m_logger) << "tryGetAllTemplates"; QList allTemplates; m_dtc->waitForHistoricalDataFileContent(); if (!m_dtc->getAllTemplates(allTemplates)) { ERROR_LOG(m_logger) << "Error requesting dtc data"; failExit(); } DEBUG_LOG(m_logger) << "Found " << allTemplates.size() << " templates"; for (const FileContent &fc : qAsConst(allTemplates)) DEBUG_LOG(m_logger) << "Found template (id, name) = (" << fc.id() << ", " << fc.name() << ")"; QTest::qWait(1000); } // ------------------------------------------------------------------------------ void FlmTests::tryGetAllPlans() { INFO_LOG(m_logger) << "tryGetAllPlans"; QStringList allPlans; m_dtc->waitForHistoricalDataFileContent(); if (!m_dtc->getAllFiles(FileManagement::FileType::TacticalPlan, m_folderId, allPlans)) { ERROR_LOG(m_logger) << "Error requesting dtc data"; failExit(); } DEBUG_LOG(m_logger) << "Found " << allPlans.size() << " plans"; for (const QString &plan : qAsConst(allPlans)) DEBUG_LOG(m_logger) << "Found plan = " << plan; QTest::qWait(1000); } // ------------------------------------------------------------------------------ void FlmTests::tryGetAllFavs() { INFO_LOG(m_logger) << "tryGetAllFavs"; QStringList allFavs; m_dtc->waitForHistoricalDataFileContent(); if (!m_dtc->getAllFiles(FileManagement::FileType::OperatorFavourite, m_folderId, allFavs)) { ERROR_LOG(m_logger) << "Error requesting dtc data"; failExit(); } DEBUG_LOG(m_logger) << "Found " << allFavs.size() << " favs"; for (const QString &fav : qAsConst(allFavs)) DEBUG_LOG(m_logger) << "Found fav = " << fav; QTest::qWait(1000); } // ------------------------------------------------------------------------------ void FlmTests::tryGetAllSymbols() { INFO_LOG(m_logger) << "tryGetAllSymbols"; QStringList allSymbols; m_dtc->waitForHistoricalDataFileContent(); if (!m_dtc->getAllFiles(FileManagement::FileType::OperatorDefinedSymbol, m_folderId, allSymbols)) { ERROR_LOG(m_logger) << "Error requesting dtc data"; failExit(); } DEBUG_LOG(m_logger) << "Found " << allSymbols.size() << " symbols"; for (const QString &symbol : qAsConst(allSymbols)) DEBUG_LOG(m_logger) << "Found symbol = " << symbol; QTest::qWait(1000); } //********************* GENERAL ************************************************* // ------------------------------------------------------------------------------ void FlmTests::onError(const QString &reason) { ERROR_LOG(m_logger) << "Got Reply error: " << reason; failExit(); } // ------------------------------------------------------------------------------ void FlmTests::onReply(const Core::FunctionReplyObject &replyObject) { if (replyObject.error()) { onError(replyObject.translated()); return; } INFO_LOG(m_logger) << "Got Reply with id " << replyObject.id() << " and errorString " << replyObject.translated(); // QTimer::singleShot(0, qApp, &QCoreApplication::quit); } // ------------------------------------------------------------------------------ void FlmTests::failExit() { ERROR_LOG(m_logger) << "FAIL EXIT !"; m_bTestsSuccessful = false; QTimer::singleShot(0, qApp, &QCoreApplication::quit); } //-------------------------------------------------------------------------- void FlmTests::onFolderModifyReply(const Core::FunctionReplyObject &replyObject) { if (replyObject.error()) { ERROR_LOG(m_logger) << "Got onFolderModifyReply error: " << replyObject(); failExit(); return; } INFO_LOG(m_logger) << "Got modifyFolderReply with id " << replyObject.id() << " and errorString " << replyObject.translated(); m_folderId = replyObject.id(); } //-------------------------------------------------------------------------- void FlmTests::onFileContentModifyReply(const Core::FunctionReplyObject &replyObject) { if (replyObject.error()) { ERROR_LOG(m_logger) << "Got onFileContentModifyReply error: " << replyObject(); failExit(); return; } INFO_LOG(m_logger) << "Got modifyFileReply with id " << replyObject.id() << " and errorString " << replyObject.translated(); m_fileContentId = replyObject.id(); } // ------------------------------------------------------------------ class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser { public: CmdLineParser() : LtsCommandLineParser() { addOption({ QStringList() << QLatin1String("t") << QLatin1String("testId") , QLatin1String("TestId.") , QLatin1String("Default: -1") , QLatin1String("-1") }); addOption({ QStringList() << QLatin1String("f") << QLatin1String("folderId") , QLatin1String("FolderId.") , QLatin1String("Default: 0 (root folder)") , QLatin1String("-1") }); addOption({ QStringList() << QLatin1String("c") << QLatin1String("fileContentId") , QLatin1String("FileContentId.") , QLatin1String("Default: -1") , QLatin1String("-1") }); addOption({ QStringList() << QLatin1String("o") << QLatin1String("operatorId") , QLatin1String("OperatorId.") , QLatin1String("Default: 99 (Organisator)") , QLatin1String("-1") }); } int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; } int folderId() const { return isSet(QLatin1String("f")) ? value(QLatin1String("f")).toInt() : 0; } int fileContentId() const { return isSet(QLatin1String("c")) ? value(QLatin1String("c")).toInt() : -1; } int operatorId() const { return isSet(QLatin1String("o")) ? value(QLatin1String("o")).toInt() : 99; } }; // ------------------------------------------------------------------ int main(int argc, char **argv) { int iRet = -1; NGLCoreApplication app(argc, argv); app.createLogger("FLM", 0); CmdLineParser options; if (!options.init()) return iRet; std::unique_ptr FlmTests(new FileManagement::FlmTests()); if (!FlmTests->init(options.domainId(), options.testId(), options.folderId(), options.fileContentId(), options.operatorId())) return iRet; QTimer::singleShot(0, FlmTests.get(), &FileManagement::FlmTests::startTest); STARTUP_LOG(app.baseLogger()); app.exec(); iRet = FlmTests->testsSuccessful() ? 0 : 1; fprintf(stderr, "\n%d\n\n", iRet); INFO_LOG(app.baseLogger()) << "** TEST result = " << iRet; SHUTDOWN_LOG(app.baseLogger()); return iRet; }