Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 def test_check_boot_partition_guid(self):
     """
     case_name:
         test_check_boot_partition_guid
     component:
         rhel-guest-image
     bugzilla_id:
         2057231
     is_customer_case:
         False
     maintainer:
         [email protected]
     description:
         check whether the GUID of boot partition is correct
     key_steps:
         1. lsblk -n -o PARTTYPE,MOUNTPOINT | grep '/boot$'
     expect_result:
         GUID = bc13c2ff-59e6-4262-a352-b275fd6f7172
     """
     product_id = utils_lib.get_product_id(self)
     if float(product_id) >= 9.0 and (
             utils_lib.is_arch(self, arch='aarch64')
             or utils_lib.is_arch(self, arch='x86_64')):
         cmd = "lsblk -n -o PARTTYPE,MOUNTPOINT | grep '/boot$'"
         output = utils_lib.run_cmd(self,
                                    cmd,
                                    expect_ret=0,
                                    msg="Get GUID of /boot")
         self.assertIn("bc13c2ff-59e6-4262-a352-b275fd6f7172", output,
                       "Boot partition GUID incorrect: %s" % output)
     else:
         self.skipTest(
             "Only run on RHEL 9.x or later on x86_64 or aarch64.")
Ejemplo n.º 3
0
 def test_check_cpu_flags(self):
     '''
     rhbz: 1061348
     check various cpu flags
     '''
     utils_lib.is_arch(self, arch='x86_64', action='cancel')
     cmd = "sudo cat /proc/cpuinfo"
     utils_lib.run_cmd(self, cmd, expect_ret=0, expect_kw='avx,xsave,pcid', msg='check avx,xsave,pcid flags')
Ejemplo n.º 4
0
 def test_start_vm_iommu(self):
     """
     case_tag:
         Lifecycle
     case_name:
         test_start_vm_iommu
     case_file:
         os_tests.tests.test_lifecycle.TestLifeCycle.test_start_vm_iommu kernel command.
     component:
         lifecycle
     bugzilla_id:
         N/A
     is_customer_case:
         False
     testplan:
         N/A
     maintainer:
         [email protected]
     description:
         Check /proc/cmdline after configure intel_iommu equal on .
     key_steps:
         1. Update kernel command line using grubby command and than check /proc/cmdline.
     expect_result:
         1. Update kernel command line using grubby command and than check /proc/cmdline.
     debug_want:
         N/A
     """
     if utils_lib.is_arch(self, arch='x86_64'):
         boot_param_required = 'intel_iommu=on'
         out = utils_lib.run_cmd(self, 'cat /proc/cmdline', msg='Check boot line')
         if boot_param_required not in out:
             cat_proc_cmdline = self._update_kernel_args(boot_param_required)
             self.assertIn(boot_param_required, cat_proc_cmdline, msg='Expect intel_iommu=on in /proc/cmdline')
Ejemplo n.º 5
0
    def test_kdump_no_specify_cpu(self):
        '''
        bz: 1654962
        polarion_id: RHEL7-58669
        '''
        for cmd in ['sudo kdumpctl showmem','cat /proc/cmdline','systemctl is-active kdump']:
            utils_lib.run_cmd(self, cmd, expect_ret=0)
        output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        product_id = utils_lib.get_product_id(self)
        if utils_lib.is_arch(self, 'aarch64') and not utils_lib.is_metal(self) and float(product_id) < 8.6:
            self.skipTest("Cancel as bug 1654962 in arm guest earlier than 8.6 2082405" )
        utils_lib.run_cmd(self,
                    r'sudo rm -rf /var/crash/*',
                    expect_ret=0,
                    msg='clean /var/crash firstly')
        utils_lib.run_cmd(self, r'sudo sync', expect_ret=0)
        self.log.info("Before system crash")
        utils_lib.run_cmd(self,
                    r'find /var/crash',
                    expect_ret=0,
                    msg='list /var/crash')
        utils_lib.run_cmd(self, "sudo bash -c \"echo c > /proc/sysrq-trigger\"", msg='trigger crash')

        utils_lib.init_connection(self, timeout=self.ssh_timeout)
        self.log.info("After system crash")
        utils_lib.run_cmd(self,
                    r'find /var/crash',
                    expect_ret=0,
                    msg='list /var/crash after crash')
        cmd = r'sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50'
        utils_lib.run_cmd(self, cmd, expect_ret=0, expect_kw='write_sysrq_trigger')
