Files
RedBear-OS/local/recipes/kde/kwin/source/autotests/test_utils.cpp
T
vasilito 7aeb3bb475 build: capture build script auto-stash changes from 0.2.5 kernel/relibc/base build
The build-redbear.sh script auto-stashes working tree changes
in nested relibc and base source trees before running the
build. These changes were captured by the failed kernel
build attempt that hit the json-target-spec / kernel rust
toolchain mismatch (fixed in 0.2.5 by creating the local
0.2.5 branch).

Captured changes:
- local/recipes/kde/* : KDE Frameworks 6 source CMakeLists
  whitespace changes from the autostash (preserved)
- local/recipes/qt/qtbase/* : qtypes.h whitespace from the
  autostash (preserved)
- local/sources/kernel/Cargo.lock : dependency lock from
  the kernel relibc rebuild attempt
- local/sources/kernel/src/lib.rs : touched (mtime) by the
  build script's touch + make prefix command

This is a bookkeeping commit — the actual code changes
for the threading plan are on the 4 submodule branches
(kernel, relibc, base, libredox) and will be pushed
separately.

0.2.5 branch was created from 0.2.4 (HEAD cd3950072e) to
continue Phase 0 of the multi-threading plan work in a
clean branch.
2026-07-02 13:41:03 +03:00

72 lines
1.8 KiB
C++

/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 MBition GmbH
SPDX-FileContributor: Kai Uwe Broulik <kai_uwe.broulik@mbition.io>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kwin.h>
#include <sys/mman.h>
#include <unistd.h>
#include "utils/ramfile.h"
#include <QTest>
using namespace KWin;
class TestUtils : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testRamFile();
void testSealedRamFile();
};
static const QByteArray s_testByteArray = QByteArrayLiteral("Test Data \0\1\2\3");
static const char s_writeTestArray[] = "test";
void TestUtils::testRamFile()
{
KWin::RamFile file("test", s_testByteArray.constData(), s_testByteArray.size());
QVERIFY(file.isValid());
QCOMPARE(file.size(), s_testByteArray.size());
QVERIFY(file.fd() != -1);
char buf[20];
int num = read(file.fd(), buf, sizeof buf);
QCOMPARE(num, file.size());
QCOMPARE(qstrcmp(s_testByteArray.constData(), buf), 0);
}
void TestUtils::testSealedRamFile()
{
#if HAVE_MEMFD
KWin::RamFile file("test", s_testByteArray.constData(), s_testByteArray.size(), KWin::RamFile::Flag::SealWrite);
QVERIFY(file.isValid());
QVERIFY(file.effectiveFlags().testFlag(KWin::RamFile::Flag::SealWrite));
// Writing should not work.
auto written = write(file.fd(), s_writeTestArray, strlen(s_writeTestArray));
QCOMPARE(written, -1);
// Cannot use MAP_SHARED on sealed file descriptor.
void *data = mmap(nullptr, file.size(), PROT_WRITE, MAP_SHARED, file.fd(), 0);
QCOMPARE(data, MAP_FAILED);
data = mmap(nullptr, file.size(), PROT_WRITE, MAP_PRIVATE, file.fd(), 0);
QVERIFY(data != MAP_FAILED);
#else
QSKIP("Sealing requires memfd support.");
#endif
}
QTEST_MAIN(TestUtils)
#include "test_utils.moc"