File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/bin/env python3
2+ import os
3+ import multiprocessing
4+ import sys
5+
6+
7+ def try_read_node (path ):
8+ """
9+ Attempts to read a single sysfs attribute.
10+ Isolated in a subprocess to protect against D-state hangs.
11+ """
12+ try :
13+ with open (path , "r" ) as f :
14+ # We only need the first byte to trigger the kernel 'show' function
15+ f .read (1 )
16+ except Exception :
17+ pass
18+
19+
20+ def walk_devices (base_path = "/sys/devices" , timeout = 10.0 ):
21+
22+ # We use os.walk but skip non-device directories if necessary
23+ failed = 0
24+ for root , dirs , files in os .walk (base_path ):
25+ for name in files :
26+ full_path = os .path .join (root , name )
27+
28+ # Skip known 'noisy' or non-hardware files to be efficient
29+ if name in ["uevent" , "modalias" , "resource" ]:
30+ continue
31+
32+ if os .access (full_path , os .R_OK ):
33+ p = multiprocessing .Process (
34+ target = try_read_node , args = (full_path ,)
35+ )
36+ p .start ()
37+
38+ p .join (timeout )
39+
40+ if p .is_alive ():
41+ failed = 1
42+ print (f"{ full_path } " )
43+ p .terminate ()
44+ p .join ()
45+ # We stay silent on success to highlight the problem areas
46+ return failed
47+
48+
49+ if __name__ == "__main__" :
50+ print (
51+ "Scanning /sys/devices for unresponsive attributes (Timeout: 10s)..."
52+ )
53+ sys .exit (walk_devices ())
Original file line number Diff line number Diff line change @@ -632,3 +632,10 @@ _steps:
632632 3. Boot into the recovered system without errors
633633_verification:
634634 1. The system boots into the factory recovery system successfully.
635+
636+ plugin: shell
637+ category_id: com.canonical.plainbox::miscellanea
638+ estimated_duration: 120.0
639+ id: miscellanea/check-hardware-attributes
640+ command: check_hardware_attributes.py
641+ _summary: Check that all the attributes are able to read
You can’t perform that action at this time.
0 commit comments