File: sysinfo_macos.t

package info (click to toggle)
libsystem-info-perl 0.066-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,904 kB
  • sloc: perl: 2,516; sh: 25; makefile: 2
file content (124 lines) | stat: -rw-r--r-- 2,959 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/perl

use strict;
use warnings;

# We need at least 5.9.5 for the CORE::GLOBEL::readpipe () override
my $not595;
BEGIN { eval qq{use 5.009005}; $not595 = $@ }

use Test::More $not595
    ? (skip_all	=> "This is only version $] (needs 5.9.5)")
    : (tests	=> 5);
use Test::Warnings;

use Carp qw( cluck );
our $DEBUG = 0;

require System::Info::Darwin;

my %output = (
    m1_macbook_pro => {
	uname	=> "Apple M1 Pro 1 [10 (8 performance and 2 efficiency) cores] arm64",
	uname_m	=> "arm64",
	output	=> <<"__EOOUT__" },
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro18,1
      Model Number: Z14W0013MB/A
      Chip: Apple M1 Pro
      Total Number of Cores: 10 (8 performance and 2 efficiency)
      Memory: 32 GB
      System Firmware Version: 8422.141.2
      OS Loader Version: 8422.141.2
      Activation Lock Status: Disabled
__EOOUT__

    mini_intel => {
	uname	=> "Intel Core Duo (1.83 GHz) 1 [2 cores] x86_64",
	uname_m	=> "x86_64",
	output	=> <<"__EOOUT__" },
Hardware:
    Hardware Overview:
      Model Name: Mac mini
      Model Identifier: Macmini1,1
      Processor Name: Intel Core Duo
      Processor Speed: 1.83 GHz
      Number Of Processors: 1
      Total Number Of Cores: 2
      L2 Cache (per processor): 2MB
      Memory: 1 GB
      Bus Speed: 667 MHz
      Boot ROM Version: MM11.0055.B08
      SMC Version: 1.3f4
__EOOUT__

    ibook_g4 => {
	uname	=> "PowerPC G4 (1.07 GHz) 1 ppc",
	uname_m	=> "ppc",
	output	=> <<"__EOOUT__" },
Hardware:

    Hardware Overview:

      Machine Name: iBook G4
      Machine Model: PowerBook6,5
      CPU Type: PowerPC G4  (1.1)
      Number Of CPUs: 1
      CPU Speed: 1.07 GHz
      L2 Cache (per CPU): 512 KB
      Memory: 768 MB
      Bus Speed: 133 MHz
      Boot ROM Version: 4.8.5f0
__EOOUT__

    macbook_pro => {
	uname	=> "Intel Core 2 Duo (2.4 GHz) 1 [2 cores] x86_64",
	uname_m	=> "x86_64",
	output	=> <<"__EOOUT__" },
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro7,1
      Processor Name: Intel Core 2 Duo
      Processor Speed: 2.4 GHz
      Number Of Processors: 1
      Total Number Of Cores: 2
      L2 Cache: 3 MB
      Memory: 8 GB
      Bus Speed: 1.07 GHz
      Boot ROM Version: MBP71.0039.B0B
      SMC Version (system): 1.62f7
      Sudden Motion Sensor:
	  State: Enabled
__EOOUT__
    );

our $SYS_OUTPUT;
our $UNAME_OUTPUT;

sub fake_qx {
    $DEBUG and cluck ("<$_[0]>");

    $_[0] =~ m{/usr/sbin/system_profiler}
	? $SYS_OUTPUT
	: $_[0] =~ m{uname -m}
	    ? $UNAME_OUTPUT
	    : CORE::readpipe ($_[0]);
    } # fake_qx

BEGIN { *CORE::GLOBAL::readpipe = \&fake_qx }

foreach my $model (keys %output) {
    $SYS_OUTPUT   = $output{$model}{output};
    $UNAME_OUTPUT = $output{$model}{uname_m};

    local $^O = "Darwin";
    my $info = System::Info::Darwin->new;
    is ($info->si_uname ("m c p"), $output{$model}{uname}, $output{$model}{uname});
    }