tests.utils.cpu_utils ===================== .. py:module:: tests.utils.cpu_utils Classes ------- .. autoapisummary:: tests.utils.cpu_utils.CpuUtils Module Contents --------------- .. py:class:: CpuUtils Utility class for CPU-related operations. .. py:method:: get_clusters_and_cores(cpu_count, cores_per_cluster) :staticmethod: Return a mapping of cluster IDs to lists of core IDs. :param cpu_count: Total number of CPUs. :param cores_per_cluster: Number of cores per cluster. :returns: Mapping ``cluster_id -> [core_id, ...]``. .. py:method:: get_cpu_index(cluster_id, core_id, cores_per_cluster) :staticmethod: Compute a global CPU index from cluster and core IDs. :param cluster_id: Cluster identifier. :param core_id: Core identifier within the cluster. :param cores_per_cluster: Number of cores per cluster. :returns: Global CPU index. .. py:method:: _list_state_dirs(mgr, port, cpu, cpu_sysfs) List cpuidle state directories for a given CPU. :param cpu: CPU index to list states for. :param cpu_sysfs: Base sysfs path for CPU information. :returns: Mapping of state names to their sysfs paths. .. py:method:: _load_states_per_cpu(platform_base_obj, names, cpu_sysfs) Load cpuidle states for each CPU. :param platform_base_obj: Object containing configuration and manager. :param names: List of state names to load. :param cpu_sysfs: Base sysfs path for CPU information. :returns: Mapping of CPU indices to their cpuidle states. .. py:method:: _check_default_status_for_state(mgr, port, cpu, state_id, states) Check the default status for a given cpuidle state on a specific CPU. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param cpu: CPU index to check. :param state_id: Identifier of the cpuidle state to check. :param states: Mapping of state names to their sysfs paths for the CPU. .. py:method:: _validate_required_files(mgr, port, *paths) Validate that required cpuidle files exist. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param paths: List of file paths to validate. :returns: None .. py:method:: _verify_usage_increases(mgr, port, usage_path, cpu, state_id, time_short = 60) Verify that the usage count increases over a short period. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param usage_path: Path to the usage file for the state. :param cpu: CPU index to check. :param state_id: Identifier of the cpuidle state to check. :param time_short: Time to wait between checks in seconds. :returns: None .. py:method:: _disable_state(mgr, port, disable_path, cpu, state_id, original_disable_values) Disable a specific cpuidle state for a given CPU. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param disable_path: Path to the disable file for the state. :param cpu: CPU index to disable the state on. :param state_id: Identifier of the cpuidle state to disable. :param original_disable_values: Dictionary to store original disable values for restoration. .. py:method:: _verify_usage_stays_same_when_disabled(mgr, port, usage_path, cpu, state_id, time_short = 60) Verify that the usage count does not change when the state is disabled. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param usage_path: Path to the usage file for the state. :param cpu: CPU index to check. :param state_id: Identifier of the cpuidle state to check. :param time_short: Time to wait between checks in seconds. .. py:method:: _verify_latency_residency_values(mgr, port, base, props, cpu, state_id) Verify latency and residency values for a specific C-state on a CPU. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param base: Base sysfs path for the C-state. :param props: Expected properties containing 'latency' and 'residency'. :param cpu: CPU index to check. :param state_id: Identifier of the cpuidle state to check. .. py:method:: _verify_usage_time_advancement(mgr, port, base, cpu, state_id, time_long = 120) Verify that usage and time values advance over a longer period. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param base: Base sysfs path for the C-state. :param cpu: CPU index to check. :param state_id: Identifier of the cpuidle state to check. :param time_long: Time to wait between checks in seconds. .. py:method:: available_governors(mgr, port, cpuidle_dir) List available cpuidle governors. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param cpuidle_dir: Base directory for cpuidle sysfs entries. :returns: List of available cpuidle governors. .. py:method:: current_governor(mgr, port, cpuidle_dir, ro = True) Get the current cpuidle governor. :param mgr: Manager object for executing commands. :param port: Port identifier for command execution. :param cpuidle_dir: Base directory for cpuidle sysfs entries. :param ro: Whether to read from the read-only current_governor_ro file. :returns: Name of the current cpuidle governor. .. py:method:: set_cpu(platform_base_obj, cpu_num, flag) Set a CPU core online/offline and verify the new state. :param platform_base_obj: Platform fixture with console access. :param cpu_num: CPU index to modify. :param flag: Desired CPU online state as string. :returns: True when the value matches flag otherwise False .. py:method:: enable_cpu(platform_base_obj, cpu_num) Enable a specific CPU core. .. py:method:: disable_cpu(platform_base_obj, cpu_num) Disable a specific CPU core. .. py:method:: validate_cpu_count_from_devicetree(platform_base_obj, expected_num_cpus) Validate CPU count in device tree against expected value. :param platform_base_obj: Platform fixture with console access. :param expected_num_cpus: Expected number of CPU nodes in device tree. :raises AssertionError: If CPU count does not match expected value. .. py:method:: assert_all_cores_online(platform_base_obj, expected_num_cpus) Check that all expected CPU cores are currently online. :param platform_base_obj: Platform fixture with console access. :param expected_num_cpus: Expected number of online processors. :raises AssertionError: If online CPU count differs from expected .. py:method:: stop_individual_core(platform_base_obj, expected_num_cpus) Verify per-core CPU hotplug by toggling each core off then on. :param platform_base_obj: Platform fixture with console access. :param expected_num_cpus: Expected number of online processors. :raises AssertionError: If online CPU count differs from expected .. py:method:: reenable_all_cpus(platform_base_obj, expected_num_cpus) Attempt to re-enable all CPU cores and assert recovery :param platform_base_obj: Platform fixture with console access. :param expected_num_cpus: number of CPU cores expected to be online. :raises AssertionError: If one or more CPU cores cannot be re-enabled. .. py:method:: check_cannot_disable_all_cores(platform_base_obj, expected_num_cpus) Verify the system refuses disabling the final online CPU core. :param platform_base_obj: Platform fixture with console access. :param expected_num_cpus: Total number of CPU cores in the system. :raises AssertionError: last core disable unexpectedly succeeds.