-
Notifications
You must be signed in to change notification settings - Fork 0
/
s76burnin.py
executable file
·166 lines (137 loc) · 5.8 KB
/
s76burnin.py
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
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/python3
""" System76 assembly burn in test script """
from argparse import ArgumentParser
from os import environ, getlogin
from os.path import realpath, dirname
from subprocess import run, PIPE, CalledProcessError, getoutput
from threading import Thread
from time import sleep, time
from datetime import datetime
from s76utils import CommandUtils
def main():
"""
Main function for the System76 assembly burn-in test script.
Command-line Arguments:
-c, --config: Use a specific stress-ng configuration file.
-i, --integrated: Use integrated graphics for testing.
-s, --skip: Skip the GPU stress tests.
-u, --unigine: Use the Unigine engine for testing.
Workflow:
1. Initializes argument parsing and handles command-line arguments.
2. Sets up environment variables and paths.
3. Executes a series of tests and utility scripts, including:
- s76-journalctl.sh
- s76-disable-suspend.sh
- s76-htop.sh
- s76-gpu-burn.sh (conditional)
- s76-unigine (conditional)
4. Waits for certain processes to start and finish.
5. Cleans up by killing specific windows and processes.
Note:
- Requires root privileges for certain operations.
- Dependent on external scripts and utilities.
"""
parser = ArgumentParser(description="Script description.")
parser.add_argument("-i", "--integrated", action="store_true", help="Use integrated graphics.")
parser.add_argument("-s", "--skip", action="store_true", help="Skip the GPU stress tests.")
parser.add_argument("-l", "--skipllvm", action="store_true", help="Skip llvm stress test.")
parser.add_argument("-u", "--unigine", action="store_true", help="Use Unigine.")
stressng_count = 5
run_time_minutes = '60'
cmd_utils = CommandUtils()
args = parser.parse_args()
cmd_utils.run_command(["clear"], sudo=True)
# Prompt for order number and set a default if blank
onum = input("Enter order number: ")
onum = onum if onum.strip() else "RMA"
# Prompt for build number and set a default if blank
bnum = input("Enter build number: ")
bnum = bnum if bnum.strip() else "RMA"
# Prompt for serial number and set a default if blank
serialnum = input("Enter serial number: ")
serialnum = serialnum if serialnum.strip() else datetime.now().strftime('%y%m%d%H%M%S')
cmd_utils.run_command(['clear'])
print("Note: total test runtime will be greater than the runtime entered.")
print(" Memtester runs first for as long as is needed.")
rt_input = input(f"Enter burn-in test runtime in minutes ({run_time_minutes}): ")
if not rt_input or not rt_input.isnumeric():
rt_input = run_time_minutes
cmd_utils.run_command(['clear'])
if int(rt_input) < 10:
rt_input = '10'
stressng_cmd = ["./s76-stress.sh", "-b", "-t", rt_input]
if int(rt_input) < 30:
stressng_cmd.append("-l")
igfx = False
if args.integrated:
igfx = True
cmd_utils.run_command(["clear"])
script_path = dirname(realpath(__file__))
local_user = getlogin()
# Update PATH
if script_path not in environ["PATH"]:
environ["PATH"] = f"{script_path}/bin:{environ.get('PATH', '')}"
# Update LD_LIBRARY_PATH
ld_library_path = environ.get("LD_LIBRARY_PATH", "")
if script_path not in ld_library_path:
environ["LD_LIBRARY_PATH"] = f"{script_path}/lib:{ld_library_path}"
env_vars = {
"LOCAL_USER": local_user
}
cmd_utils.run_in_background(["./s76-journalctl.sh",
"-s", serialnum],
sudo=True,
preserve_env=True,
env_vars=env_vars)
cmd_utils.run_command('xdotool windowsize $(xdotool getactivewindow) 100% 100%', shell=True)
env_vars = {
"PATH": f"{environ['PATH']}:{script_path}/bin",
"LD_LIBRARY_PATH": f"{script_path}/lib"
}
cmd_utils.run_in_background(["./s76-disable-suspend.sh"], env_vars=env_vars)
if not args.skip:
vga_str = getoutput('lspci | grep VGA')
if 'NVIDIA' not in vga_str and 'Radeon' not in vga_str:
igfx = True
if 'NVIDIA' in vga_str and not igfx and not args.unigine:
cmd_utils.run_in_background(["./s76-gpu-burn.sh", rt_input])
if args.unigine or 'NVIDIA' not in vga_str:
cmd_utils.run_command([f"./s76-unigine-valley.sh", "-b"])
env_vars = {
"LOCAL_USER": local_user
}
cmd_utils.run_in_background(["./s76-testpy.sh", "-b", "-s", serialnum],
sudo=True,
preserve_env=True,
env_vars=env_vars)
if igfx:
stressng_cmd.append("-i")
if args.skipllvm and "-l" not in stressng_cmd:
stressng_cmd.append("-l")
# Wait for 'stress-ng' to start
cmd_utils.run_command(stressng_cmd)
while not cmd_utils.find_processes("stress-ng"):
sleep(15)
while cmd_utils.find_processes("stress-ng"):
sleep(60)
# Let system settle before benchmarking
#sleep(1800)
#env_vars = {
# "LOCAL_USER": local_user
#}
# Benchmarks coming soon
#run_command(["./s76-kernel-benchmark.sh"],
# sudo=True,
# preserve_env=True,
# env_vars=env_vars)
for pid in cmd_utils.find_processes("s76-journal", exact=False):
cmd_utils.run_command(["kill", str(pid)], sudo=True)
for pid in cmd_utils.find_processes("s76-disable", exact=False):
cmd_utils.run_command(["kill", "-9", str(pid)], sudo=True)
env_vars = {
"LOCAL_USER": local_user,
}
cmd_utils.run_command(["./s76-check.sh", "-o", onum, "-b", bnum, "-s", serialnum],
env_vars=env_vars)
if __name__ == "__main__":
main()