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

(09408504fb67a71fde231e8db1e0c73be20113f7)

#include <QtCore/QCommandLineParser>
#include <QtCore/QCoreApplication>
#include <QtCore/QDeadlineTimer>
#include <QtCore/qdebug.h>
#include <QtCore/QDir>
#include <QtCore/QHash>
#include <QtCore/QLockFile>
#include <QtCore/QProcess>
#include <QtCore/QProcessEnvironment>
#include <QtCore/QRegularExpression>
#include <QtCore/QSet>
#include <QtCore/QStandardPaths>
#include <QtCore/QThread>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QFileInfo>
#include <QtCore/QTemporaryFile>
#include "../../../tests/shared/cidetect.h"
#include <atomic>
#include <chrono>
#include <csignal>
#include <QtCore/qxpfunctional.h>
#include <optional>
#include <unistd.h>
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

struct  Options
struct  TestInfo

Functions

static bool isTestExitCodeNormal (const int ec)
static QByteArray execCommand (const QString &programprogram, const QStringList &args, bool verbose=false, std::chrono::milliseconds timeouttimeout=std::chrono::milliseconds(-1))
static QStringList adbArgsWithSerial (const QStringList &args)
static QByteArray execAdbCommand (const QStringList &args, bool verbose=true)
static QByteArray execBundletoolCommand (const QStringList &args, bool verbose=true)
static bool setPackagePath (const QString &pathpath)
static bool collectPackagePaths (const QStringList &apkValues, const QStringList &aabValues)
static QByteArray execCommand (const QString &command, bool verbose=true, std::chrono::milliseconds timeouttimeout=std::chrono::milliseconds(-1))
static QStringList splitOwnAndTestArgs (const QStringList &args, const QSet< QString > &knownOpts, const QSet< QString > &valueOpts)
static QString ndkStackPath ()
static bool parseOptions ()
static QString gradleInitScriptPath ()
static QString getGradleProjectProperty (const QString &androidBuildDir, const QString &property)
static bool processAndroidManifest ()
static QStringList queryDangerousPermissions ()
static QString deviceOutputFileName (const QString &formatformat, const QString &hostPath)
static void setOutputFile (QString file, QString formatformat)
static bool parseTestArgs ()
static int getPid (const QString &package)
static QString runCommandAsUserArgs (const QString &cmd)
static std::optional< QStringList > runningDevices ()
static bool deviceDisconnected ()
static bool isRunning ()
static bool pollUntil (qxp::function_ref< bool() const > predicate, QDeadlineTimer deadline, std::chrono::nanoseconds interval)
static void waitForStarted ()
static bool waitForLoggingStarted ()
static bool setupStdoutLogger ()
static bool stopStdoutLogger ()
static void waitForFinished ()
static void obtainSdkVersion ()
static QString userId ()
static QByteArray adbReadAppFile (const QString &fileName, int retries, std::chrono::milliseconds backoff)
static bool pullResults ()
static QString getAbiLibsPath ()
static void printLogcatCrash (const QByteArray &logcat)
static QByteArray fetchLogcat (const QString &timeStamp, bool waitForDiagnostics)
static QByteArray takeCrashDump (QByteArray *logcat)
static QByteArray filterTestLogcat (const QByteArray &logcat, int testPid, int systemServerPid)
static 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 constexpr int EXIT_DEVICE_GONE = 250
static Options g_options
static TestInfo g_testInfo
static constexpr auto crashBannerMarker = "*** *** *** *** *** *** *** ***"

Function Documentation

◆ adbArgsWithSerial()

QStringList adbArgsWithSerial ( const QStringList & args)
static

Definition at line 151 of file main.cpp.

References g_options.

◆ adbReadAppFile()

QByteArray adbReadAppFile ( const QString & fileName,
int retries,
std::chrono::milliseconds backoff )
static

Definition at line 873 of file main.cpp.

◆ analyseLogcat()

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

Definition at line 1083 of file main.cpp.

References EXIT_ANR, EXIT_NOEXITCODE, g_options, g_testInfo, isTestExitCodeNormal(), and Options::showLogcatOutput.

