예제 #1
0
        public TestResult RunTest(string name, Bizarrefish.VMLib.IMachine machine, ITestResultBin bin, System.Collections.Generic.IDictionary <string, string> env)
        {
            var blob = Repo.Load <FileDownloaderBlob>();

            WebClient wc = new WebClient();

            wc.Headers.Add("user-agent", "FileDownloader Test Driver");

            IList <FileToDownload> ftd;

            if (blob.Tests.TryGetValue(name, out ftd))
            {
                foreach (var file in ftd)
                {
                    using (Stream s = wc.OpenRead(file.Url))
                    {
                        machine.PutFile(file.TargetPath, s);
                    }
                }
            }
            else
            {
                throw new Exception("Test: " + name + " doesn't exist");
            }

            var tr = new TestResult();

            tr.Success = true;
            return(tr);
        }
예제 #2
0
        TestResult InvokeTest(IMachine machine, string testKey, IDictionary <string, string> parameters)
        {
            ITestResultBin bin = provider.CreateBin(testKey);

            initFunc(machine);
            var testResult = func(machine, parameters, bin);

            provider.OnResult(testKey, testResult);
            return(testResult);
        }
예제 #3
0
        public TestResult RunTest(string name, IMachine machine, ITestResultBin bin, IDictionary <string, string> env)
        {
            ITestResource res = Repo.GetResource(name);

            TestResult tr = new TestResult();

            try
            {
                string winDirectory = TestPathPrefix + name + "\\" + DateTime.Now.Ticks + "\\";

                string targetFileName = winDirectory + name + ".bat";
                using (Stream s = res.Read())
                {
                    machine.PutFile(targetFileName, s);
                }

                ProgramResult result = machine.RunProgram(targetFileName, "", winDirectory, env);

                // Hoover up artifacts  *SLUURRRRRP*
                var artifacts = machine.ListFiles(winDirectory);
                foreach (var fileName in artifacts)
                {
                    string tempFile = Path.GetTempFileName();
                    using (FileStream fs = File.Create(tempFile))
                    {
                        machine.GetFile(fileName, fs);
                        fs.Seek(0, SeekOrigin.Begin);
                        bin.PutArtifact(new ArtifactInfo()
                        {
                            Name        = fileName,
                            Description = fileName,
                            FileName    = fileName
                        }, fs);
                    }
                    File.Delete(tempFile);
                }
                tr.Success = result.ExitCode == 0;
            } catch (Exception e)
            {
                tr.Success       = false;
                tr.StandardError = e.Message;
            }


            return(tr);
        }
예제 #4
0
        public TestResult RunTest(string name,  Bizarrefish.VMLib.IMachine machine, ITestResultBin bin, System.Collections.Generic.IDictionary<string, string> env)
        {
            var blob = Repo.Load<FileDownloaderBlob>();

            WebClient wc = new WebClient();
            wc.Headers.Add ("user-agent", "FileDownloader Test Driver");

            IList<FileToDownload> ftd;
            if(blob.Tests.TryGetValue(name, out ftd))
            {
                foreach(var file in ftd)
                {
                    using(Stream s = wc.OpenRead(file.Url))
                    {
                        machine.PutFile(file.TargetPath, s);
                    }
                }
            }
            else
            {
                throw new Exception("Test: " + name + " doesn't exist");
            }

            var tr = new TestResult();
            tr.Success = true;
            return tr;
        }
예제 #5
0
        public TestResult RunTest(string name, IMachine machine, ITestResultBin bin, IDictionary<string, string> env)
        {
            ITestResource res = Repo.GetResource(name);

            TestResult tr = new TestResult();
            try
            {
                string winDirectory = TestPathPrefix + name + "\\" + DateTime.Now.Ticks + "\\";

                string targetFileName = winDirectory + name + ".bat";
                using (Stream s = res.Read())
                {
                    machine.PutFile(targetFileName, s);
                }

                ProgramResult result = machine.RunProgram(targetFileName, "", winDirectory, env);

                // Hoover up artifacts  *SLUURRRRRP*
                var artifacts = machine.ListFiles(winDirectory);
                foreach(var fileName in artifacts)
                {
                    string tempFile = Path.GetTempFileName();
                    using(FileStream fs = File.Create (tempFile))
                    {
                        machine.GetFile (fileName, fs);
                        fs.Seek (0, SeekOrigin.Begin);
                        bin.PutArtifact(new ArtifactInfo()
                        {
                            Name = fileName,
                            Description = fileName,
                            FileName = fileName
                        }, fs);
                    }
                    File.Delete(tempFile);
                }
                tr.Success = result.ExitCode == 0;
            } catch (Exception e)
            {
                tr.Success = false;
                tr.StandardError = e.Message;
            }

            return tr;
        }