Module: tools Branch: master Commit: 0641c9fbb87f1005123978bcccc33cacdd7c51e0 URL: https://source.winehq.org/git/tools.git/?a=commit;h=0641c9fbb87f1005123978bc... Author: Francois Gouget <fgouget(a)codeweavers.com> Date: Tue Jan 11 19:20:12 2022 +0100 testbot/SetWinLocale: Use RunAndWait() to simplify the registry access. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- testbot/bin/SetWinLocale | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale index a6e95a2..0f624e8 100755 --- a/testbot/bin/SetWinLocale +++ b/testbot/bin/SetWinLocale @@ -505,6 +505,12 @@ my $TA = TestAgent->new($OptHostName, $AgentPort); # Registry helpers # +sub GetRunError($) +{ + my ($ExitCode) = @_; + return $TA->GetLastError() || "exit code $ExitCode"; +} + sub RegGetValues($;$) { my ($Key, $VName) = @_; @@ -519,17 +525,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) @@ -560,15 +560,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); }