-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cpus.sh
More file actions
156 lines (140 loc) · 4.73 KB
/
test_cpus.sh
File metadata and controls
156 lines (140 loc) · 4.73 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
# Test rux kernel on all available QEMU CPU models.
# Quick smoke test: boot + shell prompt + uname + echo
set -e
QEMU_X86="/opt/local/bin/qemu-system-x86_64"
QEMU_AA64="/opt/local/bin/qemu-system-aarch64"
source "$HOME/.cargo/env"
# Build once
printf "\033[1mBuilding...\033[0m\n"
rustup run nightly cargo build -p rux-kernel --target x86_64-unknown-none 2>/dev/null
rustup run nightly cargo build -p rux-kernel --target aarch64-unknown-none 2>/dev/null
run_x86() {
local cpu="$1"
local out
out=$( { cat <<'CMDS'
true
uname -a
echo smoke_ok
exit
CMDS
} | "$QEMU_X86" -cpu "$cpu" -smp 2 \
-kernel target/x86_64-unknown-none/debug/rux-kernel.elf32 \
-initrd initramfs/initramfs_x86_64.cpio \
-chardev stdio,id=c0,logfile=/dev/null \
-serial chardev:c0 -display none \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-no-reboot -monitor none -m 128M 2>&1 || true )
local boot=0 prompt=0 uname=0 echo_ok=0
echo "$out" | grep -qF "exec /sbin/init" && boot=1
echo "$out" | grep -qF "/ # " && prompt=1
echo "$out" | grep -qF "rux rux" && uname=1
echo "$out" | grep -qF "smoke_ok" && echo_ok=1
local total=$((boot + prompt + uname + echo_ok))
if [ $total -eq 4 ]; then
printf " \033[32m✓\033[0m %-30s %d/4\n" "$cpu" "$total"
elif [ $total -eq 0 ]; then
local reason="no boot"
echo "$out" | grep -qi "fault\|panic\|abort" && reason="crash"
echo "$out" | grep -qi "triple\|shutdown" && reason="triple fault"
printf " \033[31m✗\033[0m %-30s %d/4 (%s)\n" "$cpu" "$total" "$reason"
else
local details=""
[ $boot -eq 1 ] && details="${details}boot " || details="${details}- "
[ $prompt -eq 1 ] && details="${details}prompt " || details="${details}- "
[ $uname -eq 1 ] && details="${details}uname " || details="${details}- "
[ $echo_ok -eq 1 ] && details="${details}echo" || details="${details}-"
printf " \033[33m~\033[0m %-30s %d/4 (%s)\n" "$cpu" "$total" "$details"
fi
}
run_aa64() {
local cpu="$1"
local out
out=$( { cat <<'CMDS'
true
uname -a
echo smoke_ok
exit
CMDS
} | "$QEMU_AA64" -machine virt -cpu "$cpu" -smp 2 \
-kernel target/aarch64-unknown-none/debug/rux-kernel \
-device loader,file=initramfs/initramfs_aarch64.cpio,addr=0x45000000,force-raw=on \
-chardev stdio,id=c0,logfile=/dev/null \
-serial chardev:c0 -display none \
-semihosting -no-reboot -m 128M 2>&1 || true )
local boot=0 prompt=0 uname=0 echo_ok=0
echo "$out" | grep -qF "exec /sbin/init" && boot=1
echo "$out" | grep -qF "/ # " && prompt=1
echo "$out" | grep -qF "rux rux" && uname=1
echo "$out" | grep -qF "smoke_ok" && echo_ok=1
local total=$((boot + prompt + uname + echo_ok))
if [ $total -eq 4 ]; then
printf " \033[32m✓\033[0m %-30s %d/4\n" "$cpu" "$total"
elif [ $total -eq 0 ]; then
local reason="no boot"
echo "$out" | grep -qi "fault\|panic\|abort\|exception" && reason="crash"
printf " \033[31m✗\033[0m %-30s %d/4 (%s)\n" "$cpu" "$total" "$reason"
else
local details=""
[ $boot -eq 1 ] && details="${details}boot " || details="${details}- "
[ $prompt -eq 1 ] && details="${details}prompt " || details="${details}- "
[ $uname -eq 1 ] && details="${details}uname " || details="${details}- "
[ $echo_ok -eq 1 ] && details="${details}echo" || details="${details}-"
printf " \033[33m~\033[0m %-30s %d/4 (%s)\n" "$cpu" "$total" "$details"
fi
}
# ── x86_64 CPUs ────────────────────────────────────────────────────
printf "\n\033[1m=== x86_64 CPUs ===\033[0m\n"
X86_CPUS=(
max
qemu64
Nehalem
Westmere
SandyBridge
IvyBridge
Haswell
Broadwell
Skylake-Client
Skylake-Server
Cascadelake-Server
Icelake-Server
SapphireRapids
GraniteRapids
EPYC
EPYC-Rome
EPYC-Milan
EPYC-Genoa
Opteron_G5
Denverton
Snowridge
Cooperlake
SierraForest
ClearwaterForest
Penryn
Conroe
phenom
)
for cpu in "${X86_CPUS[@]}"; do
run_x86 "$cpu"
done
# ── aarch64 CPUs ───────────────────────────────────────────────────
printf "\n\033[1m=== aarch64 CPUs ===\033[0m\n"
AA64_CPUS=(
max
cortex-a53
cortex-a55
cortex-a57
cortex-a72
cortex-a76
cortex-a710
cortex-a78ae
neoverse-n1
neoverse-n2
neoverse-v1
a64fx
cortex-a35
)
for cpu in "${AA64_CPUS[@]}"; do
run_aa64 "$cpu"
done
printf "\n\033[1mDone.\033[0m\n"