Beispiel #1
0
        public bool Compile()
        {
            string reportFile = Path.Combine(workDir, NeTesterConfiguration.REPORT_FILE);
            string script     = Path.Combine(workDir, NeTesterConfiguration.COMPILE_SCRIPT);

            using (StreamWriter sw = new StreamWriter(script))
                sw.Write(lang.CompileScript);

            DfyzProc prc = new DfyzProc(NeTesterConfiguration.SHELL_COMMAND,
                                        workDir, null);

            prc.AddArgument(NeTesterConfiguration.SHELL_SCRIPT_PARAM);
            prc.AddArgument(script + " " + source + " " + exe);

            prc.SetCommonParams();

            prc.StdinRedirection        = DfyzProc.NULL_DEVICE;
            prc.StdoutRedirection       = reportFile;
            prc.DuplicateStdoutToStderr = true;

            RunResult rr = prc.Run();

            if (rr.Status != RunStatus.Ok)
            {
                throw new NeTesterException("Compilation failed");
            }

            using (StreamReader sr = new StreamReader(reportFile))
                compReport = sr.ReadToEnd();

            return(rr.ExitCode == 0);
        }
Beispiel #2
0
        public bool Compile()
        {
            string reportFile = Path.Combine(workDir, NeTesterConfiguration.ReportFile);
            string script     = Path.Combine(workDir, NeTesterConfiguration.CompileScript);


            using (StreamWriter sw = new StreamWriter(script))
            {
                throw new NotImplementedException();
                //sw.Write(lang.CompileScript);
            }

            RunResult rr = new RunResult();

            using (DfyzProc prc = new DfyzProc(NeTesterConfiguration.ShellCommand, workDir, null))
            {
                prc.AddArgument(NeTesterConfiguration.ShellScriptParam);
                prc.AddArgument(script + " " + source + " " + exe);

                prc.SetCommonParams();

                prc.StdinRedirection        = DfyzProc.NULL_DEVICE;
                prc.StdoutRedirection       = reportFile;
                prc.DuplicateStdoutToStderr = true;

                rr = prc.Run();
            }
            if (rr.Status != RunStatus.Ok)
            {
                throw new NeTesterException("Compilation failed");
            }

            using (StreamReader sr = new StreamReader(reportFile))
                compReport = sr.ReadToEnd();

            return(rr.ExitCode == 0);
        }
Beispiel #3
0
        public CheckStatus Check(string[] files)
        {
            bool okParams = true;

            foreach (string s in files)
            {
                if (string.IsNullOrEmpty(s))
                {
                    okParams = false;
                }
            }

            if (files.Length != 3 || !okParams)
            {
                throw new NeTesterException("Invalid checker parameters");
            }

            string resultXml = Path.Combine(wDir, "result.xml");

            if (!File.Exists(exe))
            {
                throw new NeTesterException("Checker file doesn't exist");
            }

            RunResult rr;

            using (DfyzProc prc = new DfyzProc(exe, wDir, null))
            {
                foreach (string s in files)
                {
                    prc.AddArgument(s);
                }

                prc.AddArgument(resultXml);
                prc.AddArgument("-appes");

                prc.SetCommonParams();
                prc.StdinRedirection = prc.StdoutRedirection = prc.StderrRedirection = DfyzProc.NULL_DEVICE;

                rr = prc.Run();
                if (rr.Status != RunStatus.Ok)
                {
                    string message = "Running checker failed";
                    if (rr.Status == RunStatus.Failure)
                    {
                        message += String.Format(": {0}", prc.Comment);
                    }
                    throw new NeTesterException(message);
                }
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(resultXml);
            }
            catch (XmlException ex)
            {
                throw new NeTesterException(String.Format("Cannot load checker's result file: {0}", ex.Message));
            }
            if (doc.DocumentElement.Name != "result" || !doc.DocumentElement.HasAttribute("outcome"))
            {
                throw new NeTesterException("Checker's result file has invalid format");
            }
            comment = doc.DocumentElement.InnerText;
            return(MapOutcomeToCheckStatus(doc.DocumentElement.Attributes["outcome"].Value));
        }