Exemplo n.º 1
0
    def run(self):
        """The run phase of the regression test pipeline.

        This call is non-blocking.
        It simply submits the job associated with this test and returns.
        """
        if not self.current_system or not self._current_partition:
            raise PipelineError('no system or system partition is set')

        exec_cmd = [
            self.job.launcher.run_command(self.job), self.executable,
            *self.executable_opts
        ]
        commands = [*self.pre_run, ' '.join(exec_cmd), *self.post_run]
        environs = [
            self._current_partition.local_env, self._current_environ,
            self._user_environ
        ]
        with os_ext.change_dir(self._stagedir):
            try:
                self._job.prepare(commands, environs, login=True)
            except OSError as e:
                raise PipelineError('failed to prepare job') from e

            self._job.submit()

        msg = ('spawned job (%s=%s)' %
               ('pid' if self.is_local() else 'jobid', self._job.jobid))
        self.logger.debug(msg)
Exemplo n.º 2
0
 def _copy_to_stagedir(self, path):
     self.logger.debug('copying %s to stage directory (%s)' %
                       (path, self._stagedir))
     self.logger.debug('symlinking files: %s' % self.readonly_files)
     try:
         os_ext.copytree_virtual(path, self._stagedir, self.readonly_files)
     except (OSError, ValueError, TypeError) as e:
         raise PipelineError('virtual copying of files failed') from e
Exemplo n.º 3
0
    def run(self):
        """The run phase of the regression test pipeline.

        This call is non-blocking.
        It simply submits the job associated with this test and returns.
        """
        if not self._current_system or not self._current_partition:
            raise PipelineError('no system or system partition is set')

        with os_ext.change_dir(self._stagedir):
            try:
                self._job.prepare(BashScriptBuilder(login=True))
            except OSError as e:
                raise PipelineError('failed to prepare job') from e

            self._job.submit()

        msg = ('spawned job (%s=%s)' %
               ('pid' if self.is_local() else 'jobid', self._job.jobid))
        self.logger.debug(msg)
Exemplo n.º 4
0
 def _setup_paths(self):
     """Setup the check's dynamic paths."""
     self.logger.debug('setting up paths')
     try:
         resources = rt.runtime().resources
         self._stagedir = resources.make_stagedir(
             self.current_system.name, self._current_partition.name,
             self._current_environ.name, self.name)
         self._outputdir = resources.make_outputdir(
             self.current_system.name, self._current_partition.name,
             self._current_environ.name, self.name)
     except OSError as e:
         raise PipelineError('failed to set up paths') from e
Exemplo n.º 5
0
    def _setup_paths(self):
        """Setup the check's dynamic paths."""
        self.logger.debug('setting up paths')
        try:
            self._stagedir = self._resources_mgr.stagedir(
                self._sanitize_basename(self._current_partition.name),
                self.name, self._sanitize_basename(self._current_environ.name))

            self.outputdir = self._resources_mgr.outputdir(
                self._sanitize_basename(self._current_partition.name),
                self.name, self._sanitize_basename(self._current_environ.name))
        except OSError as e:
            raise PipelineError('failed to set up paths') from e

        self._stdout = os.path.join(self._stagedir, '%s.out' % self.name)
        self._stderr = os.path.join(self._stagedir, '%s.err' % self.name)
Exemplo n.º 6
0
    def compile(self, **compile_opts):
        """The compilation stage of the regression test pipeline.

        The standard output and standard error of this stage will be used as
        the standard output and error of the test.
        """
        super().compile(**compile_opts)

        try:
            with open(self._stdout, 'w') as f:
                f.write(self._compile_task.stdout)

            with open(self._stderr, 'w') as f:
                f.write(self._compile_task.stderr)
        except OSError as e:
            raise PipelineError('could not write stdout/stderr') from e
