From e6ce4c460b2990a86dee0d2b180949a28cc71dc8 Mon Sep 17 00:00:00 2001 From: Simon Sobisch Date: Tue, 17 Sep 2024 13:45:43 +0000 Subject: [PATCH] feat: allow handling of compressed perfparser files all of the code was in place but checking for perfparser format used the original filename instead the temporary (unpacked) one --- src/mainwindow.cpp | 4 ++-- src/parsers/perf/perfparser.cpp | 7 ++++--- .../file_content/perf.data.broken.gz | Bin 0 -> 130 bytes .../file_content/true.perfparser.xz | Bin 0 -> 1020 bytes tests/integrationtests/tst_perfparser.cpp | 5 +++++ 5 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 tests/integrationtests/file_content/perf.data.broken.gz create mode 100644 tests/integrationtests/file_content/true.perfparser.xz diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6db41eb7..f8918344 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -286,9 +286,9 @@ void MainWindow::closeEvent(QCloseEvent* event) QString MainWindow::queryOpenDataFile() { - const auto filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser);;" + const auto filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser *.perfparser.*);;" "Linux Perf Files (perf*.data perf.data.*);;" - "Perfparser Files (*.perfparser);;" + "Perfparser Files (*.perfparser *.perfparser.*);;" "All Files (*)"); return QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(), filter); } diff --git a/src/parsers/perf/perfparser.cpp b/src/parsers/perf/perfparser.cpp index a180b832..30f7586c 100644 --- a/src/parsers/perf/perfparser.cpp +++ b/src/parsers/perf/perfparser.cpp @@ -1585,8 +1585,8 @@ void PerfParser::startParseFile(const QString& path) emit parsingStarted(); using namespace ThreadWeaver; - stream() << make_job([path, parserBinary = m_parserBinary, parserArgs = m_parserArgs, debuginfodUrls, - costAggregation, this]() { + stream() << make_job([origPath = path, path = m_parserArgs[1], parserBinary = m_parserBinary, + parserArgs = m_parserArgs, debuginfodUrls, costAggregation, this]() { PerfParserPrivate d(costAggregation); connect(&d, &PerfParserPrivate::progress, this, &PerfParser::progress); connect(&d, &PerfParserPrivate::debugInfoDownloadProgress, this, &PerfParser::debugInfoDownloadProgress); @@ -1622,7 +1622,8 @@ void PerfParser::startParseFile(const QString& path) while (!file.atEnd() && !d.stopRequested) { if (!d.tryParse()) { // TODO: provide reason - emit parsingFailed(tr("Failed to parse file %1: %2").arg(path, QStringLiteral("Unknown reason"))); + emit parsingFailed( + tr("Failed to parse file %1: %2").arg(origPath, QStringLiteral("Unknown reason"))); return; } } diff --git a/tests/integrationtests/file_content/perf.data.broken.gz b/tests/integrationtests/file_content/perf.data.broken.gz new file mode 100644 index 0000000000000000000000000000000000000000..9bf544018f23ba9f43ba75f291d0d22322dc0c57 GIT binary patch literal 130 zcmb2|=3oE==C|hzxf%=vTrOUjr=&hXfFw$l#bN8YET?P#X1^}3yHz5E3 literal 0 HcmV?d00001 diff --git a/tests/integrationtests/file_content/true.perfparser.xz b/tests/integrationtests/file_content/true.perfparser.xz new file mode 100644 index 0000000000000000000000000000000000000000..6a79a06c3b3c54f7b4d29971c6856d3cd119e9ef GIT binary patch literal 1020 zcmVvPQ1g)#`i$+_pS|D7- zbtp0!8wdtEe{37N`MvJ#38u5@m}ZU;wmr}L$UvrAjB0|w9%{#D14tjZ z;+A|twDzA)}PvDAjsZvp7-hHtw18wuA8(kVDp;w7=1d(M>sK%)Z+5mVZr z#r+_{G_&M7+IJNj1LvMKVi*u!FqlJLerxUzpJaG?XadDnc5KEM6niZ%^o@{eHeN($ zt4U{5zzAKZZEDAqL@jtdng>r9PX-QoNanx`o_JZ9rAb1zg-nUCJtqlAuC!{cB8JpR zhCZiIahIVSQ!yG}0|yMP9OohRpAx_CBBcGVgtx`JRr?NF@D92+D z7-eUpeR+chEn+f`LzbCD4p?^|h{C#yk@3DDe6YXSH3UM7M+pXcUq~UF!@lJm_SDf~ zfKxdth_S^`RH>_SW9pog*5k_xjPhmuI7(7VhgWi3v}ql#SlNGvjmhJ+R(y_XTEf9R zk0)OW$9pB4r6J$hWW3WeT%Hp4&faOshJAU^w1id-W3V$Xs6FvxoCwg-3;Z=739#;JZV={iM)HR%74MIPj!~0p qS2H7@0002U5)nIqt3<5;0oMnl8UO&UjP|Xu#Ao{g000001X)@aOWipD literal 0 HcmV?d00001 diff --git a/tests/integrationtests/tst_perfparser.cpp b/tests/integrationtests/tst_perfparser.cpp index da75784c..b68f2e30 100644 --- a/tests/integrationtests/tst_perfparser.cpp +++ b/tests/integrationtests/tst_perfparser.cpp @@ -234,6 +234,9 @@ private slots: const auto perfData = QFINDTESTDATA("file_content/true.perfparser"); QTest::addRow("pre-exported perfparser") << perfData << QString(); +#if KFArchive_FOUND + QTest::addRow("perfparser, xzipped") << QFINDTESTDATA("file_content/true.perfparser.xz") << QString(); +#endif const auto perfDataSomeName = QStringLiteral("fruitper"); QFile::copy(perfData, perfDataSomeName); // we can ignore errors (file exist) here QTest::addRow("pre-exported perfparser \"bad extension\"") << perfDataSomeName << QString(); @@ -244,6 +247,8 @@ private slots: QTest::addRow("PERF v2") << QFINDTESTDATA("file_content/perf.data.true.v2") << QString(); #if KFArchive_FOUND QTest::addRow("PERF v2, gzipped") << QFINDTESTDATA("file_content/perf.data.true.v2.gz") << QString(); + QTest::addRow("no expected magic header, gzipped") + << QFINDTESTDATA("file_content/perf.data.broken.gz") << QStringLiteral("File format unknown"); #endif }