def run_rendercheck(self):
        """Run rendercheck test suite in the current system.

		The aim of this function is to run automatically rendercheck with
		ezbench tool.
		"""
        ezbench_path = os.path.join('/home', self.dut_user, 'ezbench')
        ezbench_script = os.path.join(ezbench_path, 'ezbench')
        ezbench_campaigns = self.data['suite_conf']['igt_iterations']
        ezbench_folder_results = 'sbench_rendercheck'
        ezbench_folder_results_full_path = os.path.join(
            ezbench_path, 'logs', ezbench_folder_results)
        ezbench_wait_for_results = 20
        ezbench_cmd_setup_environment = '{script} -c HEAD -r {campaigns} ' \
         '-b x11:rendercheck -p x11-gl {results}'.format(
          script=ezbench_script, campaigns=ezbench_campaigns,
          results=ezbench_folder_results)
        ezbench_cmd_run_tests = '{script} sbench_rendercheck start'.format(
            script=ezbench_script)

        self.log.info('setting the environment for rendercheck')
        output = os.system('{cmd} 2>> {log}'.format(
            cmd=ezbench_cmd_setup_environment, log=self.log_file))

        if output:
            self.log.error('the environment could not be set')
            self.log.info('closing the log')
            sys.exit(1)

        # wait for runner.sh finished in order to apply the second command
        # for run rendercheck, since the second command check if runner.sh is
        # running
        self.log.info('waiting for (runner.sh) to finish')

        while bash.is_process_running('runner.sh'):
            continue

        self.log.info('runner.sh: is not running')

        self.log.info('the environment has been set successfully')
        utils.timer('start')
        self.log.info('running rendercheck')
        output = os.system('{cmd} 2>> {log}'.format(cmd=ezbench_cmd_run_tests,
                                                    log=self.log_file))

        if output:
            self.log.error('an error occurred while running rendercheck')
            self.log.info('closing the log')
            sys.exit(1)

        # check if ezbench generated the folder for results files
        if utils.isdir(ezbench_folder_results_full_path):
            # check if ezbench generate the results files
            if utils.wait_for_file_existence(ezbench_folder_results_full_path,
                                             '\#', ezbench_wait_for_results):
                self.log.info('rendercheck ran successfully')
                elapsed_time = utils.timer('stop', print_elapsed_time=False)
                self.log.info(elapsed_time)

                # reporting to TestReportCenter
                ezbench_csv_file_path = self.report_to_trc(
                    ezbench_path, ezbench_folder_results)
                # updating the watchdog
                trc_link, pass_test, fail_test, total_test, \
                pass_rate_of_executed = self.update_watchdog(
                 ezbench_csv_file_path, elapsed_time)
                # sending a email notification
                self.send_email(trc_link, pass_test, fail_test, total_test,
                                pass_rate_of_executed, elapsed_time)
                # unlock the system
                self.unlock_system()

                # creating a control file in order to not run again this script
                self.log.info('creating a control file')
                with open(self.control_file, 'w') as ctl_file:
                    ctl_file.write('rendercheck has finished')

            else:
                self.log.error(
                    'ezbench did not generate the results files in {0} seconds'
                    .format(ezbench_wait_for_results))
                sys.exit(1)
        else:
            self.log.error(
                'ezbench did not generate the folder for results files'.format(
                    ezbench_folder_results_full_path))
            sys.exit(1)
Exemple #2
0
 def test_isdir_not_found(self, mock_runcommand):
     mock_runcommand.return_value = (1, '')
     existence = utils.isdir('/home/test')
     self.assertFalse(existence)
     mock_runcommand.assert_called_once_with('sudo test -d /home/test')
