Files
RedBear-OS/local/recipes/kde/kwin/source/autotests/test_ftrace.cpp
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

73 lines
1.5 KiB
C++

/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <QObject>
#include <QTemporaryFile>
#include <QTest>
#include "ftrace.h"
class TestFTrace : public QObject
{
Q_OBJECT
public:
TestFTrace();
private Q_SLOTS:
void benchmarkTraceOff();
void benchmarkTraceDurationOff();
void enable();
private:
QTemporaryFile m_tempFile;
};
TestFTrace::TestFTrace()
{
m_tempFile.open();
qputenv("KWIN_PERF_FTRACE_FILE", m_tempFile.fileName().toLatin1());
KWin::FTraceLogger::create();
}
void TestFTrace::benchmarkTraceOff()
{
// this macro should no-op, so take no time at all
QBENCHMARK {
fTrace("BENCH", 123, "foo");
}
}
void TestFTrace::benchmarkTraceDurationOff()
{
QBENCHMARK {
fTraceDuration("BENCH", 123, "foo");
}
}
void TestFTrace::enable()
{
KWin::FTraceLogger::self()->setEnabled(true);
QVERIFY(KWin::FTraceLogger::self()->isEnabled());
{
fTrace("TEST", 123, "foo");
fTraceDuration("TEST_DURATION", "boo");
fTrace("TEST", 123, "foo");
}
QCOMPARE(m_tempFile.readLine(), "TEST123foo\n");
QCOMPARE(m_tempFile.readLine(), "TEST_DURATIONboo begin_ctx=1\n");
QCOMPARE(m_tempFile.readLine(), "TEST123foo\n");
QCOMPARE(m_tempFile.readLine(), "TEST_DURATIONboo end_ctx=1\n");
}
QTEST_MAIN(TestFTrace)
#include "test_ftrace.moc"