new unit tests, hehe 67
tests / linux (push) Failing after 2m18s
tests / windows (push) Skipped
tests / macos (push) Skipped
tests / package-smoke-linux (push) Skipped
tests / package-smoke-windows (push) Skipped
tests / package-smoke-macos (push) Skipped

Signed-off-by: galeon <dertiellis@gmail.com>
This commit is contained in:
galeon committed 2026-10-12 13:14:08 +03:00
1 parent ebf8ff7869
commit 41599fa82f
67 files changed
+8775 -4

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
#include "testenv.h"
#include "localization.h"
#include "zlibreference.h"
#include <QDir>
#include <QFileInfo>
#include <QProcessEnvironment>
class TestZlibReference : public QObject
{
Q_OBJECT
private slots:
void nonLinuxIsNoop()
{
#if defined(Q_OS_LINUX)
QSKIP("только для Windows и macOS");
#else
QVERIFY(!ZlibReference::systemIsZlibNg());
QVERIFY(ZlibReference::bundledPath().isEmpty());
QProcessEnvironment env;
env.insert(QStringLiteral("LD_PRELOAD"), QStringLiteral("/x.so"));
QString note = QStringLiteral("stale");
QVERIFY(ZlibReference::applyTo(env, &note));
QVERIFY(note.isEmpty());
QCOMPARE(env.value(QStringLiteral("LD_PRELOAD")), QStringLiteral("/x.so"));
#endif
}
void linuxPreloadFollowsSystemZlib()
{
#if !defined(Q_OS_LINUX)
QSKIP("только для Linux");
#else
QProcessEnvironment env;
env.insert(QStringLiteral("LD_PRELOAD"), QStringLiteral("/other.so"));
QString note;
const bool ok = ZlibReference::applyTo(env, &note);
if (!ZlibReference::systemIsZlibNg()) {
// Обычный zlib: окружение не трогаем.
QVERIFY(ok);
QVERIFY(note.isEmpty());
QCOMPARE(env.value(QStringLiteral("LD_PRELOAD")), QStringLiteral("/other.so"));
return;
}
const QString bundled = ZlibReference::bundledPath();
if (bundled.isEmpty()) {
QVERIFY(!ok);
QCOMPARE(note, Loc::text("zlib.warning.referenceMissing"));
QCOMPARE(env.value(QStringLiteral("LD_PRELOAD")), QStringLiteral("/other.so"));
} else {
QVERIFY(ok);
// Наш zlib первым, чужой LD_PRELOAD сохраняется.
QCOMPARE(env.value(QStringLiteral("LD_PRELOAD")), bundled + QStringLiteral(":/other.so"));
QVERIFY(QFileInfo(bundled).isFile());
}
#endif
}
};
BILAUNCHER_TEST_MAIN(TestZlibReference)
#include "tst_zlibreference.moc"