Exemple #1
0
    def optprobes_disable_test(self):
        optprobes_file = "/proc/sys/debug/kprobes-optimization"
        if not self.check_kernel_support():
            self.log.info(
                "No support available for optprobes, skipping optprobes test")
            return

        if not os.path.exists(optprobes_file):
            self.log.info(
                "optprobes control file %s missing, skipping optprobes test",
                optprobes_file)
            return

        cur_val = genio.read_one_line(optprobes_file)
        genio.write_one_line(optprobes_file, "0")
        self.log.info(
            "================= Disabling optprobes ==================")
        if "0" not in genio.read_one_line(optprobes_file):
            self.fail("Not able to disable optprobes")
        self.execute_test()

        self.log.info(
            "================= Restoring optprobes ==================")
        genio.write_one_line(optprobes_file, cur_val)
        if cur_val not in genio.read_one_line(optprobes_file):
            self.fail("Not able to restore optprobes to %s", cur_val)
Exemple #2
0
 def test_diag_encl(self):
     self.log.info("===========Executing diag_encl test==========")
     diag_path = '/var/log/ppc64-diag/diag_disk/'
     if not os.path.isdir(diag_path):
         self.fail('diag_disk path does not exists.')
     if not self.run_cmd_out("diag_encl -h | grep -Eai 'disk health'").strip():
         self.fail("'-d' option is not available in help message")
     for _ in range(4):
         self.run_cmd("diag_encl -d")
     xml_file_path = os.path.join(diag_path, '*diskAnalytics*')
     no_of_files = self.run_cmd_out("ls -lrt %s | wc -l" % xml_file_path).strip()
     if no_of_files == '0':
         self.fail("xml file not generated")
     if no_of_files > '1':
         self.fail("multiple xml files are generated")
     xml_file = self.run_cmd_out("ls %s" % diag_path).strip()
     xml_file = os.path.join(diag_path, xml_file)
     e_xml = xml.etree.ElementTree.parse(xml_file).getroot()
     machine_type = e_xml.find('Machine').get('type').strip()
     machine_model = e_xml.find('Machine').get('model').strip()
     machine_serial_xml = e_xml.find('Machine').get('serial').strip()
     if 'KVM' in self.run_cmd_out("pseries_platform"):
         product_path = '/proc/device-tree/host-model'
         serial_path = '/proc/device-tree/host-serial'
     else:
         product_path = '/proc/device-tree/model'
         serial_path = '/proc/device-tree/system-id'
     product_name = genio.read_one_line(product_path).rstrip(' \t\r\n\0')
     serial_num = genio.read_one_line(serial_path).rstrip(' \t\r\n\0')
     product_name_xml = "-".join((machine_type, machine_model))
     if product_name_xml != product_name:
         self.fail("type and model are incorrect")
     if machine_serial_xml not in serial_num:
         self.fail("serial is incorrect")
Exemple #3
0
 def get_size_alignval(self):
     """
     Return the size align restriction based on platform
     """
     if not os.path.exists("/sys/bus/nd/devices/region0/align"):
         size_align = 1
     else:
         size_align = int(genio.read_one_line("/sys/bus/nd/devices/region0/align"), 16)
     if not os.path.exists("/sys/bus/nd/devices/pfn0.0/align"):
         self.cancel("Cannot determine the mapping alignment size")
     map_align = int(genio.read_one_line("/sys/bus/nd/devices/pfn0.0/align"))
     return self.lcm(size_align, map_align)
    def execute_test(self):
        self.log.info("============== Enabling livepatching =================")
        self.clear_dmesg()
        self.is_fail = 0
        self.run_cmd("insmod ./livepatch-sample.ko")
        if self.is_fail >= 1:
            self.fail("insmod livepatch-sample.ko failed")

        if "enabling patch" not in self.run_cmd_out(
                "dmesg |grep -i livepatch_sample"):
            self.fail(
                "livepatch couldn't be enabled, check dmesg for more information"
            )
        """
        Execute /proc/cmdline, to check if livepatch works
        """
        if "this has been live patched" not in genio.read_one_line(
                "/proc/cmdline"):
            self.fail(
                "livepatching unsuccessful, check dmesg for more information")

        self.log.info(
            "============== Disabling livepatching =================")
        genio.write_one_line("/sys/kernel/livepatch/livepatch_sample/enabled",
                             "0")
        if "0" not in genio.read_one_line(
                "/sys/kernel/livepatch/livepatch_sample/enabled"):
            self.fail(
                "Unable to disable livepatch for livepatch_sample module")

        if "unpatching transition" not in self.run_cmd_out(
                "dmesg |grep -i livepatch_sample"):
            self.fail(
                "livepatch couldn't be disabled, check dmesg for more information"
            )

        if "this has been live patched" in genio.read_one_line(
                "/proc/cmdline"):
            self.fail(
                "livepatching disabling unsuccessful, check dmesg for more information"
            )
        """
        Wait for 3 minutes before trying to remove the livepatching module
        """
        time.sleep(60 * 3)
        self.run_cmd("rmmod livepatch-sample")
        if self.is_fail >= 1:
            self.log.info(
                "rmmod livepatch-sample.ko failed, try removing it manual"
                "after sometime")
