Commit 21e32adf authored by Kevin Tew's avatar Kevin Tew

testsuite/testswap cmdsuccess_stdin

parent 9e0ac444
......@@ -23,13 +23,13 @@ sub instance {
}
sub wrapped_ssh {
my ($invocant, $user, $cmd, $checker, $diemessage) = @_;
my ($invocant, $user, $cmd, $checker, $diemessage, $stdin) = @_;
my $ssh;
if (ref $invocant) { $ssh = $invocant }
else {
$ssh = Tools::TBSSH->new('host' => $invocant, 'user' => $user);
}
my @results = $ssh->cmd($cmd);
my @results = $ssh->cmd($cmd, $stdin);
if ($TBConfig::DEBUG_XML_CLIENT) {
$ssh->saydebug($cmd);
sayd @results;
......@@ -64,6 +64,11 @@ sub cmdsuccess {
return wrapped_ssh($host, $TBConfig::EMULAB_USER, $cmd, sub { $_[2] == 0; }, $diemessage);
}
sub cmdsuccess_stdin {
my ($host, $cmd, $stdin, $diemessage) = @_;
return wrapped_ssh($host, $TBConfig::EMULAB_USER, $cmd, sub { $_[2] == 0; }, $diemessage, $stdin);
}
sub cmdoutput {
my ($host, $cmd, $diemessage) = @_;
my @results = wrapped_ssh($host, $TBConfig::EMULAB_USER, $cmd, sub { $_[2] == 0; }, $diemessage );
......
......@@ -10,13 +10,13 @@ has 'host' => ( isa => 'Str', is => 'rw');
has 'user' => ( isa => 'Str', is => 'rw');
sub cmd {
my ($ssh, $cmd) = @_;
my ($ssh, $cmd, $stdin) = @_;
my $out;
my $err;
my $host = $ssh->host;
my $user = $ssh->user;
my $sshcmd = "ssh -x -o BatchMode=yes -o StrictHostKeyChecking=no $user\@$host $cmd";
run3($sshcmd, undef, \$out, \$err);
run3($sshcmd, \$stdin, \$out, \$err);
my $rc = $? >> 8;
($out, $err, $rc);
}
......
......@@ -4,7 +4,7 @@ use TBConfig;
use Tools;
use Tools::TBSSH;
use Data::Dumper;
use Test::More tests => 6;
use Test::More tests => 7;
ok(0 == [Tools::TBSSH::cmdcheckoutput($TBConfig::OPS_SERVER, "hostname", sub { $_[0] =~ /ops.emulab.net/; } )]->[0], 'ssh ops hostname');
ok(1 == [Tools::TBSSH::cmdcheckoutput($TBConfig::OPS_SERVER, "false", sub { $_[2] } )]->[0], 'ssh ops false return code');
......@@ -17,3 +17,5 @@ ok(0 == [Tools::TBSSH::cmdcheckoutput($TBConfig::OPS_SERVER, "hostname", sub { $
#test
ok(0 == [$ssh->cmdsuccess("hostname", sub { $_[0] =~ /ops.emulab.net/; } )]->[0], 'cmdsuccess(..) test');
ok(0 == [$ssh->cmdsuccessdump("hostname", sub { $_[0] =~ /ops.emulab.net/; } )]->[0], 'cmdsuccessdump(..) test');
ok(0 == [$ssh->cmdsuccess_stdin("python -", 'print "Hello"' )]->[0], 'python stdin Hello test');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment