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
27 from pathlib import Path
28 from fiotestlib import FioJobCmdTest, run_fio_tests
29 from fiotestcommon import SUCCESS_DEFAULT, SUCCESS_NONZERO
32 class FioReadOnlyTest(FioJobCmdTest):
33 """fio read only test."""
35 def setup(self, parameters):
44 f"--rw={self.fio_opts['rw']}",
46 if 'readonly-pre' in parameters:
47 fio_args.insert(0, "--readonly")
48 if 'readonly-post' in parameters:
49 fio_args.append("--readonly")
51 super().setup(fio_args)
57 "fio_opts": { "rw": "randread", },
59 "success": SUCCESS_DEFAULT,
60 "test_class": FioReadOnlyTest,
64 "fio_opts": { "rw": "randwrite", },
66 "success": SUCCESS_NONZERO,
67 "test_class": FioReadOnlyTest,
71 "fio_opts": { "rw": "randtrim", },
73 "success": SUCCESS_NONZERO,
74 "test_class": FioReadOnlyTest,
78 "fio_opts": { "rw": "randread", },
80 "success": SUCCESS_DEFAULT,
81 "test_class": FioReadOnlyTest,
85 "fio_opts": { "rw": "randwrite", },
87 "success": SUCCESS_NONZERO,
88 "test_class": FioReadOnlyTest,
92 "fio_opts": { "rw": "randtrim", },
94 "success": SUCCESS_NONZERO,
95 "test_class": FioReadOnlyTest,
99 "fio_opts": { "rw": "randread", },
100 "success": SUCCESS_DEFAULT,
101 "test_class": FioReadOnlyTest,
105 "fio_opts": { "rw": "randwrite", },
106 "success": SUCCESS_DEFAULT,
107 "test_class": FioReadOnlyTest,
111 "fio_opts": { "rw": "randtrim", },
112 "success": SUCCESS_DEFAULT,
113 "test_class": FioReadOnlyTest,
119 """Parse command-line arguments."""
121 parser = argparse.ArgumentParser()
122 parser.add_argument('-f', '--fio', help='path to fio executable (e.g., ./fio)')
123 parser.add_argument('-a', '--artifact-root', help='artifact root directory')
124 parser.add_argument('-s', '--skip', nargs='+', type=int,
125 help='list of test(s) to skip')
126 parser.add_argument('-o', '--run-only', nargs='+', type=int,
127 help='list of test(s) to run, skipping all others')
128 args = parser.parse_args()
134 """Run readonly tests."""
139 fio_path = str(Path(args.fio).absolute())
142 print(f"fio path is {fio_path}")
144 artifact_root = args.artifact_root if args.artifact_root else \
145 f"readonly-test-{time.strftime('%Y%m%d-%H%M%S')}"
146 os.mkdir(artifact_root)
147 print(f"Artifact directory is {artifact_root}")
150 'fio_path': fio_path,
151 'fio_root': str(Path(__file__).absolute().parent.parent),
152 'artifact_root': artifact_root,
153 'basename': 'readonly',
156 _, failed, _ = run_fio_tests(TEST_LIST, test_env, args)
160 if __name__ == '__main__':