[tools 2/2] testbot/SetWinLocale: Use RunAndWait() to simplify the registry access.
Francois Gouget
fgouget at codeweavers.com
Tue Jan 11 12:20:12 CST 2022
Signed-off-by: Francois Gouget <fgouget at 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);
}
--
2.30.2
More information about the wine-devel
mailing list