+from pathlib import Path
+from fiotestlib import FioJobCmdTest, run_fio_tests
+from fiotestcommon import SUCCESS_DEFAULT, SUCCESS_NONZERO
+
+
+class FioReadOnlyTest(FioJobCmdTest):
+ """fio read only test."""
+
+ def setup(self, parameters):
+ """Setup the test."""
+
+ fio_args = [
+ "--name=readonly",
+ "--ioengine=null",
+ "--time_based",
+ "--runtime=1s",
+ "--size=1M",
+ f"--rw={self.fio_opts['rw']}",
+ ]
+ if 'readonly-pre' in parameters:
+ fio_args.insert(0, "--readonly")
+ if 'readonly-post' in parameters:
+ fio_args.append("--readonly")
+
+ super().setup(fio_args)
+
+
+TEST_LIST = [
+ {
+ "test_id": 1,
+ "fio_opts": { "rw": "randread", },
+ "readonly-pre": 1,
+ "success": SUCCESS_DEFAULT,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 2,
+ "fio_opts": { "rw": "randwrite", },
+ "readonly-pre": 1,
+ "success": SUCCESS_NONZERO,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 3,
+ "fio_opts": { "rw": "randtrim", },
+ "readonly-pre": 1,
+ "success": SUCCESS_NONZERO,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 4,
+ "fio_opts": { "rw": "randread", },
+ "readonly-post": 1,
+ "success": SUCCESS_DEFAULT,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 5,
+ "fio_opts": { "rw": "randwrite", },
+ "readonly-post": 1,
+ "success": SUCCESS_NONZERO,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 6,
+ "fio_opts": { "rw": "randtrim", },
+ "readonly-post": 1,
+ "success": SUCCESS_NONZERO,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 7,
+ "fio_opts": { "rw": "randread", },
+ "success": SUCCESS_DEFAULT,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 8,
+ "fio_opts": { "rw": "randwrite", },
+ "success": SUCCESS_DEFAULT,
+ "test_class": FioReadOnlyTest,
+ },
+ {
+ "test_id": 9,
+ "fio_opts": { "rw": "randtrim", },
+ "success": SUCCESS_DEFAULT,
+ "test_class": FioReadOnlyTest,
+ },
+ ]