Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/lib/WineTestBot/TestAgent.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/testbot/lib/WineTestBot/TestAgent.pm b/testbot/lib/WineTestBot/TestAgent.pm index 0aa59da573..fea7e650e1 100644 --- a/testbot/lib/WineTestBot/TestAgent.pm +++ b/testbot/lib/WineTestBot/TestAgent.pm @@ -1354,6 +1354,30 @@ sub Wait($$$;$) return $Result; }
+=pod +=over 12 + +=item C<RunAndWait()> + +Starts the specified command and waits for it to complete, returning its exit +code or a negative value if running or waiting for it failed. + +Note: The TestAgent-side error codes make it so that in most cases any non-zero + return value indicates that the command did not run successfully. + +=back +=cut + +sub RunAndWait($$$;$$$$$) +{ + my ($self, $Argv, $Flags, $WaitTimeout, $ServerInPath, $ServerOutPath, $ServerErrPath, $Keepalive) = @_; + + my $Pid = $self->Run($Argv, $Flags, $ServerInPath, $ServerOutPath, $ServerErrPath); + return -1 if (!$Pid); + my $Ret = $self->Wait($Pid, $WaitTimeout, $Keepalive); + return defined $Ret ? $Ret : -2; +} + sub Rm($@) { my $self = shift @_;
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- testbot/bin/SetWinLocale | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-)
diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale index c8f681a001..06b8635c46 100755 --- a/testbot/bin/SetWinLocale +++ b/testbot/bin/SetWinLocale @@ -499,6 +499,12 @@ my $TA = TestAgent->new($OptHostName, $AgentPort); # Registry helpers #
+sub GetRunError($) +{ + my ($ExitCode) = @_; + return $TA->GetLastError() || "exit code $ExitCode"; +} + sub RegGetValues($;$) { my ($Key, $VName) = @_; @@ -513,17 +519,11 @@ sub RegGetValues($;$) push @$Cmd, "/ve"; }
- my $Pid = $TA->Run($Cmd, 0, undef, "reg.out"); - if (!$Pid) - { - FatalError("failed to run @$Cmd\n"); - } - if (!defined $TA->Wait($Pid, 10)) - { - FatalError("@$Cmd timed out: ", $TA->GetLastError(), "\n"); - } - my $RegOut = $TA->GetFileToString("reg.out"); + my $Ret = $TA->RunAndWait($Cmd, 0, 10, undef, "reg.out"); + FatalError("failed to run @$Cmd: ", $TA->GetLastError(), "\n") if ($Ret < 0); + my $RegOut = $TA->GetFileToString("reg.out") if (!$Ret); $TA->Rm("reg.out"); + return {} if ($Ret); # Presumably the registry key does not exist
my $Values = {}; foreach my $Line (split /\n/, $RegOut) @@ -554,15 +554,8 @@ sub RegSetValue($$$$) $Value = join("\0", @$Value) if (ref($Value) eq "ARRAY"); push @$Cmd, "/t" , $Type, "/d", $Value;
- my $Pid = $TA->Run($Cmd, 0); - if (!$Pid) - { - FatalError("failed to run @$Cmd\n"); - } - if (!defined $TA->Wait($Pid, 10)) - { - FatalError("@$Cmd timed out: ", $TA->GetLastError(), "\n"); - } + my $Ret = $TA->RunAndWait($Cmd, 0, 10); + FatalError("@$Cmd failed: ", GetRunError($Ret), "\n") if ($Ret); }