[committed][gdb/testsuite] Make inline-locals.c deterministic

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[committed][gdb/testsuite] Make inline-locals.c deterministic

Tom de Vries
Hi,

When running testcase gdb.opt/inline-locals.exp on openSUSE Tumbleweed, I get:
...
(gdb) info locals^M
array = {0 <repeats 48 times>, 15775231, 0, 194, 0, -11497, 32767, 4199061, \
  0, 0, 0, 0, 0, 4198992, 0, 4198432, 0}^M
(gdb) FAIL: gdb.opt/inline-locals.exp: info locals above bar 2
...

Fix this by:
- completely initializing array before printing any value
- updating the pattern to match "array = {0 <repeats 64 times>}"

Tested on x86_64-linux.

Committed to trunk.

Thanks,
- Tom

[gdb/testsuite] Make inline-locals.c deterministic

gdb/testsuite/ChangeLog:

2020-07-21  Tom de Vries  <[hidden email]>

        * gdb.opt/inline-locals.c (init_array): New func.
        (func1): Use init_array.
        * gdb.opt/inline-locals.exp: Update pattern.

---
 gdb/testsuite/gdb.opt/inline-locals.c   | 9 +++++++++
 gdb/testsuite/gdb.opt/inline-locals.exp | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.opt/inline-locals.c b/gdb/testsuite/gdb.opt/inline-locals.c
index 8fb91946fa..143a09ebc1 100644
--- a/gdb/testsuite/gdb.opt/inline-locals.c
+++ b/gdb/testsuite/gdb.opt/inline-locals.c
@@ -29,9 +29,18 @@ volatile int *array_p;
 
 void bar(void);
 
+void
+init_array (int *array, int n)
+{
+  int i;
+  for (i = 0; i < n; ++i)
+    array[i] = 0;
+}
+
 inline ATTR int func1(int arg1)
 {
   int array[64];
+  init_array (array, 64);
   array_p = array;
   array[0] = result;
   array[1] = arg1;
diff --git a/gdb/testsuite/gdb.opt/inline-locals.exp b/gdb/testsuite/gdb.opt/inline-locals.exp
index 8104b0f5b7..841f177209 100644
--- a/gdb/testsuite/gdb.opt/inline-locals.exp
+++ b/gdb/testsuite/gdb.opt/inline-locals.exp
@@ -43,7 +43,7 @@ if { ! $no_frames } {
  "backtrace from bar 2"
     gdb_test "up" "#1  .*func1 .* at .*" "up from bar 2"
     gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 2"
-    set pass_re "array = {$decimal, \[^\r\n\]*}"
+    set pass_re "array = \\{0 <repeats 64 times>\\}"
     set kfail_re [multi_line $pass_re \
       "array = {<optimized out> <repeats 64 times>}"]
     gdb_test_multiple "info locals" "info locals above bar 2" {