integer*4, dimension (:) :: lb
   integer*4, dimension (:) :: ub
 
-  print *, ""
-  print *, "Expected GDB Output:"
-  print *, ""
-
-  write(*, fmt="(A)", advance="no") "LBOUND = ("
-  do i=LBOUND (lb, 1), UBOUND (lb, 1), 1
-     if (i > LBOUND (lb, 1)) then
-        write(*, fmt="(A)", advance="no") ", "
-     end if
-     write(*, fmt="(I0)", advance="no") lb (i)
-  end do
-  write(*, fmt="(A)", advance="yes") ")"
-
-  write(*, fmt="(A)", advance="no") "UBOUND = ("
-  do i=LBOUND (ub, 1), UBOUND (ub, 1), 1
-     if (i > LBOUND (ub, 1)) then
-        write(*, fmt="(A)", advance="no") ", "
-     end if
-     write(*, fmt="(I0)", advance="no") ub (i)
-  end do
-  write(*, fmt="(A)", advance="yes") ")"
-
   print *, ""  ! Test Breakpoint
 end subroutine do_test
 
 
 
 require allow_fortran_tests
 
-# This test relies on output from the inferior.
-require {!target_info exists gdb,noinferiorio}
-
 standard_testfile ".F90"
 load_lib fortran.exp
 
        set expected_ubound ""
        set found_prompt false
        gdb_test_multiple "continue" "continue" {
-           -i $::inferior_spawn_id
-
-           -re ".*LBOUND = (\[^\r\n\]+)\r\n" {
-               set expected_lbound $expect_out(1,string)
-               if {!$found_prompt} {
-                   exp_continue
-               }
-           }
-           -re ".*UBOUND = (\[^\r\n\]+)\r\n" {
-               set expected_ubound $expect_out(1,string)
-               if {!$found_prompt} {
-                   exp_continue
-               }
+           -re -wrap "! Test Breakpoint.*" {
+               # We stopped at the next test case.
+               pass $gdb_test_name
            }
 
-           -i $::gdb_spawn_id
-
-           -re "! Test Breakpoint" {
-               set func_name "show_elem"
-               exp_continue
-           }
-           -re "! Breakpoint before deallocate" {
+           -re -wrap "! Breakpoint before deallocate.*" {
+               # There are no more test cases.
+               pass $gdb_test_name
                set found_dealloc_breakpoint true
-               exp_continue
-           }
-           -re "$gdb_prompt $" {
-               set found_prompt true
-
-               if {$found_dealloc_breakpoint
-                   || ($expected_lbound != "" && $expected_ubound != "")} {
-                   # We're done.
-               } else {
-                   exp_continue
-               }
            }
        }
 
            break
        }
 
+       set expected_lbound [get_valueof "" "lb" "" "get expected lbound"]
+       set expected_ubound [get_valueof "" "ub" "" "get expected ubound"]
+
+       if { $expected_lbound == "" } {
+           error "failed to extract expected results for lbound"
+       }
+
+       if { $expected_ubound == "" } {
+           error "failed to extract expected results for ubound"
+       }
+
        verbose -log "APB: Run a test here"
        verbose -log "APB: Expected lbound '$expected_lbound'"
        verbose -log "APB: Expected ubound '$expected_ubound'"
            }
        }
 
-       # Check we have all the information we need to successfully run one
-       # of these tests.
-       if { $expected_lbound == "" } {
-           perror "failed to extract expected results for lbound"
-           return 0
-       }
-       if { $expected_ubound == "" } {
-           perror "failed to extract expected results for ubound"
-           return 0
-       }
        if { $array_name == "" } {
-           perror "failed to extract array name"
-           return 0
+           error "failed to extract array name"
        }
 
        # Check GDB can correctly print complete set of upper and