mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-11 20:29:47 +08:00
refs #756 Added class CProcessInfo to obtain a process name from its PID, and check if a process exists.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "testlibrarypath.h"
|
||||
#include "testmath.h"
|
||||
#include "testphysicalquantities.h"
|
||||
#include "testprocess.h"
|
||||
#include "testslot.h"
|
||||
#include "teststringutils.h"
|
||||
#include "testvaluecache.h"
|
||||
@@ -95,6 +96,10 @@ namespace BlackMiscTest
|
||||
CTestLibraryPath libraryPathTests;
|
||||
status |= test.exec(&libraryPathTests, "blackmisc_librarypath");
|
||||
}
|
||||
{
|
||||
CTestProcess processTests;
|
||||
status |= test.exec(&processTests, "blackmisc_process");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
43
tests/blackmisc/testprocess.cpp
Normal file
43
tests/blackmisc/testprocess.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \ingroup testblackmisc
|
||||
*/
|
||||
|
||||
#include "testprocess.h"
|
||||
#include "blackmisc/processinfo.h"
|
||||
|
||||
#include <QTest>
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
|
||||
void CTestProcess::processInfo()
|
||||
{
|
||||
CProcessInfo invalid;
|
||||
QVERIFY2(! invalid.exists(), "Invalid process shall not exist");
|
||||
|
||||
CProcessInfo current1(CProcessInfo::currentProcess());
|
||||
CProcessInfo current2(QCoreApplication::applicationPid());
|
||||
CProcessInfo current3(QCoreApplication::applicationPid(), QCoreApplication::applicationName());
|
||||
QVERIFY2(current1.exists(), "Current process shall exist");
|
||||
QVERIFY2(current1 == current2, "Current process equals process with current PID");
|
||||
QVERIFY2(current1 == current3, "Current process equals process with current PID and name");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
41
tests/blackmisc/testprocess.h
Normal file
41
tests/blackmisc/testprocess.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project community / contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISCTEST_TESTPROCESS_H
|
||||
#define BLACKMISCTEST_TESTPROCESS_H
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \ingroup testblackmisc
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
//! Testing process tools
|
||||
class CTestProcess : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CTestProcess(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
//! Process info tests
|
||||
void processInfo();
|
||||
};
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user