Пример #1
0
 public ITestReporter Create(IFileBackedLog mainLog,
                             IReadableLog runLog,
                             ILogs logs,
                             ICrashSnapshotReporter crashReporter,
                             ISimpleListener simpleListener,
                             IResultParser parser,
                             AppBundleInformation appInformation,
                             RunMode runMode,
                             XmlResultJargon xmlJargon,
                             string?device,
                             TimeSpan timeout,
                             string?additionalLogsDirectory  = null,
                             ExceptionLogger?exceptionLogger = null,
                             bool generateHtml = false) => new TestReporter(_processManager,
                                                                            mainLog,
                                                                            runLog,
                                                                            logs,
                                                                            crashReporter,
                                                                            simpleListener,
                                                                            parser,
                                                                            appInformation,
                                                                            runMode,
                                                                            xmlJargon,
                                                                            device,
                                                                            timeout,
                                                                            additionalLogsDirectory,
                                                                            exceptionLogger,
                                                                            generateHtml);
Пример #2
0
    public int?DetectExitCode(AppBundleInformation appBundleInfo, IReadableLog log)
    {
        StreamReader reader;

        try
        {
            reader = log.GetReader();
        }
        catch (FileNotFoundException e)
        {
            throw new Exception("Failed to detect application's exit code. The log file was empty / not found at " + e.FileName);
        }

        using (reader)
            while (!reader.EndOfStream)
            {
                if (reader.ReadLine() is string line &&
                    IsSignalLine(appBundleInfo, line) is Match match && match.Success &&
                    int.TryParse(match.Groups["exitCode"].Value, out var exitCode))
                {
                    return(exitCode);
                }
            }

        return(null);
    }
Пример #3
0
        private void GetCrashReason(int pid, IReadableLog crashLog, out string?crashReason)
        {
            crashReason           = null;
            using var crashReader = crashLog.GetReader(); // dispose when we leave the method
            var text = crashReader.ReadToEnd();

            var reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(text), new XmlDictionaryReaderQuotas());
            var doc    = new XmlDocument();

            doc.Load(reader);
            foreach (XmlNode?node in doc.SelectNodes($"/root/processes/item[pid = '" + pid + "']"))
            {
                Console.WriteLine(node?.InnerXml);
                Console.WriteLine(node?.SelectSingleNode("reason")?.InnerText);
                crashReason = node?.SelectSingleNode("reason")?.InnerText;
            }
        }
Пример #4
0
        public TestReporter(IMlaunchProcessManager processManager,
                            IFileBackedLog mainLog,
                            IReadableLog runLog,
                            ILogs logs,
                            ICrashSnapshotReporter crashReporter,
                            ISimpleListener simpleListener,
                            IResultParser parser,
                            AppBundleInformation appInformation,
                            RunMode runMode,
                            XmlResultJargon xmlJargon,
                            string?device,
                            TimeSpan timeout,
                            string?additionalLogsDirectory  = null,
                            ExceptionLogger?exceptionLogger = null,
                            bool generateHtml = false)
        {
            _processManager          = processManager ?? throw new ArgumentNullException(nameof(processManager));
            _deviceName              = device; // can be null on simulators
            _listener                = simpleListener ?? throw new ArgumentNullException(nameof(simpleListener));
            _mainLog                 = mainLog ?? throw new ArgumentNullException(nameof(mainLog));
            _runLog                  = runLog ?? throw new ArgumentNullException(nameof(runLog));
            _logs                    = logs ?? throw new ArgumentNullException(nameof(logs));
            _crashReporter           = crashReporter ?? throw new ArgumentNullException(nameof(crashReporter));
            _crashLogs               = new Logs(logs.Directory);
            _resultParser            = parser ?? throw new ArgumentNullException(nameof(parser));
            _appInfo                 = appInformation ?? throw new ArgumentNullException(nameof(appInformation));
            _runMode                 = runMode;
            _xmlJargon               = xmlJargon;
            _timeout                 = timeout;
            _additionalLogsDirectory = additionalLogsDirectory;
            _exceptionLogger         = exceptionLogger;
            _timeoutWatch            = Stopwatch.StartNew();
            _generateHtml            = generateHtml;

            CallbackLog = new CallbackLog(line =>
            {
                // MT1111: Application launched successfully, but it's not possible to wait for the app to exit as
                // requested because it's not possible to detect app termination when launching using gdbserver
                _waitedForExit &= line?.Contains("MT1111: ") != true;
                if (line?.Contains("error MT1007") == true)
                {
                    _launchFailure = true;
                }
            });
        }
Пример #5
0
        public int DetectExitCode(AppBundleInformation appBundleInfo, IReadableLog systemLog)
        {
            using var reader = systemLog.GetReader();
            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();

                if (IsSignalLine(appBundleInfo, line))
                {
                    var match = ExitCodeRegex.Match(line);

                    if (match.Success && int.TryParse(match.Captures.First().Value, out var exitCode))
                    {
                        return(exitCode);
                    }
                }
            }

            return(0);
        }
Пример #6
0
        public int DetectExitCode(AppBundleInformation appBundleInfo, IReadableLog systemLog)
        {
            using var reader = systemLog.GetReader();
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();

                // This will be improved when we find out it differes for new iOS versions
                if (line.Contains("UIKitApplication:") && line.Contains(appBundleInfo.AppName) && line.Contains("Service exited with abnormal code"))
                {
                    var regex = new Regex(" (\\-?[0-9]+)$");
                    var match = regex.Match(line);

                    if (match.Success && int.TryParse(match.Captures.First().Value, out var exitCode))
                    {
                        return(exitCode);
                    }
                }
            }

            return(0);
        }