Changeset View
Changeset View
Standalone View
Standalone View
debuggers/common/tests/testhelper.cpp
Show All 38 Lines | 38 | { | |||
---|---|---|---|---|---|
39 | QFileInfo info(QString::fromLocal8Bit(DEBUGGEE_BIN_DIR), name); | 39 | QFileInfo info(QString::fromLocal8Bit(DEBUGGEE_BIN_DIR), name); | ||
40 | Q_ASSERT_X(info.exists(), "findExecutable", info.filePath().toLocal8Bit()); | 40 | Q_ASSERT_X(info.exists(), "findExecutable", info.filePath().toLocal8Bit()); | ||
41 | Q_ASSERT(info.isExecutable()); | 41 | Q_ASSERT(info.isExecutable()); | ||
42 | return QUrl::fromLocalFile(info.canonicalFilePath()); | 42 | return QUrl::fromLocalFile(info.canonicalFilePath()); | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | QString findSourceFile(const QString& name) | 45 | QString findSourceFile(const QString& name) | ||
46 | { | 46 | { | ||
47 | QFileInfo info(QString::fromLocal8Bit(DEBUGGEE_SRC_DIR), name); | 47 | return findFile(DEBUGGEE_SRC_DIR, name); | ||
48 | Q_ASSERT_X(info.exists(), "findSourceFile", info.filePath().toLocal8Bit()); | 48 | } | ||
49 | | ||||
50 | QString findFile(const char* dir, const QString& name) | ||||
51 | { | ||||
52 | QFileInfo info(QString::fromLocal8Bit(dir), name); | ||||
53 | Q_ASSERT_X(info.exists(), "findFile", info.filePath().toLocal8Bit()); | ||||
49 | 54 | | |||
50 | return info.canonicalFilePath(); | 55 | return info.canonicalFilePath(); | ||
51 | } | 56 | } | ||
52 | 57 | | |||
53 | bool isAttachForbidden(const char *file, int line) | 58 | bool isAttachForbidden(const char *file, int line) | ||
54 | { | 59 | { | ||
55 | // if on linux, ensure we can actually attach | 60 | // if on linux, ensure we can actually attach | ||
56 | QFile canRun(QStringLiteral("/proc/sys/kernel/yama/ptrace_scope")); | 61 | QFile canRun(QStringLiteral("/proc/sys/kernel/yama/ptrace_scope")); | ||
Show All 16 Lines | 77 | { | |||
73 | QString s = index.model()->data(index, Qt::DisplayRole).toString(); | 78 | QString s = index.model()->data(index, Qt::DisplayRole).toString(); | ||
74 | bool matched = true; | 79 | bool matched = true; | ||
75 | if (useRE) { | 80 | if (useRE) { | ||
76 | QRegularExpression re(expected); | 81 | QRegularExpression re(expected); | ||
77 | matched = re.match(s).hasMatch(); | 82 | matched = re.match(s).hasMatch(); | ||
78 | } else { | 83 | } else { | ||
79 | matched = s == expected; | 84 | matched = s == expected; | ||
80 | } | 85 | } | ||
81 | if (!matched) { | 86 | return QTest::qVerify(matched, "Comparsion of data", qPrintable(QString("'%0' didn't match expected '%1' in %2:%3") | ||
82 | QTest::qFail(qPrintable(QString("'%0' didn't match expected '%1' in %2:%3") | | |||
83 | .arg(s).arg(expected).arg(file).arg(line)), | 87 | .arg(s).arg(expected).arg(file).arg(line)), | ||
84 | file, line); | 88 | file, line); | ||
85 | return false; | | |||
86 | } | | |||
87 | return true; | | |||
88 | } | 89 | } | ||
89 | 90 | | |||
90 | bool waitForAWhile(MIDebugSession *session, int ms, const char *file, int line) | 91 | bool waitForAWhile(MIDebugSession *session, int ms, const char *file, int line) | ||
91 | { | 92 | { | ||
92 | QPointer<MIDebugSession> s(session); //session can get deleted in DebugController | 93 | QPointer<MIDebugSession> s(session); //session can get deleted in DebugController | ||
93 | QTest::qWait(ms); | 94 | QTest::qWait(ms); | ||
94 | if (!s) { | 95 | if (!s) { | ||
95 | QTest::qFail("Session ended while waiting", file, line); | 96 | QTest::qFail("Session ended while waiting", file, line); | ||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |