1f08c3bdfSopenharmony_ciTestcase 06 2f08c3bdfSopenharmony_ci----------- 3f08c3bdfSopenharmony_ci 4f08c3bdfSopenharmony_ciIt's been found that sometimes onlining and offlining CPUs confuse some 5f08c3bdfSopenharmony_ciof the various system tools. In particular, we found it caused top to 6f08c3bdfSopenharmony_cicrash, and found that sar wouldn't register newly available cpus that 7f08c3bdfSopenharmony_ciweren't there when it started. This test case seeks to exercise these 8f08c3bdfSopenharmony_ciknown error cases and verify that they behave correctly now. 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_ciAlgorithm - Top 12f08c3bdfSopenharmony_ci=============== 13f08c3bdfSopenharmony_ciGiven a CPU to test that exists 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_ciMake sure the specified cpu is online 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_ciLoop until done: 18f08c3bdfSopenharmony_ci Start up top and give it a little time to run 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci Offline the specified CPU 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci Wait a little time for top to notice the CPU is gone 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_ci Now check that top hasn't crashed by verifying its PID is still 25f08c3bdfSopenharmony_ci being reported by ps. 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ciWhen exiting: 28f08c3bdfSopenharmony_ci Kill the top process 29f08c3bdfSopenharmony_ci Restore all CPUs to their initial state 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ciAlgorithm - Sar 33f08c3bdfSopenharmony_ci=============== 34f08c3bdfSopenharmony_ciGiven a CPU to test that exists 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_ciMake sure the specified cpu is offline 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_ciLoop until done: 39f08c3bdfSopenharmony_ci Start up sar writing to a temp log and give it a little time to run 40f08c3bdfSopenharmony_ci 41f08c3bdfSopenharmony_ci Verify that SAR has correctly listed the missing CPU as 'nan' in its 42f08c3bdfSopenharmony_ci tmp log 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_ci Take a timestamp and count how many CPUs sar is reporting to be 45f08c3bdfSopenharmony_ci offline 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci Online the specified cpu 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ci Take another timestamp and another count of offlined CPUs. 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_ci Verify that the number of CPUs offline has changed 52f08c3bdfSopenharmony_ci 53f08c3bdfSopenharmony_ciWhen exiting: 54f08c3bdfSopenharmony_ci Kill the sar process 55f08c3bdfSopenharmony_ci 56f08c3bdfSopenharmony_ci 57