Here is the call graph for this function:

◆ collectPackagePaths()

bool collectPackagePaths ( const QStringList & apkValues,
const QStringList & aabValues )
static

Definition at line 180 of file main.cpp.

◆ deviceDisconnected()

bool deviceDisconnected ( )
static

Definition at line 716 of file main.cpp.

References g_options.

Referenced by isRunning(), pullResults(), and testExitCode().

Here is the caller graph for this function:

◆ deviceOutputFileName()

QString deviceOutputFileName ( const QString & format,
const QString & hostPath )
static

Definition at line 589 of file main.cpp.

◆ execAdbCommand()

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

Definition at line 158 of file main.cpp.

◆ execBundletoolCommand()

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

Definition at line 163 of file main.cpp.

◆ execCommand() [1/2]

QByteArray execCommand ( const QString & command,
bool verbose = true,
std::chrono::milliseconds timeout = std::chrono::milliseconds(-1) )
static

Definition at line 199 of file main.cpp.

◆ execCommand() [2/2]

QByteArray execCommand ( const QString & program,
const QStringList & args,
bool verbose = false,
std::chrono::milliseconds timeout = std::chrono::milliseconds(-1) )
static

Definition at line 103 of file main.cpp.

References g_options, and Options::verbose.

◆ fetchLogcat()

QByteArray fetchLogcat ( const QString & timeStamp,
bool waitForDiagnostics )
static

Definition at line 991 of file main.cpp.

References crashBannerMarker, g_options, g_testInfo, and pollUntil().

Here is the call graph for this function:

◆ filterTestLogcat()

QByteArray filterTestLogcat ( const QByteArray & logcat,
int testPid,
int systemServerPid )
static

Definition at line 1047 of file main.cpp.

◆ getAbiLibsPath()

QString getAbiLibsPath ( )
static

Definition at line 921 of file main.cpp.

◆ getCurrentTimeString()

QString getCurrentTimeString ( )
static

Definition at line 1124 of file main.cpp.

References g_testInfo, and TestInfo::sdkVersion.

◆ getGradleProjectProperty()

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

Definition at line 466 of file main.cpp.

◆ getPid()

int getPid ( const QString & package)
static

Definition at line 682 of file main.cpp.

◆ gradleInitScriptPath()

QString gradleInitScriptPath ( )
static

Definition at line 437 of file main.cpp.

◆ isRunning()

bool isRunning ( )
static

Definition at line 722 of file main.cpp.

References deviceDisconnected(), g_options, and g_testInfo.

Referenced by waitForFinished(), and waitForStarted().

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

◆ isTestExitCodeNormal()

bool isTestExitCodeNormal ( const int ec)
static

Definition at line 98 of file main.cpp.

References HIGHEST_QTEST_EXITCODE.

Referenced by analyseLogcat(), and main().

Here is the caller graph for this function:

◆ main()

int main ( int argc,
char * argv[] )

◆ ndkStackPath()

QString ndkStackPath ( )
static

Definition at line 258 of file main.cpp.

◆ obtainSdkVersion()

void obtainSdkVersion ( )
static

Definition at line 838 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 278 of file main.cpp.

References g_options, 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 610 of file main.cpp.

References g_options.

Referenced by main().

Here is the caller graph for this function:

◆ pollUntil()

bool pollUntil ( qxp::function_ref< bool() const > predicate,
QDeadlineTimer deadline,
std::chrono::nanoseconds interval )
static

Definition at line 737 of file main.cpp.

Referenced by fetchLogcat(), waitForFinished(), waitForLoggingStarted(), and waitForStarted().

Here is the caller graph for this function:

◆ printLogcatCrash()

void printLogcatCrash ( const QByteArray & logcat)
static

Definition at line 940 of file main.cpp.

References g_options.

◆ processAndroidManifest()

bool processAndroidManifest ( )
static

Definition at line 499 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 888 of file main.cpp.

References deviceDisconnected(), g_options, and g_testInfo.

Referenced by main().

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

