dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: add --local_init and --global_init options to override use of sit


From: Jacob Bachmeyer
Subject: PATCH: add --local_init and --global_init options to override use of site.exp [reissued]
Date: Fri, 30 Nov 2018 16:10:27 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.22) Gecko/20090807 MultiZilla/1.8.3.4e SeaMonkey/1.1.17 Mnenhy/0.7.6.0

This is the previous --{loc,glob}al_init patch regenerated against current master HEAD. This version of the patch also adds 2018 to the copyright notices in runtest.exp and runtest.1, but there does not seem to be a copyright/permission notice in dejagnu.texi. Did I miss it or is it missing?

ChangeLog entries:
----
        * doc/dejagnu.texi (Invoking runtest): Document new --local_init
        and --global_init command line options.
        * doc/runtest.1: Document same new command line options.

        * runtest.exp: Remove useless tests before setting default values
        for variables: all_flag, binpath, debug, options, outdir, reboot,
        tracelevel, verbose, log_dialog.  They are set before loading any
        files or parsing the command line.

        * runtest.exp: Add options --local_init and --global_init for
        selecting alternate testsuite configuration files.

        * runtest.exp: Split variable "configfile" into "local_init_file"
        and "global_init_file" in preparation for adding command-line
        options to specify these independently.  Defaults:  site.exp

        * runtest.exp (load_generic_config): Remove unused global variable.
        (load_board_description): Remove unused global variable.
        (load_base_board_description): Remove unused global variable.
----

patch:
----
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index 85a1730..0700182 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -554,6 +554,14 @@ output of the tool with the scripted patterns describing 
expected
output.  The output generated with @code{--strace} also goes into
@file{dbg.log}.

address@hidden @code{--global_init [name]}
+Use @emph{name} as the global init file instead of @file{site.exp} in
address@hidden  The default is, of course, @file{site.exp}.  Note that
+this option accepts a relative file name, interpreted starting at
address@hidden, so a file in a subdirectory may be used.  This is
+probably less useful for most sites, but is orthogonal with the
address@hidden option and may be useful in large testing labs.
+
@item @code{--help}
Prints out a short summary of the @emph{runtest} options, then exits
(even if you specify other options).
@@ -578,6 +586,12 @@ The host board to use.
@item @code{--ignore [name(s)] }
The name(s) of specific tests to ignore.

address@hidden @code{--local_init [name]}
+Use @emph{name} as the testsuite local init file instead of
address@hidden in the current directory and in @emph{objdir}.  The
+default is, of course, @file{site.exp}.  Note that this option accepts a
+relative file name, so a file in a subdirectory may be used.
+
@item @code{--log_dialog}
Emit Expect output to stdout.  The Expect output is usually only written
to the @file{.log} file. By enabling this option, they are also printed
@@ -1354,6 +1368,17 @@ table describes the correspondence between command line 
options and
variables you can set in @file{site.exp}.  @ref{Invoking runtest}, for
explanations of the command-line options.

