[autotests/server] Check whether test is run as root

If the test is run as root we cannot compare the user id to not be 0.
Thus let's check for that and expect fail.
This commit is contained in:
Martin Gräßlin 2017-07-01 17:01:18 +02:00
parent ac1a3b8b90
commit 464ba18321

View file

@ -133,7 +133,13 @@ void TestWaylandServerDisplay::testClientConnection()
ClientConnection *connection = display.getConnection(client);
QVERIFY(connection);
QCOMPARE(connection->client(), client);
if (getuid() == 0) {
QEXPECT_FAIL("", "Please don't run test as root", Continue);
}
QVERIFY(connection->userId() != 0);
if (getgid() == 0) {
QEXPECT_FAIL("", "Please don't run test as root", Continue);
}
QVERIFY(connection->groupId() != 0);
QVERIFY(connection->processId() != 0);
QCOMPARE(connection->display(), &display);