Esempio n. 1
0
    def read_xml(self):
        if (len(self._env_files_that_need_rewrite) > 0):
            files = ""
            for env_file in self._env_files_that_need_rewrite:
                files += " " + env_file.filename
            expect(
                False,
                "Object(s) %s seem to have newer data than the corresponding case file"
                % files)

        self._env_entryid_files = []
        self._env_entryid_files.append(EnvCase(self._caseroot,
                                               components=None))
        components = self._env_entryid_files[0].get_values("COMP_CLASSES")
        self._env_entryid_files.append(
            EnvRun(self._caseroot, components=components))
        self._env_entryid_files.append(
            EnvBuild(self._caseroot, components=components))
        self._env_entryid_files.append(
            EnvMachPes(self._caseroot, components=components))
        if os.path.isfile(os.path.join(self._caseroot, "env_test.xml")):
            self._env_entryid_files.append(
                EnvTest(self._caseroot, components=components))
        self._env_generic_files = []
        self._env_generic_files.append(EnvBatch(self._caseroot))
        self._env_generic_files.append(EnvMachSpecific(self._caseroot))
        self._env_generic_files.append(EnvArchive(self._caseroot))
        self._files = self._env_entryid_files + self._env_generic_files
Esempio n. 2
0
    def _xml_phase(self, test):
        ###########################################################################
        test_case = CIME.utils.parse_test_name(test)[0]

        # Create, fill and write an envtest object
        test_dir = self._get_test_dir(test)
        envtest = EnvTest(test_dir)

        # Determine list of component classes that this coupler/driver knows how
        # to deal with. This list follows the same order as compset longnames follow.
        files = Files()
        drv_config_file = files.get_value("CONFIG_CPL_FILE")
        drv_comp = Component(drv_config_file)
        envtest.add_elements_by_group(files, {}, "env_test.xml")
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)
        if test in self._test_data and "options" in self._test_data[test] and \
                "memleak_tolerance" in self._test_data[test]['options']:
            envtest.set_value(
                "TEST_MEMLEAK_TOLERANCE",
                self._test_data[test]['options']['memleak_tolerance'])

        test_argv = "-testname %s -testroot %s" % (test, self._test_root)
        if self._baseline_gen_name:
            test_argv += " -generate %s" % self._baseline_gen_name
            basegen_case_fullpath = os.path.join(self._baseline_root,
                                                 self._baseline_gen_name, test)
            logger.debug("basegen_case is %s" % basegen_case_fullpath)
            envtest.set_value("BASELINE_NAME_GEN", self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE",
                              os.path.join(self._baseline_gen_name, test))
        if self._baseline_cmp_name:
            test_argv += " -compare %s" % self._baseline_cmp_name
            envtest.set_value("BASELINE_NAME_CMP", self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE",
                              os.path.join(self._baseline_cmp_name, test))

        envtest.set_value("TEST_ARGV", test_argv)
        envtest.set_value("CLEANUP", self._clean)

        if self._baseline_gen_name or self._baseline_cmp_name:
            envtest.set_value("BASELINE_ROOT", self._baseline_root)
        envtest.set_value("GENERATE_BASELINE", self._baseline_gen_name
                          is not None)
        envtest.set_value("COMPARE_BASELINE", self._baseline_cmp_name
                          is not None)
        envtest.set_value(
            "CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC",
                                                  resolved=False))

        # Add the test instructions from config_test to env_test in the case
        config_test = Tests()
        testnode = config_test.get_test_node(test_case)
        envtest.add_test(testnode)

        # Determine the test_case from the test name
        test_case, case_opts = CIME.utils.parse_test_name(test)[:2]

        # Determine case_opts from the test_case
        if case_opts is not None:
            logger.debug("case_opts are %s " % case_opts)
            for opt in case_opts:

                logger.debug("case_opt is %s" % opt)
                if opt == 'D':
                    envtest.set_test_parameter("DEBUG", "TRUE")
                    logger.debug(" DEBUG set to TRUE")

                elif opt == 'E':
                    envtest.set_test_parameter("USE_ESMF_LIB", "TRUE")
                    envtest.set_test_parameter("COMP_INTERFACE", "ESMF")
                    logger.debug(" USE_ESMF_LIB set to TRUE")
                    logger.debug(" COMP_INTERFACE set to ESMF")

                elif opt == 'CG':
                    envtest.set_test_parameter("CALENDAR", "GREGORIAN")
                    logger.debug(" CALENDAR set to %s" % opt)

                elif opt.startswith('L'):
                    match = re.match('L([A-Za-z])([0-9]*)', opt)
                    stop_option = {
                        "y": "nyears",
                        "m": "nmonths",
                        "d": "ndays",
                        "h": "nhours",
                        "s": "nseconds",
                        "n": "nsteps"
                    }
                    opt = match.group(1)
                    envtest.set_test_parameter("STOP_OPTION", stop_option[opt])
                    opti = match.group(2)
                    envtest.set_test_parameter("STOP_N", opti)
                    logger.debug(" STOP_OPTION set to %s" % stop_option[opt])
                    logger.debug(" STOP_N      set to %s" % opti)

                elif opt.startswith('M'):
                    # M option handled by create newcase
                    continue

                elif opt.startswith('P'):
                    # P option handled by create newcase
                    continue

                elif opt.startswith('N'):
                    # handled in create_newcase
                    continue
                elif opt.startswith('IOP'):
                    logger.warn("IOP test option not yet implemented")
                else:
                    expect(False, "Could not parse option '%s' " % opt)

        envtest.write()
        lockedfiles = os.path.join(test_dir, "LockedFiles")
        if not os.path.exists(lockedfiles):
            os.mkdir(lockedfiles)
        shutil.copy(os.path.join(test_dir, "env_run.xml"),
                    os.path.join(lockedfiles, "env_run.orig.xml"))

        with Case(test_dir, read_only=False) as case:
            if self._output_root is None:
                self._output_root = case.get_value("CIME_OUTPUT_ROOT")
            case.set_value(
                "SHAREDLIBROOT",
                os.path.join(self._output_root,
                             "sharedlibroot.%s" % self._test_id))
            envtest.set_initial_values(case)
            case.set_value("TEST", True)
            if self._save_timing:
                case.set_value("SAVE_TIMING", True)
