summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfileinfo
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-11-16 11:53:14 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-11-16 18:36:02 (GMT)
commit02aca4e5a1d3e3e47a2c69a63faa772439ac92cf (patch)
tree782eee1ddc25450d60b5880313e1cc0a9accb4b3 /tests/auto/qfileinfo
parenteb474123412c52e74f402e082c85286047c9aeda (diff)
downloadQt-02aca4e5a1d3e3e47a2c69a63faa772439ac92cf.zip
Qt-02aca4e5a1d3e3e47a2c69a63faa772439ac92cf.tar.gz
Qt-02aca4e5a1d3e3e47a2c69a63faa772439ac92cf.tar.bz2
Fix tst_qfileinfo crash on windows with UAC enabled
Creating symbolic links requires admin privilege by default - when UAC is enabled then even users in the administrators group do not have admin privileges without an escalation prompt. (which is inappropriate for an autotest). When run with insufficient privileges, the test is skipped with a warning Reviewed-By: Prasanth Ullattil
Diffstat (limited to 'tests/auto/qfileinfo')
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 898bf54..07e33d3 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -1353,8 +1353,24 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data()
file.open(QIODevice::ReadWrite);
file.close();
- QVERIFY(pwd.exists("abs_symlink") || createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1));
- QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1));
+ DWORD err = ERROR_SUCCESS ;
+ if (!pwd.exists("abs_symlink"))
+ if (!createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1))
+ err = GetLastError();
+ if (err == ERROR_SUCCESS && !pwd.exists(relSymlink))
+ if (!createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1))
+ err = GetLastError();
+ if (err != ERROR_SUCCESS) {
+ wchar_t errstr[0x100];
+ DWORD count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, err, 0, errstr, 0x100, 0);
+ QString error(QString::fromUtf16(errstr, count));
+ qWarning() << error;
+ //we need at least one data set for the test not to assert fail when skipping _data function
+ QDir target("target");
+ QTest::newRow("dummy") << target.path() << false << "" << target.canonicalPath();
+ QSKIP("link not supported by FS or insufficient privilege", SkipSingle);
+ }
QVERIFY(file.exists());
QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath();