This is the mail archive of the gdb-patches@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]

[PATCH] Make gdb.base/default.exp get the GDB version number from version.in


Commit

  7734102d6d8b ("Introduce new convenience variables $_gdb_major and $_gdb_minor")

introduced a test hardcoding the GDB version in gdb.base/default.exp, to
test the value of the new convenience variables.  This is not ideal,
because it's something more that will need to be changed at every
version bump.

This patch makes the test get the current GDB version from version.in.
I added a get_gdb_version proc in lib/gdb.exp in case some other test is
ever interested in getting the gdb version.

I have manually tested with different contents of version.in, such as
"8.3", "8.3.50" and the current, "8.3.50.DATE-git".

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (get_gdb_version): New proc.
	* gdb.base/default.exp: Test $_gdb_major and $gdb_minor against
	the version obtained from get_gdb_version.
---
 gdb/testsuite/gdb.base/default.exp |  7 +++++--
 gdb/testsuite/lib/gdb.exp          | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 9ff5144448d8..284193effd84 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -602,9 +602,12 @@ set show_conv_list \
 	{$_probe_arg10 = <error: No frame selected>} \
 	{$_probe_arg11 = <error: No frame selected>} \
 	{$_isvoid = <internal function _isvoid>} \
-	{$_gdb_major = 8} \
-	{$_gdb_minor = 4} \
     }
+
+lassign [get_gdb_version] gdb_version_major gdb_version_minor
+lappend show_conv_list "\$_gdb_major = $gdb_version_major"
+lappend show_conv_list "\$_gdb_minor = $gdb_version_minor"
+
 if ![skip_python_tests] {
     append show_conv_list \
 	{
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e3c6b2d6f5e5..83172fe2b754 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6353,5 +6353,31 @@ proc cd { dir } {
     builtin_cd $dir
 }
 
+# Read the version of GDB from the version.in file in the GDB source directory.
+#
+# Return a two-element list with the major and minor version components.
+#
+# If the third component of the GDB version is greater than 0, we increment
+# minor by 1.  For example, for version "8.3.50", we will return {8 4}.
+
+gdb_caching_proc get_gdb_version {
+  global srcdir
+
+  set version_file [open "$srcdir/../version.in" r]
+  set version_string [read $version_file]
+  close $version_file
+
+  # Remove trailing newline so that the last component doesn't include it.
+  set version_string [string trimright $version_string \n]
+
+  lassign [split $version_string .] major minor patch
+
+  if { $patch > 0 } {
+    incr minor
+  }
+
+  return [list $major $minor]
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
2.21.0


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