Exemple #5
0
 def test_dimm_health(self):
     """
     Test the dimm health
     """
     dimms = self.plib.run_ndctl_list('-DH')
     if not dimms:
         self.fail('Failed to fetch DIMMs')
     for dimm in dimms:
         health = self.plib.run_ndctl_list_val(dimm, 'health')
         nmem = self.plib.run_ndctl_list_val(dimm, 'dev')
         region = "region%s" % re.findall(r'\d+', nmem)[0]
         dev_type = genio.read_one_line("/sys/bus/nd/devices/%s/devtype" %
                                        region)
         if not health:
             self.cancel("kernel/ndctl does not support health reporting")
         if dev_type == "nd_pmem":
             if 'life_used_percentage' not in health:
                 self.fail("life_used_percentage missing for HMS")
             self.log.info("%s life is %s", nmem,
                           health['life_used_percentage'])
         if 'health_state' in health:
             if health['health_state'] != "ok":
                 self.log.warn("%s health is bad", nmem)
         if 'shutdown_state' in health:
             if health['shutdown_state'] != "clean":
                 self.log.warn("%s shutdown state is dirty", nmem)
         self.log.info("DIMM %s Health info: %s", nmem, health)
 def get_size_alignval(self):
     """
     Return the size align restriction based on platform
     """
     if not os.path.exists("/sys/bus/nd/devices/region0/align"):
         self.cancel("Test cannot execute without the size alignment value")
     return int(genio.read_one_line("/sys/bus/nd/devices/region0/align"), 16)
 def execute_perf_test(self):
     os.chdir(self.sourcedir)
     genio.write_one_line("/proc/sys/kernel/perf_event_paranoid", "-1")
     if "-1" not in genio.read_one_line(
             "/proc/sys/kernel/perf_event_paranoid"):
         self.cancel("Unable to set perf_event_paranoid to -1 ")
     self.output = self.run_cmd_out("./run_tests.sh")
Exemple #8
0
    def test_check_ns_numa(self):
        self.plib.enable_region()
        regions = self.plib.run_ndctl_list('-R')
        for dev in regions:
            region = self.plib.run_ndctl_list_val(dev, 'dev')
            if not self.plib.is_region_legacy(region):
                self.plib.disable_namespace(region=region)
                self.plib.destroy_namespace(region=region)
                for _ in range(3):
                    self.plib.create_namespace(region=region,
                                               mode='fsdax',
                                               size='128M')

            namespaces = self.plib.run_ndctl_list('-N -r %s' % region)
            if not os.path.exists(
                    '/sys/bus/nd/devices/namespace0.0/numa_node'):
                self.fail("Numa node entries not found!")
            for val in namespaces:
                ns_name = self.plib.run_ndctl_list_val(val, 'dev')
                numa = genio.read_one_line('/sys/bus/nd/devices/%s/numa_node' %
                                           ns_name)
                # Check numa config in ndctl and sys interface
                if len(
                        self.plib.run_ndctl_list('-N -n %s -U %s' %
                                                 (ns_name, numa))) != 1:
                    self.fail('Numa mismatch between ndctl and sys interface')