+The @code{--local_init} and @code{--global_init} options have
+associated Tcl variables, but they influence the search for
+configuration files and overriding them is unlikely to be useful
+because they are not used after the configuration files are loaded.
+Once the configuration file is opened, it is too late for a change to
+these variables to be effective.  However, the local init file name is
+used twice, once relative to @code{base_dir} (the directory in which
+runtest was started) and once relative to @code{objdir}.  While
+testsuites should not make assumptions about what global init files
+are available, the user could usefully write such a setting.
+
@multitable @columnfractions 0.2 0.2 0.6
@item
@address@hidden @strong{Tcl address@hidden @strong{Description}
@@ -1368,6 +1393,9 @@ explanations of the command-line options.
address@hidden address@hidden run only tests in the specified directory

@item
address@hidden address@hidden file name for global init file in @code{libdir}
+
address@hidden
address@hidden address@hidden system triplet for the host

@item
@@ -1377,6 +1405,9 @@ explanations of the command-line options.
address@hidden ignoretests @tab do not run the specified tests

@item
address@hidden address@hidden file name for local init file in @code{objdir}
+
address@hidden
address@hidden address@hidden emit Expect output to standard output

@item
@@ -5227,3 +5258,5 @@ This makes runtest exit. It is abbreviated as @emph{q}.
@end table

@bye
+
address@hidden  LocalWords:  subdirectory
diff --git a/doc/runtest.1 b/doc/runtest.1
index 5b70d35..39ebf4a 100644
--- a/doc/runtest.1
+++ b/doc/runtest.1
@@ -1,4 +1,4 @@
-.TH runtest 1 "2017-10-16"
+.TH runtest 1 "2018-11-18"
.SH NAME
runtest \- DejaGnu test driver
.SH SYNOPSIS
@@ -29,6 +29,10 @@ internal debugging output. The output is logged to a file 
called
.BI --directory \ DIRECTORY
Run only tests in the specified DIRECTORY.
.TP
+.BI --global_init \ NAME
+The NAME to use for the global init file in libdir.
+The default is "site.exp" if this option is not given.
+.TP
.B --help
Prints a usage message and then exits.
.TP
@@ -41,6 +45,11 @@ The host board definition to use.
.BI --ignore \ test1.exp\ test2.exp\ ...
Do not run the specified tests.
.TP
+.BI --local_init \ NAME
+The NAME to use for the testsuite local init file in both the current
+directory and objdir.
+The default is "site.exp" if this option is not given.
+.TP
.B --log_dialog
Emit Expect output to standard output.
.TP
@@ -125,7 +134,7 @@ Rob Savoye (address@hidden)
.SH "REPORTING BUGS"
Report bugs to <address@hidden>.
.SH COPYRIGHT
-Copyright \(co 2005\-2016 Free Software Foundation, Inc.
+Copyright \(co 2005\-2016, 2018 Free Software Foundation, Inc.
.PP
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
diff --git a/runtest.exp b/runtest.exp
index be9f0e5..c7a6f26 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -1,5 +1,5 @@
# runtest.exp -- Test framework driver
-# Copyright (C) 1992-2016 Free Software Foundation, Inc.
+# Copyright (C) 1992-2016, 2018 Free Software Foundation, Inc.
#
# This file is part of DejaGnu.
#
@@ -63,7 +63,6 @@ set srcdir      "."         ;# source directory containing 
the test suite
set ignoretests ""            ;# list of tests to not execute
set objdir      "."           ;# directory where test case binaries live
set reboot      0
-set configfile  site.exp       ;# (local to this file)
set multipass   ""            ;# list of passes and var settings
set errno       "";           ;#
set exit_error  1               ;# Toggle for whether to set the exit status
@@ -86,6 +85,12 @@ set target_cpu     ""              ;# type of the cpu tests 
are running on
set target_alias   ""         ;# standard abbreviation of target
set compiler_flags ""         ;# the flags used by the compiler

+#
+# These set configuration file names and are local to this file.
+#
+set local_init_file    site.exp        ;# testsuite-local init file name
+set global_init_file   site.exp        ;# global init file name
+
# Various ccache versions provide incorrect debug info such as ignoring
# different current directory, breaking GDB testsuite.
set env(CCACHE_DISABLE) 1
@@ -107,37 +112,18 @@ if {![info exists decimal]} {
set base_dir [pwd]

#
-# These are tested in case they are not initialized in $configfile. They are
-# tested here instead of the init module so they can be overridden by command
-# line options.
+# These are set here instead of the init module so they can be overridden
+# by command line options.
#
-if {![info exists all_flag]} {
-    set all_flag 0
-}
-if {![info exists binpath]} {
-    set binpath ""
-}
-if {![info exists debug]} {
-    set debug 0
-}
-if {![info exists options]} {
-    set options ""
-}
-if {![info exists outdir]} {
-    set outdir "."
-}
-if {![info exists reboot]} {
-    set reboot 1
-}
-if {![info exists tracelevel]} {
-    set tracelevel 0
-}
-if {![info exists verbose]} {
-    set verbose 0
-}
-if {![info exists log_dialog]} {
-    set log_dialog 0
-}
+set all_flag   0
+set binpath    ""
+set debug      0
+set options    ""
+set outdir     "."
+set reboot     1
+set tracelevel 0
+set verbose    0
+set log_dialog 0

#
# verbose [-n] [-log] [--] message [level]
@@ -378,10 +364,12 @@ proc usage { } {
    send_user "\t--build \[triplet\]\tThe canonical triplet of the build 
machine\n"
    send_user "\t--debug\t\t\tSet expect debugging ON\n"
    send_user "\t--directory name\tRun only the tests in directory 'name'\n"
+    send_user "\t--global_init \[name\]\tThe file to load for global 
configuration\n"
    send_user "\t--help\t\t\tPrint help text\n"
    send_user "\t--host \[triplet\]\tThe canonical triplet of the host 
machine\n"
    send_user "\t--host_board \[name\]\tThe host board to use\n"
    send_user "\t--ignore \[name(s)\]\tThe names of specific tests to ignore\n"
+    send_user "\t--local_init \[name\]\tThe file to load for local 
configuration\n"
    send_user "\t--log_dialog\t\t\Emit Expect output on stdout\n"
    send_user "\t--mail \[name(s)\]\tWhom to mail the results to\n"
    send_user "\t--objdir \[name\]\t\tThe test suite binary directory\n"
@@ -412,9 +400,9 @@ proc usage { } {
# parse them twice.  Things are complicated because:
# - we want to parse --verbose early on
# - we don't want config files to override command line arguments
-#   (eg: $base_dir/$configfile vs --host/--target)
+#   (eg: $base_dir/$local_init_file vs --host/--target)
# - we need some command line arguments before we can process some config files
-#   (eg: --objdir before $objdir/$configfile, --host/--target before $DEJAGNU)
+#   (eg: --objdir before $objdir/$local_init_file, --host/--target before 
$DEJAGNU)
# The use of `arg_host_triplet' and `arg_target_triplet' lets us avoid parsing
# the arguments three times.
#
@@ -441,8 +429,10 @@ for { set i 0 } { $i < $argc } { incr i } {
            regexp {^[^=]*=(.*)$} $option nil optarg
        }
        "--bu*" -
+       "--g*" -
        "--ho*" -
        "--ig*"  -
+       "--loc*" -
        "--m*"  -
        "--n*"  -
        "--ob*" -
@@ -463,6 +453,11 @@ for { set i 0 } { $i < $argc } { incr i } {
            continue
        }

+       "--g*" {                      # (--global_init) the global init file 
name
+           set global_init_file $optarg
+           continue
+       }
+
        "--host_bo*" {
            set host_board $optarg
            continue
@@ -473,6 +468,11 @@ for { set i 0 } { $i < $argc } { incr i } {
            continue
        }

+       "--loc*" {                    # (--local_init) the local init file name
+           set local_init_file $optarg
+           continue
+       }
+
        "--ob*" {                     # (--objdir) where the test case object 
code lives
            set objdir $optarg
            continue
@@ -611,25 +611,26 @@ verbose "Login name is $logname"
# All are sourced in order.
#
# Search order:
-#      $base_dir/$configfile -> $objdir/$configfile ->
-#      installed -> $DEJAGNU -> $HOME/.dejagnurc
+#    (local)   $base_dir/$local_init_file -> $objdir/$local_init_file ->
+#    (global)  installed($global_init_file) -> $DEJAGNU -> $HOME/.dejagnurc
#
-# For the normal case, we rely on $base_dir/$configfile to set
+# For the normal case, we expect $base_dir/$local_init_file to set
# host_triplet and target_triplet.
#

-load_file $base_dir/$configfile
+load_file [file join $base_dir $local_init_file]

#
-# If objdir didn't get set in $base_dir/$configfile, set it to $base_dir.
-# Make sure we source $objdir/$configfile in case $base_dir/$configfile doesn't
-# exist and objdir was given on the command line.
+# If objdir didn't get set in $base_dir/$local_init_file, set it to
+# $base_dir.  Make sure we source $objdir/$local_init_file in case
+# $base_dir/$local_init_file doesn't exist and objdir was given on the
+# command line.
#

if {[expr {[string match "." $objdir] || [string match $srcdir $objdir]}]} {
    set objdir $base_dir
} else {
-    load_file $objdir/$configfile
+    load_file [file join $objdir $local_init_file]
}

# Well, this just demonstrates the real problem...
@@ -853,7 +854,7 @@ proc setup_build_hook { name } {
# These files assume the host and target have been set.
#

-if { [load_file -- $libdir/$configfile] == 0 } {
+if { [load_file -- [file join $libdir $global_init_file]] == 0 } {
    # If $DEJAGNU isn't set either then there isn't any global config file.
    # Warn the user as there really should be one.
    if { ! [info exists env(DEJAGNU)] } {
@@ -997,8 +998,10 @@ for { set i 0 } { $i < $argc } { incr i } {
            regexp {^[^=]*=(.*)$} $option nil optarg
        }
        "--bu*" -
+       "--g*" -
        "--ho*" -
        "--ig*"  -
+       "--loc*" -
        "--m*"  -
        "--n*"  -
        "--ob*" -
@@ -1027,6 +1030,16 @@ for { set i 0 } { $i < $argc } { incr i } {
            continue
        }

+       "--g*" {                      # (--global_init) the global init file 
name
+           # Already parsed (and no longer useful).  The file has been loaded.
+           continue
+       }
+
+       "--loc*" {                    # (--local_init) the local init file name
+           # Already parsed (and no longer useful).  The file has been loaded.
+           continue
+       }
+
        "--bu*" {                     # (--build) the build host configuration
            # Already parsed (and don't set again).  Let $DEJAGNU rename it.
            continue
@@ -1247,7 +1260,6 @@ clone_output "\n\t\t=== $tool tests ===\n"

proc load_generic_config { name } {
    global srcdir
-    global configfile
    global libdir
    global env
    global board
@@ -1323,7 +1335,6 @@ proc load_tool_target_config { name } {

proc load_board_description { board_name args } {
    global srcdir
-    global configfile
    global libdir
    global env
    global board
@@ -1392,7 +1403,6 @@ proc load_board_description { board_name args } {

proc load_base_board_description { board_name } {
    global srcdir
-    global configfile
    global libdir
    global env
    global board
----


-- Jacob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]