Exemplo n.º 7
0
    def compile(self):
        """The compilation phase of the regression test pipeline.

        :raises reframe.core.exceptions.ReframeError: In case of errors.
        """
        if not self._current_environ:
            raise PipelineError('no programming environment set')

        # Copy the check's resources to the stage directory
        if self.sourcesdir:
            try:
                commonpath = os.path.commonpath(
                    [self.sourcesdir, self.sourcepath])
            except ValueError:
                commonpath = None

            if commonpath:
                self.logger.warn(
                    "sourcepath `%s' seems to be a subdirectory of "
                    "sourcesdir `%s', but it will be interpreted "
                    "as relative to it." % (self.sourcepath, self.sourcesdir))

            if os_ext.is_url(self.sourcesdir):
                self._clone_to_stagedir(self.sourcesdir)
            else:
                self._copy_to_stagedir(
                    os.path.join(self._prefix, self.sourcesdir))

        # Verify the sourcepath and determine the sourcepath in the stagedir
        if (os.path.isabs(self.sourcepath)
                or os.path.normpath(self.sourcepath).startswith('..')):
            raise PipelineError(
                'self.sourcepath is an absolute path or does not point to a '
                'subfolder or a file contained in self.sourcesdir: ' +
                self.sourcepath)

        staged_sourcepath = os.path.join(self._stagedir, self.sourcepath)
        self.logger.debug('Staged sourcepath: %s' % staged_sourcepath)
        if os.path.isdir(staged_sourcepath):
            if not self.build_system:
                # Try to guess the build system
                cmakelists = os.path.join(staged_sourcepath, 'CMakeLists.txt')
                configure_ac = os.path.join(staged_sourcepath, 'configure.ac')
                configure_in = os.path.join(staged_sourcepath, 'configure.in')
                if os.path.exists(cmakelists):
                    self.build_system = 'CMake'
                    self.build_system.builddir = 'rfm_build'
                elif (os.path.exists(configure_ac)
                      or os.path.exists(configure_in)):
                    self.build_system = 'Autotools'
                    self.build_system.builddir = 'rfm_build'
                else:
                    self.build_system = 'Make'

            self.build_system.srcdir = self.sourcepath
        else:
            if not self.build_system:
                self.build_system = 'SingleSource'

            self.build_system.srcfile = self.sourcepath
            self.build_system.executable = self.executable

        # Prepare build job
        build_commands = [
            *self.prebuild_cmd,
            *self.build_system.emit_build_commands(self._current_environ),
            *self.postbuild_cmd
        ]
        environs = [
            self._current_partition.local_env, self._current_environ,
            self._user_environ
        ]
        self._build_job = getscheduler('local')(
            name='rfm_%s_build' % self.name,
            launcher=getlauncher('local')(),
            workdir=self._stagedir)

        with os_ext.change_dir(self._stagedir):
            try:
                self._build_job.prepare(build_commands,
                                        environs,
                                        login=True,
                                        trap_errors=True)
            except OSError as e:
                raise PipelineError('failed to prepare build job') from e

            self._build_job.submit()
Exemplo n.º 8
0
    def compile(self, **compile_opts):
        """The compilation phase of the regression test pipeline.

        :arg compile_opts: Extra options to be passed to the programming
            environment for compiling the source code of the test.
        :raises reframe.core.exceptions.ReframeError: In case of errors.
        """
        if not self._current_environ:
            raise PipelineError('no programming environment set')

        # Copy the check's resources to the stage directory
        if self.sourcesdir:
            try:
                commonpath = os.path.commonpath(
                    [self.sourcesdir, self.sourcepath])
            except ValueError:
                commonpath = None

            if commonpath:
                self.logger.warn(
                    "sourcepath (`%s') seems to be a subdirectory of "
                    "sourcesdir (`%s'), but it will be interpreted "
                    "as relative to it." % (self.sourcepath, self.sourcesdir))

            if os_ext.is_url(self.sourcesdir):
                self._clone_to_stagedir(self.sourcesdir)
            else:
                self._copy_to_stagedir(
                    os.path.join(self._prefix, self.sourcesdir))

        # Verify the sourcepath and determine the sourcepath in the stagedir
        if (os.path.isabs(self.sourcepath)
                or os.path.normpath(self.sourcepath).startswith('..')):
            raise PipelineError(
                'self.sourcepath is an absolute path or does not point to a '
                'subfolder or a file contained in self.sourcesdir: ' +
                self.sourcepath)

        staged_sourcepath = os.path.join(self._stagedir, self.sourcepath)
        self.logger.debug('Staged sourcepath: %s' % staged_sourcepath)

        # Remove source and executable from compile_opts
        compile_opts.pop('source', None)
        compile_opts.pop('executable', None)

        # Change working dir to stagedir although absolute paths are used
        # everywhere in the compilation process. This is done to ensure that
        # any other files (besides the executable) generated during the the
        # compilation will remain in the stage directory
        with os_ext.change_dir(self._stagedir):
            self.prebuild()
            if os.path.isdir(staged_sourcepath):
                includedir = staged_sourcepath
            else:
                includedir = os.path.dirname(staged_sourcepath)

            self._current_environ.include_search_path.append(includedir)
            self._compile_task = self._current_environ.compile(
                sourcepath=staged_sourcepath,
                executable=os.path.join(self._stagedir, self.executable),
                **compile_opts)
            self.logger.debug('compilation stdout:\n%s' %
                              self._compile_task.stdout)
            self.logger.debug('compilation stderr:\n%s' %
                              self._compile_task.stderr)
            self.postbuild()

        self.logger.debug('compilation finished')