From 5cd73e508886c38ce52e883294484f1ab58a519e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 8 Feb 2012 15:03:34 +1000 Subject: [PATCH] Fixed tst_qfileinfo::group crash if getgrgid fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit QVERIFY2 and gracefully fail with an error message, rather than crashing, if getgrgid() fails. Change-Id: I82a7290f83208486577988cc831d5d3cba20f98e Reviewed-by: João Abecasis --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 7b80152..a3d80cb 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1722,7 +1722,13 @@ void tst_QFileInfo::group() #if defined(Q_OS_UNIX) struct group *gr; gid_t gid = getegid(); + + errno = 0; gr = getgrgid(gid); + + QVERIFY2(gr, qPrintable( + QString("getgrgid returned 0: %1, cannot determine my own group") + .arg(QString::fromLocal8Bit(strerror(errno))))); expected = QString::fromLocal8Bit(gr->gr_name); #endif -- 2.7.4