Exemple #9
0
def is_selinux_enforcing():
    """
    Returns True if SELinux is in enforcing mode, False if permissive/disabled.
    """
    if "1" in genio.read_one_line("/sys/fs/selinux/enforce"):
        return True
    return False
Exemple #10
0
    def test(self):
        self.plib.enable_region()
        regions = self.plib.run_ndctl_list('-R')
        region = self.plib.run_ndctl_list_val(regions[0], 'dev')
        legacy = self.plib.is_region_legacy(region)
        buses = self.plib.run_ndctl_list('-RBN')
        failures = []
        assoc_ref_index = self.get_ref_point_index(legacy=legacy)
        for val in buses:
            region = self.plib.run_ndctl_list_val(val, 'regions')
            sys_id = self.plib.run_ndctl_list_val(region[0], 'dev')
            if legacy:
                # Use namespace level node for legacy h/w
                nss = self.plib.run_ndctl_list_val(region[0], 'namespaces')
                sys_id = self.plib.run_ndctl_list_val(nss[0], 'dev')
            node_path = '/sys/bus/nd/devices/%s/target_node' % sys_id
            if not os.path.exists(node_path):
                # Fallback to numa_node if target_node support does not exist
                node_path = '/sys/bus/nd/devices/%s/numa_node' % sys_id
            node = genio.read_one_line(node_path)

            provider = self.plib.run_ndctl_list_val(val, 'provider')
            if legacy:
                dt_node = str(self.parse_legacy_dt(assoc_ref_index, provider))
            else:
                dt_node = str(self.parse_pmem_dt(assoc_ref_index, provider))
            if node != dt_node:
                failures.append("%s associativity is wrong! "
                                "Exp:%s, Got:%s" % (sys_id, dt_node, node))
            else:
                self.log.info(
                    "Working as expected. "
                    "ndctl node: %s, DT node: %s", node, dt_node)
        if failures:
            self.fail(failures)
Exemple #11
0
def get_proc_sys(key):
    """
    Read values from /proc/sys

    :param key: A location under /proc/sys
    :return: The single-line sysctl value as a string.
    """
    path = os.path.join("/proc/sys/%s", key)
    return genio.read_one_line(path)
 def test_check_numa(self):
     self.enable_region()
     regions = self.get_json(short_opt='-R')
     for reg in regions:
         numa = genio.read_one_line('/sys/devices/ndbus%s/%s/numa_node'
                                    % (re.findall(r'\d+', reg)[0], reg))
         # Check numa config in ndctl and sys interface
         if len(self.get_json(long_opt='-r %s -U %s' % (reg, numa))) != 1:
             self.fail('Region mismatch between ndctl and sys interface')
Exemple #13
0
 def get_provisioning_mode(device, host_id):
     """
     Get disk provisioning_mode, value usually is 'writesame_16', depends
     on params for scsi_debug module.
     """
     device_name = os.path.basename(device)
     path = "/sys/block/%s/device/scsi_disk" % device_name
     path += "/%s/provisioning_mode" % host_id
     return genio.read_one_line(path).strip()
Exemple #14
0
 def get_hnv_bond(self, mac):
     """
     Get the newly created hnv bond interface name
     """
     output = genio.read_one_line("/sys/class/net/bonding_masters").split()
     for bond in output:
         if mac in netifaces.ifaddresses(bond)[17][0]['addr'].replace(':', ''):
             return bond
     self.fail("Test fail due to mac address mismatch")
Exemple #15
0
 def get_provisioning_mode(device, host_id):
     """
     Get disk provisioning_mode, value usually is 'writesame_16', depends
     on params for scsi_debug module.
     """
     device_name = os.path.basename(device)
     path = "/sys/block/%s/device/scsi_disk" % device_name
     path += "/%s/provisioning_mode" % host_id
     return genio.read_one_line(path).strip()
Exemple #16
0
 def test_check_numa(self):
     self.enable_region()
     regions = self.run_ndctl_list('-R')
     for val in regions:
         reg = self.run_ndctl_list_val(val, 'dev')
         numa = genio.read_one_line('/sys/devices/ndbus%s/%s/numa_node' %
                                    (re.findall(r'\d+', reg)[0], reg))
         # Check numa config in ndctl and sys interface
         if len(self.run_ndctl_list('-r %s -U %s' % (reg, numa))) != 1:
             self.fail('Region mismatch between ndctl and sys interface')
