Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
main.cpp File Reference

(15bb1fbf78a55eb111baebaa864a6676ec88684a)

#include <QtCore/QCoreApplication>
#include <QtCore/QDeadlineTimer>
#include <QtCore/qdebug.h>
#include <QtCore/QDir>
#include <QtCore/QHash>
#include <QtCore/QProcess>
#include <QtCore/QProcessEnvironment>
#include <QtCore/QRegularExpression>
#include <QtCore/QSystemSemaphore>
#include <QtCore/QThread>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QFileInfo>
#include <QtCore/QSysInfo>
#include <QtCore/QTemporaryFile>
#include <atomic>
#include <csignal>
#include <functional>
#include <optional>
#include <unistd.h>
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

struct  Options
struct  TestInfo
struct  TestRunnerSystemSemaphore

Functions

static bool isTestExitCodeNormal (const int ec)
static bool execCommand (const QString &program, const QStringList &args, QByteArray *output=nullptr, bool verbose=false)
static bool execAdbCommand (const QStringList &args, QByteArray *output=nullptr, bool verbose=true)
static bool execBundletoolCommand (const QStringList &args, QByteArray *output=nullptr, bool verbose=true)
static void setPackagePath (const QString &path)
static bool execCommand (const QString &command, QByteArray *output=nullptr, bool verbose=true)
static bool parseOptions ()
static void printHelp ()
static QString gradleInitScriptPath ()
static QString getGradleProjectProperty (const QString &androidBuildDir, const QString &property)
static bool processAndroidManifest ()
static QStringList queryDangerousPermissions ()
static void setOutputFile (QString file, QString format)
static bool parseTestArgs ()
static int getPid (const QString &package)
static QString runCommandAsUserArgs (const QString &cmd)
static bool isRunning ()
static void waitForStarted ()
static void waitForLoggingStarted ()
static bool setupStdoutLogger ()
static bool stopStdoutLogger ()
static void waitForFinished ()
static void obtainSdkVersion ()
static QString userId ()
static QStringList runningDevices ()
static bool pullResults ()
static QString getAbiLibsPath ()
void printLogcatCrash (const QByteArray &logcat)
void analyseLogcat (const QString &timeStamp, int *exitCode)
static QString getCurrentTimeString ()
static int testExitCode ()
static bool uninstallTestPackage ()
void sigHandler (int signal)
int main (int argc, char *argv[])

Variables

static constexpr int HIGHEST_QTEST_EXITCODE = 127
static constexpr int EXIT_ERROR = 254
static constexpr int EXIT_NOEXITCODE = 253
static constexpr int EXIT_ANR = 252
static constexpr int EXIT_NORESULTS = 251
static Options g_options
static TestInfo g_testInfo
TestRunnerSystemSemaphore testRunnerLock

Function Documentation

◆ analyseLogcat()

void analyseLogcat ( const QString & timeStamp,
int * exitCode )

Definition at line 840 of file main.cpp.

References EXIT_ANR, EXIT_NOEXITCODE, g_options, g_testInfo, and isTestExitCodeNormal().

Here is the call graph for this function:

◆ execAdbCommand()

bool execAdbCommand ( const QStringList & args,
QByteArray * output = nullptr,
bool verbose = true )
static

Definition at line 124 of file main.cpp.

◆ execBundletoolCommand()

bool execBundletoolCommand ( const QStringList & args,
QByteArray * output = nullptr,
bool verbose = true )
static

Definition at line 136 of file main.cpp.

◆ execCommand() [1/2]

bool execCommand ( const QString & command,
QByteArray * output = nullptr,
bool verbose = true )
static

Definition at line 154 of file main.cpp.

◆ execCommand() [2/2]

bool execCommand ( const QString & program,
const QStringList & args,
QByteArray * output = nullptr,
bool verbose = false )
static

Definition at line 91 of file main.cpp.

References g_options, Options::timeoutSecs, and Options::verbose.

◆ getAbiLibsPath()

QString getAbiLibsPath ( )
static

Definition at line 775 of file main.cpp.

◆ getCurrentTimeString()

QString getCurrentTimeString ( )
static

Definition at line 926 of file main.cpp.

◆ getGradleProjectProperty()

QString getGradleProjectProperty ( const QString & androidBuildDir,
const QString & property )
static

Definition at line 350 of file main.cpp.

◆ getPid()

int getPid ( const QString & package)
static

Definition at line 556 of file main.cpp.

◆ gradleInitScriptPath()

QString gradleInitScriptPath ( )
static

Definition at line 321 of file main.cpp.

◆ isRunning()

bool isRunning ( )
static

Definition at line 584 of file main.cpp.

References g_options, g_testInfo, and TestInfo::pid.

Referenced by waitForFinished().

Here is the caller graph for this function:

◆ isTestExitCodeNormal()

bool isTestExitCodeNormal ( const int ec)
static

Definition at line 86 of file main.cpp.