Ejemplo n.º 6
0
 def setUp(self):
     utils_lib.init_case(self)
     if utils_lib.is_arch(self, arch='aarch64'):
         ltp_url = self.params.get('ltp_url_aarch64')
     else:
         ltp_url = self.params.get('ltp_url_x86_64')
     utils_lib.pkg_install(self, pkg_name='ltp', pkg_url=ltp_url)
     self.cursor = utils_lib.get_cmd_cursor(self, cmd='journalctl --since today', rmt_redirect_stdout=True)
Ejemplo n.º 7
0
 def setUp(self):
     utils_lib.init_case(self)
     if utils_lib.is_arch(self, arch='aarch64'):
         blktests_url = self.params.get('blktests_url_aarch64')
     else:
         blktests_url = self.params.get('blktests_url_x86_64')
     utils_lib.pkg_install(self, pkg_name='blktests', pkg_url=blktests_url)
     self.cursor = utils_lib.get_cmd_cursor(self,
                                            cmd='journalctl --since today')
Ejemplo n.º 8
0
 def test_ltp_hugemmap(self):
     '''
     polarion_id: RHEL7-88729
     bz: 1312331
     '''
     utils_lib.get_memsize(self)
     if utils_lib.is_arch(self, arch='aarch64') and utils_lib.get_memsize(self) < 100:
         #Hugepagesize is big in aarch64, so not run all hugetlb case in low memory arm system
         self._ltp_run(case_name="hugemmap01", file_name="hugetlb")
     elif utils_lib.get_memsize(self) < 4:
         self._ltp_run(case_name="hugemmap01", file_name="hugetlb")
     else:
         self._ltp_run(file_name="hugetlb")
Ejemplo n.º 9
0
 def test_check_cmdline_crashkernel(self):
     '''
     crashkernel should be enabled in image
     '''
     product_id = utils_lib.get_product_id(self)
     if float(product_id) < float('9'):
         expect_kw = 'crashkernel=auto'
     else:
         # rhbz: 1942398
         if utils_lib.is_arch(self, arch='x86_64'):
             expect_kw = 'crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M'
         else:
             expect_kw = 'crashkernel=2G-:448M'
     utils_lib.run_cmd(self, "sudo cat /proc/cmdline", expect_ret=0, expect_kw=expect_kw, msg='check crashkernel is enabled')
Ejemplo n.º 10
0
 def test_check_partitions(self):
     """
     case_name:
        test_check_partitions
     component:
         rhel-guest-image
     bugzilla_id:
         1673094
     is_customer_case:
         False
     maintainer:
         [email protected]
     description:
         check whether root partition is identified by UUID in fstab
     key_steps:
         1. lsblk
     expect_result:
         #TODO
     """
     cmd = "df / | tail -n 1"
     output = utils_lib.run_cmd(self,
                                cmd,
                                expect_ret=0,
                                msg="df output for rootfs")
     m = re.search('/dev/([a-z]+)[0-9].*', output)
     self.assertTrue(m, "root dev name not found: %s" % output)
     dev_name = m.group(1)
     cmd = "sudo lsblk"
     output = utils_lib.run_cmd(self, cmd, expect_ret=0, msg="lsblk")
     count = 0
     for line in output.splitlines():
         if re.search(dev_name, line):
             count = count + 1
     product_id = utils_lib.get_product_id(self)
     if float(product_id) >= 9.0:
         expected_partitions = 5
         if utils_lib.is_arch(self, arch='s390x'):
             expected_partitions = 3
         elif utils_lib.is_arch(self, arch='aarch64') or utils_lib.is_arch(
                 self, arch='ppc64le'):
             expected_partitions = 4
     elif float(product_id) <= 7.0:
         expected_partitions = 2
     else:
         expected_partitions = 4
         if utils_lib.is_arch(self, arch='s390x'):
             expected_partitions = 2
         elif utils_lib.is_arch(self, arch='aarch64') or utils_lib.is_arch(
                 self, arch='ppc64le'):
             expected_partitions = 3
     self.assertEqual(expected_partitions, count,
                      "More than one partition exists:\n %s" % output)