Exemple #17
0
 def get_allocation_bitmap():
     """
     Get block allocation bitmap
     """
     path = "/sys/bus/pseudo/drivers/scsi_debug/map"
     try:
         return genio.read_one_line(path).strip()
     except IOError:
         logging.warn("block allocation bitmap not exists")
     return ""
 def execute_perf_fuzzer(self):
     os.chdir(self.sourcedir)
     genio.write_one_line("/proc/sys/kernel/perf_event_paranoid", "-1")
     if "-1" not in genio.read_one_line("/proc/sys/kernel/"
                                        "perf_event_paranoid"):
         self.cancel("Unable to set perf_event_paranoid to -1 ")
     self.perf_fuzzer = os.path.join(self.sourcedir, "fuzzer/perf_fuzzer")
     if not os.path.exists(self.perf_fuzzer):
         self.cancel("fuzzer not found at %s" % self.perf_fuzzer)
     self.output = self.run_cmd_out(self.perf_fuzzer)
Exemple #19
0
 def get_allocation_bitmap():
     """
     Get block allocation bitmap
     """
     path = "/sys/bus/pseudo/drivers/scsi_debug/map"
     try:
         return genio.read_one_line(path).strip()
     except IOError:
         logging.warn("block allocation bitmap not exists")
     return ""
Exemple #20
0
 def get_allocation_bitmap():
     """
     get block allocation bitmap
     """
     path = "/sys/bus/pseudo/drivers/scsi_debug/map"
     try:
         return genio.read_one_line(path).strip()
     except IOError:
         logging.warn("could not get bitmap info, path '%s' is "
                      "not exist", path)
     return ""
Exemple #21
0
 def test_check_numa(self):
     self.plib.enable_region()
     regions = self.plib.run_ndctl_list('-R')
     if not os.path.exists('/sys/bus/nd/devices/region0/numa_node'):
         self.fail("Numa node entries not found!")
     for val in regions:
         reg = self.plib.run_ndctl_list_val(val, 'dev')
         numa = genio.read_one_line('/sys/bus/nd/devices/%s/numa_node' % reg)
         # Check numa config in ndctl and sys interface
         if len(self.plib.run_ndctl_list('-r %s -R -U %s' % (reg, numa))) != 1:
             self.fail('Region mismatch between ndctl and sys interface')
 def get_allocation_bitmap():
     """
     get block allocation bitmap
     """
     path = "/sys/bus/pseudo/drivers/scsi_debug/map"
     try:
         return genio.read_one_line(path).strip()
     except IOError:
         logging.warn("could not get bitmap info, path '%s' is "
                      "not exist", path)
     return ""
