tst_QFile::moveToTrash: add tests for /var/tmp

These must pass, but they're highly unlikely to be trashable because
/var/tmp is usually not its own filesystem (it might be a subvolume of
its own, but usually isn't). Instead, it's usually part of / or /var.

On my machine:
 openat(AT_FDCWD, "/var/.Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
 openat(AT_FDCWD, "/var/.Trash-1000", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
 mkdirat(AT_FDCWD, "/var/.Trash-1000", 0700) = -1 EACCES (Permission denied)

Change-Id: Ifeb6206a9fa04424964bfffd17884246a4d27443
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Thiago Macieira 2023-09-25 14:42:10 -07:00
parent a40341366f
commit b0329f8560
1 changed files with 8 additions and 0 deletions

View File

@ -3949,6 +3949,10 @@ void tst_QFile::moveToTrash_data()
if (!temp.open())
QSKIP("Failed to create temporary file!");
QTest::newRow("temporary file") << temp.fileName() << true << true;
#ifdef Q_OS_UNIX
if (QDir::tempPath() == "/tmp")
QTest::newRow("var-temporary file") << "/var" + temp.fileName() << true << true;
#endif
}
{
QTemporaryDir tempDir(QDir::tempPath() + "/tst_qfile-moveToTrash-XXXXXX");
@ -3958,6 +3962,10 @@ void tst_QFile::moveToTrash_data()
QTest::newRow("temporary dir")
<< tempDir.path() + QLatin1Char('/')
<< true << true;
#ifdef Q_OS_UNIX
if (QDir::tempPath() == "/tmp")
QTest::newRow("var-temporary dir") << "/var" + tempDir.path() << true << true;
#endif
}
{
QTemporaryDir homeDir(QDir::homePath() + QLatin1String("/tst_qfile.moveToTrash-XXXXXX"));