Ejemplo n.º 11
0
    def test_kdump_no_specify_cpu(self):
        '''
        bz: 1654962
        polarion_id: RHEL7-58669
        '''
        cmd = 'systemctl is-active kdump'
        utils_lib.run_cmd(self, cmd, expect_ret=0, msg='check kdump service')
        output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        self.is_metal = utils_lib.is_metal(self)
        if utils_lib.is_arch(self, 'aarch64') and not utils_lib.is_metal(self):
            self.cancel("Cancel as bug 1654962 in arm guest which \
no plan to fix it in the near future!")

        utils_lib.run_cmd(self,
                          r'sudo rm -rf /var/crash/*',
                          expect_ret=0,
                          msg='clean /var/crash firstly')
        utils_lib.run_cmd(self, r'sudo sync', expect_ret=0)
        self.log.info("Before system crash")
        utils_lib.run_cmd(self,
                          r'find /var/crash',
                          expect_ret=0,
                          msg='list /var/crash')
        utils_lib.run_cmd(self,
                          'sudo echo c > /proc/sysrq-trigger',
                          msg='trigger crash')

        if self.is_metal:
            self.log.info("Wait 180s")
            time.sleep(180)
        else:
            self.log.info("Wait 30s")
            time.sleep(30)
        utils_lib.init_connection(self)
        self.log.info("After system crash")
        utils_lib.run_cmd(self,
                          r'find /var/crash',
                          expect_ret=0,
                          msg='list /var/crash after crash')
        cmd = r'sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50'
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          expect_kw='write_sysrq_trigger')
Ejemplo n.º 12
0
 def setUp(self):
     utils_lib.init_case(self)
     if utils_lib.is_arch(self, arch='aarch64'):
         ltp_rpm = self.utils_dir + '/ltp-master.aarch64.rpm'
         ltp_rpm_tmp = '/tmp/ltp-master.aarch64.rpm'
     else:
         ltp_rpm = self.utils_dir + '/ltp-master.x86_64.rpm'
         ltp_rpm_tmp = '/tmp/ltp-master.x86_64.rpm'
     cmd = 'ls -l /opt/ltp/runtest/smoketest'
     ret = utils_lib.run_cmd(self, cmd, ret_status=True, msg='Check if it is ltp version with smoketest')
     if not utils_lib.is_pkg_installed(self, pkg_name='ltp',is_install=False) or ret != 0:
         if self.params['remote_node'] is not None:
             self.log.info('Copy {} to remote'.format(ltp_rpm))
             self.SSH.put_file(local_file=ltp_rpm, rmt_file=ltp_rpm_tmp)
             ltp_rpm = ltp_rpm_tmp
     if ret != 0:
         force = True
     else:
         force = False
     utils_lib.pkg_install(self, pkg_name='ltp', pkg_url=ltp_rpm, force=force)
     self.cursor = utils_lib.get_cmd_cursor(self, rmt_redirect_stdout=True)
