def test_boot_usbcore_quirks(self): ''' bz: 1809429 polarion_id: ''' utils_lib.run_cmd(self, r'sudo rm -rf /var/crash/*', expect_ret=0, msg='clean /var/crash firstly') option = 'usbcore.quirks=quirks=0781:5580:bk,0a5c:5834:gij' cmd = 'sudo grubby --update-kernel=ALL --args="{}"'.format(option) utils_lib.run_cmd(self, cmd, msg='Append {} to command line!'.format(option), timeout=600) utils_lib.run_cmd(self, 'sudo reboot', msg='reboot system under test') time.sleep(10) utils_lib.init_connection(self, timeout=800) utils_lib.run_cmd(self, 'cat /proc/cmdline', expect_kw=option) cmd = r'sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50' utils_lib.run_cmd(self, cmd, expect_kw='No such file or directory', msg='make sure there is no core generated') utils_lib.check_log(self, "error,warn,fail,trace,Trace", skip_words='ftrace', rmt_redirect_stdout=True)
def tearDown(self): if 'blktests' in self.id(): utils_lib.check_log(self, "trace", cursor=self.cursor) else: utils_lib.check_log(self, "error,warn,fail,trace", cursor=self.cursor)
def test_boot_hpet_mmap_enabled(self): ''' bz: 1660796, 1764790 polarion_id: ''' utils_lib.run_cmd(self, r'sudo rm -rf /var/crash/*', expect_ret=0, msg='clean /var/crash firstly') utils_lib.is_arch(self, arch='x86', action='cancel') cmd = 'sudo grubby --update-kernel=ALL --args="hpet_mmap=1"' utils_lib.run_cmd(self, cmd, msg='Append hpet_mmap=1 to command line!', timeout=600) utils_lib.run_cmd(self, 'sudo reboot', msg='reboot system under test') time.sleep(10) utils_lib.init_connection(self, timeout=800) utils_lib.run_cmd(self, 'cat /proc/cmdline', expect_kw='hpet_mmap=1') utils_lib.run_cmd(self, 'dmesg | grep -i hpet', expect_kw='enabled', expect_not_kw='6HPET') cmd = 'sudo cat /sys/devices/system/clocksource/clocksource0/available_clocksource' out = utils_lib.run_cmd(self, cmd) if 'hpet' in out: utils_lib.run_cmd(self, 'sudo cat /proc/iomem|grep -i hpet', expect_kw='HPET 0') utils_lib.check_log(self, "error,warn,fail,trace,Trace", rmt_redirect_stdout=True)
def test_check_dmesg_unable(self): ''' :avocado: tags=test_check_dmesg_unable,fast_check polarion_id: bz: 1779454 ''' utils_lib.check_log(self, 'unable', log_cmd='dmesg')
def test_check_journalctl_warn(self): ''' polarion_id: RHEL7-103851 ''' utils_lib.check_log(self, 'warn', skip_words='test_check', rmt_redirect_stdout=True)
def test_check_journalctl_invalid(self): ''' polarion_id: bz:1750417 ''' utils_lib.check_log(self, 'invalid', skip_words="Invalid user,invalid user,test_check", rmt_redirect_stdout=True)
def test_boot_mitigations(self): ''' polarion_id: bz: 1896786 ''' cmd = 'sudo grubby --update-kernel=ALL --args="mitigations=auto,nosmt"' utils_lib.run_cmd(self, cmd, msg='Append mitigations=auto,nosmt to command line!', timeout=600) utils_lib.run_cmd(self, 'sudo reboot', msg='reboot system under test') time.sleep(10) utils_lib.init_connection(self, timeout=800) utils_lib.run_cmd(self, 'cat /proc/cmdline', expect_kw='mitigations=auto,nosmt') utils_lib.check_log(self, "error,warn,fail,trace,Trace", rmt_redirect_stdout=True)
def test_check_journalctl_service_unknown_lvalue(self): ''' polarion_id: bz:1871139 ''' cmd = "systemctl list-unit-files |grep -v UNIT|grep -v listed|awk -F' ' '{print $1}'" all_services = utils_lib.run_cmd( self, cmd, msg='Get all systemd unit files').split('\n') for service in all_services: if len(service) == 0: continue cmd = "systemctl status {}".format(service) utils_lib.run_cmd(self, cmd) cmd = "journalctl --unit {}".format(service) utils_lib.check_log(self, 'Unknown lvalue', log_cmd=cmd, rmt_redirect_stdout=True)
def test_boot_mitigations(self): ''' bz: 1896786 polarion_id: ''' utils_lib.run_cmd(self, r'sudo rm -rf /var/crash/*', expect_ret=0, msg='clean /var/crash firstly') cmd = 'cat /proc/cpuinfo |grep processor|wc -l' cpucount = utils_lib.run_cmd(self, cmd, msg='get cpu count') if int(cpucount) > 36: self.skipTest("skip when cpu count over 36 when nosmt passing") cmd = 'sudo grubby --update-kernel=ALL --args="mitigations=auto,nosmt"' utils_lib.run_cmd(self, cmd, msg='Append mitigations=auto,nosmt to command line!', timeout=600) utils_lib.run_cmd(self, 'sudo reboot', msg='reboot system under test') time.sleep(10) utils_lib.init_connection(self, timeout=self.ssh_timeout) utils_lib.run_cmd(self, 'cat /proc/cmdline', expect_kw='mitigations=auto,nosmt') utils_lib.check_log(self, "error,warn,fail,CallTrace", skip_words='ftrace,Failed to write ATTR', rmt_redirect_stdout=True)
def test_systemd_coredump(self): """ case_name: test_systemd_coredump case_file: os_tests.tests.test_general_test.TestGeneralTest.test_systemd_coredump component: systemd bugzilla_id: 2025479, 1905582 is_customer_case: False testplan: N/A maintainer: [email protected] description: The DefaultLimitCORESoft is set to 0 by default. Test systemd-coredump can save process core successfully when process crashed key_steps: 1. # systemctl show | grep CORE DefaultLimitCORE=infinity DefaultLimitCORESoft=0 (rhel default set) 2. create test.c #include <stdio.h> #include <stdlib.h> void main(){ int x; free(&x); } 3. # gcc -g -o pp test.c 4. # ./pp expect_result: pp crashed and new core file is generated under /var/lib/systemd/coredump debug_want: - journal log """ test_str = ''' #include <stdio.h> #include <stdlib.h> void main(){ int x; free(&x); } ''' product_name = utils_lib.get_os_release_info(self, field='NAME') if 'Red Hat Enterprise Linux' in product_name: cmd = 'systemctl show | grep CORE' utils_lib.run_cmd( self, cmd, expect_kw='DefaultLimitCORESoft=0,DefaultLimitCORE=infinity', msg='check default limit core setting') utils_lib.run_cmd(self, 'ulimit -c 0;ulimit -c', expect_ret=0, expect_kw='0', msg='test user can change limit core setting') utils_lib.run_cmd(self, 'ulimit -c unlimited;ulimit -c', expect_ret=0, expect_kw='unlimited', msg='test user can change limit core setting') utils_lib.run_cmd(self, 'sudo rm -rf /var/lib/systemd/coredump/core.pp*', msg='clean up core files before testing') self.cursor = utils_lib.get_cmd_cursor(self, cmd='journalctl -b0', rmt_redirect_stdout=True) test_file = '/tmp/test.c' utils_lib.is_cmd_exist(self, 'gcc') cmd = "echo '{}' > {}".format(test_str, test_file) utils_lib.run_cmd(self, cmd, expect_ret=0, msg='generate {}'.format(test_file)) cmd = "gcc -g -o /tmp/pp {}".format(test_file) utils_lib.run_cmd(self, cmd, expect_ret=0) utils_lib.run_cmd(self, 'ulimit -c unlimited;/tmp/pp', msg='run it to trigger core dump') utils_lib.run_cmd(self, 'sudo ls /var/lib/systemd/coredump/core.pp*', expect_ret=0, msg='check core file generated') utils_lib.check_log(self, "error,warn,fail", log_cmd='journalctl -b0', cursor=self.cursor, rmt_redirect_stdout=True)
def tearDown(self): utils_lib.check_log( self, "error,warn,fail,unable,unknown,Unknown,Call trace,Call Trace", log_cmd='dmesg -T', cursor=self.dmesg_cursor)
def test_check_dmesg_unable(self): ''' bz: 1779454 polarion_id: ''' utils_lib.check_log(self, 'unable', log_cmd='dmesg')
def test_virsh_pci_reattach(self): ''' case_name: test_virsh_pci_reattach case_priority: 1 component: kernel bugzilla_id: 1700254 polarion_id: n/a maintainer: [email protected] description: Test no exception when system does pci detach and attach operation in virsh. virsh can detach host pci device and attach it to guest. key_steps: 1. #virsh nodedev-detach $pci 2. #virsh nodedev-reattach $pci expected_result: No panic/crash happen. eg. # virsh nodedev-detach pci_0000_2b_00_0 Device pci_0000_2b_00_0 detached # virsh nodedev-reattach pci_0000_2b_00_0 Device pci_0000_2b_00_0 re-attached ''' utils_lib.is_metal(self, action="cancel") cmd = "sudo yum install -y libvirt" utils_lib.run_cmd(self, cmd, msg="install libvirt pkg") cmd = "sudo systemctl restart libvirtd" utils_lib.run_cmd(self, cmd, cancel_ret='0', msg="restart libvirtd") utils_lib.is_cmd_exist(self, cmd='virsh') if utils_lib.is_arch(self, arch='x86_64'): utils_lib.run_cmd(self, 'cat /proc/cmdline', cancel_kw='intel_iommu=on', msg='Check boot line') utils_lib.run_cmd(self, 'sudo lspci', msg="get pci list") tmp_pci = None cmd = "lspci|grep 'Non-Volatile memory'|wc -l" out = utils_lib.run_cmd(self, cmd) if int(out) > 0: cmd = 'sudo find /sys/devices -name *nvme*n1p1*' tmp_root = utils_lib.run_cmd(self, cmd, msg="get boot nvme pci") boot_pci = tmp_root.split('/')[-2] cmd = 'sudo find /sys/devices -name *nvme*|grep -v %s|\ grep -i pci|grep n1' % boot_pci ret = utils_lib.run_cmd(self, cmd, msg="get test pci", ret_status=True) if int(ret) == 0: tmp_pci = utils_lib.run_cmd(self, cmd, msg="get test pci") if len(tmp_pci) > 0: tmp_pci = tmp_pci.split('/')[-4] else: tmp_pci = None else: tmp_pci = None if tmp_pci is None: cmd = 'sudo find /sys/devices -name *ttyS0*|grep [0-9]:[0-9]' tmp_root = utils_lib.run_cmd(self, cmd, msg="try to get ttyS0 pci device") if len(tmp_root) == 0: tmp_pci = None else: serial_pci = tmp_root.split('/')[-3] tmp_pci = serial_pci if tmp_pci is None: cmd = 'sudo find /sys/devices -name *vga*|grep [0-9]:[0-9]' tmp_root = utils_lib.run_cmd(self, cmd, msg="try to get vga pci device") if len(tmp_root) == 0: tmp_pci = None else: vga_pci = tmp_root.split('/')[-2] tmp_pci = vga_pci if tmp_pci is not None: self.log.info("Get pci device: {}".format(tmp_pci)) else: self.skipTest("No pci device found to detach") tmp_pci = tmp_pci.replace('.', '_') tmp_pci = tmp_pci.replace(':', '_') pci_dev_1 = utils_lib.run_cmd( self, 'sudo virsh nodedev-list|grep %s |tail -1' % tmp_pci, msg='pick up device to detach') if pci_dev_1.endswith('1'): pci_dev_0 = pci_dev_1.rstrip('1') + '0' utils_lib.run_cmd(self, 'sudo virsh nodedev-detach %s' % pci_dev_0, msg='detach pci device', expect_ret=0) utils_lib.run_cmd(self, 'sudo virsh nodedev-detach %s' % pci_dev_1, msg='detach pci device', expect_ret=0) utils_lib.run_cmd(self, 'sudo virsh nodedev-reattach %s' % pci_dev_1, msg='reattach pci device', expect_ret=0) if pci_dev_1.endswith('1'): utils_lib.run_cmd(self, 'sudo virsh nodedev-reattach %s' % pci_dev_0, msg='reattach pci device', expect_ret=0) utils_lib.check_log(self, "error,warn,fail,trace,Trace", log_cmd='dmesg -T', cursor=self.dmesg_cursor)
def test_mtu_min_max_set(self): ''' polarion_id: RHEL-111097 bz: 1502554, 1497228 ena mtu range: 128~9216 ixgbevf mtu range: 68~9710 vif mtu range: 68~65535 vmxnet3 mtu range: 60~9000 ''' utils_lib.is_cmd_exist(self, cmd='ethtool') utils_lib.msg_to_syslog(self) cmd = 'ip link show {}'.format(self.nic) out = utils_lib.run_cmd(self, cmd, expect_ret=0, msg='save the mtu before change') self.mtu_old = re.findall('mtu [0-9]+', out)[0].split(' ')[1] self.log.info("Get old mtu: {}".format(self.mtu_old)) cmd = "sudo ethtool -i {}".format(self.nic) output = utils_lib.run_cmd(self, cmd, expect_ret=0) if 'ena' in output: self.log.info('ena found!') mtu_range = [0, 127, 128, 4500, 9216, 9217] mtu_min = 128 mtu_max = 9216 elif 'ixgbe' in output: self.log.info('ixgbevf found!') mtu_range = [0, 67, 68, 4500, 9710, 9711] mtu_min = 68 mtu_max = 9710 elif 'vif' in output: self.log.info('vif found!') mtu_range = [0, 67, 68, 4500, 65535, 65536] mtu_min = 68 mtu_max = 65535 elif 'vmxnet3' in output: self.log.info('vmxnet3 found!') if self.params['remote_node'] != 'None' or len( self.params['remote_node']) >= 5: self.skipTest( "Skip mtu test while running remotely with vmxnet3") self.log.info( "vmxnet3 min mtu is 60, because of bz1503193, skip test lower value than 68" ) mtu_range = [68, 4500, 9000, 9001] mtu_min = 60 mtu_max = 9000 elif 'igb' in output: self.log.info('igb found!') mtu_range = [0, 67, 68, 4500, 9216, 9217] mtu_min = 68 mtu_max = 9216 elif 'tg3' in output: self.log.info('tg3 found!') mtu_range = [0, 59, 60, 4500, 9000, 9001] mtu_min = 60 mtu_max = 9000 else: self.log.info( 'Did not detect network type, use default min~max mtu. %s' % output) mtu_range = [0, 67, 68, 4500, 65535, 65536] mtu_min = 68 mtu_max = 65535 self.log.info("Trying to change mtu to %s" % mtu_range) for mtu_size in mtu_range: mtu_cmd = "sudo ip link set dev %s mtu %s" % (self.nic, mtu_size) mtu_check = "sudo ip link show dev {}".format(self.nic) if mtu_size <= mtu_max and mtu_size >= mtu_min: utils_lib.run_cmd(self, mtu_cmd, expect_ret=0) utils_lib.run_cmd(self, mtu_check, expect_ret=0, expect_kw="mtu {}".format(mtu_size)) elif mtu_size < mtu_min or mtu_size > mtu_max: utils_lib.run_cmd(self, mtu_cmd, expect_not_ret=0) utils_lib.run_cmd(self, mtu_check, expect_ret=0, expect_not_kw="mtu {}".format(mtu_size)) cmd = "ping {} -c 2 -I {}".format(self.params.get('ping_server'), self.nic) utils_lib.run_cmd(self, cmd, expect_ret=0) utils_lib.check_log(self, "error,warn,fail,trace", log_cmd='dmesg -T', cursor=self.dmesg_cursor, skip_words='ftrace')
def test_ethtool_G(self): ''' case_name: test_ethtool_G case_priority: 1 component: kernel bugzilla_id: 1722628 polarion_id: n/a maintainer: [email protected] description: Use ethtool to change the rx/tx ring parameters of the specified network device. key_steps: 1. # ethtool -g $nic 2. # ethtool -G $nic rx $num 3. # ethtool -G $nic rx-mini $num 4. # ethtool -G $nic rx-jumbo $num 5. # ethtool -G $nic tx $num expected_result: Can change the supported rx/tx ring parameters of the specified network device. Cannot set the ring parameters to -1. eg. # ethtool -G eth0 rx 512 # ethtool -g eth0 Ring parameters for eth0: Pre-set maximums: RX: 2048 RX Mini: 0 RX Jumbo: 0 TX: 1024 Current hardware settings: RX: 512 RX Mini: 0 RX Jumbo: 0 TX: 1024 # ethtool -G eth0 rx -1 no ring parameters changed, aborting ''' self.log.info("Test change rx/tx ring setting.") query_cmd = "ethtool -g {}".format(self.nic) output = utils_lib.run_cmd(self, query_cmd, cancel_not_kw='Operation not supported', msg='Query Operation not supported') max_rx, max_rx_mini, max_rx_jumbo, max_tx = None, None, None, None for i in output.split('\n'): if "RX:" in i: max_rx = i.split('\t')[-1] if "RX Mini:" in i: max_rx_mini = i.split('\t')[-1] if "RX Jumbo:" in i: max_rx_jumbo = i.split('\t')[-1] if "TX:" in i: max_tx = i.split('\t')[-1] if max_tx is not None: break self.log.info( "Got max_rx:{} max_rx_mini:{} max_rx_jumbo:{} max_tx:{}".format( max_rx, max_rx_mini, max_rx_jumbo, max_tx)) if max_rx is not None and 'n/a' not in max_rx and int(max_rx) > 0: if int(max_rx) >= 1024: rx = 512 elif int(max_rx) <= 256: rx = 128 else: rx = 256 cmd = "sudo ethtool -G {} rx {}".format(self.nic, rx) output = utils_lib.run_cmd(self, cmd, msg="Set rx") if "not supported" not in output: utils_lib.run_cmd(self, query_cmd, expect_kw="RX:\t\t{}".format(rx), msg="Check rx") #cmd = "sudo ethtool -G {} rx 0".format(self.nic) #utils_lib.run_cmd(self, cmd, expect_kw="Invalid argument", msg="Check rx cannot set to 0") cmd = "sudo ethtool -G {} rx -1".format(self.nic) utils_lib.run_cmd(self, cmd, expect_not_ret=0, msg="Check rx cannot set to -1") if max_rx_mini is not None and 'n/a' not in max_rx_mini and int( max_rx_mini) > 0: if int(max_rx_mini) >= 1024: rx_mini = 512 elif int(max_rx_mini) <= 256: rx_mini = 128 else: rx_mini = 256 cmd = "sudo ethtool -G {} rx-mini {}".format(self.nic, rx_mini) output = utils_lib.run_cmd(self, cmd, msg="Set rx-mini") if "not supported" not in output: out = utils_lib.run_cmd( self, query_cmd, expect_kw="RX Mini:\t{}".format(rx_mini), msg="Check rx-mini") if "RX Mini:\t0" not in out: cmd = "sudo ethtool -G {} rx-mini 0".format(self.nic) utils_lib.run_cmd(self, cmd) utils_lib.run_cmd(self, query_cmd, expect_kw="RX Mini:\t0", msg="Check rx-mini canset to 0") cmd = "sudo ethtool -G {} rx-mini -1".format(self.nic) utils_lib.run_cmd(self, cmd, expect_not_ret=0, msg="Check rx cannot rx-mini to -1") if max_rx_jumbo is not None and 'n/a' not in max_rx_jumbo and int( max_rx_jumbo) > 0: if int(max_rx_jumbo) >= 1024: rx_jumbo = 512 elif int(max_rx_jumbo) <= 256: rx_jumbo = 128 else: rx_jumbo = 256 cmd = "sudo ethtool -G {} rx-jumbo {}".format(self.nic, rx_jumbo) output = utils_lib.run_cmd(self, cmd, msg="Set rx_jumbo") if "not supported" not in output: out = utils_lib.run_cmd( self, query_cmd, expect_kw="RX Jumbo:\t{}".format(rx_jumbo), msg="Check rx_jumbo") if "RX Jumbo:\t0" not in out: cmd = "sudo ethtool -G {} rx-jumbo 0".format(self.nic) #utils_lib.run_cmd(self, cmd, expect_kw="Invalid argument", msg="Check rx-jumbo cannot set to 0") utils_lib.run_cmd(self, cmd, expect_not_ret=0, msg="Check rx-jumbo cannot set to 0") cmd = "sudo ethtool -G {} rx-jumbo -1".format(self.nic) utils_lib.run_cmd(self, cmd, expect_not_ret=0, msg="Check rx-jumbo cannot set to -1") if max_tx is not None and 'n/a' not in max_tx and int(max_tx) > 0: if int(max_tx) >= 1024: tx = 512 elif int(max_tx) <= 256: tx = 128 else: tx = 256 cmd = "sudo ethtool -G {} tx {}".format(self.nic, tx) output = utils_lib.run_cmd(self, cmd, msg="Set tx") if "not supported" not in output: utils_lib.run_cmd(self, query_cmd, expect_kw="TX:\t\t{}".format(tx), msg="Check tx") #cmd = "sudo ethtool -G {} tx 0".format(self.nic) #utils_lib.run_cmd(self, cmd, expect_kw="Invalid argument", msg="Check tx cannot set to 0") cmd = "sudo ethtool -G {} tx -1".format(self.nic) utils_lib.run_cmd(self, cmd, expect_not_ret=0, msg="Check tx cannot set to -1") utils_lib.check_log(self, "error,warn,fail,trace", log_cmd='dmesg -T', cursor=self.dmesg_cursor)
def tearDown(self): utils_lib.check_log(self, "error,warn,fail,trace", cursor=self.cursor, rmt_redirect_stdout=True)
def test_check_dmesg_warn(self): ''' polarion_id: RHEL7-103851 ''' utils_lib.check_log(self, 'warn', log_cmd='dmesg')
def test_check_dmesg_error(self): ''' :avocado: tags=test_check_dmesg_error,fast_check polarion_id: RHEL7-103851 ''' utils_lib.check_log(self, 'error', log_cmd='dmesg')
def test_check_dmesg_error(self): ''' polarion_id: RHEL7-103851 ''' utils_lib.check_log(self, 'error', log_cmd='dmesg')