From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [OSSTEST PATCH 07/16] cri-getconfig: Provide debugging for get_psql_cmd Date: Mon, 7 Dec 2015 17:27:25 +0000 Message-ID: <1449509254-27007-8-git-send-email-ian.jackson@eu.citrix.com> References: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a5zZi-00088Q-QR for xen-devel@lists.xenproject.org; Mon, 07 Dec 2015 17:27:46 +0000 In-Reply-To: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org This allows us to execute only the first 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 Acked-by: Ian Campbell --- cri-getconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cri-getconfig b/cri-getconfig index 973f1c0..7b75700 100644 --- a/cri-getconfig +++ b/cri-getconfig @@ -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; -- 1.7.10.4