Module: tools Branch: master Commit: 2beaab04a36679838fe429c16106d92cdb87fa39 URL: http://source.winehq.org/git/tools.git/?a=commit;h=2beaab04a36679838fe429c16...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Jul 21 23:24:14 2014 +0200
testbot/testagentd: Add a GetCwd RPC.
---
testbot/lib/WineTestBot/TestAgent.pm | 18 ++++++++++++++++++ testbot/scripts/TestAgent | 12 +++++++++++- testbot/src/testagentd/testagentd.c | 18 +++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm index 2cb61ff..5d03a18 100644 --- a/testbot/lib/WineTestBot/TestAgent.pm +++ b/testbot/lib/WineTestBot/TestAgent.pm @@ -40,6 +40,7 @@ my $RPC_SETTIME = 7; my $RPC_GETPROPERTIES = 8; my $RPC_UPGRADE = 9; my $RPC_RMCHILDPROC = 10; +my $RPC_GETCWD = 11;
my %RpcNames=( $RPC_PING => 'ping', @@ -53,6 +54,7 @@ my %RpcNames=( $RPC_GETPROPERTIES => 'getproperties', $RPC_UPGRADE => 'upgrade', $RPC_RMCHILDPROC => 'rmchildproc', + $RPC_GETCWD => 'getcwd', );
my $Debug = 0; @@ -1407,4 +1409,20 @@ sub RemoveChildProcess($$) return $self->_RecvList(''); }
+sub GetCwd($) +{ + my ($self) = @_; + debug("GetCwd\n"); + + # Send the command + if (!$self->_StartRPC($RPC_GETCWD) or + !$self->_SendListSize('ArgC', 0)) + { + return undef; + } + + # Get the reply + return $self->_RecvList('s'); +} + 1; diff --git a/testbot/scripts/TestAgent b/testbot/scripts/TestAgent index ec4504f..ced1165 100755 --- a/testbot/scripts/TestAgent +++ b/testbot/scripts/TestAgent @@ -198,6 +198,10 @@ while (@ARGV) @Rm = @ARGV; last; } + elsif ($arg eq "getcwd") + { + $Cmd = $arg; + } elsif ($arg eq "getversion") { set_cmd($arg); @@ -296,7 +300,7 @@ if (defined $Usage) print "or $name0 [options] <hostname> wait <pid>\n"; print "or $name0 [options] <hostname> settime\n"; print "or $name0 [options] <hostname> rm <serverfiles>\n"; - print "or $name0 [options] <hostname> [ping|version]\n"; + print "or $name0 [options] <hostname> [getcwd|ping|version]\n"; print "\n"; print "This is a testagentd client. It can be used to send/receive files and to run commands on the server.\n"; print "\n"; @@ -323,6 +327,7 @@ if (defined $Usage) print " getproperty <name> Retrieves and prints the specified server property, for\n"; print " instance its architecture, 'server.arch'. One can print all the\n"; print " properties at once by omitting the name or setting it to '*'.\n"; + print " getcwd Returns the server's current working directory.\n"; print " ping Makes sure the server is still alive.\n"; print " upgrade Replaces the server executable with the specified file and\n"; print " restarts it.\n"; @@ -440,6 +445,11 @@ elsif ($Cmd eq "upgrade") { $Result = $TA->Upgrade($LocalFilename); } +elsif ($Cmd eq "getcwd") +{ + $Result = $TA->GetCwd(); + print "Current directory: $Result\n" if (defined $Result); +} elsif ($Cmd eq "getversion") { $Result = $TA->GetVersion(); diff --git a/testbot/src/testagentd/testagentd.c b/testbot/src/testagentd/testagentd.c index dc181a6..e776cc7 100644 --- a/testbot/src/testagentd/testagentd.c +++ b/testbot/src/testagentd/testagentd.c @@ -37,7 +37,7 @@ * 1.3: Fix the zero / infinite timeouts in the wait2 RPC. * 1.4: Add the settime RPC. * 1.5: Add support for upgrading the server. - * 1.6: Add support for the rmchildproc RPC. + * 1.6: Add support for the rmchildproc and getcwd RPC. */ #define PROTOCOL_VERSION "testagentd 1.6"
@@ -90,6 +90,7 @@ enum rpc_ids_t RPCID_GETPROPERTIES, RPCID_UPGRADE, RPCID_RMCHILDPROC, + RPCID_GETCWD, };
/* This is the RPC currently being processed */ @@ -111,6 +112,7 @@ static const char* rpc_name(uint32_t id) "getproperties", "upgrade", "rmchildproc", + "getcwd", };
if (id < sizeof(names) / sizeof(*names)) @@ -1037,7 +1039,19 @@ static void do_upgrade(SOCKET client) } else send_error(client); +} + +static void do_getcwd(SOCKET client) +{ + char curdir[261];
+ if (expect_list_size(client, 0)) + { + send_list_size(client, 1); + send_string(client, getcwd(curdir, sizeof(curdir))); + } + else + send_error(client); }
static void do_unknown(SOCKET client, uint32_t id) @@ -1109,6 +1123,8 @@ static void process_rpc(SOCKET client) break; case RPCID_UPGRADE: do_upgrade(client); + case RPCID_GETCWD: + do_getcwd(client); break; case RPCID_RMCHILDPROC: do_rmchildproc(client);