5 This contains constant definitions, helpers, and a Requirements class that can
6 be used to help with running fio tests.
13 import multiprocessing
14 from fiotestlib import FioJobTest
24 'stderr_empty': False,
29 'stderr_empty': False,
34 """Requirements consists of multiple run environment characteristics.
35 These are to determine if a particular test can be run"""
49 def __init__(self, fio_root, args):
50 Requirements._not_macos = platform.system() != "Darwin"
51 Requirements._not_windows = platform.system() != "Windows"
52 Requirements._linux = platform.system() == "Linux"
54 if Requirements._linux:
55 config_file = os.path.join(fio_root, "config-host.h")
56 contents, success = FioJobTest.get_file(config_file)
58 print(f"Unable to open {config_file} to check requirements")
59 Requirements._zbd = True
61 Requirements._zbd = "CONFIG_HAS_BLKZONED" in contents
62 Requirements._libaio = "CONFIG_LIBAIO" in contents
64 contents, success = FioJobTest.get_file("/proc/kallsyms")
66 print("Unable to open '/proc/kallsyms' to probe for io_uring support")
68 Requirements._io_uring = "io_uring_setup" in contents
70 Requirements._root = os.geteuid() == 0
71 if Requirements._zbd and Requirements._root:
73 subprocess.run(["modprobe", "null_blk"],
74 stdout=subprocess.PIPE,
75 stderr=subprocess.PIPE)
76 if os.path.exists("/sys/module/null_blk/parameters/zoned"):
77 Requirements._zoned_nullb = True
81 if platform.system() == "Windows":
82 utest_exe = "unittest.exe"
84 utest_exe = "unittest"
85 unittest_path = os.path.join(fio_root, "unittests", utest_exe)
86 Requirements._unittests = os.path.exists(unittest_path)
88 Requirements._cpucount4 = multiprocessing.cpu_count() >= 4
89 Requirements._nvmecdev = args.nvmecdev
94 Requirements.io_uring,
97 Requirements.zoned_nullb,
98 Requirements.not_macos,
99 Requirements.not_windows,
100 Requirements.unittests,
101 Requirements.cpucount4,
102 Requirements.nvmecdev,
106 logging.debug("Requirements: Requirement '%s' met? %s", desc, value)
110 """Are we running on Linux?"""
111 return Requirements._linux, "Linux required"
115 """Is libaio available?"""
116 return Requirements._libaio, "libaio required"
120 """Is io_uring available?"""
121 return Requirements._io_uring, "io_uring required"
125 """Is ZBD support available?"""
126 return Requirements._zbd, "Zoned block device support required"
130 """Are we running as root?"""
131 return Requirements._root, "root required"
134 def zoned_nullb(cls):
135 """Are zoned null block devices available?"""
136 return Requirements._zoned_nullb, "Zoned null block device support required"
140 """Are we running on a platform other than macOS?"""
141 return Requirements._not_macos, "platform other than macOS required"
144 def not_windows(cls):
145 """Are we running on a platform other than Windws?"""
146 return Requirements._not_windows, "platform other than Windows required"
150 """Were unittests built?"""
151 return Requirements._unittests, "Unittests support required"
155 """Do we have at least 4 CPUs?"""
156 return Requirements._cpucount4, "4+ CPUs required"
160 """Do we have an NVMe character device to test?"""
161 return Requirements._nvmecdev, "NVMe character device test target required"