diff --git a/PythonScripts/test_disk.py b/PythonScripts/test_disk.py index 11c3190..e9bb54c 100644 --- a/PythonScripts/test_disk.py +++ b/PythonScripts/test_disk.py @@ -9,14 +9,18 @@ from datetime import datetime def run_cmd(cmd, log_file, check=True, capture_output=True): print(f"Running: {cmd}") result = subprocess.run(cmd, shell=True, capture_output=capture_output, text=True) + log_file.write(f"\n$ {cmd}\n") if result.stdout: log_file.write(result.stdout) if result.stderr: log_file.write(result.stderr) + log_file.flush() # ✅ Flush after writing + if check and result.returncode != 0: - print(f"Command failed: {cmd}\n{result.stderr}") - sys.exit(1) + print(f"[!] Non-zero exit code ({result.returncode}) for: {cmd}") + if result.stderr: + print(result.stderr.strip()) return result.stdout.strip() @@ -81,13 +85,13 @@ def run_badblocks(device, log_file): def fill_random(device, log_file): - print("Overwriting disk with random data...") + print("Writing 25 GiB of random data to disk...") run_cmd( - f"sudo dd if=/dev/urandom of={device} bs=1M status=progress", + f"sudo dd if=/dev/urandom of={device} bs=1M count=25600 status=progress", log_file, check=False, ) - print("Random data written to disk.") + print("Random data write complete.") def run_fio(device, rw_mode, log_file, bs="4k", runtime=30):