Ejemplo n.º 1
0
    def test__get_highest_freq(self):
        class CPU:
            def __init__(self, freq):
                self.highest_freq = freq

        for ret_val in [[], None]:
            with mock.patch("power_common.get_pwr_cpus",
                            return_value=ret_val) as mock_get_cpus:
                assert None == power_common.get_pwr_highest_freq()
                mock_get_cpus.assert_called_once()

        for freq in [3000, 3500, 4000]:
            with mock.patch("power_common.get_pwr_cpus",
                            return_value=[CPU(freq)]) as mock_get_cpus:
                assert freq == power_common.get_pwr_highest_freq()
                mock_get_cpus.assert_called_once()
Ejemplo n.º 2
0
def _is_max_freq_valid(freq):
    """
    Validate max. freq value
    Returns None on error.

    Parameters
        freq: frequency value
    """

    highest_freq = power_common.get_pwr_highest_freq()
    if not highest_freq:
        return None

    if freq > highest_freq:
        return False

    return True