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 parameter
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):
45 "--rw={rw}".format(**test),
47 if 'readonly-pre' in test:
48 fio_args.insert(0, "--readonly")
49 if 'readonly-post' in test:
50 fio_args.append("--readonly")
52 output = subprocess.run([fio] + fio_args, stdout=subprocess.PIPE,
53 stderr=subprocess.PIPE)
58 def check_output(output, test):
60 if 'readonly-pre' in test or 'readonly-post' in test:
61 if 'write' in test['rw'] or 'trim' in test['rw']:
64 # print(output.stdout)
65 # print(output.stderr)
67 if output.returncode == 0:
79 if __name__ == '__main__':
128 output = run_fio(fio_path, test, index)
129 status = check_output(output, test)
130 print("Test {0} {1}".format(index, ("PASSED" if status else "FAILED")))
137 print("{0} tests passed, {1} failed".format(passed, failed))