예제 #1
0
 def test_comma_separated_ranges_to_list(self):
     """
     Verify the correct value is obtained when converting a comma separated
     range string to list
     """
     node_values = ["0", "1-3", "0-1,16-17", "0-1,16-20,23-25"]
     expected_values = [[0], [1, 2, 3], [0, 1, 16, 17],
                        [0, 1, 16, 17, 18, 19, 20, 23, 24, 25]]
     for index, value in enumerate(node_values):
         self.assertEqual(data_structures.comma_separated_ranges_to_list(
             value), expected_values[index])
예제 #2
0
 def test_comma_separated_ranges_to_list(self):
     """
     Verify the correct value is obtained when converting a comma separated
     range string to list
     """
     node_values = ["0", "1-3", "0-1,16-17", "0-1,16-20,23-25"]
     expected_values = [[0], [1, 2, 3], [0, 1, 16, 17],
                        [0, 1, 16, 17, 18, 19, 20, 23, 24, 25]]
     for index, value in enumerate(node_values):
         self.assertEqual(data_structures.comma_separated_ranges_to_list(
             value), expected_values[index])
예제 #3
0
def numa_nodes_with_memory():
    """
    Get a list of NUMA nodes present with memory on the system.

    :return: List with nodes which has memory.
    """
    mem_path = "/sys/devices/system/node/has_normal_memory"
    if not os.path.exists(mem_path):
        mem_path = "/sys/devices/system/node/has_memory"
        if not os.path.exists(mem_path):
            raise MemError("No NUMA nodes have memory")

    node_list = str(genio.read_file(mem_path).rstrip("\n"))
    return data_structures.comma_separated_ranges_to_list(node_list)
예제 #4
0
    def _create_test_list(self, test_range, test_type=None, dangerous=True):
        test_list = []
        dangerous_tests = []
        if self.skip_dangerous:
            dangerous_tests = self._get_tests_for_group('dangerous')
        if test_range:
            for test in data_structures.comma_separated_ranges_to_list(test_range):
                test = "%03d" % test
                if dangerous:
                    if test in dangerous_tests:
                        self.log.debug('Test %s is dangerous. Skipping.', test)
                        continue
                if not self._is_test_valid(test):
                    self.log.debug('Test %s invalid. Skipping.', test)
                    continue
                test_list.append(test)

        if test_type:
            with open(self.exclude_file, 'a') as fp:
                for test in test_list:
                    fp.write('%s/%s\n' % (test_type, test))
예제 #5
0
    def _create_test_list(self, test_range, test_type=None, dangerous=True):
        test_list = []
        dangerous_tests = []
        if self.skip_dangerous:
            dangerous_tests = self._get_tests_for_group('dangerous')
        if test_range:
            for test in data_structures.comma_separated_ranges_to_list(test_range):
                test = "%03d" % test
                if dangerous:
                    if test in dangerous_tests:
                        self.log.debug('Test %s is dangerous. Skipping.', test)
                        continue
                if not self._is_test_valid(test):
                    self.log.debug('Test %s invalid. Skipping.', test)
                    continue
                test_list.append(test)

        if test_type:
            with open(self.exclude_file, 'a') as fp:
                for test in test_list:
                    fp.write('%s/%s\n' % (test_type, test))
        return test_list