예제 #1
0
    public async Task KillEverythingAsyncTest()
    {
        Func <IList <string>, bool> verifyKillAll = (args) =>
        {
            var toKill = new List <string> {
                "-9", "iPhone Simulator", "iOS Simulator", "Simulator", "Simulator (Watch)", "com.apple.CoreSimulator.CoreSimulatorService", "ibtoold"
            };
            return(args.Where(a => toKill.Contains(a)).Count() == toKill.Count);
        };

        var simulator = new SimulatorDevice(_processManager.Object, new TCCDatabase(_processManager.Object));
        await simulator.KillEverything(_executionLog.Object);

        // verify that all the diff process have been killed making sure args are correct
        _processManager.Verify(p => p.ExecuteCommandAsync(It.Is <string>(s => s == "launchctl"), It.Is <string[]>(args => args.Where(a => a == "remove" || a == "com.apple.CoreSimulator.CoreSimulatorService").Count() == 2), It.IsAny <ILog>(), It.IsAny <TimeSpan>(), null, null));
        _processManager.Verify(p => p.ExecuteCommandAsync(It.Is <string>(s => s == "killall"), It.Is <IList <string> >(a => verifyKillAll(a)), It.IsAny <ILog>(), It.IsAny <TimeSpan>(), null, null));
    }
예제 #2
0
        public int Run()
        {
            try {
                Directory.CreateDirectory(LogDirectory);
                ILog log = Logs.Create($"Harness-{Helpers.Timestamp}.log", "Harness log");
                if (Harness.InCI)
                {
                    log = Log.CreateAggregatedLog(log, new ConsoleLog());
                }
                Harness.HarnessLog = MainLog = log;

                var tasks = new List <Task> ();
                if (IsServerMode)
                {
                    var testServer = new TestServer();
                    tasks.Add(testServer.RunAsync(this, xamarinStorageHtmlReportWriter));
                }

                if (Harness.InCI)
                {
                    Task.Factory.StartNew(async() => {
                        while (true)
                        {
                            await Task.Delay(TimeSpan.FromMinutes(10));
                            Console.WriteLine("Still running tests. Please be patient.");
                        }
                    });
                }
                if (!string.IsNullOrEmpty(Harness.PeriodicCommand))
                {
                    var periodicCommand = new PeriodicCommand(
                        command: Harness.PeriodicCommand,
                        processManager: processManager,
                        interval: Harness.PeriodicCommandInterval,
                        logs: logs,
                        arguments: string.IsNullOrEmpty(Harness.PeriodicCommandArguments) ? null : Harness.PeriodicCommandArguments);
                    periodicCommand.Execute().DoNotAwait();
                }

                // We can populate and build test-libraries in parallel.
                var populate = Task.Run(async() => {
                    var simulator = new SimulatorDevice(processManager, new TCCDatabase(processManager));
                    await simulator.KillEverything(MainLog);
                    await PopulateTasksAsync();
                    Populating = false;
                });
                var preparations = new List <Task> ();
                preparations.Add(populate);
                preparations.Add(BuildTestLibrariesAsync());
                Task.WaitAll(preparations.ToArray());

                GenerateReport();

                if (!IsServerMode)
                {
                    foreach (var task in Tasks)
                    {
                        tasks.Add(task.RunAsync());
                    }
                }
                Task.WaitAll(tasks.ToArray());
                GenerateReport();
                return(Tasks.Any((v) => v.Failed || v.DeviceNotFound) ? 1 : 0);
            } catch (Exception ex) {
                MainLog.WriteLine("Unexpected exception: {0}", ex);
                Console.WriteLine("Unexpected exception: {0}", ex);
                return(2);
            }
        }
예제 #3
0
 public SimDeviceSpecification(SimulatorDevice main, SimulatorDevice companion)
 {
     Main      = main;
     Companion = companion;
 }
예제 #4
0
 public void TearDown()
 {
     executionLog   = null;
     processManager = null;
     simulator      = null;
 }