Ejemplo n.º 13
0
 def test_check_virtwhat(self):
     '''
     bz: 1782435
     polarion_id: RHEL7-103857
     test virt-what, not use systemd-detect-virt
     '''
     utils_lib.is_cmd_exist(self, cmd='virt-what')
     utils_lib.run_cmd(self,
                       "rpm -q virt-what",
                       expect_ret=0,
                       msg='get virt-what version')
     virt_what_output = utils_lib.run_cmd(self,
                                          r"sudo virt-what",
                                          expect_ret=0)
     lscpu_output = utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
     if 'Xen' in lscpu_output:
         self.log.info("Found it is a xen system!")
         if 'full' in lscpu_output:
             self.assertIn('xen-hvm', virt_what_output)
         else:
             self.assertIn('xen-domU', virt_what_output)
     elif 'KVM' in lscpu_output and not utils_lib.is_metal(self):
         self.log.info("Found it is a kvm system!")
         self.assertIn('kvm', virt_what_output)
     elif 'VMware' in lscpu_output:
         self.log.info("Found it is a vmware system!")
         self.assertIn('vmware', virt_what_output)
     elif 'Microsoft' in lscpu_output:
         self.log.info("Found it is a Hyper-V system!")
         self.assertIn('hyperv', virt_what_output)
     elif utils_lib.is_metal(self) and utils_lib.is_aws(self):
         self.log.info("Found it is a bare metal system!")
         self.assertEqual('aws', virt_what_output.strip('\n'))
     elif utils_lib.is_metal(self):
         self.log.info("Found it is a bare metal system!")
     elif utils_lib.is_aws(self) and utils_lib.is_arch(self,
                                                       arch='aarch64'):
         self.assertEqual('aws', virt_what_output.strip('\n'))
     else:
         self.skipTest("Unknow hypervisor")
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
    def test_ethtool_S_xdp(self):
        '''
        case_name:
            test_ethtool_S_xdp

        case_priority:
            2

        component:
            kernel

        bugzilla_id:
            1908542

        polarion_id:
            n/a

        maintainer:
            [email protected]

        description:
            Use ethtool to query the specified network device xdp statistics.

        key_steps:
            1. # ethtool -S $nic |grep xdp

        expected_result:
            xdp status found
            eg. # ethtool -S eth0 |grep xdp
                  queue_0_rx_xdp_aborted: 0
                  queue_0_rx_xdp_drop: 0
                  queue_0_rx_xdp_pass: 0
                  queue_0_rx_xdp_tx: 0
                  queue_0_rx_xdp_invalid: 0
                  queue_0_rx_xdp_redirect: 0

        '''
        product_id = utils_lib.get_product_id(self)
        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 driver found!')
            if float(product_id) > 8.4:
                cmd = "ethtool -S {}|grep xdp".format(self.nic)
                utils_lib.run_cmd(self,
                                  cmd,
                                  expect_ret=0,
                                  msg='Check if have xdp information')
            else:
                self.skipTest('ena driver does not support xdp prior to 8.4')
        else:
            cmd = "ethtool -S {}|grep xdp".format(self.nic)
            utils_lib.run_cmd(self,
                              cmd,
                              cancel_ret='0',
                              msg='Check if have xdp support')
        if float(product_id) > 8.3 and utils_lib.is_arch(self, arch='x86_64'):
            utils_lib.is_cmd_exist(self, 'xdp-loader')
            cmd = 'sudo xdp-loader status'
            utils_lib.run_cmd(self,
                              cmd,
                              expect_ret=0,
                              msg='Check xdp-loader status')
            cmd = 'sudo xdp-loader unload -a {}'.format(self.nic)
            utils_lib.run_cmd(self, cmd, msg='unload xdp-filter if have')
            cmd = 'sudo xdp-filter load --mode skb {}'.format(self.nic)
            utils_lib.run_cmd(self, cmd, expect_ret=0, msg='load xdp-filter')
            cmd = 'sudo xdp-loader status'
            utils_lib.run_cmd(self,
                              cmd,
                              expect_ret=0,
                              expect_kw='XDP_PASS',
                              msg='Check xdp-loader status again')
            cmd = 'sudo xdp-loader unload -a {}'.format(self.nic)
            utils_lib.run_cmd(self, cmd, expect_ret=0, msg='unload xdp-filter')
            cmd = 'sudo xdp-loader status'
            utils_lib.run_cmd(self,
                              cmd,
                              expect_ret=0,
                              expect_not_kw='XDP_PASS',
                              msg='Check xdp-loader status again')
Ejemplo n.º 16
0
    def test_kdump_each_cpu(self):
        """
        case_tag:
            kdump
        case_name:
            test_kdump_each_cpu
        case_file:
            os_tests.tests.test_lifecycle.test_kdump_each_cpu
        component:
            kdump
        bugzilla_id:
            1396554
        is_customer_case:
            False
        customer_case_id:
            N/A
        testplan:
            N/A
        maintainer:
            [email protected]
        description:
            Test kdump on each cpu core
        key_steps: |
            1. Triger crash on each cpu core
            2. Check if kdump is working and dump file will be generated
        expect_result:
            kdump is working and dump file will be generated
        debug_want:
            N/A
        debug_want:
            N/A
        """
        utils_lib.run_cmd(self, 'lscpu', expect_ret=0)
        product_id = utils_lib.get_product_id(self)
        if utils_lib.is_arch(self, 'aarch64') and not utils_lib.is_metal(self) and float(product_id) < 8.6:
            self.skipTest("Cancel as bug 1654962 in arm guest earlier than 8.6 2082405" )
        
        cmd = "grep processor /proc/cpuinfo | wc -l"
        cpu_counts = int(utils_lib.run_cmd(self, cmd, expect_ret=0,
                                           msg = "Get cpu counts"))
        for core_num in range(cpu_counts):
            self.log.info("Trigger kdump on core %d" % core_num)
            cmd = "systemctl is-active kdump || sudo systemctl start kdump"
            utils_lib.run_cmd(self, cmd, expect_ret=0, msg="check kdump service status")
            
            utils_lib.run_cmd(self,
                        "sudo rm -rf /var/crash/*",
                        expect_ret=0,
                        msg="clean /var/crash")
            utils_lib.run_cmd(self, "sudo sync", expect_ret=0)
            self.log.info("Before system crash")
            res_before = utils_lib.run_cmd(self,
                                           "find /var/crash",
                                           expect_ret=0,
                                           msg="list /var/crash before crash")
            cmd = "sudo bash -c 'taskset -c %d echo c > /proc/sysrq-trigger'" % core_num
            utils_lib.run_cmd(self, cmd, msg='trigger crash')
            time.sleep(30)

            self.params['remote_node'] = self.vm.floating_ip
            utils_lib.init_connection(self, timeout=self.ssh_timeout)
            self.log.info("After system crash")
            res_after = utils_lib.run_cmd(self,
                                          "find /var/crash",
                                          expect_ret=0,
                                          msg="list /var/crash after crash")
            self.assertNotEqual(res_after, res_before,
                                "Test failed as no crash dump file found")

            cmd = "sudo cat /var/crash/*/vmcore-dmesg.txt|tail -50"
            utils_lib.run_cmd(self, cmd, expect_ret=0,
                              expect_kw="write_sysrq_trigger",
                              msg="Check if crash happened")
