[v2,1/3] gdb/testsuise: gdb.rocm/precise-memory.exp to not require hip_devices_support_precise_memory

Message ID 20250321144618.363628-2-lancelot.six@amd.com
State New
Headers
Series gdb/testsuite/gdb.rocm: refactor precise-memory detection |

Commit Message

Lancelot SIX March 21, 2025, 2:46 p.m. UTC
  The gdb.rocm/precise-memory.exp test adjusts its behaviour based on the
value returned by hip_devices_support_precise_memory.  This function has
static assumption regarding HW capabilities, which might not be
accurate.

Adjust the test so it does not assume anything about HW capabilities,
but instead just ensure that GDB behaves consistently.

Change-Id: Ie1f9c6219b88b94f6d461a254b2ad616b92db6b9
---
 gdb/testsuite/gdb.rocm/precise-memory.exp | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
  

Comments

Pedro Alves March 21, 2025, 4:09 p.m. UTC | #1
On 2025-03-21 14:46, Lancelot SIX wrote:
> +	    -re -wrap "warning: AMDGPU precise memory access reporting could not be enabled." {

Pedantically that . should be escaped, otherwise it's a wildcard that matches any character.  Like:

    -re -wrap "warning: AMDGPU precise memory access reporting could not be enabled\\." {

Pedro Alves
  

Patch

diff --git a/gdb/testsuite/gdb.rocm/precise-memory.exp b/gdb/testsuite/gdb.rocm/precise-memory.exp
index f423a11784c..732cbe3f2e7 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory.exp
+++ b/gdb/testsuite/gdb.rocm/precise-memory.exp
@@ -39,13 +39,16 @@  proc do_test { } {
 	    "AMDGPU precise memory access reporting is off \\(currently disabled\\)." \
 	    "show precise-memory setting in CLI before"
 
-	if {[hip_devices_support_precise_memory]} {
-	    gdb_test_no_output "set amdgpu precise-memory on"
-	    set cli_effective_value "enabled"
-	} else {
-	    gdb_test "set amdgpu precise-memory on" \
-		"warning: AMDGPU precise memory access reporting could not be enabled."
-	    set cli_effective_value "disabled"
+	# Assume precise-memory is available, unless GDB reports otherwise.
+	gdb_test_multiple "set amdgpu precise-memory on" "" {
+	    -re -wrap "warning: AMDGPU precise memory access reporting could not be enabled." {
+		set cli_effective_value "disabled"
+		pass $gdb_test_name
+	    }
+	    -re -wrap "^" {
+		set cli_effective_value "enabled"
+		pass $gdb_test_name
+	    }
 	}
 
 	gdb_test "show amdgpu precise-memory" \