def get_firmware_version():
    """Gets the firmware version loaded into the kernel.

	Collects the required GUC, HUC and DMC firmware versions for the
	host's
	kernel, and its load status.
	:return: a tuple with the required values for GUC, HUC and DMC
	firmwares,
	if the firmwares failed to be loaded or have a different version than
	the
	expected one, it returns None for that firmware
	"""
    # initialize values
    guc_version = None
    huc_version = None
    dmc_version = None

    # Make sure the dri data is available
    dri_path = '/sys/kernel/debug/dri/0'
    if utils.isdir(dri_path):

        # get the GUC requirements
        guc_file = os.path.join(dri_path, 'i915_guc_load_status')
        if utils.isfile(guc_file):

            # depending on the kernel version we might have a couple of
            # variations in the content of the file, so we need to consider both
            error_code, output = bash.run_command(
                "sudo cat {guc} | grep 'GuC firmware:'".format(guc=guc_file))

            # if there is no error code, it means the content of the file should
            # contain something similar to this:
            # status: fetch SUCCESS, load SUCCESS\n\t
            # version: wanted 9.39, found 9.39
            # or when not loaded:
            # status: fetch NONE, load NONE\n\t
            # version: wanted 9.39, found 0.0
            if not error_code:
                error_code, output = bash.run_command(
                    "sudo cat {guc} | egrep 'version:|status:'".format(
                        guc=guc_file))
                if not error_code:
                    output = output.split('\n')
                    status = output[0]
                    version = output[1].replace(',', '').split()
                    # grab the firmware version only if the version found
                    # matches the wanted version
                    guc_version = version[4] if version[2] == version[
                        4] else None
                    # finally verify "fetch" and "load" have both SUCCESS
                    # status, if they don't then return None as firmware version
                    guc_version = guc_version if status.count(
                        'SUCCESS') == 2 else None

            # if there an error code, it means the content of the file should
            # contain something similar to this:
            # fetch: SUCCESS\n\t
            # load: SUCCESS\n\t
            # version wanted: 6.1\n\t
            # version found: 6.1\n\t
            else:
                error_code, output = bash.run_command(
                    "sudo cat {guc} | egrep 'fetch:|load:|version wanted:|version found:'"
                    .format(guc=guc_file))
                if not error_code:
                    output = output.replace('\t', '').split('\n')
                    loaded = True if 'SUCCESS' in output[0] and output[
                        1] else False
                    version_wanted = output[2].replace('version wanted: ', '')
                    version_found = output[3].replace('version found: ', '')
                    correct_version = True if version_wanted == version_found else False
                    guc_version = version_found if correct_version and loaded else None

        # get the HUC requirements
        huc_file = os.path.join(dri_path, 'i915_huc_load_status')
        if utils.isfile(huc_file):

            error_code, output = bash.run_command(
                "sudo cat {huc} | grep 'HuC firmware:'".format(huc=huc_file))

            if not error_code:
                error_code, output = bash.run_command(
                    "sudo cat {huc} | egrep 'version:|status:'".format(
                        huc=huc_file))
                if not error_code:
                    output = output.split('\n')
                    status = output[0]
                    version = output[1].replace(',', '').split()
                    huc_version = version[4] if version[2] == version[
                        4] else None
                    huc_version = huc_version if status.count(
                        'SUCCESS') == 2 else None

            else:
                error_code, output = bash.run_command(
                    "sudo cat {huc} | egrep 'fetch:|load:|version wanted:|version found:'"
                    .format(huc=huc_file))
                if not error_code:
                    output = output.replace('\t', '').split('\n')
                    loaded = True if 'SUCCESS' in output[0] and output[
                        1] else False
                    version_wanted = output[2].replace('version wanted: ', '')
                    version_found = output[3].replace('version found: ', '')
                    correct_version = True if version_wanted == version_found else False
                    huc_version = version_found if correct_version and loaded else None

        # get the DMC requirements
        dmc_file = os.path.join(dri_path, 'i915_dmc_info')
        if utils.isfile(dmc_file):

            # the content of the file should contain something similar to this:
            # fw loaded: yes\nversion: 1.4
            # or when not loaded:
            # fw loaded: no
            error_code, output = bash.run_command(
                "sudo cat {dmc} | egrep 'loaded:|version:'".format(
                    dmc=dmc_file))
            if not error_code:
                output = output.split('\n')
                status = output[0].split()[2]
                version = output[1].split()[1] if len(output) > 1 else None
                dmc_version = version if status == 'yes' else None

    firmwares = {'guc': guc_version, 'huc': huc_version, 'dmc': dmc_version}

    # print and return the formatted data
    print(json.dumps(firmwares))
    return json.dumps(firmwares)
Exemple #4
0
 def test_isdir_non_sudo(self, mock_runcommand):
     mock_runcommand.return_value = (0, '')
     existence = utils.isdir('/home/test', sudo=False)
     self.assertTrue(existence)
     mock_runcommand.assert_called_once_with('test -d /home/test')