Exemple #23
0
    def test_diag_encl(self):
        self.log.info("===========Executing diag_encl test==========")
        diag_path = '/var/log/ppc64-diag/diag_disk/'

        if 'disk health' not in process.system_output("diag_encl -h"):
            self.fail("'-d' option is not available in help message")
        if not os.path.isdir(diag_path):
            self.run_cmd_out("diag_encl -d")

        for _ in range(4):
            self.run_cmd("diag_encl -d")
        no_of_files = len(glob.glob1(diag_path, "*diskAnalytics*"))

        if no_of_files == '0':
            self.fail("xml file not generated")
        if no_of_files > '1':
            self.fail("multiple xml files are generated")
        xml_file = os.listdir(diag_path)[0]
        xml_file = os.path.join(diag_path, xml_file)
        e_xml = xml.etree.ElementTree.parse(xml_file).getroot()
        machine_type = e_xml.find('Machine').get('type').strip()
        machine_model = e_xml.find('Machine').get('model').strip()
        machine_serial_xml = e_xml.find('Machine').get('serial').strip()
        if 'KVM' in self.run_cmd_out("pseries_platform"):
            product_path = '/proc/device-tree/host-model'
            serial_path = '/proc/device-tree/host-serial'
        else:
            product_path = '/proc/device-tree/model'
            serial_path = '/proc/device-tree/system-id'
        product_name = genio.read_one_line(product_path).rstrip(' \t\r\n\0')
        if 'PowerNV' not in open('/proc/cpuinfo', 'r').read():
            product_name = product_name.split(',')[1]
        serial_num = genio.read_one_line(serial_path).rstrip(' \t\r\n\0')
        product_name_xml = "-".join((machine_type, machine_model))
        if product_name_xml != product_name:
            self.fail("type and model are incorrect")
        if machine_serial_xml not in serial_num:
            self.fail("serial is incorrect")
    def test_diag_encl(self):
        self.log.info("===========Executing diag_encl test==========")
        diag_path = '/var/log/ppc64-diag/diag_disk/'

        if 'disk health' not in process.system_output("diag_encl -h"):
            self.fail("'-d' option is not available in help message")
        if not os.path.isdir(diag_path):
            self.run_cmd_out("diag_encl -d")

        for _ in range(4):
            self.run_cmd("diag_encl -d")
        no_of_files = len(glob.glob1(diag_path, "*diskAnalytics*"))

        if no_of_files == '0':
            self.fail("xml file not generated")
        if no_of_files > '1':
            self.fail("multiple xml files are generated")
        xml_file = os.listdir(diag_path)[0]
        xml_file = os.path.join(diag_path, xml_file)
        e_xml = xml.etree.ElementTree.parse(xml_file).getroot()
        machine_type = e_xml.find('Machine').get('type').strip()
        machine_model = e_xml.find('Machine').get('model').strip()
        machine_serial_xml = e_xml.find('Machine').get('serial').strip()
        if 'KVM' in self.run_cmd_out("pseries_platform"):
            product_path = '/proc/device-tree/host-model'
            serial_path = '/proc/device-tree/host-serial'
        else:
            product_path = '/proc/device-tree/model'
            serial_path = '/proc/device-tree/system-id'
        product_name = genio.read_one_line(product_path).rstrip(' \t\r\n\0')
        if 'PowerNV' not in open('/proc/cpuinfo', 'r').read():
            product_name = product_name.split(',')[1]
        serial_num = genio.read_one_line(serial_path).rstrip(' \t\r\n\0')
        product_name_xml = "-".join((machine_type, machine_model))
        if product_name_xml != product_name:
            self.fail("type and model are incorrect")
        if machine_serial_xml not in serial_num:
            self.fail("serial is incorrect")
Exemple #25
0
    def check_namespace_align(self, region):
        """
        Utility to check if the namespaces of given region adapts following
        1. Aligning of sys fs map_align attribute and ndctl list align value
        2. The size after creation is a multiple of the map_align

        Note: Function to be used after creation of namespace(s)
        """
        idx = re.findall(r'\d+', region)[0]
        map_align = int(genio.read_one_line("/sys/bus/nd/devices/pfn%s.0/align" % idx))
        namespaces = self.plib.run_ndctl_list('-N -r %s' % region)
        for ns in namespaces:
            ns_name = self.plib.run_ndctl_list_val(ns, 'dev')
            namespace = self.plib.run_ndctl_list('-n %s' % ns_name)[0]
            ndctl_align = self.plib.run_ndctl_list_val(namespace, 'align')
            if map_align != ndctl_align:
                self.fail("Mismatch in mapping alignment and ndctl list align")
            ndctl_size = self.plib.run_ndctl_list_val(namespace, 'size')
            print(ndctl_size, map_align)
            if ndctl_size % map_align:
                self.fail("Created Size is not a multiple of map alignment")
 def execute_perf_test(self):
     os.chdir(self.sourcedir)
     genio.write_one_line("/proc/sys/kernel/perf_event_paranoid", "-1")
     if "-1" not in genio.read_one_line("/proc/sys/kernel/perf_event_paranoid"):
         self.cancel("Unable to set perf_event_paranoid to -1 ")
     self.output = self.run_cmd_out("./run_tests.sh")
Exemple #27
0
 def data(self, data):
     if os.path.isfile(data):
         self.data_file = data
         self._data = genio.read_one_line(self.data_file)
     else:
         self._data = data
Exemple #28
0
 def data_file(self, data_file):
     if os.path.isfile(data_file):
         self._data = genio.read_one_line(self.data_file)
     else:
         genio.write_one_line(data_file, self.data)