Esempio n. 3
0
    def _xml_phase(self, test):
    ###########################################################################
        test_case = CIME.utils.parse_test_name(test)[0]

        # Create, fill and write an envtest object
        test_dir = self._get_test_dir(test)
        envtest = EnvTest(test_dir)

        # Determine list of component classes that this coupler/driver knows how
        # to deal with. This list follows the same order as compset longnames follow.
        files = Files()
        drv_config_file = files.get_value("CONFIG_CPL_FILE")
        drv_comp = Component(drv_config_file, "CPL")
        envtest.add_elements_by_group(files, {}, "env_test.xml")
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)
        if test in self._test_data and "options" in self._test_data[test] and \
                "memleak_tolerance" in self._test_data[test]['options']:
            envtest.set_value("TEST_MEMLEAK_TOLERANCE", self._test_data[test]['options']['memleak_tolerance'])

        test_argv = "-testname {} -testroot {}".format(test, self._test_root)
        if self._baseline_gen_name:
            test_argv += " -generate {}".format(self._baseline_gen_name)
            basegen_case_fullpath = os.path.join(self._baseline_root,self._baseline_gen_name, test)
            logger.debug("basegen_case is {}".format(basegen_case_fullpath))
            envtest.set_value("BASELINE_NAME_GEN", self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE", os.path.join(self._baseline_gen_name, test))
        if self._baseline_cmp_name:
            test_argv += " -compare {}".format(self._baseline_cmp_name)
            envtest.set_value("BASELINE_NAME_CMP", self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE", os.path.join(self._baseline_cmp_name, test))

        envtest.set_value("TEST_ARGV", test_argv)
        envtest.set_value("CLEANUP", self._clean)

        envtest.set_value("BASELINE_ROOT", self._baseline_root)
        envtest.set_value("GENERATE_BASELINE", self._baseline_gen_name is not None)
        envtest.set_value("COMPARE_BASELINE", self._baseline_cmp_name is not None)
        envtest.set_value("CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC", resolved=False))
        tput_tolerance = self._machobj.get_value("TEST_TPUT_TOLERANCE", resolved=False)
        envtest.set_value("TEST_TPUT_TOLERANCE", 0.25 if tput_tolerance is None else tput_tolerance)

        # Add the test instructions from config_test to env_test in the case
        config_test = Tests()
        testnode = config_test.get_test_node(test_case)
        envtest.add_test(testnode)
        # Determine the test_case from the test name
        test_case, case_opts = CIME.utils.parse_test_name(test)[:2]

        # Determine case_opts from the test_case
        if case_opts is not None:
            logger.debug("case_opts are {} ".format(case_opts))
            for opt in case_opts: # pylint: disable=not-an-iterable

                logger.debug("case_opt is {}".format(opt))
                if opt == 'D':
                    envtest.set_test_parameter("DEBUG", "TRUE")
                    logger.debug (" DEBUG set to TRUE")

                elif opt == 'E':
                    envtest.set_test_parameter("USE_ESMF_LIB", "TRUE")
                    logger.debug (" USE_ESMF_LIB set to TRUE")

                elif opt == 'CG':
                    envtest.set_test_parameter("CALENDAR", "GREGORIAN")
                    logger.debug (" CALENDAR set to {}".format(opt))

                elif opt.startswith('L'):
                    match =  re.match('L([A-Za-z])([0-9]*)', opt)
                    stop_option = {"y":"nyears", "m":"nmonths", "d":"ndays", "h":"nhours",
                                   "s":"nseconds", "n":"nsteps"}
                    opt = match.group(1)
                    envtest.set_test_parameter("STOP_OPTION",stop_option[opt])
                    opti = match.group(2)
                    envtest.set_test_parameter("STOP_N", opti)

                    logger.debug (" STOP_OPTION set to {}".format(stop_option[opt]))
                    logger.debug (" STOP_N      set to {}".format(opti))

                elif opt.startswith('R'):
                    # R option is for testing in PTS_MODE or Single Column Model
                    #  (SCM) mode
                    envtest.set_test_parameter("PTS_MODE", "TRUE")

                    # For PTS_MODE, compile with mpi-serial
                    envtest.set_test_parameter("MPILIB", "mpi-serial")

                elif (opt.startswith('I') or # Marker to distinguish tests with same name - ignored
                      opt.startswith('M') or # handled in create_newcase
                      opt.startswith('P') or # handled in create_newcase
                      opt.startswith('N') or # handled in create_newcase
                      opt.startswith('C') or # handled in create_newcase
                      opt.startswith('V')):  # handled in create_newcase
                    pass

                elif opt.startswith('IOP'):
                    logger.warning("IOP test option not yet implemented")
                else:
                    expect(False, "Could not parse option '{}' ".format(opt))

        envtest.write()
        lock_file("env_run.xml", caseroot=test_dir, newname="env_run.orig.xml")

        with Case(test_dir, read_only=False) as case:
            if self._output_root is None:
                self._output_root = case.get_value("CIME_OUTPUT_ROOT")
            # if we are running a single test we don't need sharedlibroot
            if len(self._tests) > 1 and self._cime_model != "e3sm":
                case.set_value("SHAREDLIBROOT",
                               os.path.join(self._output_root,
                                            "sharedlibroot.{}".format(self._test_id)))
            envtest.set_initial_values(case)
            case.set_value("TEST", True)
            case.set_value("SAVE_TIMING", self._save_timing)

            # Scale back build parallelism on systems with few cores
            if self._model_build_cost > self._proc_pool:
                case.set_value("GMAKE_J", self._proc_pool)
                self._model_build_cost = self._proc_pool

        return True, ""
Esempio n. 4
0
    def _xml_phase(self, test):
    ###########################################################################
        test_case = CIME.utils.parse_test_name(test)[0]

        # Create, fill and write an envtest object
        test_dir = self._get_test_dir(test)
        envtest = EnvTest(test_dir)

        # Determine list of component classes that this coupler/driver knows how
        # to deal with. This list follows the same order as compset longnames follow.
        files = Files()
        drv_config_file = files.get_value("CONFIG_CPL_FILE")
        drv_comp = Component(drv_config_file, "CPL")
        envtest.add_elements_by_group(files, {}, "env_test.xml")
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)
        if test in self._test_data and "options" in self._test_data[test] and \
                "memleak_tolerance" in self._test_data[test]['options']:
            envtest.set_value("TEST_MEMLEAK_TOLERANCE", self._test_data[test]['options']['memleak_tolerance'])

        test_argv = "-testname {} -testroot {}".format(test, self._test_root)
        if self._baseline_gen_name:
            test_argv += " -generate {}".format(self._baseline_gen_name)
            basegen_case_fullpath = os.path.join(self._baseline_root,self._baseline_gen_name, test)
            logger.debug("basegen_case is {}".format(basegen_case_fullpath))
            envtest.set_value("BASELINE_NAME_GEN", self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE", os.path.join(self._baseline_gen_name, test))
        if self._baseline_cmp_name:
            test_argv += " -compare {}".format(self._baseline_cmp_name)
            envtest.set_value("BASELINE_NAME_CMP", self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE", os.path.join(self._baseline_cmp_name, test))

        envtest.set_value("TEST_ARGV", test_argv)
        envtest.set_value("CLEANUP", self._clean)

        envtest.set_value("BASELINE_ROOT", self._baseline_root)
        envtest.set_value("GENERATE_BASELINE", self._baseline_gen_name is not None)
        envtest.set_value("COMPARE_BASELINE", self._baseline_cmp_name is not None)
        envtest.set_value("CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC", resolved=False))
        tput_tolerance = self._machobj.get_value("TEST_TPUT_TOLERANCE", resolved=False)
        envtest.set_value("TEST_TPUT_TOLERANCE", 0.25 if tput_tolerance is None else tput_tolerance)

        # Add the test instructions from config_test to env_test in the case
        config_test = Tests()
        testnode = config_test.get_test_node(test_case)
        envtest.add_test(testnode)
        # Determine the test_case from the test name
        test_case, case_opts = CIME.utils.parse_test_name(test)[:2]

        # Determine case_opts from the test_case
        if case_opts is not None:
            logger.debug("case_opts are {} ".format(case_opts))
            for opt in case_opts: # pylint: disable=not-an-iterable

                logger.debug("case_opt is {}".format(opt))
                if opt == 'D':
                    envtest.set_test_parameter("DEBUG", "TRUE")
                    logger.debug (" DEBUG set to TRUE")

                elif opt == 'E':
                    envtest.set_test_parameter("USE_ESMF_LIB", "TRUE")
                    logger.debug (" USE_ESMF_LIB set to TRUE")

                elif opt == 'CG':
                    envtest.set_test_parameter("CALENDAR", "GREGORIAN")
                    logger.debug (" CALENDAR set to {}".format(opt))

                elif opt.startswith('L'):
                    match =  re.match('L([A-Za-z])([0-9]*)', opt)
                    stop_option = {"y":"nyears", "m":"nmonths", "d":"ndays", "h":"nhours",
                                   "s":"nseconds", "n":"nsteps"}
                    opt = match.group(1)
                    envtest.set_test_parameter("STOP_OPTION",stop_option[opt])
                    opti = match.group(2)
                    envtest.set_test_parameter("STOP_N", opti)

                    logger.debug (" STOP_OPTION set to {}".format(stop_option[opt]))
                    logger.debug (" STOP_N      set to {}".format(opti))

                elif opt.startswith('R'):
                    # R option is for testing in PTS_MODE or Single Column Model
                    #  (SCM) mode
                    envtest.set_test_parameter("PTS_MODE", "TRUE")

                    # For PTS_MODE, compile with mpi-serial
                    envtest.set_test_parameter("MPILIB", "mpi-serial")

                elif (opt.startswith('I') or # Marker to distinguish tests with same name - ignored
                      opt.startswith('M') or # handled in create_newcase
                      opt.startswith('P') or # handled in create_newcase
                      opt.startswith('N') or # handled in create_newcase
                      opt.startswith('C') or # handled in create_newcase
                      opt.startswith('V')):  # handled in create_newcase
                    pass

                elif opt.startswith('IOP'):
                    logger.warning("IOP test option not yet implemented")
                else:
                    expect(False, "Could not parse option '{}' ".format(opt))

        envtest.write()
        lock_file("env_run.xml", caseroot=test_dir, newname="env_run.orig.xml")

        with Case(test_dir, read_only=False) as case:
            if self._output_root is None:
                self._output_root = case.get_value("CIME_OUTPUT_ROOT")
            # if we are running a single test we don't need sharedlibroot
            if len(self._tests) > 1 and self._cime_model != "e3sm":
                case.set_value("SHAREDLIBROOT",
                               os.path.join(self._output_root,
                                            "sharedlibroot.{}".format(self._test_id)))
            envtest.set_initial_values(case)
            case.set_value("TEST", True)
            case.set_value("SAVE_TIMING", self._save_timing)

            # Scale back build parallelism on systems with few cores
            if self._model_build_cost > self._proc_pool:
                case.set_value("GMAKE_J", self._proc_pool)
                self._model_build_cost = self._proc_pool
Esempio n. 5
0
    def _xml_phase(self, test):
    ###########################################################################
        test_case = CIME.utils.parse_test_name(test)[0]

        # Create, fill and write an envtest object
        test_dir = self._get_test_dir(test)
        envtest = EnvTest(test_dir)

        # Determine list of component classes that this coupler/driver knows how
        # to deal with. This list follows the same order as compset longnames follow.
        files = Files()
        drv_config_file = files.get_value("CONFIG_CPL_FILE")
        drv_comp = Component(drv_config_file)
        envtest.add_elements_by_group(files, {}, "env_test.xml")
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)
        if test in self._test_data and "options" in self._test_data[test] and \
                "memleak_tolerance" in self._test_data[test]['options']:
            envtest.set_value("TEST_MEMLEAK_TOLERANCE", self._test_data[test]['options']['memleak_tolerance'])

        test_argv = "-testname %s -testroot %s" % (test, self._test_root)
        if self._baseline_gen_name:
            test_argv += " -generate %s" % self._baseline_gen_name
            basegen_case_fullpath = os.path.join(self._baseline_root,self._baseline_gen_name, test)
            logger.debug("basegen_case is %s"%basegen_case_fullpath)
            envtest.set_value("BASELINE_NAME_GEN", self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE", os.path.join(self._baseline_gen_name, test))
        if self._baseline_cmp_name:
            test_argv += " -compare %s" % self._baseline_cmp_name
            envtest.set_value("BASELINE_NAME_CMP", self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE", os.path.join(self._baseline_cmp_name, test))

        envtest.set_value("TEST_ARGV", test_argv)
        envtest.set_value("CLEANUP", self._clean)

        if self._baseline_gen_name or self._baseline_cmp_name:
            envtest.set_value("BASELINE_ROOT", self._baseline_root)
        envtest.set_value("GENERATE_BASELINE", self._baseline_gen_name is not None)
        envtest.set_value("COMPARE_BASELINE", self._baseline_cmp_name is not None)
        envtest.set_value("CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC", resolved=False))
        tput_tolerance = self._machobj.get_value("TEST_TPUT_TOLERANCE", resolved=False)
        envtest.set_value("TEST_TPUT_TOLERANCE", 0.25 if tput_tolerance is None else tput_tolerance)

        # Add the test instructions from config_test to env_test in the case
        config_test = Tests()
        testnode = config_test.get_test_node(test_case)
        envtest.add_test(testnode)

        # Determine the test_case from the test name
        test_case, case_opts = CIME.utils.parse_test_name(test)[:2]

        # Determine case_opts from the test_case
        if case_opts is not None:
            logger.debug("case_opts are %s " %case_opts)
            for opt in case_opts:

                logger.debug("case_opt is %s" %opt)
                if opt == 'D':
                    envtest.set_test_parameter("DEBUG", "TRUE")
                    logger.debug (" DEBUG set to TRUE")

                elif opt == 'E':
                    envtest.set_test_parameter("USE_ESMF_LIB", "TRUE")
                    envtest.set_test_parameter("COMP_INTERFACE", "ESMF")
                    logger.debug (" USE_ESMF_LIB set to TRUE")
                    logger.debug (" COMP_INTERFACE set to ESMF")

                elif opt == 'CG':
                    envtest.set_test_parameter("CALENDAR", "GREGORIAN")
                    logger.debug (" CALENDAR set to %s" %opt)

                elif opt.startswith('L'):
                    match =  re.match('L([A-Za-z])([0-9]*)', opt)
                    stop_option = {"y":"nyears", "m":"nmonths", "d":"ndays", "h":"nhours",
                                   "s":"nseconds", "n":"nsteps"}
                    opt = match.group(1)
                    envtest.set_test_parameter("STOP_OPTION",stop_option[opt])
                    opti = match.group(2)
                    envtest.set_test_parameter("STOP_N", opti)
                    logger.debug (" STOP_OPTION set to %s" %stop_option[opt])
                    logger.debug (" STOP_N      set to %s" %opti)
		    
		elif opt.startswith('R'):
                    # R option is for testing in PTS_MODE or Single Column Model 
                    #  (SCM) mode
                    envtest.set_test_parameter("PTS_MODE", "TRUE")
		    
                    # For PTS_MODE, compile with mpi-serial
                    envtest.set_test_parameter("MPILIB", "mpi-serial")
                    comps=["ATM","LND","ICE","OCN","CPL","GLC","ROF","WAV"]
                    for comp in comps:
                        envtest.set_test_parameter("NTASKS_"+comp,"1") 
		    
                    # Set latitude and longitude for the appropriate case
                    # Below for ARM97, default SCM test case
                    if 'A97' in test:
                        envtest.set_test_parameter("PTS_LAT", "36.6")
                        envtest.set_test_parameter("PTS_LON", "262.5")
		    
                elif opt.startswith('M'):
                    # M option handled by create newcase
                    continue

                elif opt.startswith('P'):
                    # P option handled by create newcase
                    continue

                elif opt.startswith('N'):
                    # handled in create_newcase
                    continue
                elif opt.startswith('IOP'):
                    logger.warn("IOP test option not yet implemented")
                else:
                    expect(False, "Could not parse option '%s' " %opt)

        envtest.write()
        lock_file("env_run.xml", caseroot=test_dir, newname="env_run.orig.xml")

        with Case(test_dir, read_only=False) as case:
            if self._output_root is None:
                self._output_root = case.get_value("CIME_OUTPUT_ROOT")
            # if we are running a single test we don't need sharedlibroot
            if len(self._tests) > 1 and get_model() != "acme":
                case.set_value("SHAREDLIBROOT",
                               os.path.join(self._output_root,
                                            "sharedlibroot.%s"%self._test_id))
            envtest.set_initial_values(case)
            case.set_value("TEST", True)
            case.set_value("SAVE_TIMING", self._save_timing)
Esempio n. 6
0
def get_testreporter_xml(testroot, testid, tagname, testtype):
    ###############################################################################
    os.chdir(testroot)

    #
    # Retrieve compiler name and mpi library
    #
    xml_file = glob.glob("*" + testid + "/env_build.xml")
    expect(
        len(xml_file) > 0,
        "Tests not found.  It's possible your testid, {} is wrong.".format(
            testid))
    envxml = (EnvBuild(".", infile=xml_file[0]))
    compiler = envxml.get_value("COMPILER")
    mpilib = envxml.get_value("MPILIB")

    #
    # Retrieve machine name
    #
    xml_file = glob.glob("*" + testid + "/env_case.xml")
    envxml = (EnvCase(".", infile=xml_file[0]))
    machine = envxml.get_value("MACH")

    #
    # Retrieve baseline tag to compare to
    #
    xml_file = glob.glob("*" + testid + "/env_test.xml")
    envxml = (EnvTest(".", infile=xml_file[0]))
    baseline = envxml.get_value("BASELINE_NAME_CMP")

    #
    # Create XML header
    #

    testxml = TestReporter()
    testxml.setup_header(tagname, machine, compiler, mpilib, testroot,
                         testtype, baseline)

    #
    # Create lists on tests based on the testid in the testroot directory.
    #
    test_names = glob.glob("*" + testid)
    #
    # Loop over all tests and parse the test results
    #
    test_status = {}
    for test_name in test_names:
        if not os.path.isfile(test_name + "/TestStatus"):
            continue
        test_status['COMMENT'] = ""
        test_status['BASELINE'] = '----'
        test_status['MEMCOMP'] = '----'
        test_status['MEMLEAK'] = '----'
        test_status['NLCOMP'] = '----'
        test_status['STATUS'] = '----'
        test_status['TPUTCOMP'] = '----'
        #
        # Check to see if TestStatus is present, if not then continue
        # I might want to set the status to fail
        #
        try:
            lines = [
                line.rstrip('\n') for line in open(test_name + "/TestStatus")
            ]
        except (IOError, OSError):
            test_status['STATUS'] = "FAIL"
            test_status['COMMENT'] = "TestStatus missing. "
            continue
        #
        # Loop over each line of TestStatus, and check for different types of failures.
        #
        for line in lines:
            if "NLCOMP" in line:
                test_status['NLCOMP'] = line[0:4]
            if "MEMLEAK" in line:
                test_status['MEMLEAK'] = line[0:4]
            if "MEMCOMP" in line:
                test_status['MEMCOMP'] = line[0:4]
            if "BASELINE" in line:
                test_status['BASELINE'] = line[0:4]
            if "TPUTCOMP" in line:
                test_status['TPUTCOMP'] = line[0:4]
                if "FAIL PFS" in line:
                    test_status['STATUS'] = "FAIL"
            if "INIT" in line:
                test_status['INIT'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['STATUS'] = "SFAIL"
                    test_status['COMMENT'] += "INIT fail! "
                    break
            if "CREATE_NEWCASE" in line:
                test_status['CREATE_NEWCASE'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['STATUS'] = "SFAIL"
                    test_status['COMMENT'] += "CREATE_NEWCASE fail! "
                    break
            if "XML" in line:
                test_status['XML'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['STATUS'] = "SFAIL"
                    test_status['COMMENT'] += "XML fail! "
                    break
            if "SETUP" in line:
                test_status['SETUP'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['STATUS'] = "SFAIL"
                    test_status['COMMENT'] += "SETUP fail! "
                    break
            if "SHAREDLIB_BUILD" in line:
                test_status['SHAREDLIB_BUILD'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['STATUS'] = "CFAIL"
                    test_status['COMMENT'] += "SHAREDLIB_BUILD fail! "
                    break
            if "MODEL_BUILD" in line:
                test_status['MODEL_BUILD'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['STATUS'] = "CFAIL"
                    test_status['COMMENT'] += "MODEL_BUILD fail! "
                    break
            if "SUBMIT" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "SUBMIT fail! "
                    break
            if "RUN" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "RUN fail! "
                    break
            if "COMPARE_base_rest" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "Restart fail! "
                    break
            if "COMPARE_base_hybrid" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "Hybrid fail! "
                    break
            if "COMPARE_base_multiinst" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "Multi instance fail! "
                    break
            if "COMPARE_base_test" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "Base test fail! "
                    break
            if "COMPARE_base_single_thread" in line:
                test_status['STATUS'] = line[0:4]
                if line[0:4] in ("FAIL", "PEND"):
                    test_status['COMMENT'] += "Thread test fail! "
                    break

            #
            #  Do not include time comments.  Just a preference to have cleaner comments in the test database
            #
            try:
                if 'time=' not in line and 'GENERATE' not in line:
                    if 'BASELINE' not in line:
                        test_status['COMMENT'] += line.split(' ', 3)[3] + ' '
                    else:
                        test_status['COMMENT'] += line.split(' ', 4)[4] + ' '
            except Exception:  # Probably want to be more specific here
                pass

        #
        # Fill in the xml with the test results
        #
        testxml.add_result(test_name, test_status)

    return testxml
Esempio n. 7
0
    def _xml_phase(self, test):
    ###########################################################################
        test_case = CIME.utils.parse_test_name(test)[0]

        # Create, fill and write an envtest object
        test_dir = self._get_test_dir(test)
        envtest = EnvTest(test_dir)

        # Determine list of component classes that this coupler/driver knows how
        # to deal with. This list follows the same order as compset longnames follow.
        files = Files()
        drv_config_file = files.get_value("CONFIG_DRV_FILE")
        drv_comp = Component(drv_config_file)
        envtest.add_elements_by_group(files, {}, "env_test.xml")
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)
        if test in self._test_data and "options" in self._test_data[test] and \
                "memleak_tolerance" in self._test_data[test]['options']:
            envtest.set_value("TEST_MEMLEAK_TOLERANCE", self._test_data[test]['options']['memleak_tolerance'])

        test_argv = "-testname %s -testroot %s" % (test, self._test_root)
        if self._baseline_gen_name:
            test_argv += " -generate %s" % self._baseline_gen_name
            basegen_case_fullpath = os.path.join(self._baseline_root,self._baseline_gen_name, test)
            logger.debug("basegen_case is %s"%basegen_case_fullpath)
            envtest.set_value("BASELINE_NAME_GEN", self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE", os.path.join(self._baseline_gen_name, test))
        if self._baseline_cmp_name:
            test_argv += " -compare %s" % self._baseline_cmp_name
            envtest.set_value("BASELINE_NAME_CMP", self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE", os.path.join(self._baseline_cmp_name, test))

        envtest.set_value("TEST_ARGV", test_argv)
        envtest.set_value("CLEANUP", self._clean)

        if self._baseline_gen_name or self._baseline_cmp_name:
            envtest.set_value("BASELINE_ROOT", self._baseline_root)
        envtest.set_value("GENERATE_BASELINE", self._baseline_gen_name is not None)
        envtest.set_value("COMPARE_BASELINE", self._baseline_cmp_name is not None)
        envtest.set_value("CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC", resolved=False))

        # Add the test instructions from config_test to env_test in the case
        config_test = Tests()
        testnode = config_test.get_test_node(test_case)
        envtest.add_test(testnode)

        # Determine the test_case from the test name
        test_case, case_opts = CIME.utils.parse_test_name(test)[:2]

        # Determine case_opts from the test_case
        if case_opts is not None:
            logger.debug("case_opts are %s " %case_opts)
            for opt in case_opts:

                logger.debug("case_opt is %s" %opt)
                if opt == 'D':
                    envtest.set_test_parameter("DEBUG", "TRUE")
                    logger.debug (" DEBUG set to TRUE")

                elif opt == 'E':
                    envtest.set_test_parameter("USE_ESMF_LIB", "TRUE")
                    envtest.set_test_parameter("COMP_INTERFACE", "ESMF")
                    logger.debug (" USE_ESMF_LIB set to TRUE")
                    logger.debug (" COMP_INTERFACE set to ESMF")

                elif opt == 'CG':
                    envtest.set_test_parameter("CALENDAR", "GREGORIAN")
                    logger.debug (" CALENDAR set to %s" %opt)

                elif opt.startswith('L'):
                    match =  re.match('L([A-Za-z])([0-9]*)', opt)
                    stop_option = {"y":"nyears", "m":"nmonths", "d":"ndays", "h":"nhours",
                                   "s":"nseconds", "n":"nsteps"}
                    opt = match.group(1)
                    envtest.set_test_parameter("STOP_OPTION",stop_option[opt])
                    opti = match.group(2)
                    envtest.set_test_parameter("STOP_N", opti)
                    logger.debug (" STOP_OPTION set to %s" %stop_option[opt])
                    logger.debug (" STOP_N      set to %s" %opti)

                elif opt.startswith('M'):
                    # M option handled by create newcase
                    continue

                elif opt.startswith('P'):
                    # P option handled by create newcase
                    continue

                elif opt.startswith('N'):
                    # handled in create_newcase
                    continue
                elif opt.startswith('IOP'):
                    logger.warn("IOP test option not yet implemented")
                else:
                    expect(False, "Could not parse option '%s' " %opt)

        envtest.write()
        lockedfiles = os.path.join(test_dir, "LockedFiles")
        if not os.path.exists(lockedfiles):
            os.mkdir(lockedfiles)
        shutil.copy(os.path.join(test_dir,"env_run.xml"),
                    os.path.join(lockedfiles, "env_run.orig.xml"))

        with Case(test_dir, read_only=False) as case:
            case.set_value("SHAREDLIBROOT",
                           os.path.join(self._test_root,
                                        "sharedlibroot.%s"%self._test_id))
            envtest.set_initial_values(case)
            if self._save_timing:
                case.set_value("SAVE_TIMING", True)

        return True
Esempio n. 8
0
    def _xml_phase(self, test):
    ###########################################################################

        test_case = CIME.utils.parse_test_name(test)[0]
        envtest = EnvTest(self._get_test_dir(test))

        files = Files()
        drv_config_file = files.get_value("CONFIG_DRV_FILE")
        logging.info("Found drv_config_file %s" % drv_config_file)

        drv_comp = Component(drv_config_file)
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)

        test_argv = "-testname %s -testroot %s" % (test, self._test_root)
        if (self._generate):
            test_argv += " -generate %s" % self._baseline_gen_name
            envtest.set_value("BASELINE_NAME_GEN",self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE",os.path.join(self._baseline_gen_name,test))
        if (self._compare):
            test_argv += " -compare %s" % self._baseline_cmp_name
            envtest.set_value("BASELINE_NAME_CMP",self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE",os.path.join(self._baseline_cmp_name,test))

        envtest.set_value("TEST_ARGV",test_argv)
        envtest.set_value("CLEANUP", ("TRUE" if self._clean else "FALSE"))

        if (self._generate or self._compare):
            envtest.set_value("BASELINE_ROOT", self._baseline_root)

        envtest.set_value("GENERATE_BASELINE", "TRUE" if self._generate else "FALSE")
        envtest.set_value("COMPARE_BASELINE", "TRUE" if self._compare else "FALSE")
        envtest.set_value("CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC",resolved=False))
        envtest.write()
        return True
Esempio n. 9
0
    def _xml_phase(self, test):
    ###########################################################################
        test_case = CIME.utils.parse_test_name(test)[0]

        # Create, fill and write an envtest object
        test_dir = self._get_test_dir(test)
        envtest = EnvTest(test_dir)

        # Determine list of component classes that this coupler/driver knows how
        # to deal with. This list follows the same order as compset longnames follow.
        files = Files()
        drv_config_file = files.get_value("CONFIG_DRV_FILE")
        drv_comp = Component(drv_config_file)
        component_classes = drv_comp.get_valid_model_components()
        envtest.add_elements_by_group(drv_comp, {}, "env_test.xml")
        envtest.set_value("TESTCASE", test_case)
        envtest.set_value("TEST_TESTID", self._test_id)
        envtest.set_value("CASEBASEID", test)

        test_argv = "-testname %s -testroot %s" % (test, self._test_root)
        if self._generate:
            test_argv += " -generate %s" % self._baseline_gen_name
            envtest.set_value("BASELINE_NAME_GEN", self._baseline_gen_name)
            envtest.set_value("BASEGEN_CASE", os.path.join(self._baseline_gen_name, test))
        if self._compare:
            test_argv += " -compare %s" % self._baseline_cmp_name
            envtest.set_value("BASELINE_NAME_CMP", self._baseline_cmp_name)
            envtest.set_value("BASECMP_CASE", os.path.join(self._baseline_cmp_name, test))

        envtest.set_value("TEST_ARGV", test_argv)
        envtest.set_value("CLEANUP", self._clean)

        if self._generate or self._compare:
            envtest.set_value("BASELINE_ROOT", self._baseline_root)
        envtest.set_value("GENERATE_BASELINE", self._generate)
        envtest.set_value("COMPARE_BASELINE", self._compare)
        envtest.set_value("CCSM_CPRNC", self._machobj.get_value("CCSM_CPRNC", resolved=False))

        """
        Add the test instructions from config_test to env_test in the case
        """
        config_test = Tests()
        testnode = config_test.get_test_node(test_case)
        envtest.add_test(testnode)

        # Determine the test_case from the test name
        test_case, case_opts = CIME.utils.parse_test_name(test)[:2]

        # Determine case_opts from the test_case
        if case_opts is not None:
            logger.debug("case_opts are %s " %case_opts)
            for opt in case_opts:

                logger.debug("case_opt is %s" %opt)
                if opt == 'D':
                    envtest.set_test_parameter("DEBUG", "TRUE")
                    logger.debug (" DEBUG set to TRUE")

                elif opt == 'E':
                    envtest.set_test_parameter("USE_ESMF_LIB", "TRUE")
                    envtest.set_test_parameter("COMP_INTERFACE", "ESMF")
                    logger.debug (" USE_ESMF_LIB set to TRUE")
                    logger.debug (" COMP_INTERFACE set to ESMF")

                elif opt == 'CG':
                    envtest.set_test_parameter("CALENDAR", "GREGORIAN")
                    logger.debug (" CALENDAR set to %s" %opt)

                elif opt.startswith('L'):
                    match =  re.match('L([A-Za-z])([0-9]*)', opt)
                    stop_option = {"y":"nyears", "m":"nmonths", "d":"ndays", "h":"nhours",
                                   "s":"nseconds", "n":"nsteps"}
                    opt = match.group(1)
                    envtest.set_test_parameter("STOP_OPTION",stop_option[opt])
                    opti = match.group(2)
                    envtest.set_test_parameter("STOP_N", opti)
                    logger.debug (" STOP_OPTION set to %s" %stop_option[opt])
                    logger.debug (" STOP_N      set to %s" %opti)

                elif opt.startswith('M'):
                    # M option handled by create newcase
                    continue

                elif opt.startswith('P'):
                    match1 =  re.match('P([0-9]+)', opt)
                    match2 =  re.match('P([0-9]+)x([0-9]+)', opt)
                    match3 =  re.match('P[SMLX][12]?', opt)

                    opti_tasks = None
                    if match1:
                        opti_tasks = match1.group(1)
                        for component_class in component_classes:
                            if component_class == "DRV":
                                component_class = "CPL"
                            string = "NTASKS_" + component_class
                            envtest.set_test_parameter(string, opti_tasks)
                            string = "NTHRDS_" + component_class
                            envtest.set_test_parameter(string, str(1))
                            string = "ROOTPE_" + component_class
                            envtest.set_test_parameter(string, str(0))
                        opti_thrds = 1
                    elif match2:
                        opti_tasks = match2.group(1)
                        opti_thrds = match2.group(2)
                        for component_class in component_classes:
                            if component_class == "DRV":
                                component_class = "CPL"
                            string = "NTASKS_" + component_class
                            envtest.set_test_parameter(string, opti_tasks)
                            string = "NTHRDS_" + component_class
                            envtest.set_test_parameter(string, opti_thrds)
                            string = "ROOTPE_" + component_class
                            envtest.set_test_parameter(string, str(0))
                    elif match3:

                        # handled by create_newcase
                        continue
                    if not match3:
                        expect(opti_tasks is not None, "No match found for PE option %s"%opt)
                        logger.debug (" NTASKS_xxx set to %s" %opti_tasks)
                        logger.debug (" NTHRDS_xxx set to %s" %opti_thrds)
                        logger.debug (" ROOTPE_xxx set to %s 0")

                elif opt.startswith('N'):
                    # handled in create_newcase
                    continue
                elif opt.startswith('IOP'):
                    logger.warn("IOP test option not yet implemented")
                else:
                    expect(False, "Could not parse option '%s' " %opt)

        envtest.write()
        lockedfiles = os.path.join(test_dir, "LockedFiles")
        try:
            os.stat(lockedfiles)
        except:
            os.mkdir(lockedfiles)
        shutil.copy(os.path.join(test_dir,"env_run.xml"),
                    os.path.join(lockedfiles, "env_run.orig.xml"))

        case = Case(test_dir)
        case.set_value("SHAREDLIBROOT",
                       os.path.join(self._test_root,
                                    "sharedlibroot.%s"%self._test_id))

        envtest.set_initial_values(case)
        return True