mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-30 06:34:13 +00:00 
			
		
		
		
	TM: Update and Refactor
TM has been updated and restructured to be clearer, including splitting off assistant and creating a runtime parameter manager into their own files.
This commit is contained in:
		
							
								
								
									
										50
									
								
								wa/tests/test_runtime_param_utils.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								wa/tests/test_runtime_param_utils.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| import unittest | ||||
| from nose.tools import assert_equal | ||||
| from mock.mock import Mock | ||||
|  | ||||
| from wa.utils.misc import resolve_cpus, resolve_unique_domain_cpus | ||||
|  | ||||
| class TestRuntimeParameterUtils(unittest.TestCase): | ||||
|  | ||||
|     def test_resolve_cpu(self): | ||||
|         # Set up a mock target | ||||
|         mock = Mock() | ||||
|         mock.big_core = "A72" | ||||
|         mock.little_core = "A53" | ||||
|         mock.core_names = ['A72', 'A72', 'A53', 'A53'] | ||||
|         mock.number_of_cpus = 4 | ||||
|         def mock_core_cpus(core): | ||||
|             return [i for i, c in enumerate(mock.core_names) if c == core] | ||||
|         def mock_online_cpus(): | ||||
|             return [0, 1, 2] | ||||
|         def mock_offline_cpus(): | ||||
|             return [3] | ||||
|         def mock_domain_cpus(core): | ||||
|             if core in [0, 1]: | ||||
|                 return [0, 1] | ||||
|             elif core in [2, 3]: | ||||
|                 return [2, 3] | ||||
|  | ||||
|         mock.list_online_cpus = mock_online_cpus | ||||
|         mock.list_offline_cpus = mock_offline_cpus | ||||
|         mock.core_cpus = mock_core_cpus | ||||
|         mock.core_cpus = mock_core_cpus | ||||
|         mock.cpufreq.get_domain_cpus = mock_domain_cpus | ||||
|  | ||||
|         # Check retrieving cpus from a given prefix | ||||
|         assert_equal(resolve_cpus('A72', mock), [0, 1]) | ||||
|         assert_equal(resolve_cpus('A53', mock), [2, 3]) | ||||
|         assert_equal(resolve_cpus('big', mock), [0, 1]) | ||||
|         assert_equal(resolve_cpus('little', mock), [2, 3]) | ||||
|         assert_equal(resolve_cpus('', mock), [0, 1, 2, 3]) | ||||
|         assert_equal(resolve_cpus('cpu0', mock), [0]) | ||||
|         assert_equal(resolve_cpus('cpu3', mock), [3]) | ||||
|  | ||||
|         # Check get unique domain cpus | ||||
|         assert_equal(resolve_unique_domain_cpus('A72', mock), [0]) | ||||
|         assert_equal(resolve_unique_domain_cpus('A53', mock), [2]) | ||||
|         assert_equal(resolve_unique_domain_cpus('big', mock), [0]) | ||||
|         assert_equal(resolve_unique_domain_cpus('little', mock), [2]) | ||||
|         assert_equal(resolve_unique_domain_cpus('', mock), [0, 2]) | ||||
|         assert_equal(resolve_unique_domain_cpus('cpu0', mock), [0]) | ||||
|         assert_equal(resolve_unique_domain_cpus('cpu3', mock), [2]) | ||||
		Reference in New Issue
	
	Block a user