2 # SPDX-License-Identifier: GPL-2.0-only
4 # Copyright (c) 2019 Western Digital Corporation or its affiliates.
9 # Do some basic tests of the --readonly paramter
12 # python readonly.py [-f fio-executable]
15 # python t/readonly.py
16 # python t/readonly.py -f ./fio
29 parser = argparse.ArgumentParser()
30 parser.add_argument('-f', '--fio',
31 help='path to fio executable (e.g., ./fio)')
32 args = parser.parse_args()
37 def run_fio(fio, test, index):
44 "--rw={rw}".format(**test),
46 if 'readonly-pre' in test:
47 fio_args.insert(0, "--readonly")
48 if 'readonly-post' in test:
49 fio_args.append("--readonly")
51 output = subprocess.run([fio] + fio_args, stdout=subprocess.PIPE,
52 stderr=subprocess.PIPE)
57 def check_output(output, test):
59 if 'readonly-pre' in test or 'readonly-post' in test:
60 if 'write' in test['rw'] or 'trim' in test['rw']:
63 # print(output.stdout)
64 # print(output.stderr)
66 if output.returncode == 0:
78 if __name__ == '__main__':
127 output = run_fio(fio_path, test, index)
128 status = check_output(output, test)
129 print("Test {0} {1}".format(index, ("PASSED" if status else "FAILED")))
136 print("{0} tests passed, {1} failed".format(passed, failed))