mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
fetch the owner and group from the QFile file descriptor in QFileInof tests
much more reliable comparison Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d8c00c3e71
commit
7f04979b7e
1 changed files with 23 additions and 14 deletions
|
@ -974,10 +974,7 @@ void tst_QFileInfo::detachingOperations()
|
||||||
|
|
||||||
void tst_QFileInfo::owner()
|
void tst_QFileInfo::owner()
|
||||||
{
|
{
|
||||||
struct passwd *pw = ::getpwuid(::geteuid());
|
QString expected;
|
||||||
QVERIFY(pw);
|
|
||||||
QString expected = QString::fromLocal8Bit(pw->pw_name);
|
|
||||||
QVERIFY(!expected.isEmpty());
|
|
||||||
|
|
||||||
QString fileName("ownertest.txt");
|
QString fileName("ownertest.txt");
|
||||||
QVERIFY(!QFile::exists(fileName) || QFile::remove(fileName));
|
QVERIFY(!QFile::exists(fileName) || QFile::remove(fileName));
|
||||||
|
@ -986,6 +983,13 @@ void tst_QFileInfo::owner()
|
||||||
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QByteArray testData("testfile");
|
QByteArray testData("testfile");
|
||||||
QVERIFY(testFile.write(testData) != -1);
|
QVERIFY(testFile.write(testData) != -1);
|
||||||
|
|
||||||
|
QT_STATBUF statbuf;
|
||||||
|
QVERIFY(QT_FSTAT(testFile.handle(), &statbuf) == 0);
|
||||||
|
struct passwd *pw = ::getpwuid(statbuf.st_uid);
|
||||||
|
QVERIFY(pw);
|
||||||
|
expected = QString::fromLocal8Bit(pw->pw_name);
|
||||||
|
QVERIFY(!expected.isEmpty());
|
||||||
}
|
}
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
QVERIFY(fi.exists());
|
QVERIFY(fi.exists());
|
||||||
|
@ -996,20 +1000,25 @@ void tst_QFileInfo::owner()
|
||||||
|
|
||||||
void tst_QFileInfo::group()
|
void tst_QFileInfo::group()
|
||||||
{
|
{
|
||||||
struct group *gr = ::getgrgid(::getegid());
|
QString expected;
|
||||||
QVERIFY(gr);
|
|
||||||
QString expected = QString::fromLocal8Bit(gr->gr_name);
|
|
||||||
QVERIFY(!expected.isEmpty());
|
|
||||||
|
|
||||||
QString fileName("ownertest.txt");
|
QString fileName("ownertest.txt");
|
||||||
|
QVERIFY(!QFile::exists(fileName) || QFile::remove(fileName));
|
||||||
|
{
|
||||||
QFile testFile(fileName);
|
QFile testFile(fileName);
|
||||||
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QByteArray testData("testfile");
|
QByteArray testData("testfile");
|
||||||
QVERIFY(testFile.write(testData) != -1);
|
QVERIFY(testFile.write(testData) != -1);
|
||||||
testFile.close();
|
|
||||||
|
QT_STATBUF statbuf;
|
||||||
|
QVERIFY(QT_FSTAT(testFile.handle(), &statbuf) == 0);
|
||||||
|
struct group *gr = ::getgrgid(statbuf.st_gid);
|
||||||
|
QVERIFY(gr);
|
||||||
|
expected = QString::fromLocal8Bit(gr->gr_name);
|
||||||
|
QVERIFY(!expected.isEmpty());
|
||||||
|
}
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
QVERIFY(fi.exists());
|
QVERIFY(fi.exists());
|
||||||
|
|
||||||
QCOMPARE(fi.group(), expected);
|
QCOMPARE(fi.group(), expected);
|
||||||
|
|
||||||
QFile::remove(fileName);
|
QFile::remove(fileName);
|
||||||
|
|
Loading…
Add table
Reference in a new issue