def set_target(self, target, bind_dev=True): """ Set env variable, these have to be setup all the time. Some tests need to compile example apps by themselves and will fail otherwise. Set hugepage on DUT and install modules required by DPDK. Configure default ixgbe PMD function. """ self.target = target self.set_toolchain(target) # set env variable # These have to be setup all the time. Some tests need to compile # example apps by themselves and will fail otherwise. self.send_expect("export RTE_TARGET=" + target, "#") self.send_expect("export RTE_SDK=`pwd`", "#") self.set_rxtx_mode() drivername = load_global_setting(HOST_DRIVER_SETTING) self.set_driver_specific_configurations(drivername) if not self.skip_setup: self.build_install_dpdk(target) self.setup_memory() drivername = load_global_setting(HOST_DRIVER_SETTING) drivermode = load_global_setting(HOST_DRIVER_MODE_SETTING) self.setup_modules(target, drivername, drivermode) if bind_dev and self.get_os_type() == 'linux': self.bind_interfaces_linux(drivername) self.extra_nic_setup()
def setup_modules_linux(self, target): drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == "vfio-pci": self.send_expect("rmmod vfio_pci", "#", 70) self.send_expect("rmmod vfio_iommu_type1", "#", 70) self.send_expect("rmmod vfio", "#", 70) self.send_expect("modprobe vfio", "#", 70) self.send_expect("modprobe vfio-pci", "#", 70) out = self.send_expect("lsmod | grep vfio_iommu_type1", "#") assert ("vfio_iommu_type1" in out), "Failed to setup vfio-pci" drivermode = load_global_setting(HOST_DRIVER_MODE_SETTING) if drivermode == "noiommu": self.send_expect( "echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode", "#", 70) else: self.send_expect("modprobe uio", "#", 70) out = self.send_expect("lsmod | grep igb_uio", "#") if "igb_uio" in out: self.send_expect("rmmod -f igb_uio", "#", 70) self.send_expect("insmod ./" + target + "/kmod/igb_uio.ko", "#", 60) out = self.send_expect("lsmod | grep igb_uio", "#") assert ("igb_uio" in out), "Failed to insmod igb_uio"
def execute_test_cases(self): """ Execute all test cases in one suite. """ # prepare debugger rerun case environment if self._enable_debug or self._debug_case: debugger.AliveSuite = self debugger.AliveModule = __import__('TestSuite_' + self.suite_name) if load_global_setting(FUNC_SETTING) == 'yes': for case_obj in self._get_functional_cases(): for i in range(self.tester.re_run_time + 1): ret = self.execute_test_case(case_obj) if ret is False and self.tester.re_run_time: for dutobj in self.duts: dutobj.get_session_output(timeout = 0.5 * (i + 1)) self.tester.get_session_output(timeout = 0.5 * (i + 1)) time.sleep(i + 1) self.logger.info(" Test case %s failed and re-run %d time" % (case_obj.__name__, i + 1)) else: break if load_global_setting(PERF_SETTING) == 'yes': for case_obj in self._get_performance_cases(): self.execute_test_case(case_obj)
def aware_keyintr(): """ Reenable interrupt handler. """ # signal can't be used in thread if load_global_setting(DEBUG_SETTING) != 'yes' or load_global_setting( DTS_PARALLEL_SETTING) == 'yes': return return signal.signal(signal.SIGINT, keyboard_handle)
def execute_test_cases(self): """ Execute all test cases in one suite. """ if load_global_setting(FUNC_SETTING) == 'yes': for case_obj in self._get_functional_cases(): self._execute_test_case(case_obj) if load_global_setting(PERF_SETTING) == 'yes': for case_obj in self._get_performance_cases(): self._execute_test_case(case_obj)
def restore_modules_linux(self): """ Restore DPDK Linux kernel module on DUT. """ drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == "vfio-pci": drivermode = load_global_setting(HOST_DRIVER_MODE_SETTING) if drivermode == "noiommu": self.send_expect( "echo 0 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode", "#", 70)
def spdk_crbs_init(crbInsts, skip_setup, project, base_dir, serializer, dpdk_dir): """ Create dut/tester instance and initialize them. """ duts = [] serializer.set_serialized_filename(settings.FOLDERS['Output'] + '/.%s.cache' % crbInsts[0]['IP']) serializer.load_from_file() testInst = copy.copy(crbInsts[0]) testInst['My IP'] = crbInsts[0]['tester IP'] tester = get_project_obj(project, Tester, testInst, serializer) for crbInst in crbInsts: dutInst = copy.copy(crbInst) dutInst['My IP'] = crbInst['IP'] dutobj = get_project_obj(project, Dut, dutInst, serializer) duts.append(dutobj) spdk_log_execution(duts, tester, log_handler) tester.duts = duts show_speedup_options_messages(skip_setup) tester.set_speedup_options(skip_setup) nic = settings.load_global_setting(settings.HOST_NIC_SETTING) for dutobj in duts: dutobj.tester = tester dutobj.set_speedup_options(skip_setup) dutobj.set_directory(base_dir) dutobj.set_path(dpdk_dir) return duts, tester
def __log_handler(self, fh, ch): """ Config stream handler and file handler. """ if load_global_setting(DTS_PARALLEL_SETTING) == 'yes': message_fmt = '%(asctime)s %(name)30s %(threadName)s: %(message)s' else: message_fmt = '%(asctime)s %(name)30s: %(message)s' fh.setFormatter(logging.Formatter(message_fmt, date_fmt)) ch.setFormatter(logging.Formatter(stream_fmt, date_fmt)) fh.setLevel(logging.DEBUG) # file hander default level global verbose if verbose is True: ch.setLevel(logging.DEBUG) else: ch.setLevel(logging.INFO) # console handler default level self.logger.addHandler(fh) self.logger.addHandler(ch) if self.fh is not None: self.logger.removeHandler(self.fh) if self.ch is not None: self.logger.removeHandler(self.ch) self.fh = fh self.ch = ch
def spdk_run_target(duts, tester, targets, test_suites): """ Run each target in execution targets. """ for target in targets: log_handler.info("\nTARGET " + target) result.target = target try: drivername = settings.load_global_setting( settings.HOST_DRIVER_SETTING) if drivername == "": for dutobj in duts: dutobj.set_target(target, bind_dev=False) else: for dutobj in duts: dutobj.set_target(target) except AssertionError as ex: log_handler.error(" TARGET ERROR: " + str(ex)) settings.report_error("SPDK_BUILD_ERR") result.add_failed_target(result.dut, target, str(ex)) continue except Exception as ex: settings.report_error("GENERIC_ERR") log_handler.error(" !!! DEBUG IT: " + traceback.format_exc()) result.add_failed_target(result.dut, target, str(ex)) continue spdk_run_suite(duts, tester, test_suites, target)
def ignore_keyintr(): """ Temporary disable interrupt handler. """ # signal can't be used in thread if load_global_setting(DEBUG_SETTING) != 'yes' or load_global_setting( DTS_PARALLEL_SETTING) == 'yes': return global debug_cmd signal.siginterrupt(signal.SIGINT, True) # if there's waiting request, first handler it if debug_cmd == 'waiting': keyboard_handle(signal.SIGINT, None) return signal.signal(signal.SIGINT, capture_handle)
def set_target(self, target, bind_dev=True): """ Set env variable, these have to be setup all the time. Some tests need to compile example apps by themselves and will fail otherwise. Set hugepage on DUT and install modules required by DPDK. Configure default ixgbe PMD function. """ self.target = target self.set_toolchain(target) # set env variable # These have to be setup all the time. Some tests need to compile # example apps by themselves and will fail otherwise. self.send_expect("export RTE_TARGET=" + target, "#") self.send_expect("export RTE_SDK=`pwd`", "#") self.set_rxtx_mode() # Enable MLNX driver before installing dpdk drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == DRIVERS['ConnectX4']: self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_MLX5_PMD=n/" + "CONFIG_RTE_LIBRTE_MLX5_PMD=y/' config/common_base", "# ", 30) if not self.skip_setup: self.build_install_dpdk(target) self.setup_memory() self.setup_modules(target) if bind_dev and self.get_os_type() == 'linux': self.bind_interfaces_linux(drivername) self.extra_nic_setup()
def aware_keyintr(): """ Reenable interrupt handler. """ if load_global_setting(DEBUG_SETTING) != 'yes': return return signal.signal(signal.SIGINT, keyboard_handle)
def _check_host_driver(self, drivers): host_driver = load_global_setting(HOST_DRIVER_SETTING) if 'all' == drivers[0].lower(): return True if host_driver in drivers: return True else: return False
def __init__(self, duts, tester, target, suitename): self.suite_name = suitename self.dut = duts[0] self.duts = duts self.tester = tester self.target = target class_name = self.__class__.__name__ self.logger = getLogger(class_name) self.logger.config_suite(class_name) self._requested_tests = None self.nics = [] drivername = [] execution_path = os.path.dirname(os.path.dirname(__file__)) execution_file = execution_path + '/framework/execution.cfg' execution = open(execution_file, 'r') status = re.findall(r"\n+parameters=nic_type=(.*)", execution.read()) status_nic = status[0].split(":") self.nic = status_nic[0] self.kdriver = self._get_nic_driver(self.nic) self._suite_result = Result() self._suite_result.dut = self.dut.crb['IP'] self._suite_result.target = target self._suite_result.nic = self.nic self._suite_result.test_suite = self.suite_name if self._suite_result is None: raise ValueError("Result object should not None") if load_global_setting(PERF_SETTING) == "yes": self._enable_perf = True else: self._enable_perf = False if load_global_setting(FUNC_SETTING) == "yes": self._enable_func = True else: self._enable_func = False if load_global_setting(DEBUG_SETTING) == "yes": self._enable_debug = True else: self._enable_debug = False if load_global_setting(DEBUG_CASE_SETTING) == "yes": self._debug_case = True else: self._debug_case = False self.drivername = load_global_setting(HOST_DRIVER_SETTING)
def dts_crbs_init(crbInsts, skip_setup, read_cache, project, base_dir, serializer, virttype): """ Create dts dut/tester instance and initialize them. """ duts = [] serializer.set_serialized_filename(settings.FOLDERS['Output'] + '/.%s.cache' % crbInsts[0]['IP']) serializer.load_from_file() testInst = copy.copy(crbInsts[0]) testInst['My IP'] = crbInsts[0]['tester IP'] tester = get_project_obj(project, Tester, testInst, serializer, dut_id=0) dut_id = 0 for crbInst in crbInsts: dutInst = copy.copy(crbInst) dutInst['My IP'] = crbInst['IP'] if project == "mydut": dutobj = get_project_obj(project, MyDut, dutInst, serializer, dut_id=dut_id) # Changes has to be made here according to the board elif project == "dpdk": dutobj = get_project_obj(project, Dut, dutInst, serializer, dut_id=dut_id) else: pass duts.append(dutobj) dut_id += 1 dts_log_execution(duts, tester, log_handler) tester.duts = duts show_speedup_options_messages(read_cache, skip_setup) tester.set_speedup_options(read_cache, skip_setup) tester.init_ext_gen() nic = settings.load_global_setting(settings.HOST_NIC_SETTING) for dutobj in duts: dutobj.tester = tester #dutobj.setup_virtenv(virttype) dutobj.set_speedup_options(read_cache, skip_setup) dutobj.set_directory(base_dir) # save execution nic setting dutobj.set_nic_type(nic) return duts, tester
def install_apps(host): build_time = 300 debug_make = 'EXTRA_CFLAGS="-g -O0" ' \ if load_global_setting(DEBUG_SETTING) == "yes" else "" for app in host.apps: host.send_expect("cd {}/{}".format(host.base_dir, app), "#") out = host.send_expect("echo $?", "#") if "0" in out: cmd = "{}make".format(debug_make) out = host.send_expect(cmd, "# ", build_time) check_build(out) host.send_expect("cd {}".format(host.base_dir), "#")
def build_install_spdk(self, target, extra_options=''): self.send_expect("make clean", "#", 20) drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == "ConnectX4" or "ConnectX3": self.send_expect("./configure --with-rdma", "#", 100) else: self.send_expect("./configure", "#", 100) out = self.send_expect("make -j", "# ", 100) if("Error" in out or "No rule to make" in out): self.logger.error("ERROR - try to compile again") out = self.send_expect("make", "# ", 100) assert ("Error" not in out), "Compilation error..." assert ("No rule to make" not in out), "No rule to make error..." self.send_expect("NRHUGE=12288 %s" % r'./scripts/setup.sh', "#", 200)
def dts_crbs_init(crbInsts, read_cache, project, base_dir, serializer, virttype, test_configs): """ Create dts dut/tester instance and initialize them. """ duts = [] test_configs["two_way_mono"] = False serializer.set_serialized_filename(settings.FOLDERS['Output'] + '/.%s.cache' % crbInsts[0]['IP']) serializer.load_from_file() testInst = copy.copy(crbInsts[0]) testInst['My IP'] = crbInsts[0]['tester IP'] testers = [ get_project_obj(project, Tester, testInst, serializer, test_configs) ] if 'tester2 IP' in testInst.keys(): test2Inst = copy.copy(testInst) test2Inst['My IP'] = test2Inst['tester2 IP'] test2Inst['tester IP'] = test2Inst['tester2 IP'] test2Inst['tester_user'] = test2Inst['tester2_user'] test2Inst['tester_ssh_key'] = test2Inst['tester2_ssh_key'] testers.append( get_project_obj(project, Tester, test2Inst, serializer, test_configs)) for crbInst in crbInsts: dutInst = copy.copy(crbInst) dutInst['My IP'] = crbInst['IP'] dutobj = get_project_obj(project, Dut, dutInst, serializer, test_configs) duts.append(dutobj) dts_log_execution(duts, testers, log_handler) for tester in testers: tester.duts = duts tester.init_ext_gen() nic = settings.load_global_setting(settings.HOST_NIC_SETTING) for dutobj in duts: dutobj.tester = testers[0] dutobj.set_virttype(virttype) dutobj.set_directory(base_dir) # save execution nic setting dutobj.set_nic_type(nic) return duts, testers
def config_ports(host, prompt, ports): drivername = load_global_setting(HOST_DRIVER_SETTING) bind_cmd = "" for port in ports: bind_cmd += " %s" % host.ports_info[port]['pci'] host.send_expect( "ifconfig {} down".format(host.ports_info[port]['intf']), prompt) devbind = devbind_path(host, prompt) host.send_expect("{} --bind={} {}".format(devbind, drivername, bind_cmd), prompt) host.setup_memory(16384)
def setup_modules(self, target): drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == "ConnectX4" or "ConnectX3": out = self.send_expect("lsmod | grep ib_cm", "#") if "ib_cm" not in out: self.send_expect("modprobe ib_addr", "#", 70) self.send_expect("modprobe ib_cm", "#", 70) self.send_expect("modprobe ib_core", "#", 70) self.send_expect("modprobe ib_mad", "#", 70) self.send_expect("modprobe ib_sa", "#", 70) self.send_expect("modprobe ib_ucm", "#", 70) self.send_expect("modprobe ib_umad", "#", 70) self.send_expect("modprobe ib_uverbs", "#", 70) self.send_expect("modprobe iw_cm", "#", 70) self.send_expect("modprobe rdma_cm", "#", 70) self.send_expect("modprobe rdma_ucm", "#", 70) print " load some kernel modules" print " kernel modules has loaded"
def setup_modules_linux(self, target): drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == "vfio-pci": self.send_expect("rmmod vfio_pci", "#", 70) self.send_expect("rmmod vfio_iommu_type1", "#", 70) self.send_expect("rmmod vfio", "#", 70) self.send_expect("modprobe vfio", "#", 70) self.send_expect("modprobe vfio-pci", "#", 70) out = self.send_expect("lsmod | grep vfio_iommu_type1", "#") assert ("vfio_iommu_type1" in out), "Failed to setup vfio-pci" else: self.send_expect("modprobe uio", "#", 70) out = self.send_expect("lsmod | grep igb_uio", "#") if "igb_uio" in out: self.send_expect("rmmod -f igb_uio", "#", 70) self.send_expect("insmod ./" + target + "/kmod/igb_uio.ko", "#", 60) out = self.send_expect("lsmod | grep igb_uio", "#") assert ("igb_uio" in out), "Failed to insmod igb_uio"
def set_rxtx_mode(self): """ Set default RX/TX PMD function, only i40e support scalar/full RX/TX model. ixgbe and fm10k only support vector and no vector model all NIC default rx/tx model is vector PMD """ mode = load_global_setting(DPDK_RXMODE_SETTING) if mode == 'scalar': self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=.*$/" + "CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=n/' config/common_base", "# ", 30) self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=.*$/" + "CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y/' config/common_base", "# ", 30) if mode == 'full': self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=.*$/" + "CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=n/' config/common_base", "# ", 30) self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=.*$/" + "CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=n/' config/common_base", "# ", 30) if mode == 'novector': self.send_expect( "sed -i -e 's/CONFIG_RTE_IXGBE_INC_VECTOR=.*$/" + "CONFIG_RTE_IXGBE_INC_VECTOR=n/' config/common_base", "# ", 30) self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=.*$/" + "CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=n/' config/common_base", "# ", 30) self.send_expect( "sed -i -e 's/CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=.*$/" + "CONFIG_RTE_LIBRTE_FM10K_INC_VECTOR=n/' config/common_base", "# ", 30)
def dts_run_target(duts, testers, targets, test_suites, test_configs): """ Run each target in execution targets. """ for target in targets: log_handler.info("TARGET " + target) result.target = target try: drivername = settings.load_global_setting( settings.HOST_DRIVER_SETTING) if drivername == "": for dutobj in duts: dutobj.set_target(target, bind_dev=False) else: for dutobj in duts: dutobj.set_target(target, test_configs) for tester in testers: tester.set_target(target, test_configs) except AssertionError as ex: log_handler.error(" TARGET ERROR: " + str(ex)) settings.report_error("DPDK_BUILD_ERR") result.add_failed_target(result.dut, target, str(ex)) continue except Exception as ex: settings.report_error("GENERIC_ERR") log_handler.error(" !!! DEBUG IT: " + traceback.format_exc()) result.add_failed_target(result.dut, target, str(ex)) continue dts_run_suite(duts, testers, test_suites, target, test_configs) for tester in testers: tester.restore_interfaces(test_configs["skip_target_env_setup"]) tester.restore_modules(test_configs["skip_target_env_setup"]) for dutobj in duts: dutobj.stop_ports() dutobj.restore_interfaces(test_configs["skip_target_env_setup"]) dutobj.restore_modules(test_configs["skip_target_env_setup"])
def set_target(self, target): self.target = target drivername = load_global_setting(HOST_DRIVER_SETTING) if drivername == DRIVERS['ConnectX4']: out = self.send_expect("lsmod | grep mlx5_ib", "#") if "mlx5_ib" not in out: self.send_expect("modprobe mlx5_core", "#", 70) self.send_expect("modprobe mlx5_ib", "#", 70) if drivername == DRIVERS['ConnectX3']: out = self.send_expect("lsmod | grep mlx4_ib", "#") if "mlx4_ib" not in out: self.send_expect("modprobe mlx4_en", "#", 70) self.send_expect("modprobe mlx4_core", "#", 70) self.send_expect("modprobe mlx4_ib", "#", 70) if drivername == DRIVERS['chelsio_40gb']: out = self.send_expect("lsmod | grep iw_cxgb4", "#") if "iw_cxgb4" not in out: self.send_expect("modprobe cxgb4", "#", 70) self.send_expect("modprobe iw_cxgb4", "#", 70) self.setup_modules(target) if not self.skip_setup: self.build_install_spdk(target)
def test_vlan_qinq_tpid(self): """ Test Case 6: Change S-Tag and C-Tag within QinQ It need be tested in nonvector mode. """ self.verify( self.nic in [ "fortville_eagle", "fortville_spirit", "fortville_spirit_single" ], "%s NIC not support QinQ " % self.nic) rx_mode = load_global_setting(DPDK_RXMODE_SETTING) self.verify(rx_mode == 'novector', "The case must by tested in novector mode") random_vlan = random.randint(1, MAX_VLAN - 1) rx_vlans = [1, random_vlan, MAX_VLAN] self.dut.send_expect("vlan set qinq on %d" % dutRxPortId, "testpmd> ", 20) self.dut.send_expect("set verbose 1", "testpmd> ") self.dut.send_expect("set fwd rxonly", "testpmd> ") self.dut.send_expect("start", "testpmd> ") self.dut.send_expect("vlan set filter off %s" % dutRxPortId, "testpmd> ") tpids = [0x8100, 0xA100, 0x88A8, 0x9100] for outer_tpid in tpids: for inner_tpid in tpids: self.dut.send_expect( "vlan set outer tpid 0x%x %s" % (outer_tpid, dutRxPortId), "testpmd> ") self.dut.send_expect( "vlan set inner tpid 0x%x %s" % (inner_tpid, dutRxPortId), "testpmd> ") for outer_vlan in rx_vlans: for inner_vlan in rx_vlans: self.vlan_send_packet(outer_vlan, outer_tpid, inner_vlan, inner_tpid) out = self.dut.get_session_output() self.verify("QinQ VLAN" in out, "Wrong QinQ:" + str(out))
def run_all(config_file, pkgName, git, patch, skip_setup, read_cache, project, suite_dir, test_cases, base_dir, output_dir, verbose, virttype, debug, debugcase, re_run, commands): """ Main process of DTS, it will run all test suites in the config file. """ global requested_tests global result global excel_report global json_report global stats_report global log_handler global check_case_inst # save global variable serializer = Serializer() # load check/support case lists check_case_inst = CheckCase() # prepare the output folder if output_dir == '': output_dir = settings.FOLDERS['Output'] if not os.path.exists(output_dir): os.mkdir(output_dir) # add external library exec_file = os.path.realpath(__file__) extra_libs_path = exec_file.replace('framework/dts.py', '') + 'extra_libs' sys.path.insert(1, extra_libs_path) # add python module search path sys.path.append(suite_dir) # enable debug mode if debug is True: settings.save_global_setting(settings.DEBUG_SETTING, 'yes') if debugcase is True: settings.save_global_setting(settings.DEBUG_CASE_SETTING, 'yes') # init log_handler handler if verbose is True: logger.set_verbose() if re_run < 0: re_run = 0 logger.log_dir = output_dir log_handler = getLogger('dts') log_handler.config_execution('dts') # run designated test case requested_tests = test_cases # Read config file dts_cfg_folder = settings.load_global_setting(settings.DTS_CFG_FOLDER) if dts_cfg_folder != '': config_file = dts_cfg_folder + os.sep + config_file config = ConfigParser.SafeConfigParser() load_cfg = config.read(config_file) if len(load_cfg) == 0: raise ConfigParseException(config_file) # parse commands dts_commands = dts_parse_commands(commands) os.environ["TERM"] = "dumb" # change rst output folder rst.path2Result = output_dir # report objects excel_report = ExcelReporter(output_dir + '/test_results.xls') json_report = JSONReporter(output_dir + '/test_results.json') stats_report = StatsReporter(output_dir + '/statistics.txt') result = Result() crbInsts = [] crbs_conf = CrbsConf() crbs = crbs_conf.load_crbs_config() # for all Execution sections for section in config.sections(): dts_parse_param(config, section) # verify if the delimiter is good if the lists are vertical duts, targets, test_suites = dts_parse_config(config, section) for dut in duts: log_handler.info("\nDUT " + dut) # look up in crbs - to find the matching IP for dut in duts: for crb in crbs: if crb['section'] == dut: crbInsts.append(crb) break # only run on the dut in known crbs if len(crbInsts) == 0: log_handler.error(" SKIP UNKNOWN CRB") continue result.dut = duts[0] # init global lock create_parallel_locks(len(duts)) # init dut, tester crb duts, tester = dts_crbs_init(crbInsts, skip_setup, read_cache, project, base_dir, serializer, virttype) tester.set_re_run(re_run) # register exit action atexit.register(quit_execution, duts, tester) check_case_inst.check_dut(duts[0]) # Run DUT prerequisites if dts_run_prerequisties(duts, tester, pkgName, patch, dts_commands, serializer) is False: dts_crbs_exit(duts, tester) continue dts_run_target(duts, tester, targets, test_suites) dts_crbs_exit(duts, tester) save_all_results()
def __init__(self, duts, tester, target, suitename): self.suite_name = suitename self.dut = duts[0] self.duts = duts self.tester = tester self.target = target # local variable self._requested_tests = None # check session and reconnect if possible for dutobj in self.duts: self._check_and_reconnect(crb=dutobj) self._check_and_reconnect(crb=self.tester) # covert netdevice to codename self.nics = [] for portid in range(len(self.dut.ports_info)): nic_type = self.dut.ports_info[portid]['type'] self.nics.append(get_nic_name(nic_type)) if len(self.nics): self.nic = self.nics[0] else: self.nic = '' self.kdriver = self._get_nic_driver(self.nic) # result object for save suite result self._suite_result = Result() self._suite_result.dut = self.dut.crb['IP'] self._suite_result.target = target self._suite_result.nic = self.nic self._suite_result.test_suite = self.suite_name if self._suite_result is None: raise ValueError("Result object should not None") # load running enviornment if load_global_setting(PERF_SETTING) == "yes": self._enable_perf = True else: self._enable_perf = False if load_global_setting(FUNC_SETTING) == "yes": self._enable_func = True else: self._enable_func = False if load_global_setting(DEBUG_SETTING) == "yes": self._enable_debug = True else: self._enable_debug = False if load_global_setting(DEBUG_CASE_SETTING) == "yes": self._debug_case = True else: self._debug_case = False self.drivername = load_global_setting(HOST_DRIVER_SETTING) # create rst format report for this suite self._rst_obj = RstReport('rst_report', target, self.nic, self.suite_name, self._enable_perf) # load suite configuration self._suite_conf = SuiteConf(self.suite_name) self._suite_cfg = self._suite_conf.suite_cfg
def it_uses_external_generator(self): """ Check whether IXIA generator is ready for performance test. """ return load_global_setting( PERF_SETTING) == 'yes' and self.has_external_traffic_generator()
def build_install_dpdk_linux(self, target, extra_options): """ Build DPDK source code on linux with specified target. """ debug_make = 'EXTRA_CFLAGS="-g -O0" ' \ if load_global_setting(DEBUG_SETTING) == "yes" else "" build_time = 300 if "icc" in target: build_time = 900 # Remove any previous installed DPDK self.send_expect( "rm -f $PKG_CONFIG_PATH/libdpdk.pc $PKG_CONFIG_PATH/libdpdk-libs.pc", "# ") if self.build_system is MAKE_BUILD: # Configure out = self.send_expect("make config T=%s O=%s" % (target, target), "# ", build_time) # compile out = self.send_expect( "%smake -j %d T=%s O=%s %s" % (debug_make, self.number_of_cores, target, target, extra_options), "# ", build_time) #should not check test app compile status, because if test compile # fail, all unit test can't exec, but others case will exec # sucessfull self.build_install_dpdk_test_app(target, build_time) if ("Error" in out or "No rule to make" in out): self.logger.error("ERROR - try without '-j'") # if Error try to execute make without -j option out = self.send_expect( "%smake T=%s O=%s %s" % (debug_make, target, target, extra_options), "# ", 120) self.build_install_dpdk_test_app(target, build_time) check_build(out) elif self.build_system is MESON_BUILD: # configure out = self.send_expect( "meson {} -Dprefix={}".format(target, self.install_dir), "# ", build_time) check_build(out) out = self.send_expect("ninja -C %s" % (target), "# ", build_time) check_build(out) out = self.send_expect("ninja -C %s install" % (target), "# ", build_time) check_build(out) else: assert False, "Invalid build system detected" # Build pktgen if self.pktgen is not None: include_var = "C_INCLUDE_PATH={}/include".format(self.install_dir) self.send_expect("cd {}".format(self.pktgen_dir), "# ") if self.build_system is MAKE_BUILD: out = self.send_expect( "{} {} make".format(debug_make, include_var), "# ", build_time) else: out = self.send_expect("meson build -Denable_lua=true", "#", build_time) check_build(out) out = self.send_expect("{} ninja -C build".format(include_var), "#", build_time) self.send_expect("cd ..", "# ") check_build(out)
def set_target(self, target, test_configs): build_time = 300 [arch, _, _, toolchain] = target.split('-') debug_make = 'EXTRA_CFLAGS="-g -O0" ' \ if load_global_setting(DEBUG_SETTING) == "yes" else "" self.architecture = arch self.send_expect("cd {}".format(self.base_dir), "#") ver_str = self.send_expect("cat VERSION", "# ") self.build_system = check_build_system(ver_str) self.send_expect("export RTE_TARGET=" + target, "#") if not test_configs["skip_target_env_setup"]: # Remove any previous installed DPDK self.send_expect( "rm -f $PKG_CONFIG_PATH/libdpdk.pc $PKG_CONFIG_PATH/libdpdk-libs.pc", "# ") if self.build_system is MAKE_BUILD: self.send_expect( "make config T={} O={}".format(target, target), "# ", build_time) out = self.send_expect( "{}make -j {} T={} O={}".format(debug_make, self.number_of_cores, target, target), "# ", build_time) check_build(out) elif self.build_system is MESON_BUILD: # configure out = self.send_expect( "meson {} -Dprefix={}".format(target, self.install_dir), "# ", build_time) check_build(out) out = self.send_expect("ninja -C %s" % (target), "# ", build_time) check_build(out) out = self.send_expect("ninja -C %s install" % (target), "# ", build_time) check_build(out) else: assert False, "Invalid build system detected" self.send_expect("cd {}".format(self.pktgen_dir), "#") include_var = "C_INCLUDE_PATH={}/include".format(self.install_dir) if self.build_system is MAKE_BUILD: out = self.send_expect( "{} {} make".format(debug_make, include_var), "# ", build_time) else: out = self.send_expect("meson build -Denable_lua=true", "#", build_time) check_build(out) out = self.send_expect("{} ninja -C build".format(include_var), "#", build_time) check_build(out) install_apps(self) self.setup_modules() self.send_expect("cd {}".format(self.base_dir), "#") else: self.logger.info('SKIPPED target environment setup')