Пример #1
0
        protected string RunTest(Zone zone, AutoEvaluation job)
        {
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            //Get interface to external running tool
            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);

            exttool.Arguments = job.RunToolArgs;

            //Execute the test with the tool
            try {
                if (exttool.Execute(zone.LocalPath, job.TimeLimit * 1000) != 0)
                {
                    return(FormErrorXml(AutoResult.CRITICALLYFLAWED,
                                        exttool.ErrorOutput, job.Points));
                }
                else
                {
                    return(ValidateResult(exttool.Output));
                }
            } catch (ToolExecutionException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (ResultFormatException er) {
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (Exception) {
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points));
            }
        }
Пример #2
0
        protected string RunBuildTest(Zone zone, AutoEvaluation job, out bool suc)
        {
            int retval = -1;
            ExternalToolFactory extfact = ExternalToolFactory.GetInstance();

            IExternalTool exttool = extfact.CreateExternalTool(job.RunTool);

            exttool.Arguments = job.RunToolArgs;

            DateTime begin = DateTime.Now;

            try {
                retval = exttool.Execute(zone.LocalPath, job.TimeLimit * 1000);
            } catch (ToolExecutionException er) {
                suc = false;
                m_logger.Log("Error: " + er.Message, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, er.Message, job.Points));
            } catch (Exception) {
                suc = false;
                string ermsg = "Unexpected tool execution error. Contact administrator";
                m_logger.Log("Error: " + ermsg, TestLogger.LogType.ERROR);
                return(FormErrorXml(AutoResult.CRITICALLYFLAWED, ermsg, job.Points));
            }

            DateTime end = DateTime.Now;

            int time = Convert.ToInt32(end.Subtract(begin).TotalSeconds);

            suc = (retval == 0);
            return(FormBuildXml(suc, time,
                                String.Format("{0}\n\n{1}", exttool.Output, exttool.ErrorOutput),
                                job.Points));
        }