References HIGHEST_QTEST_EXITCODE.

Referenced by analyseLogcat(), and main().

Here is the caller graph for this function:

◆ main()

◆ obtainSdkVersion()

void obtainSdkVersion ( )
static

Definition at line 687 of file main.cpp.

References g_testInfo, and TestInfo::sdkVersion.

Referenced by main().

Here is the caller graph for this function:

◆ parseOptions()

bool parseOptions ( )
static

Definition at line 162 of file main.cpp.

References g_options, Options::helpRequested, Options::showLogcatOutput, Options::skipAddInstallRoot, Options::timeoutSecs, and Options::verbose.

Referenced by main().

Here is the caller graph for this function:

◆ parseTestArgs()

bool parseTestArgs ( )
static

Definition at line 484 of file main.cpp.

References g_options.

Referenced by main().

Here is the caller graph for this function:

◆ printHelp()

void printHelp ( )
static

Definition at line 267 of file main.cpp.

Referenced by main(), and parseCommandLine().

Here is the caller graph for this function:

◆ printLogcatCrash()

void printLogcatCrash ( const QByteArray & logcat)

Definition at line 803 of file main.cpp.

References g_options.

◆ processAndroidManifest()

bool processAndroidManifest ( )
static

Definition at line 375 of file main.cpp.

References g_options.

Referenced by main().

Here is the caller graph for this function:

◆ pullResults()

bool pullResults ( )
static

Definition at line 734 of file main.cpp.

References g_options, and Options::resultsPullRetries.

Referenced by main().

Here is the caller graph for this function:

◆ queryDangerousPermissions()

QStringList queryDangerousPermissions ( )
static

Definition at line 419 of file main.cpp.

◆ runCommandAsUserArgs()

QString runCommandAsUserArgs ( const QString & cmd)
static

Definition at line 579 of file main.cpp.

◆ runningDevices()

QStringList runningDevices ( )
static

Definition at line 720 of file main.cpp.

◆ setOutputFile()

void setOutputFile ( QString file,
QString format )
static

Definition at line 466 of file main.cpp.

References g_options.

◆ setPackagePath()

void setPackagePath ( const QString & path)
static

Definition at line 144 of file main.cpp.

References g_options, and Options::helpRequested.

◆ setupStdoutLogger()

bool setupStdoutLogger ( )
static

Definition at line 627 of file main.cpp.

References g_options.

Referenced by main().

Here is the caller graph for this function:

◆ sigHandler()

void sigHandler ( int signal)

Definition at line 994 of file main.cpp.

References EXIT_ERROR, g_testInfo, TestRunnerSystemSemaphore::release(), and testRunnerLock.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopStdoutLogger()

bool stopStdoutLogger ( )
static

Definition at line 646 of file main.cpp.

References g_options.

Referenced by main().

Here is the caller graph for this function:

◆ testExitCode()

int testExitCode ( )
static

Definition at line 941 of file main.cpp.

References EXIT_NOEXITCODE.

Referenced by main().

Here is the caller graph for this function:

◆ uninstallTestPackage()

bool uninstallTestPackage ( )
static

Definition at line 957 of file main.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ userId()

QString userId ( )
static

Definition at line 702 of file main.cpp.

References g_testInfo, and TestInfo::sdkVersion.

◆ waitForFinished()

void waitForFinished ( )
static

Definition at line 673 of file main.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ waitForLoggingStarted()

void waitForLoggingStarted ( )
static

Definition at line 614 of file main.cpp.

References g_testInfo.

Referenced by main().

Here is the caller graph for this function:

◆ waitForStarted()

void waitForStarted ( )
static

Definition at line 602 of file main.cpp.

References g_testInfo, and TestInfo::pid.

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ EXIT_ANR

constexpr int EXIT_ANR = 252
staticconstexpr

Definition at line 39 of file main.cpp.

Referenced by analyseLogcat().

◆ EXIT_ERROR

constexpr int EXIT_ERROR = 254
staticconstexpr

Definition at line 36 of file main.cpp.

Referenced by main(), and sigHandler().

◆ EXIT_NOEXITCODE

constexpr int EXIT_NOEXITCODE = 253
staticconstexpr

Definition at line 38 of file main.cpp.

Referenced by analyseLogcat(), main(), and testExitCode().

◆ EXIT_NORESULTS

constexpr int EXIT_NORESULTS = 251
staticconstexpr

Definition at line 40 of file main.cpp.

Referenced by main().

◆ g_options

◆ g_testInfo

◆ HIGHEST_QTEST_EXITCODE

constexpr int HIGHEST_QTEST_EXITCODE = 127
staticconstexpr

Definition at line 34 of file main.cpp.

Referenced by isTestExitCodeNormal().

◆ testRunnerLock

TestRunnerSystemSemaphore testRunnerLock

Definition at line 992 of file main.cpp.

Referenced by main(), and sigHandler().