Ejemplo n.º 17
0
    def test_boot_debugkernel(self):
        '''
        polarion_id:
        bz: 1703366
        '''
        self.old_grub_index = utils_lib.run_cmd(self,
                                                'sudo grubby --default-index',
                                                expect_ret=0)
        self.log.info("Check kernel-debug can boot up!")
        mini_mem = utils_lib.get_memsize(self)
        if int(mini_mem) < 2:
            self.skipTest('minimal 2G memory required for debug kernel')
        if utils_lib.is_arch(self, 'aarch64') and int(mini_mem) < 4:
            self.skipTest('minimal 4G memory required in aarch64')

        kernel_ver = utils_lib.run_cmd(self, 'uname -r', expect_ret=0)
        if 'el7' in kernel_ver:
            debug_kernel = "/boot/vmlinuz-" + kernel_ver.strip('\n') + ".debug"
        else:
            debug_kernel = "/boot/vmlinuz-" + kernel_ver.strip('\n') + "+debug"

        utils_lib.run_cmd(self,
                          "sudo grubby --info=%s" % debug_kernel,
                          expect_ret=0,
                          msg="check kernel-debug installed")
        cmd = "sudo grubby --info=%s|grep index|cut -d'=' -f2" % debug_kernel
        debug_kernel_index = utils_lib.run_cmd(self,
                                               cmd,
                                               expect_ret=0,
                                               cancel_ret='0',
                                               msg="check kernel-debug index")
        cmd = "sudo grubby --set-default-index=%s" % debug_kernel_index
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          msg="change default boot index")
        cmd = 'sudo grubby --update-kernel=ALL --args="kmemleak=on"'
        utils_lib.run_cmd(self, cmd, expect_ret=0, msg="enable kmemleak")
        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,
                          'uname -r',
                          expect_ret=0,
                          expect_kw='debug',
                          msg="checking debug kernel booted")
        utils_lib.run_cmd(self,
                          'dmesg',
                          expect_ret=0,
                          msg="saving dmesg output")
        cmd = 'journalctl > /tmp/journalctl.log'
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          msg="saving journalctl output")
        utils_lib.run_cmd(self, 'cat /tmp/journalctl.log', expect_ret=0)
        utils_lib.run_cmd(self, "sudo systemd-analyze blame > /tmp/blame.log")
        utils_lib.run_cmd(self, "cat /tmp/blame.log")
        cmd = "sudo systemd-analyze "
        time_start = int(time.time())
        while True:
            output = utils_lib.run_cmd(self, cmd)
            if 'Bootup is not yet finished' not in output:
                break
            time_end = int(time.time())
            utils_lib.run_cmd(self, 'sudo systemctl list-jobs')
            if time_end - time_start > 120:
                self.fail("Bootup is not yet finished after 120s")
            self.log.info("Wait for bootup finish......")
            time.sleep(1)
        utils_lib.run_cmd(self, "dmesg", expect_not_kw="Call trace,Call Trace")
        if int(mini_mem) < 17:
            cmd = 'sudo echo scan > /sys/kernel/debug/kmemleak'
            utils_lib.run_cmd(self, cmd, expect_ret=0, timeout=1800)

            cmd = 'sudo cat /sys/kernel/debug/kmemleak'
            output = utils_lib.run_cmd(self, cmd, expect_ret=0)
            if len(output) > 0:
                self.fail('Memory leak found!')
