示例#1
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)
示例#2
0
    def test_fips_selftest(self):
        '''
        case_name:
            test_fips_selftest

        case_priority:
            2

        component:
            openssl

        bugzilla_id:
            1940085

        customer_case_id:
            02874840

        polarion_id:
            n/a

        maintainer:
            [email protected]

        description:
            FIPS_selftest() pass

        key_steps:
            1. # gcc fipstest.c -o fipstest -lcrypto
            2. # # ./fipstest

        expected_result:
            No fips selftest failed.
        '''
        fipstest = """
//required pkg: openssl-devel
//compile: gcc fipstest.c -o fipstest -lcrypto
//run ./fipstest
//https://www.openssl.org/docs/fips/UserGuide-2.0.pdf
#include <stdio.h>
#include <openssl/ssl.h>
#include <openssl/fips.h>
#include <openssl/err.h>

int fips_test(int fipsset){
    FIPS_mode_set(fipsset);
    if (FIPS_mode()){
        fprintf(stderr, "fips mode set.\\n");
    }
    else{
        fprintf(stderr, "fips mode not set.\\n");
    }
    if (FIPS_selftest()){
        fprintf(stderr, "fips selftest pass.\\n");
    }
    else{
        fprintf(stderr, "fips selftest failed.\\n");
        ERR_print_errors_fp(stderr);
    }
}
int main(int argc, char *argv[])
{
	fips_test(0);
	fips_test(1);
}
        """
        utils_lib.is_pkg_installed(self, pkg_name="openssl-devel")
        utils_lib.is_pkg_installed(self, pkg_name="gcc")
        cmd = "echo '{}' > /tmp/fipstest.c".format(fipstest)
        utils_lib.run_cmd(self, cmd, expect_ret=0, msg='generate fipstest.c')
        cmd = "gcc /tmp/fipstest.c -o /tmp/fipstest -lcrypto"
        utils_lib.run_cmd(self, cmd, expect_ret=0, msg='compile fipstest.c')
        cmd = "/tmp/fipstest"
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          expect_not_kw="fips selftest failed",
                          msg='run fipstest')
示例#3
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!')
示例#4
0
    def test_reboot_vm_debugkernel(self):
        """
        case_tag:
            GeneralVerification
        case_name:
            test_reboot_vm_debugkernel
        case_file:
            os_tests.tests.test_nutanix_vm.test_reboot_vm_debugkernel
        component:
            GeneralVerification
        bugzilla_id:
            N/A
        is_customer_case:
            False
        customer_case_id:
            N/A
        testplan:
            N/A
        maintainer:
            [email protected]
        description:
            Reboot VM for 10 times with debug kernel and check VM status
        key_steps: |
            1. Boot VM with debug kernel
            2. Reboot VM for more than 100 times
            2. Check VM status
            3. Check OS status
        expect_result:
            1. VM working normally after reboot
            2. No unexpected error
        debug_want:
            N/A
        debug_want:
            N/A
        """
        if_secure_boot = self.vm.params['VM']['if_secure_boot']
        if 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'''
                          )

        mem_gb_current = self.vm.get_memory_size()
        if mem_gb_current < 2:
            self.skipTest(
                "Skip test as minimal 2G memory is required for debug kernel")

        default_kernel = utils_lib.run_cmd(self,
                                           "sudo grubby --default-kernel",
                                           expect_ret=0)
        kernel_version = utils_lib.run_cmd(self, "uname -r", expect_ret=0)
        if "debug" in kernel_version:
            self.log.info("Already in debug kernel")
        else:
            debug_kernel = "/boot/vmlinuz-" + kernel_version.strip(
                '\n') + "+debug"
            debug_kernel_pkg = "kernel-debug-" + kernel_version
            utils_lib.is_pkg_installed(self,
                                       pkg_name=debug_kernel_pkg,
                                       timeout=300)
            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")

        utils_lib.run_cmd(self,
                          "sudo reboot",
                          msg='Reboot OS to boot to debug kernel')
        time.sleep(60)
        utils_lib.init_connection(self)
        utils_lib.run_cmd(self,
                          "uname -r",
                          expect_ret=0,
                          expect_kw="debug",
                          msg="checking debug kernel booted")

        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)

        reboot_cycles = 10
        self._reboot_os_cycles(reboot_cycles, time_wait=30)

        cmd = "sudo grubby --set-default %s" % default_kernel
        utils_lib.run_cmd(self,
                          cmd,
                          expect_ret=0,
                          msg="Recover kernel to origin: %s" % default_kernel)
        utils_lib.run_cmd(self,
                          "sudo reboot",
                          msg='Reboot OS to boot to default kernel')
        time.sleep(30)
        utils_lib.init_connection(self)
        utils_lib.run_cmd(self,
                          "uname -r",
                          expect_ret=0,
                          expect_not_kw="debug",
                          msg="Verifying default kernel has recovered")