コード例 #1
0
def run(test, params, env):
    """
    Test the command virsh nodecpumap

    (1) Call virsh nodecpumap
    (2) Call virsh nodecpumap with pretty option
    (3) Call virsh nodecpumap with an unexpected option
    """

    option = params.get("virsh_node_options")
    status_error = params.get("status_error")
    cpu_off_on_test = params.get("cpu_off_on", "no") == "yes"
    online_cpus = cpu.cpu_online_list()
    test_cpu = random.choice(online_cpus)

    if cpu_off_on_test:
        # Turn off CPU
        cpu.offline(test_cpu)

    result = virsh.nodecpumap(option, ignore_status=True, debug=True)
    check_result(result, option, status_error, test)

    if cpu_off_on_test:
        # Turn on CPU and check again
        cpu.online(test_cpu)
        result = virsh.nodecpumap(option, ignore_status=True, debug=True)
        check_result(result, option, status_error, test)
コード例 #2
0
def run(test, params, env):
    """
    Test the command virsh nodecpumap

    (1) Call virsh nodecpumap
    (2) Call virsh nodecpumap with pretty option
    (3) Call virsh nodecpumap with an unexpected option
    """

    option = params.get("virsh_node_options")
    status_error = params.get("status_error")
    cpu_off_on_test = params.get("cpu_off_on", "no") == "yes"
    online_cpus = cpu.cpu_online_list()
    test_cpu = random.choice(online_cpus)

    if cpu_off_on_test:
        # Turn off CPU
        cpu.offline(test_cpu)

    result = virsh.nodecpumap(option, ignore_status=True, debug=True)
    check_result(result, option, status_error, test)

    if cpu_off_on_test:
        # Turn on CPU and check again
        cpu.online(test_cpu)
        result = virsh.nodecpumap(option, ignore_status=True, debug=True)
        check_result(result, option, status_error, test)
コード例 #3
0
def run(test, params, env):
    """
    Test the command virsh nodecpumap

    (1) Call virsh nodecpumap
    (2) Call virsh nodecpumap with pretty option
    (3) Call virsh nodecpumap with an unexpected option
    """

    option = params.get("virsh_node_options")
    status_error = params.get("status_error")

    result = virsh.nodecpumap(option, ignore_status=True, debug=True)
    output = result.stdout.strip()
    status = result.exit_status

    # Check result
    if status_error == "yes":
        if status == 0:
            raise error.TestFail("Run successfully with wrong command!")
        else:
            logging.info("Run failed as expected")
    else:
        out_value = []
        out = output.split('\n')
        for i in range(3):
            out_value.append(out[i].split()[-1])

        present = get_present_cpu()
        if not present:
            raise error.TestNAError("Host cpu counting not supported")
        else:
            if present != int(out_value[0]):
                raise error.TestFail("Present cpu is not expected")

        cpu_map = get_online_cpu(option)
        if not cpu_map:
            raise error.TestNAError("Host cpu map not supported")
        else:
            if cpu_map != tuple(out_value[2]):
                logging.info(cpu_map)
                logging.info(tuple(out_value[2]))
                raise error.TestFail("Cpu map is not expected")

        online = 0
        if 'pretty' in option:
            cpu_map = get_online_cpu()
        for i in range(present):
            if cpu_map[i] == 'y':
                online += 1
        if online != int(out_value[1]):
            raise error.TestFail("Online cpu is not expected")
コード例 #4
0
def run(test, params, env):
    """
    Test the command virsh nodecpumap

    (1) Call virsh nodecpumap
    (2) Call virsh nodecpumap with pretty option
    (3) Call virsh nodecpumap with an unexpected option
    """

    option = params.get("virsh_node_options")
    status_error = params.get("status_error")

    result = virsh.nodecpumap(option, ignore_status=True, debug=True)
    output = result.stdout.strip()
    status = result.exit_status

    # Check result
    if status_error == "yes":
        if status == 0:
            raise error.TestFail("Run successfully with wrong command!")
        else:
            logging.info("Run failed as expected")
    else:
        out_value = []
        out = output.split("\n")
        for i in range(3):
            out_value.append(out[i].split()[-1])

        present = get_present_cpu()
        if not present:
            raise error.TestNAError("Host cpu counting not supported")
        else:
            if present != int(out_value[0]):
                raise error.TestFail("Present cpu is not expected")

        cpu_map = get_online_cpu(option)
        if not cpu_map:
            raise error.TestNAError("Host cpu map not supported")
        else:
            if cpu_map != tuple(out_value[2]):
                logging.info(cpu_map)
                logging.info(tuple(out_value[2]))
                raise error.TestFail("Cpu map is not expected")

        online = 0
        if "pretty" in option:
            cpu_map = get_online_cpu()
        for i in range(present):
            if cpu_map[i] == "y":
                online += 1
        if online != int(out_value[1]):
            raise error.TestFail("Online cpu is not expected")