Skip to content

Commit

Permalink
macos improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-hensley committed Mar 27, 2024
1 parent 7c27a8b commit f072073
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SDK/Resource/Detectors/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function parseMacOsId(string $out): string
if (str_contains($line, 'IOPlatformUUID')) {
$parts = explode('=', $line);

return trim($parts[1]);
return trim(str_replace('"', '', $parts[1]));
}
}

Expand Down
33 changes: 31 additions & 2 deletions tests/Unit/SDK/Resource/Detectors/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,39 @@ public function test_host_get_resource(): void

public function test_host_parse_macos_id(): void
{
$out = 'IOPlatformUUID=1234567890';
$out = <<<END
+-o J293AP <class IOPlatformExpertDevice, id 0x100000227, registered, matched,$
{
"IOPolledInterface" = "AppleARMWatchdogTimerHibernateHandler is not seria$
"#address-cells" = <02000000>
"AAPL,phandle" = <01000000>
"serial-number" = <432123465233514651303544000000000000000000000000000000$
"IOBusyInterest" = "IOCommand is not serializable"
"target-type" = <"J293">
"platform-name" = <743831303300000000000000000000000000000000000000000000$
"secure-root-prefix" = <"md">
"name" = <"device-tree">
"region-info" = <4c4c2f41000000000000000000000000000000000000000000000000$
"manufacturer" = <"Apple Inc.">
"compatible" = <"J293AP","MacBookPro17,1","AppleARM">
"config-number" = <000000000000000000000000000000000000000000000000000000$
"IOPlatformSerialNumber" = "A01BC3QFQ05D"
"regulatory-model-number" = <41323333380000000000000000000000000000000000$
"time-stamp" = <"Mon Jun 27 20:12:10 PDT 2022">
"clock-frequency" = <00366e01>
"model" = <"MacBookPro17,1">
"mlb-serial-number" = <432123413230363030455151384c4c314a0000000000000000$
"model-number" = <4d59443832000000000000000000000000000000000000000000000$
"IONWInterrupts" = "IONWInterrupts"
"model-config" = <"SUNWAY;MoPED=0x803914B08BE6C5AF0E6C990D7D8240DA4CAC2FF$
"device_type" = <"bootrom">
"#size-cells" = <02000000>
"IOPlatformUUID" = "1AB2345C-03E4-57D4-A375-1234D48DE123"
}
END;
$hostId = Detectors\Host::parseMacOsId($out);
$this->assertIsString($hostId);
$this->assertSame('1234567890', $hostId);
$this->assertSame('1AB2345C-03E4-57D4-A375-1234D48DE123', $hostId);
}

public function test_host_parse_windows_id(): void
Expand Down

0 comments on commit f072073

Please sign in to comment.