◆ queryDangerousPermissions()

QStringList queryDangerousPermissions ( )
static

Definition at line 543 of file main.cpp.

◆ runCommandAsUserArgs()

QString runCommandAsUserArgs ( const QString & cmd)
static

Definition at line 694 of file main.cpp.

◆ runningDevices()

std::optional< QStringList > runningDevices ( )
static

Definition at line 701 of file main.cpp.

◆ setOutputFile()

void setOutputFile ( QString file,
QString format )
static

Definition at line 594 of file main.cpp.

References g_options.

◆ setPackagePath()

bool setPackagePath ( const QString & path)
static

Definition at line 170 of file main.cpp.

References g_options.

◆ setupStdoutLogger()

bool setupStdoutLogger ( )
static

Definition at line 778 of file main.cpp.

References g_options, and g_testInfo.

Referenced by main().

Here is the caller graph for this function:

◆ sigHandler()

void sigHandler ( int signal)

Definition at line 1166 of file main.cpp.

References EXIT_ERROR, and g_testInfo.

Referenced by main().

Here is the caller graph for this function:

◆ splitOwnAndTestArgs()

QStringList splitOwnAndTestArgs ( const QStringList & args,
const QSet< QString > & knownOpts,
const QSet< QString > & valueOpts )
static

Definition at line 208 of file main.cpp.

◆ stopStdoutLogger()

bool stopStdoutLogger ( )
static

Definition at line 802 of file main.cpp.

References g_options, and g_testInfo.

Referenced by main().

Here is the caller graph for this function:

◆ takeCrashDump()

QByteArray takeCrashDump ( QByteArray * logcat)
static

Definition at line 1037 of file main.cpp.

References crashBannerMarker.

◆ testExitCode()

int testExitCode ( )
static

Definition at line 1140 of file main.cpp.

References deviceDisconnected(), EXIT_NOEXITCODE, and g_testInfo.

Referenced by main().

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

◆ uninstallTestPackage()

bool uninstallTestPackage ( )
static

Definition at line 1160 of file main.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ userId()

QString userId ( )
static

Definition at line 856 of file main.cpp.

References g_testInfo, and TestInfo::sdkVersion.

◆ waitForFinished()

void waitForFinished ( )
static

Definition at line 829 of file main.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ waitForLoggingStarted()

bool waitForLoggingStarted ( )
static

Definition at line 765 of file main.cpp.

References g_options, and pollUntil().

Referenced by main().

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

◆ waitForStarted()

void waitForStarted ( )
static

Definition at line 752 of file main.cpp.

References g_testInfo, isRunning(), TestInfo::pid, and pollUntil().

Referenced by main().

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

Variable Documentation

◆ crashBannerMarker

constexpr auto crashBannerMarker = "*** *** *** *** *** *** *** ***"
staticconstexpr

Definition at line 989 of file main.cpp.

Referenced by fetchLogcat(), and takeCrashDump().

◆ EXIT_ANR

constexpr int EXIT_ANR = 252
staticconstexpr

Definition at line 45 of file main.cpp.

Referenced by analyseLogcat().

◆ EXIT_DEVICE_GONE

constexpr int EXIT_DEVICE_GONE = 250
staticconstexpr

Definition at line 47 of file main.cpp.

Referenced by main().

◆ EXIT_ERROR

constexpr int EXIT_ERROR = 254
staticconstexpr

Definition at line 42 of file main.cpp.

Referenced by main(), and sigHandler().

◆ EXIT_NOEXITCODE

constexpr int EXIT_NOEXITCODE = 253
staticconstexpr

Definition at line 44 of file main.cpp.

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

◆ EXIT_NORESULTS

constexpr int EXIT_NORESULTS = 251
staticconstexpr

Definition at line 46 of file main.cpp.

Referenced by main().

◆ g_options

◆ g_testInfo

◆ HIGHEST_QTEST_EXITCODE

constexpr int HIGHEST_QTEST_EXITCODE = 127
staticconstexpr

Definition at line 40 of file main.cpp.

Referenced by isTestExitCodeNormal().