This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Ensure deterministic result order in gdb.ada/info_auto_lang.exp


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=161d081c56f12e7a00d8a07ccac445855d5d357b

commit 161d081c56f12e7a00d8a07ccac445855d5d357b
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Sat Dec 1 14:10:10 2018 +0100

    Ensure deterministic result order in gdb.ada/info_auto_lang.exp
    
    standard_ada_testfile, standard_test_file and the explicit
    csrcfile assignment in info_auto_lang.exp all gives similar pathnames
    prefix for a source, such as
    /home/philippe/gdb/git/build_binutils-gdb/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.<something>.
    
    Note that the above pathnames contain ../ which appears when a relative
    pathname is used to call configure.
    
    In any case, the gnat compiler normalizes Ada sources path when compiling.
    So, the 'Ada' .o object are referencing a pathname such as
    /home/philippe/gdb/git/binutils-gdb/gdb/testsuite/gdb.ada/info_auto_lang/proc_in_ada.adb,
    while the 'C' .o object still references the not normalized pathname.
    
    As the results of 'info functions | ...' are sorted by pathname first,
    the order of the results depends on the comparison between different directories,
    leading to results that can change depending on these directories.
    
    => Ensure the result order is always the same, by normalising the C source file,
    which makes the results independent of the way configure is launched.
    
    Tested by running the testcase in 2 different builds, that without normalize
    were giving different results.
    
    Note: such 'set csrcfile' is used in 4 other tests mixing Ada and C.
    After discussion, it was deemed sufficient to just normalize the pathname
    for this test.
    
    gdb/testsuite/ChangeLog
    2018-12-20  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
    
    	* gdb.ada/info_auto_lang.exp: Normalize some_c source file.
    	Update order of results accordingly.

Diff:
---
 gdb/testsuite/ChangeLog                  |  5 +++++
 gdb/testsuite/gdb.ada/info_auto_lang.exp | 38 ++++++++++++++++++--------------
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ab3a74f..c499d62 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-20  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+	* gdb.ada/info_auto_lang.exp: Normalize some_c source file.
+	Update order of results accordingly.
+
 2018-12-12  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* gdb.base/annota1.exp: Update a test regexp.
diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp
index 4ba79ff..31d7062 100644
--- a/gdb/testsuite/gdb.ada/info_auto_lang.exp
+++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp
@@ -24,7 +24,11 @@ load_lib "ada.exp"
 
 standard_ada_testfile proc_in_ada
 set cfile "some_c"
-set csrcfile ${srcdir}/${subdir}/${testdir}/${cfile}.c
+# gnat normalizes proc_in_ada source file when compiling.
+# As the 'info' commands results are sorted by absolute path names, also normalize
+# the some_c source file to ensure that the 'info' results are always
+# giving Ada results first.
+set csrcfile [file normalize ${srcdir}/${subdir}/${testdir}/${cfile}.c]
 set cobject [standard_output_file ${cfile}.o]
 
 if { [gdb_compile "${csrcfile}" "${cobject}" object [list debug]] != "" } {
@@ -111,41 +115,41 @@ foreach_with_prefix language_choice { "auto" "ada" "c" } {
 		[multi_line \
 		     "All functions matching regular expression \"proc_in_\":" \
 		     "" \
-		     "File .*some_c.c:" \
-		     $func_in_c($c_match) \
-		     "" \
 		     "File .*proc_in_ada.adb:" \
-		     $func_in_ada($ada_match)
+		     $func_in_ada($ada_match) \
+		     "" \
+		     "File .*some_c.c:" \
+		     $func_in_c($c_match)
 		]
 
 	    gdb_test "info types some_type" \
 		[multi_line \
-		     "All types matching regular expression \"some_type\":" \
-		     "" \
-		     "File .*some_c.c:" \
-		     $type_in_c($c_match) \
+		     "All types matching regular expression \"some_type\":"  \
 		     "" \
 		     "File .*global_pack.ads:" \
-		     $type_in_ada($ada_match)
+		     $type_in_ada($ada_match)\
+		     "" \
+		     "File .*some_c.c:" \
+		     $type_in_c($c_match)
 		]
 
 	    gdb_test "info variables some_struct" \
 		[multi_line \
 		     "All variables matching regular expression \"some_struct\":" \
 		     "" \
-		     "File .*some_c.c:" \
-		     $var_in_c($c_match) \
-		     "" \
 		     "File .*global_pack.ads:" \
-		     $var_in_ada($ada_match)
+		     $var_in_ada($ada_match) \
+		     "" \
+		     "File .*some_c.c:" \
+		     $var_in_c($c_match)
 		]
 
 	    gdb_test "rbreak proc_in_" \
 		[multi_line \
-		     "Breakpoint.*file .*some_c.c,.*" \
-		     $rbreak_func_in_c($c_match) \
 		     "Breakpoint.*file .*proc_in_ada.adb,.*" \
-		     $rbreak_func_in_ada($ada_match)
+		     $rbreak_func_in_ada($ada_match) \
+		     "Breakpoint.*file .*some_c.c,.*" \
+		     $rbreak_func_in_c($c_match)
 		]
 	    delete_breakpoints
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]