]> git.saurik.com Git - apple/xnu.git/blame - tests/sysctl_hw.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / sysctl_hw.c
CommitLineData
f427ee49
A
1#include <darwintest.h>
2#include <sys/sysctl.h>
3
2a1bd2d3 4T_DECL(sysctl_hw_cpu, "ensure vital product and CPU-related sysctls exist")
f427ee49
A
5{
6 char buffer[64] = "";
7 size_t buffer_size = sizeof(buffer);
c3c9b80d
A
8 int v;
9 size_t v_size;
f427ee49
A
10
11 int ret = sysctlbyname("hw.target", buffer,
12 &buffer_size, NULL, 0);
13 T_ASSERT_POSIX_SUCCESS(ret, "hw.target sysctl");
14 T_LOG("hw.target = %s", buffer);
15
16 buffer_size = sizeof(buffer);
17
18 ret = sysctlbyname("hw.product", buffer,
19 &buffer_size, NULL, 0);
20 T_ASSERT_POSIX_SUCCESS(ret, "hw.product sysctl");
21 T_LOG("hw.product = %s", buffer);
2a1bd2d3
A
22
23 buffer_size = sizeof(buffer);
24
25 ret = sysctlbyname("machdep.cpu.brand_string", buffer,
26 &buffer_size, NULL, 0);
27
28 T_ASSERT_POSIX_SUCCESS(ret, "machdep.cpu.brand_string sysctl");
29 T_LOG("machdep.cpu.brand_string = %s", buffer);
c3c9b80d
A
30
31 v = 0;
32 v_size = sizeof(v);
33 ret = sysctlbyname("hw.cpu64bit_capable", &v, &v_size, NULL, 0);
34 T_ASSERT_POSIX_SUCCESS(ret, "hw.cpu64bit_capable");
35
36#if __arm__
37 T_EXPECT_EQ(v, 0, "cpu is not 64 bit capable");
38#else
39 T_EXPECT_EQ(v, 1, "cpu is 64 bit capable");
40#endif
f427ee49 41}