[icinga-checkins] icinga.org: icinga-core/dev/cgis: Add run_cmd to Test.pm

git at icinga.org git at icinga.org
Sat Feb 25 15:43:48 CET 2012


Module: icinga-core
Branch: dev/cgis
Commit: ffbadfd34fa495290b1eb4e138075a0fc14b9730
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=ffbadfd34fa495290b1eb4e138075a0fc14b9730

Author: Alexander Wirt <formorer at debian.org>
Date:   Sat Feb 25 10:45:15 2012 +0100

Add run_cmd to Test.pm

---

 t/Icinga/Test.pm |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/t/Icinga/Test.pm b/t/Icinga/Test.pm
index 44dc96c..e1d7470 100644
--- a/t/Icinga/Test.pm
+++ b/t/Icinga/Test.pm
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 
 use Exporter 'import';
-our @EXPORT_OK = qw( run_cgi get_body );
+our @EXPORT_OK = qw( run_cgi get_body run_cmd );
 
 use IPC::Run3 qw( run3 );
 
@@ -34,6 +34,16 @@ sub run_cgi ($$$$) {
     return $out;
 }
 
+sub run_cmd (@) {
+    my $cmd = shift;
+
+    my ($in, $out, $err) = '';
+    print STDERR "\nDEBUG: execute '". join(" ", @$cmd) . "'\n", if $DEBUG;
+    run3 ($cmd, \$in, \$out, \$err) or die "cat: $? - $! - $err";
+    print STDERR "\nError executing $cmd: \n $err\n" if $err;
+    return $out;
+}
+
 sub get_body ($) {
     my $output = shift;
     # remove cr from output





More information about the icinga-checkins mailing list