* [PATCH OSSTEST v2 1/2] tcl: Handle environment variables which are unset.
2015-03-31 15:06 [PATCH OSSTEST v2 0/2] standalone: Add --dry-run option for run-job Ian Campbell
@ 2015-03-31 15:06 ` Ian Campbell
2015-03-31 16:42 ` Ian Jackson
2015-03-31 15:06 ` [PATCH OSSTEST v2 2/2] standalone: Add --dry-run option for run-job Ian Campbell
1 sibling, 1 reply; 5+ messages in thread
From: Ian Campbell @ 2015-03-31 15:06 UTC (permalink / raw)
To: ian.jackson; +Cc: Ian Campbell, xen-devel
This allows wrappers such as the standalone wrapper to do
OSSTEST_SIMULATE=$foo ./sg-run-job
and not worry if $foo is unset.
Do likewise for OSSTEST_TCL_JOBDB_DEBUG.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
v2:
- Was: "sg-run-job: Only consider $OSSTEST_SIMULATE > 0"
- Insert before "standalone: Add --dry-run option for run-job."
- Use var-or-default from Ian J
---
sg-run-job | 2 +-
tcl/JobDB-Executive.tcl | 2 +-
tcl/osstestlib.tcl | 6 ++++++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/sg-run-job b/sg-run-job
index 0ec314f..eae159d 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -159,7 +159,7 @@ proc spawn-ts {iffail testid args} {
jobdb::spawn-step-commit $flight $jobinfo(job) $stepno $testid
set xprefix {}
- if {[info exists env(OSSTEST_SIMULATE)]} { set xprefix echo }
+ if {[var-or-default env(OSSTEST_SIMULATE) 0]} { set xprefix echo }
set log [jobdb::step-log-filename $flight $jobinfo(job) $stepno $ts]
set redirects {< /dev/null}
diff --git a/tcl/JobDB-Executive.tcl b/tcl/JobDB-Executive.tcl
index 430ea84..7228712 100644
--- a/tcl/JobDB-Executive.tcl
+++ b/tcl/JobDB-Executive.tcl
@@ -117,7 +117,7 @@ proc db-update-1 {stmt} {
}
proc db-execute-debug {stmt} {
- if {[info exists env(OSSTEST_TCL_JOBDB_DEBUG)]} {
+ if {[var-or-default env(OSSTEST_TCL_JOBDB_DEBUG) 0]} {
puts stderr "EXECUTING >$stmt<"
}
}
diff --git a/tcl/osstestlib.tcl b/tcl/osstestlib.tcl
index a0413c4..61a6a09 100644
--- a/tcl/osstestlib.tcl
+++ b/tcl/osstestlib.tcl
@@ -74,3 +74,9 @@ proc lshift {listvar} {
set list [lrange $list 1 end]
return $head
}
+
+proc var-or-default {varname {default {}}} {
+ upvar 1 $varname var
+ if {[info exists var]} { return $var }
+ return $default
+}
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH OSSTEST v2 2/2] standalone: Add --dry-run option for run-job.
2015-03-31 15:06 [PATCH OSSTEST v2 0/2] standalone: Add --dry-run option for run-job Ian Campbell
2015-03-31 15:06 ` [PATCH OSSTEST v2 1/2] tcl: Handle environment variables which are unset Ian Campbell
@ 2015-03-31 15:06 ` Ian Campbell
1 sibling, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2015-03-31 15:06 UTC (permalink / raw)
To: ian.jackson; +Cc: Ian Campbell, xen-devel
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
standalone | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/standalone b/standalone
index caf3fd5..d8113e4 100755
--- a/standalone
+++ b/standalone
@@ -17,7 +17,7 @@ Operations:
Setup dist path runvars for JOB from existing build results. Useful
after recreating a flight to avoid the need to rebuild.
-* run-job [cfhrR] [JOB]
+* run-job [cfhrRs] [JOB]
Run the named JOB.
@@ -42,6 +42,7 @@ Options:
-h HOST, --host=HOST Test host
-r, --reuse Do not wipe test host (default)
-R, --noreuse, --noreinstall Wipe the test host (if job or test does so)
+-s, --simulate, --dry-run Dry run, printing what would be run
--lvextendmax=GB Limit the size of the build logical volume
--baseline Create a baseline flight instead of a tip flight
@@ -63,7 +64,7 @@ if [ x$op = x--help ] ; then
exit 0
fi
-TEMP=$(getopt -o c:f:h:rR --long config:,flight:,host:,reuse,noreuse,reinstall,lvextendmax:,baseline,help -- "$@")
+TEMP=$(getopt -o c:f:h:rRs --long config:,flight:,host:,reuse,noreuse,reinstall,simulate,dry-run,lvextendmax:,baseline,help -- "$@")
eval set -- "$TEMP"
@@ -71,6 +72,7 @@ config=${OSSTEST_CONFIG-$HOME/.xen-osstest/config}
flight="standalone"
host=
reuse=1 # Don't blow away machines by default
+dryrun=0
lvextendmax=50 # Leave some LVM space free for running tests
nobaseline=y
@@ -81,6 +83,7 @@ while true ; do
-h|--host) host=$2; shift 2;;
-r|--reuse) reuse=1; shift 1;;
-R|--noreuse|--reinstall)reuse=0;shift 1;;
+ -s|--simulate|--dry-run)dryrun=1;shift 1;;
--lvextendmax)lvextendmax=$2; shift 2;;
--baseline)nobaseline=n; shift 1;;
--help) usage; exit 0;;
@@ -241,6 +244,7 @@ case $op in
OSSTEST_FLIGHT=$flight \
OSSTEST_HOST_HOST=$host \
OSSTEST_HOST_REUSE=$reuse \
+ OSSTEST_SIMULATE=$dryrun \
with_logging logs/$flight/$job.log ./sg-run-job $job
;;
run-test)
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread