File indexing completed on 2024-04-21 16:12:20
0001 /* 0002 SPDX-FileCopyrightText: 2019 Harald Sitter <sitter@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include <QTest> 0008 0009 #include <config-drkonqi.h> 0010 0011 #include <KCoreAddons> 0012 0013 #include <errno.h> 0014 #include <sys/utsname.h> 0015 0016 #include <systeminformation.h> 0017 0018 class SystemInformationTest : public QObject 0019 { 0020 Q_OBJECT 0021 private Q_SLOTS: 0022 static int uname(utsname *buf) 0023 { 0024 strcpy(buf->sysname, "FreeBSD"); 0025 strcpy(buf->release, "1.0.0"); 0026 strcpy(buf->machine, "x86_64"); 0027 return 0; 0028 } 0029 0030 void initTestCase() 0031 { 0032 } 0033 0034 // NOTE: bugzillaOperatingSystem is not tested anywhere because it is based 0035 // on the compilation platform and testing it fairly moot because of that 0036 0037 void testLsb() 0038 { 0039 SystemInformation::Config config; 0040 config.basicOperatingSystem = "Linux"; // other parts getting filled depends on OS 0041 config.lsbReleasePath = QFINDTESTDATA("lsb_release"); // double binary 0042 config.osReleasePath.clear(); 0043 config.unameFunc = (void *)&uname; 0044 0045 SystemInformation info(config); 0046 QTRY_VERIFY(info.complete()); 0047 0048 QCOMPARE(info.bugzillaPlatform(), "openSUSE RPMs"); 0049 QCOMPARE(info.operatingSystem(), "FreeBSD 1.0.0 x86_64"); 0050 QCOMPARE(info.distributionPrettyName(), "KDE SUSE User Edition 5.16"); 0051 QCOMPARE(info.compiledSources(), false); 0052 QCOMPARE(info.qtVersion(), qVersion()); 0053 QCOMPARE(info.frameworksVersion(), KCoreAddons::versionString()); 0054 } 0055 0056 void testOsRelease() 0057 { 0058 SystemInformation::Config config; 0059 config.basicOperatingSystem = "Linux"; // other parts getting filled depends on OS 0060 config.lsbReleasePath.clear(); 0061 config.osReleasePath = QFINDTESTDATA("data/os-release"); // fixture 0062 config.unameFunc = (void *)&uname; 0063 0064 SystemInformation info(config); 0065 QTRY_VERIFY(info.complete()); 0066 0067 QCOMPARE(info.bugzillaPlatform(), "FreeBSD Ports"); 0068 QCOMPARE(info.operatingSystem(), "FreeBSD 1.0.0 x86_64"); 0069 QCOMPARE(info.distributionPrettyName(), "FreeBSD #1"); 0070 QCOMPARE(info.compiledSources(), false); 0071 QCOMPARE(info.qtVersion(), qVersion()); 0072 QCOMPARE(info.frameworksVersion(), KCoreAddons::versionString()); 0073 } 0074 }; 0075 0076 QTEST_GUILESS_MAIN(SystemInformationTest) 0077 0078 #include "systeminformationtest.moc"