From 9048fb5a1a22514bd75801636f04f8536766bd7e Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Wed, 14 Aug 2019 20:34:44 -0400 Subject: [PATCH] kfdtest: Implement SuspendAndWakeUp() Change-Id: I16384cd0ca35f15841344ded4d4237a0a862a934 Signed-off-by: Yong Zhao --- tests/kfdtest/scripts/kfdtest.exclude | 14 ++++++++++---- tests/kfdtest/scripts/run_kfdtest.sh | 3 ++- tests/kfdtest/src/LinuxOSWrapper.cpp | 18 ++++++++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/kfdtest/scripts/kfdtest.exclude b/tests/kfdtest/scripts/kfdtest.exclude index 9559cd549a..e694b1a9d4 100644 --- a/tests/kfdtest/scripts/kfdtest.exclude +++ b/tests/kfdtest/scripts/kfdtest.exclude @@ -1,5 +1,14 @@ + +# Power management tests +PM_TESTS=\ +"KFDPMTest.SuspendWithActiveProcess:"\ +"KFDPMTest.SuspendWithIdleQueue:"\ +"KFDPMTest.SuspendWithIdleQueueAfterWork:"\ + # Permanent exclusions # These tests are included for debugging, but are not executed in normal execution on any ASIC: +# PM_TESTS need human intervention, so put it here. Developers can run them +# manually through "-p pm" option. # # Fragmentation test fails intermittently on different systems (see KFD-344). It # stresses memory management in unusual ways by having lots of memory allocated but @@ -12,6 +21,7 @@ # clears memory at allocation time. PERMANENT_BLACKLIST_ALL_ASICS=\ "-KFDEventTest.MeasureInterruptConsumption:"\ +"$PM_TESTS:"\ "KFDLocalMemoryTest.Fragmentation:"\ "KFDQMTest.BasicCuMaskingLinear:"\ "RDMATest.GPUDirect:"\ @@ -24,15 +34,11 @@ PERMANENT_BLACKLIST_ALL_ASICS=\ # failures can be found # NOTE: If you update this alphabetical listing, add the corresponding JIRA ticket for reference # -# KFDPMTest.SuspendWith[ActiveProcess|IdleQueue|IdleQueueAfterWork] (KFD-326|327|328) # KFDPNPTest.DisableAndCreateQueue (KFD-329) # KFDQMTest.GPUDoorbellWrite fails intermittently (KFD-318) # KFDQMTest.mGPUShareBO (KFD-334) # KFDHWSTest.* (SWDEV-193035) TEMPORARY_BLACKLIST_ALL_ASICS=\ -"KFDPMTest.SuspendWithActiveProcess:"\ -"KFDPMTest.SuspendWithIdleQueue:"\ -"KFDPMTest.SuspendWithIdleQueueAfterWork:"\ "KFDPNPTest.DisableAndCreateQueue:"\ "KFDQMTest.GPUDoorbellWrite:"\ "KFDQMTest.mGPUShareBO:"\ diff --git a/tests/kfdtest/scripts/run_kfdtest.sh b/tests/kfdtest/scripts/run_kfdtest.sh index 9694b7415e..46f3ffaee1 100755 --- a/tests/kfdtest/scripts/run_kfdtest.sh +++ b/tests/kfdtest/scripts/run_kfdtest.sh @@ -51,7 +51,7 @@ printUsage() { echo echo "Gtest arguments will be forwarded to the app" echo - echo "Valid platform options: polaris10, vega10, vega20, all, and so on" + echo "Valid platform options: pm, core, polaris10, vega10, vega20, all, and so on" echo "'all' option runs all tests" return 0 @@ -76,6 +76,7 @@ getFilter() { arcturus ) FILTER="--gtest_filter=$ARCT_TESTS_BLACKLIST" ;; navi10 ) FILTER="--gtest_filter=$NAVI10_TESTS_BLACKLIST" ;; core ) FILTER="--gtest_filter=$CORE_TESTS" ;; + pm ) FILTER="--gtest_filter=$PM_TESTS" ;; all ) FILTER="" ;; *) die "Unsupported platform $platform. Exiting" ;; esac diff --git a/tests/kfdtest/src/LinuxOSWrapper.cpp b/tests/kfdtest/src/LinuxOSWrapper.cpp index fd1e7b8aeb..a8728944c1 100644 --- a/tests/kfdtest/src/LinuxOSWrapper.cpp +++ b/tests/kfdtest/src/LinuxOSWrapper.cpp @@ -87,8 +87,22 @@ HSAuint64 GetSystemTickCountInMicroSec() { } bool SuspendAndWakeUp() { - // TODO: Implement - return false; + printf("Please press any key after the system suspends....\n"); + + // Use "sudo apt install pm-utils" to install the "pm-suspend" + int ret = system("sudo pm-suspend"); + + if (ret == -1) { + printf("The system linux command could not be run!\n"); + return false; + } else { + if (WEXITSTATUS(ret)) { + printf("Use 'sudo apt install pm-utils' to install 'pm-suspend' on Ubuntu\n"); + return false; + } + } + + return true; } void AcquirePrivilege(OS_PRIVILEGE priv) {