]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
cri-getconfig: Provide debugging for get_psql_cmd
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 25 Nov 2015 15:34:04 +0000 (15:34 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 8 Dec 2015 14:51:02 +0000 (14:51 +0000)
This allows us to execute only the first <some number> SQL
invocations.  The first non-executed one is dumped, instead, by having
get_psql_command print a rune involving ./mg-debug-fail (which the
caller will then execute).

The locking makes things work roughly-correctly if get_psql_cmd is run
in multiple processes at once: it is not defined exactly which
invocations get which counter values, but they will all work properly
and get exactly one counter value each.

If set -x is in force, turn it off for get_psql_cmd: our perl rune is
uninteresting to see repeated ad infinitum in debugging output.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
cri-getconfig

index 973f1c010c3b873bf6d6568ec3b804a721a458a8..7b75700e5e06a9f8e56811aa0ca2dbd6de8a5369 100644 (file)
@@ -41,6 +41,22 @@ getrepos() {
 }
 
 get_psql_cmd () {
+       # To use this:
+       #  on each test run, rm -f t.psql-counter
+       #  and set OSSTEST_PSQL_ONLY_DO to an integer
+       if [ "x$OSSTEST_PSQL_ONLY_DO" != x ]; then
+               local f=t.psql-counter
+               psql_counter=$( with-lock-ex -w $f.lock bash -ec '
+                       psql_counter=$(cat '$f' || echo 0)
+                       echo $(( $psql_counter + 1 )) >'$f'.tmp
+                       mv -f '$f'.tmp '$f'
+                       echo $psql_counter' )
+               if ! [ $psql_counter -lt $OSSTEST_PSQL_ONLY_DO ]; then
+                       printf './mg-debug-fail '
+               fi
+       fi
+
+       set +x
        perl -we '
        use Osstest;
        use Osstest::Executive;