Example #1
0
    def run_once(self, gs_bucket, server_videos_dir, videos, shard_number,
                 shard_count):
        if not gs_bucket.endswith('/'):
            gs_bucket += '/'

        # Probably should not use os.path.join for gs:// paths.
        gs_video_list = '%s%s' % (gs_bucket, VIDEO_LIST)
        local_video_list = os.path.join(server_videos_dir, VIDEO_LIST)
        try:
            utils.system('gsutil cp %s %s' % (gs_video_list, local_video_list))
            videos.extend(json.load(open(local_video_list)))
        finally:
            os.remove(local_video_list)

        # Break test_video_list into equal sized shards numbered 0 and only
        # download shard_number.
        video_count = len(videos)
        shard_size = int(math.ceil(video_count / float(shard_count)))
        begin = shard_size * shard_number
        end = min(video_count, shard_size * (shard_number + 1))
        # Enforce sorting even if VIDEO_LIST file is not sorted.
        videos.sort()
        videos = videos[begin:end]

        for video in videos:
            file_name, _, _ = video.partition(':')
            utils.system('gsutil cp %s %s' %
                         ('%s%s' % (gs_bucket, file_name), server_videos_dir))
Example #2
0
    def prompt(self, banner=">>>>>>>>>>> Achtung! <<<<<<<<<<<"):
        """prompt the user with the supplied banner,
        then wait for them to press enter

        @param banner: A [possibly multi-line] banner prompt to display
        """
        temp = autotemp.tempfile(unique_id='vtprompt', text=True)
        os.write(temp.fd, banner)
        pcmd = ("sudo openvt -s -w -- " +
                "sh -c 'clear && cat %s && read -p \"READY> \" REPLY &&" +
                " echo $REPLY'") % temp.name
        utils.system(pcmd)
        temp.clean()
Example #3
0
 def get(self, location=None):
     if not location:
         location = os.path.join(self.serverdir, '../client')
         location = os.path.abspath(location)
     # If there's stuff run on our client directory already, it
     # can cause problems. Try giving it a quick clean first.
     cwd = os.getcwd()
     os.chdir(location)
     try:
         utils.system('tools/make_clean', ignore_status=True)
     finally:
         os.chdir(cwd)
     super(BaseAutotest, self).get(location)
     self.got = True
Example #4
0
 def get(self, location=None):
     if not location:
         location = os.path.join(self.serverdir, '../client')
         location = os.path.abspath(location)
     # If there's stuff run on our client directory already, it
     # can cause problems. Try giving it a quick clean first.
     cwd = os.getcwd()
     os.chdir(location)
     try:
         utils.system('tools/make_clean', ignore_status=True)
     finally:
         os.chdir(cwd)
     super(BaseAutotest, self).get(location)
     self.got = True
Example #5
0
 def ping(self):
     """
     Ping the remote system, and return whether it's available
     """
     fpingcmd = "%s -q %s" % ('/usr/bin/fping', self.hostname)
     rc = utils.system(fpingcmd, ignore_status = 1)
     return (rc == 0)
def _extract_image_from_tarball(tarball, dest_dir, image_candidates):
    """Try extracting the image_candidates from the tarball.

    @param tarball: The path of the tarball.
    @param dest_path: The path of the destination.
    @param image_candidates: A tuple of the paths of image candidates.

    @return: The first path from the image candidates, which succeeds, or None
             if all the image candidates fail.
    """
    for image in image_candidates:
        status = server_utils.system(
            ('tar xf %s -C %s %s' % (tarball, dest_dir, image)),
            timeout=60,
            ignore_status=True)
        if status == 0:
            return image
    return None
Example #7
0
 def check_dependencies(self):
     if not utils.system('which openvt', ignore_status=True) == 0:
         raise error.TestError('openvt missing (see control file)')
     if not utils.system('sudo true', ignore_status=True) == 0:
         raise error.TestError('Insufficient privileges: cannot sudo')
Example #8
0
    def run_once(self, host=None, args=[]):
        self.client = host

        parser = OptionParser()
        parser.add_option(
            '--gcc_dir',
            dest='gcc_dir',
            default='/var/tmp/portage/cross-*/gcc-*/work/gcc-*build*',
            help='Path to the gcc build directory.')
        parser.add_option('--test_flags',
                          dest='test_flags',
                          default='',
                          help='Options to pass to dejagnu.')

        options, args = parser.parse_args(args)

        utils.system(
            '%s %s' %
            (os.path.join(self.bindir, 'dejagnu_init_remote'), self.client.ip))

        gcc_dirs = glob.glob(options.gcc_dir)
        if len(gcc_dirs) == 0:
            # If there is no directory present, try untarring the tarball
            # installed by the gcc package.
            logging.info(
                'No gcc directory found, attempting to untar from %s' %
                self.TARBALL)
            os.chdir('/')
            os.system('tar -xzf %s' % self.TARBALL)
            gcc_dirs = glob.glob(options.gcc_dir)
            if len(gcc_dirs) == 0:
                raise error.TestFail('No gcc directory to test was found')

        gcc_dir = gcc_dirs[0]

        logging.info('Testing gcc in the following directory: %s' % gcc_dir)
        exp_file = os.path.join(self.bindir, 'site.exp')
        client_hostname = str(self.client.ip)
        test_flags = options.test_flags
        test_command = (
            'cd %s; DEJAGNU="%s" DEJAGNU_SCRIPTS=%s '
            'DEJAGNU_HOSTNAME=%s make '
            'RUNTESTFLAGS="%s" check-gcc' %
            (gcc_dir, exp_file, self.bindir, client_hostname, test_flags))
        utils.system(test_command)

        error_messages = []
        for log in ('gcc', 'g++'):
            log_from = os.path.join(gcc_dir,
                                    'gcc/testsuite/%s/%s.log' % (log, log))
            log_to = os.path.join(self.resultsdir, '%s.log' % (log))
            shutil.copy(log_from, log_to)

            baseline = os.path.join(self.bindir, '%s.log' % (log))

            differences = self.compare_logs(baseline, log_to)
            for difference in differences:
                error_string = (
                    '(%s) "%s" Expected: "%s" Actual: "%s"' %
                    (log_to, difference[0], difference[1], difference[2]))
                error_messages.append(error_string)
            keyname = log.replace('+', 'p')
            self.results['%s_differences' % keyname] = len(differences)

        self.write_perf_keyval(self.results)

        if len(error_messages) != 0:
            raise error.TestFail('\n'.join(error_messages))
Example #9
0
 def cleanup(self):
     utils.system(os.path.join(self.bindir, 'dejagnu_cleanup_remote'))