Test: Make valgrind modeldemo test compile with cmake

As on it, correct the handling of the launcher interface.
This still does not work due to wrong call of valgrind-fake.

Change-Id: Id835e84eee29720579ac2947906bb95f84377185
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2022-06-20 12:26:37 +02:00
committed by Christian Stenger
parent be5a77a767
commit 8e22e08d21
5 changed files with 80 additions and 32 deletions

View File

@@ -1,3 +1,5 @@
include(../valgrind.cmake)
add_qtc_test(tst_callgrindparsertests add_qtc_test(tst_callgrindparsertests
DEPENDS Utils Core ProjectExplorer Debugger Qt5::Core Qt5::Network DEPENDS Utils Core ProjectExplorer Debugger Qt5::Core Qt5::Network
DEFINES DEFINES
@@ -7,31 +9,6 @@ add_qtc_test(tst_callgrindparsertests
SOURCES callgrindparsertests.cpp callgrindparsertests.h SOURCES callgrindparsertests.cpp callgrindparsertests.h
) )
extend_qtc_test(tst_callgrindparsertests extend_valgrind_test(tst_callgrindparsertests)
SOURCES_PREFIX "${PROJECT_SOURCE_DIR}/src/plugins/valgrind/"
SOURCES
callgrind/callgrindcallmodel.h callgrind/callgrindcallmodel.cpp
callgrind/callgrindcostitem.h callgrind/callgrindcostitem.cpp
callgrind/callgrindcycledetection.h callgrind/callgrindcycledetection.cpp
callgrind/callgrinddatamodel.h callgrind/callgrinddatamodel.cpp
callgrind/callgrindfunction.h callgrind/callgrindfunction_p.h callgrind/callgrindfunction.cpp
callgrind/callgrindfunctioncall.h callgrind/callgrindfunctioncall.cpp
callgrind/callgrindfunctioncycle.h callgrind/callgrindfunctioncycle.cpp
callgrind/callgrindparsedata.h callgrind/callgrindparsedata.cpp
callgrind/callgrindparser.h callgrind/callgrindparser.cpp
callgrind/callgrindproxymodel.h callgrind/callgrindproxymodel.cpp
callgrind/callgrindstackbrowser.h callgrind/callgrindstackbrowser.cpp
valgrindrunner.h valgrindrunner.cpp
xmlprotocol/announcethread.h xmlprotocol/announcethread.cpp
xmlprotocol/error.h xmlprotocol/error.cpp
xmlprotocol/errorlistmodel.h xmlprotocol/errorlistmodel.cpp
xmlprotocol/frame.h xmlprotocol/frame.cpp
xmlprotocol/modelhelpers.h xmlprotocol/modelhelpers.cpp
xmlprotocol/parser.h xmlprotocol/parser.cpp
xmlprotocol/stack.h xmlprotocol/stack.cpp
xmlprotocol/stackmodel.h xmlprotocol/stackmodel.cpp
xmlprotocol/status.h xmlprotocol/status.cpp
xmlprotocol/suppression.h xmlprotocol/suppression.cpp
xmlprotocol/threadedparser.h xmlprotocol/threadedparser.cpp
)
# skipping modeltest (does not compile due to missing widget handler) # skipping modeltest (does not compile due to missing widget handler)

View File

@@ -1 +1,27 @@
add_subdirectory(testapps) add_subdirectory(testapps)
include(../valgrind.cmake)
file(RELATIVE_PATH RELATIVE_TEST_PATH "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
file(RELATIVE_PATH TEST_RELATIVE_LIBEXEC_PATH "/${RELATIVE_TEST_PATH}" "/${IDE_LIBEXEC_PATH}")
add_qtc_test(modeldemo
MANUALTEST
DEPENDS
Utils
Core
Debugger
ProjectExplorer
TextEditor
SOURCES
modeldemo.cpp
modeldemo.h
DEFINES
PARSERTESTS_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data"
VALGRIND_FAKE_PATH="${PROJECT_BINARY_DIR}/src/tools/valgrindfake/valgrind-fake"
TEST_RELATIVE_LIBEXEC_PATH="${TEST_RELATIVE_LIBEXEC_PATH}"
)
extend_valgrind_test(modeldemo)

View File

@@ -24,6 +24,9 @@
** **
****************************************************************************/ ****************************************************************************/
#include <utils/launcherinterface.h>
#include <utils/temporarydirectory.h>
#include <valgrind/xmlprotocol/frame.h> #include <valgrind/xmlprotocol/frame.h>
#include <valgrind/xmlprotocol/parser.h> #include <valgrind/xmlprotocol/parser.h>
#include <valgrind/xmlprotocol/stack.h> #include <valgrind/xmlprotocol/stack.h>
@@ -41,12 +44,17 @@ using namespace Valgrind::XmlProtocol;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
Utils::TemporaryDirectory::setMasterTemporaryDirectory(QDir::tempPath() + "/QtCreator-XXXXXX");
const QString libExecPath(qApp->applicationDirPath() + '/'
+ QLatin1String(TEST_RELATIVE_LIBEXEC_PATH));
Utils::LauncherInterface::setPathToLauncher(libExecPath);
qRegisterMetaType<Error>(); qRegisterMetaType<Error>();
ValgrindRunner runner; ValgrindRunner runner;
runner.setValgrindCommand({VALGRIND_FAKE_PATH, runner.setValgrindCommand({VALGRIND_FAKE_PATH,
{"-i", PARSERTESTS_DATA_DIR "/memcheck-output-sample1.xml"}}); {"-i", PARSERTESTS_DATA_DIR "/memcheck-output-sample1.xml"}});
ModelDemo demo(&runner); ModelDemo demo(&runner);
QObject::connect(&runner, &ValgrindRunner::finished, QObject::connect(&runner, &ValgrindRunner::finished,
&demo, &ModelDemo::finished); &demo, &ModelDemo::finished);

View File

@@ -1,4 +1,5 @@
import qbs import qbs
import qbs.FileInfo
import "../valgrindautotest.qbs" as ValgrindAutotest import "../valgrindautotest.qbs" as ValgrindAutotest
ValgrindAutotest { ValgrindAutotest {
@@ -6,8 +7,14 @@ ValgrindAutotest {
Depends { name: "valgrind-fake" } Depends { name: "valgrind-fake" }
Depends { name: "Qt.network" } Depends { name: "Qt.network" }
files: ["modeldemo.h", "modeldemo.cpp"] files: ["modeldemo.h", "modeldemo.cpp"]
cpp.defines: base.concat([ cpp.defines: {
'PARSERTESTS_DATA_DIR="' + path + '/data"', var defines = base;
'VALGRIND_FAKE_PATH="' + project.buildDirectory + '/' + qtc.ide_bin_path + '/valgrind-fake"' var absLibExecPath = FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix,
]) qtc.ide_libexec_path);
var relLibExecPath = FileInfo.relativePath(destinationDirectory, absLibExecPath);
defines.push('TEST_RELATIVE_LIBEXEC_PATH="' + relLibExecPath + '"');
defines.push('PARSERTESTS_DATA_DIR="' + path + '/data"');
defines.push('VALGRIND_FAKE_PATH="' + project.buildDirectory + '/' + qtc.ide_bin_path + '/valgrind-fake"');
return defines;
}
} }

View File

@@ -0,0 +1,30 @@
function(extend_valgrind_test targetName)
extend_qtc_test(${targetName}
SOURCES_PREFIX "${PROJECT_SOURCE_DIR}/src/plugins/valgrind/"
SOURCES
callgrind/callgrindcallmodel.h callgrind/callgrindcallmodel.cpp
callgrind/callgrindcostitem.h callgrind/callgrindcostitem.cpp
callgrind/callgrindcycledetection.h callgrind/callgrindcycledetection.cpp
callgrind/callgrinddatamodel.h callgrind/callgrinddatamodel.cpp
callgrind/callgrindfunction.h callgrind/callgrindfunction_p.h callgrind/callgrindfunction.cpp
callgrind/callgrindfunctioncall.h callgrind/callgrindfunctioncall.cpp
callgrind/callgrindfunctioncycle.h callgrind/callgrindfunctioncycle.cpp
callgrind/callgrindparsedata.h callgrind/callgrindparsedata.cpp
callgrind/callgrindparser.h callgrind/callgrindparser.cpp
callgrind/callgrindproxymodel.h callgrind/callgrindproxymodel.cpp
callgrind/callgrindstackbrowser.h callgrind/callgrindstackbrowser.cpp
valgrindrunner.h valgrindrunner.cpp
xmlprotocol/announcethread.h xmlprotocol/announcethread.cpp
xmlprotocol/error.h xmlprotocol/error.cpp
xmlprotocol/errorlistmodel.h xmlprotocol/errorlistmodel.cpp
xmlprotocol/frame.h xmlprotocol/frame.cpp
xmlprotocol/modelhelpers.h xmlprotocol/modelhelpers.cpp
xmlprotocol/parser.h xmlprotocol/parser.cpp
xmlprotocol/stack.h xmlprotocol/stack.cpp
xmlprotocol/stackmodel.h xmlprotocol/stackmodel.cpp
xmlprotocol/status.h xmlprotocol/status.cpp
xmlprotocol/suppression.h xmlprotocol/suppression.cpp
xmlprotocol/threadedparser.h xmlprotocol/threadedparser.cpp
)
endfunction()