]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
Osstest.pm: Provide new db_prepare helper with built-in debugging
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 29 May 2015 13:19:39 +0000 (13:19 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 18 Jun 2015 15:30:41 +0000 (16:30 +0100)
No callers, so no functional change, as yet.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Suppress "used only once" warning

Osstest.pm

index e8bd77bf3a02dd52257b0c5f1d8188e75c0b8ac9..89486669015c8df2a3e085c05e7b3287a6b30687 100644 (file)
@@ -35,7 +35,7 @@ BEGIN {
                       getmethod
                       postfork
                       $dbh_tests db_retry db_retry_retry db_retry_abort
-                      db_begin_work
+                      db_begin_work db_prepare
                       ensuredir get_filecontents_core_quiet system_checked
                       nonempty visible_undef show_abs_time
                       );
@@ -49,6 +49,10 @@ our $mjobdb;
 
 our $dbh_tests;
 
+scalar *main::DEBUG;
+# declaration prevents `Name "main::DEBUG" used only once'
+# scalar prevents `useless use of a variable in void context'
+
 #---------- static default config settings ----------
 
 our %c = qw(
@@ -268,6 +272,13 @@ sub db_retry ($$$;$$) {
     return $r;
 }
 
+sub db_prepare ($) {
+    # caller must ensure global filehandle DEBUG is open
+    my ($stmt) = @_;
+    print ::DEBUG "DB PREPARING:\n$stmt\n";
+    return $dbh_tests->prepare($stmt);
+}
+
 sub postfork () {
     $mjobdb->jobdb_postfork();
 }