mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
mostly tests cleanups
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
abafb73acb
commit
8889cd2073
10 changed files with 26 additions and 228 deletions
|
@ -568,10 +568,10 @@ add_subdirectory(src/sql)
|
|||
add_subdirectory(src/svg)
|
||||
add_subdirectory(src/test)
|
||||
add_subdirectory(src/uitools)
|
||||
add_subdirectory(src/tools)
|
||||
if(ENABLE_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
add_subdirectory(src/tools)
|
||||
|
||||
# utilities needed for Katie maintainance
|
||||
if(KATIE_UTILS)
|
||||
|
|
|
@ -979,7 +979,6 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
|
|||
# define Q_SVG_EXPORT Q_DECL_EXPORT
|
||||
# define Q_TEST_EXPORT Q_DECL_EXPORT
|
||||
# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
|
||||
# define Q_OPENGL_EXPORT Q_DECL_EXPORT
|
||||
# define Q_XML_EXPORT Q_DECL_EXPORT
|
||||
# define Q_SCRIPT_EXPORT Q_DECL_EXPORT
|
||||
# define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT
|
||||
|
@ -993,7 +992,6 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
|
|||
# define Q_SVG_EXPORT
|
||||
# define Q_TEST_EXPORT
|
||||
# define Q_DECLARATIVE_EXPORT
|
||||
# define Q_OPENGL_EXPORT
|
||||
# define Q_XML_EXPORT
|
||||
# define Q_SCRIPT_EXPORT
|
||||
# define Q_SCRIPTTOOLS_EXPORT
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
Q_DECLARE_METATYPE(QList<QByteArray>)
|
||||
Q_DECLARE_METATYPE(QTextCodec *)
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_QTextCodec: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -171,9 +173,6 @@ void tst_QTextCodec::toUnicode() const
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QTEST_MAIN(tst_QTextCodec)
|
||||
|
||||
#include "moc_main.cpp"
|
||||
|
|
|
@ -42,14 +42,12 @@
|
|||
#include <QtTest/QtTest>
|
||||
#include <QtCore/QDirIterator>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
# include <sys/types.h>
|
||||
# include <dirent.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class bench_QDir_10000 : public QObject{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
#include "../../../../../shared/filesystem.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class bench_QDir_tree
|
||||
: public QObject
|
||||
{
|
||||
|
|
|
@ -41,21 +41,18 @@
|
|||
#include <QDebug>
|
||||
#include <QDirIterator>
|
||||
#include <QString>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
# include <sys/types.h>
|
||||
# include <dirent.h>
|
||||
# include <errno.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include <qtest.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "qfilesystemiterator.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class tst_qdiriterator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -72,20 +69,11 @@ private slots:
|
|||
|
||||
void tst_qdiriterator::data()
|
||||
{
|
||||
#if defined(Q_OS_WINCE)
|
||||
QByteArray qtdir = qPrintable(QCoreApplication::applicationDirPath());
|
||||
qtdir += "/depot";
|
||||
#else
|
||||
#if defined(Q_OS_WIN)
|
||||
const char *qtdir = "C:\\depot\\qt\\main";
|
||||
#else
|
||||
const char *qtdir = ::getenv("QTDIR");
|
||||
#endif
|
||||
if (!qtdir) {
|
||||
fprintf(stderr, "QTDIR not set\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
QTest::addColumn<QByteArray>("dirpath");
|
||||
QByteArray ba = QByteArray(qtdir) + "/src/core";
|
||||
|
@ -94,48 +82,6 @@ void tst_qdiriterator::data()
|
|||
//QTest::newRow(ba1) << ba1;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static int posix_helper(const wchar_t *dirpath)
|
||||
{
|
||||
int count = 0;
|
||||
HANDLE hSearch;
|
||||
WIN32_FIND_DATA fd;
|
||||
|
||||
const size_t origDirPathLength = wcslen(dirpath);
|
||||
|
||||
wchar_t appendedPath[MAX_PATH];
|
||||
wcscpy(appendedPath, dirpath);
|
||||
wcscat(appendedPath, L"\\*");
|
||||
hSearch = FindFirstFile(appendedPath, &fd);
|
||||
appendedPath[origDirPathLength] = 0;
|
||||
|
||||
if (hSearch == INVALID_HANDLE_VALUE) {
|
||||
qWarning("FindFirstFile failed");
|
||||
return count;
|
||||
}
|
||||
|
||||
do {
|
||||
if (!(fd.cFileName[0] == L'.' && fd.cFileName[1] == 0) &&
|
||||
!(fd.cFileName[0] == L'.' && fd.cFileName[1] == L'.' && fd.cFileName[2] == 0))
|
||||
{
|
||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
wcscat(appendedPath, L"\\");
|
||||
wcscat(appendedPath, fd.cFileName);
|
||||
count += posix_helper(appendedPath);
|
||||
appendedPath[origDirPathLength] = 0;
|
||||
}
|
||||
else {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
} while (FindNextFile(hSearch, &fd));
|
||||
FindClose(hSearch);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int posix_helper(const char *dirpath)
|
||||
{
|
||||
//qDebug() << "DIR" << dirpath;
|
||||
|
@ -164,7 +110,6 @@ static int posix_helper(const char *dirpath)
|
|||
::closedir(dir);
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void tst_qdiriterator::posix()
|
||||
|
@ -174,13 +119,7 @@ void tst_qdiriterator::posix()
|
|||
int count = 0;
|
||||
QString path = QString::fromLatin1(dirpath);
|
||||
QBENCHMARK {
|
||||
#ifdef Q_OS_WIN
|
||||
wchar_t wPath[MAX_PATH];
|
||||
path.toWCharArray(wPath);
|
||||
count = posix_helper(wPath);
|
||||
#else
|
||||
count = posix_helper(dirpath.constData());
|
||||
#endif
|
||||
}
|
||||
qDebug() << count;
|
||||
}
|
||||
|
|
|
@ -96,15 +96,10 @@
|
|||
#include <QtCore/qstack.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
# include <atlbase.h>
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
# include <sys/types.h>
|
||||
# include <dirent.h>
|
||||
# include <errno.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -122,15 +117,8 @@ public:
|
|||
//bool matchesFilters(const QAbstractFileEngineIterator *it) const;
|
||||
inline bool atEnd() const { return m_dirPaths.isEmpty(); }
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QStack<HANDLE> m_dirStructs;
|
||||
WIN32_FIND_DATA* m_entry;
|
||||
WIN32_FIND_DATA m_fileSearchResult;
|
||||
bool m_bFirstSearchResult;
|
||||
#else
|
||||
QStack<DIR *> m_dirStructs;
|
||||
dirent *m_entry;
|
||||
#endif
|
||||
|
||||
QSet<QString> visitedLinks;
|
||||
QStack<QByteArray> m_dirPaths;
|
||||
|
@ -181,25 +169,10 @@ QFileSystemIteratorPrivate::QFileSystemIteratorPrivate(const QString &path,
|
|||
*/
|
||||
QFileSystemIteratorPrivate::~QFileSystemIteratorPrivate()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
while (!m_dirStructs.isEmpty())
|
||||
::FindClose(m_dirStructs.pop());
|
||||
#else
|
||||
while (!m_dirStructs.isEmpty())
|
||||
::closedir(m_dirStructs.pop());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static bool isDotOrDotDot(const wchar_t* name)
|
||||
{
|
||||
if (name[0] == L'.' && name[1] == 0)
|
||||
return true;
|
||||
if (name[0] == L'.' && name[1] == L'.' && name[2] == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
static bool isDotOrDotDot(const char *name)
|
||||
{
|
||||
if (name[0] == '.' && name[1] == 0)
|
||||
|
@ -208,7 +181,6 @@ static bool isDotOrDotDot(const char *name)
|
|||
return true;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
@ -227,18 +199,10 @@ void QFileSystemIteratorPrivate::pushSubDirectory(const QByteArray &path)
|
|||
}
|
||||
*/
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
wchar_t szSearchPath[MAX_PATH];
|
||||
QString::fromAscii(path).toWCharArray(szSearchPath);
|
||||
wcscat(szSearchPath, L"\\*");
|
||||
HANDLE dir = FindFirstFile(szSearchPath, &m_fileSearchResult);
|
||||
m_bFirstSearchResult = true;
|
||||
#else
|
||||
DIR *dir = ::opendir(path.constData());
|
||||
//m_entry = ::readdir(dir);
|
||||
//while (m_entry && isDotOrDotDot(m_entry->d_name))
|
||||
// m_entry = ::readdir(m_dirStructs.top());
|
||||
#endif
|
||||
m_dirStructs.append(dir);
|
||||
m_dirPaths.append(path);
|
||||
m_entry = 0;
|
||||
|
@ -306,32 +270,6 @@ bool QFileSystemIteratorPrivate::advanceHelper()
|
|||
m_currentDirShown = DontShowDir;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
m_entry = &m_fileSearchResult;
|
||||
if (m_bFirstSearchResult) {
|
||||
m_bFirstSearchResult = false;
|
||||
} else {
|
||||
if (!FindNextFile(m_dirStructs.top(), m_entry))
|
||||
m_entry = 0;
|
||||
}
|
||||
|
||||
while (m_entry && isDotOrDotDot(m_entry->cFileName))
|
||||
if (!FindNextFile(m_dirStructs.top(), m_entry))
|
||||
m_entry = 0;
|
||||
|
||||
if (!m_entry) {
|
||||
m_dirPaths.pop();
|
||||
FindClose(m_dirStructs.pop());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
QByteArray ba = m_dirPaths.top();
|
||||
ba += '\\';
|
||||
ba += QString::fromWCharArray(m_entry->cFileName);
|
||||
pushSubDirectory(ba);
|
||||
}
|
||||
#else
|
||||
m_entry = ::readdir(m_dirStructs.top());
|
||||
while (m_entry && isDotOrDotDot(m_entry->d_name))
|
||||
m_entry = ::readdir(m_dirStructs.top());
|
||||
|
@ -357,7 +295,6 @@ bool QFileSystemIteratorPrivate::advanceHelper()
|
|||
pushSubDirectory(ba);
|
||||
return false; // further iteration possibly needed
|
||||
}
|
||||
#endif
|
||||
return false; // further iteration possiblye needed
|
||||
}
|
||||
|
||||
|
@ -622,11 +559,7 @@ QString QFileSystemIterator::fileName() const
|
|||
return QLatin1String("@");
|
||||
if (d->m_currentDirShown == QFileSystemIteratorPrivate::ShowDotDotDir)
|
||||
return QLatin1String("@@");
|
||||
#ifdef Q_OS_WIN
|
||||
return QString::fromWCharArray(d->m_entry->cFileName);
|
||||
#else
|
||||
return QString::fromLocal8Bit(d->m_entry->d_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -647,11 +580,7 @@ QString QFileSystemIterator::filePath() const
|
|||
ba += "/..";
|
||||
else if (d->m_entry) {
|
||||
ba += '/';
|
||||
#ifdef Q_OS_WIN
|
||||
ba += QString::fromWCharArray(d->m_entry->cFileName);
|
||||
#else
|
||||
ba += d->m_entry->d_name;
|
||||
#endif
|
||||
}
|
||||
return QString::fromLocal8Bit(ba);
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ QT_BEGIN_HEADER
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFileSystemIteratorPrivate;
|
||||
class //Q_CORE_EXPORT
|
||||
QFileSystemIterator
|
||||
class QFileSystemIterator
|
||||
{
|
||||
public:
|
||||
enum IteratorFlag {
|
||||
|
|
|
@ -44,14 +44,11 @@
|
|||
#include <QFSFileEngine>
|
||||
#include <QString>
|
||||
#include <QDirIterator>
|
||||
|
||||
#include <qtest.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
#define BUFSIZE 1024*512
|
||||
#define FACTOR 1024*512
|
||||
|
|
|
@ -48,17 +48,7 @@
|
|||
#include <QDir>
|
||||
#include <QFile>
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
#ifndef IO_REPARSE_TAG_MOUNT_POINT
|
||||
#define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L)
|
||||
#endif
|
||||
#define REPARSE_MOUNTPOINT_HEADER_SIZE 8
|
||||
#ifndef FSCTL_SET_REPARSE_POINT
|
||||
#define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
|
||||
#endif
|
||||
#endif
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
struct FileSystem
|
||||
{
|
||||
|
@ -108,59 +98,6 @@ struct FileSystem
|
|||
}
|
||||
return false;
|
||||
}
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||
static void createNtfsJunction(QString target, QString linkName)
|
||||
{
|
||||
typedef struct {
|
||||
DWORD ReparseTag;
|
||||
DWORD ReparseDataLength;
|
||||
WORD Reserved;
|
||||
WORD ReparseTargetLength;
|
||||
WORD ReparseTargetMaximumLength;
|
||||
WORD Reserved1;
|
||||
WCHAR ReparseTarget[1];
|
||||
} REPARSE_MOUNTPOINT_DATA_BUFFER, *PREPARSE_MOUNTPOINT_DATA_BUFFER;
|
||||
|
||||
char reparseBuffer[MAX_PATH*3];
|
||||
HANDLE hFile;
|
||||
DWORD returnedLength;
|
||||
wchar_t fileSystem[MAX_PATH] = L"";
|
||||
PREPARSE_MOUNTPOINT_DATA_BUFFER reparseInfo = (PREPARSE_MOUNTPOINT_DATA_BUFFER) reparseBuffer;
|
||||
|
||||
QFileInfo junctionInfo(linkName);
|
||||
linkName = QDir::toNativeSeparators(junctionInfo.absoluteFilePath());
|
||||
|
||||
GetVolumeInformationW( (wchar_t*)linkName.left(3).utf16(), NULL, 0, NULL, NULL, NULL,
|
||||
fileSystem, sizeof(fileSystem)/sizeof(WCHAR));
|
||||
if(QString().fromWCharArray(fileSystem) != "NTFS")
|
||||
QSKIP("This seems not to be an NTFS volume. Junctions are not allowed.",SkipSingle);
|
||||
|
||||
if (!target.startsWith("\\??\\") && !target.startsWith("\\\\?\\")) {
|
||||
QFileInfo targetInfo(target);
|
||||
target = QDir::toNativeSeparators(targetInfo.absoluteFilePath());
|
||||
target.prepend("\\??\\");
|
||||
if(target.endsWith('\\') && target.at(target.length()-2) != ':')
|
||||
target.chop(1);
|
||||
}
|
||||
QDir().mkdir(linkName);
|
||||
hFile = CreateFileW( (wchar_t*)linkName.utf16(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL );
|
||||
QVERIFY(hFile != INVALID_HANDLE_VALUE );
|
||||
|
||||
memset( reparseInfo, 0, sizeof( *reparseInfo ));
|
||||
reparseInfo->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
|
||||
reparseInfo->ReparseTargetLength = target.size() * sizeof(wchar_t);
|
||||
reparseInfo->ReparseTargetMaximumLength = reparseInfo->ReparseTargetLength + sizeof(wchar_t);
|
||||
target.toWCharArray(reparseInfo->ReparseTarget);
|
||||
reparseInfo->ReparseDataLength = reparseInfo->ReparseTargetLength + 12;
|
||||
|
||||
bool ioc = DeviceIoControl(hFile, FSCTL_SET_REPARSE_POINT, reparseInfo,
|
||||
reparseInfo->ReparseDataLength + REPARSE_MOUNTPOINT_HEADER_SIZE,
|
||||
NULL, 0, &returnedLength, NULL);
|
||||
CloseHandle( hFile );
|
||||
QVERIFY(ioc);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
QDir currentDir;
|
||||
|
|
Loading…
Add table
Reference in a new issue