From da9a404ac3ebbcebdce5bd46fbc7ce8ffc130f12 Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Sun, 22 Sep 2019 17:48:10 -0400 Subject: [PATCH] kfdtest: Add a function to wait indefinitely until user input This will facilitate the need of halting the execution during debugging. Change-Id: I058c81bbc9f655bbc477b2b542d6b43aa423324c Signed-off-by: Yong Zhao --- tests/kfdtest/src/KFDTestUtil.cpp | 8 ++++++++ tests/kfdtest/src/KFDTestUtil.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/tests/kfdtest/src/KFDTestUtil.cpp b/tests/kfdtest/src/KFDTestUtil.cpp index 991bea2e11..c949259439 100644 --- a/tests/kfdtest/src/KFDTestUtil.cpp +++ b/tests/kfdtest/src/KFDTestUtil.cpp @@ -30,6 +30,14 @@ #include "Dispatch.hpp" #include "SDMAPacket.hpp" +void WaitUntilInput() { + char dummy; + printf("Press enter to continue: "); + do { + scanf("%c", &dummy); + } while (dummy != 10); // enter key's ascii value is 10 +} + uint64_t RoundToPowerOf2(uint64_t val) { int bytes = sizeof(uint64_t); diff --git a/tests/kfdtest/src/KFDTestUtil.hpp b/tests/kfdtest/src/KFDTestUtil.hpp index 4cbaa395e7..7e2fe7e16d 100644 --- a/tests/kfdtest/src/KFDTestUtil.hpp +++ b/tests/kfdtest/src/KFDTestUtil.hpp @@ -35,6 +35,7 @@ class BaseQueue; #define ALIGN_UP(x, align) (((uint64_t)(x) + (align) - 1) & ~(uint64_t)((align)-1)) #define CounterToNanoSec(x) ((x) * 1000 / (is_dgpu() ? 27 : 100)) +void WaitUntilInput(); uint64_t RoundToPowerOf2(uint64_t val); // @brief: waits until the value is written to the buffer or until time out if received through args