Ejemplo n.º 18
0
    def test_boot_debugkernel(self):
        '''
        polarion_id:
        bz: 1703366
        '''
        if self.vm.provider == 'nutanix' and self.vm.prism.if_secure_boot:
            self.skipTest('''Red Hat Insights error "sed: can't read /sys/kernel/debug/sched_features: Operation not permitted" When using secure boot''')
        self.old_grub_index = utils_lib.run_cmd(self, 'sudo grubby --default-index', expect_ret=0)
        self.log.info("Check kernel-debug can boot up!")
        mini_mem = utils_lib.get_memsize(self)
        if int(mini_mem) < 2:
            self.skipTest('minimal 2G memory required for debug kernel')
        if utils_lib.is_arch(self, 'aarch64') and int(mini_mem) < 4:
            self.skipTest('minimal 4G memory required in aarch64')
        need_reboot = False
        kernel_ver = utils_lib.run_cmd(self, 'uname -r', expect_ret=0)
        if 'debug' in kernel_ver:
            self.log.info('already in debug kernel')
        else:
            need_reboot = True
            if 'el7' in kernel_ver:
                debug_kernel = "/boot/vmlinuz-" + kernel_ver.strip('\n') + ".debug"
            else:
                debug_kernel = "/boot/vmlinuz-" + kernel_ver.strip('\n') + "+debug"
            kernel_pkg = 'kernel-debug-' + kernel_ver
            utils_lib.is_pkg_installed(self, pkg_name=kernel_pkg, timeout=600) #Increase this timeout time for once failure against Nutanix VM
            utils_lib.run_cmd(self,
                        "sudo grubby --info=%s" % debug_kernel,
                        expect_ret=0,
                        msg="check kernel-debug installed")
            cmd = "sudo grubby --info=%s|grep index|cut -d'=' -f2" % debug_kernel
            debug_kernel_index = utils_lib.run_cmd(self,
                                             cmd,
                                             expect_ret=0, cancel_ret='0',
                                             msg="check kernel-debug index")
            cmd = "sudo grubby --set-default-index=%s" % debug_kernel_index
            utils_lib.run_cmd(self, cmd, expect_ret=0, msg="change default boot index")
        cmd = 'cat /proc/cmdline'
        cmd_options = utils_lib.run_cmd(self, cmd)
        if 'kmemleak=on' not in cmd_options:
            need_reboot = True
        if need_reboot:
            cmd = 'sudo grubby --update-kernel=ALL --args="kmemleak=on"'
            utils_lib.run_cmd(self, cmd, expect_ret=0, msg="enable kmemleak")
            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,
                    'uname -r',
                    expect_ret=0,
                    expect_kw='debug',
                    msg="checking debug kernel booted")
        utils_lib.run_cmd(self, 'dmesg', expect_ret=0, msg="saving dmesg output")
        cmd = 'journalctl > /tmp/journalctl.log'
        utils_lib.run_cmd(self, cmd, expect_ret=0, msg="saving journalctl output")
        utils_lib.run_cmd(self, 'cat /tmp/journalctl.log', expect_ret=0)
        utils_lib.run_cmd(self, "sudo systemd-analyze blame > /tmp/blame.log")
        utils_lib.run_cmd(self, "cat /tmp/blame.log")
        cmd = "sudo systemd-analyze "
        time_start = int(time.time())
        while True:
            output = utils_lib.run_cmd(self, cmd)
            if 'Bootup is not yet finished' not in output:
                break
            time_end = int(time.time())
            utils_lib.run_cmd(self, 'sudo systemctl list-jobs')
            if time_end - time_start > 120:
                self.fail("Bootup is not yet finished after 120s")
            self.log.info("Wait for bootup finish......")
            time.sleep(1)
        utils_lib.run_cmd(self, "dmesg", expect_not_kw="Call trace,Call Trace")
        if int(mini_mem) < 17:
            cmd = 'sudo bash -c "echo scan > /sys/kernel/debug/kmemleak"'
            utils_lib.run_cmd(self, cmd, expect_ret=0, timeout=1800)

            cmd = 'sudo cat /sys/kernel/debug/kmemleak'
            output = utils_lib.run_cmd(self, cmd, expect_ret=0)
            if len(output) > 0:
                self.fail('Memory leak found!')