zpool/zfs: restore -V & --version options
[zfs.git] / tests / test-runner / bin / zts-report.py.in
blob2562836213af559f566253b6e4bd5331ba75979b
1 #!/usr/bin/env @PYTHON_SHEBANG@
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
15 # Copyright (c) 2017 by Delphix. All rights reserved.
16 # Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
18 # This script must remain compatible with Python 3.6+.
21 import os
22 import re
23 import sys
24 import argparse
27 # This script parses the stdout of zfstest, which has this format:
29 # Test: /path/to/testa (run as root) [00:00] [PASS]
30 # Test: /path/to/testb (run as jkennedy) [00:00] [PASS]
31 # Test: /path/to/testc (run as root) [00:00] [FAIL]
32 # [...many more results...]
34 # Results Summary
35 # FAIL 22
36 # SKIP 32
37 # PASS 1156
39 # Running Time: 02:50:31
40 # Percent passed: 95.5%
41 # Log directory: /var/tmp/test_results/20180615T205926
45 # Common generic reasons for a test or test group to be skipped.
47 # Some test cases are known to fail in ways which are not harmful or dangerous.
48 # In these cases simply mark the test as a known failure until it can be
49 # updated and the issue resolved. Note that it's preferable to open a unique
50 # issue on the GitHub issue tracker for each test case failure.
52 known_reason = 'Known issue'
55 # Some tests require that a test user be able to execute the zfs utilities.
56 # This may not be possible when testing in-tree due to the default permissions
57 # on the user's home directory. When testing this can be resolved by granting
58 # group read access.
60 # chmod 0750 $HOME
62 exec_reason = 'Test user execute permissions required for utilities'
65 # Some tests require that the kernel supports renameat2 syscall.
67 renameat2_reason = 'Kernel renameat2 support required'
70 # Some tests require the statx(2) system call on Linux which was first
71 # introduced in the 4.11 kernel.
73 statx_reason = 'Kernel statx(2) system call required on Linux'
76 # Some tests require that the lsattr utility support the project id feature.
78 project_id_reason = 'lsattr with set/show project ID required'
81 # Some tests require that the kernel support user namespaces.
83 user_ns_reason = 'Kernel user namespace support required'
86 # Some rewind tests can fail since nothing guarantees that old MOS blocks
87 # are not overwritten. Snapshots protect datasets and data files but not
88 # the MOS. Reasonable efforts are made in the test case to increase the
89 # odds that some txgs will have their MOS data left untouched, but it is
90 # never a sure thing.
92 rewind_reason = 'Arbitrary pool rewind is not guaranteed'
95 # Some tests require a minimum version of the fio benchmark utility.
96 # Older distributions such as CentOS 6.x only provide fio-2.0.13.
98 fio_reason = 'Fio v2.3 or newer required'
101 # Some tests require that the DISKS provided support the discard operation.
102 # Normally this is not an issue because loop back devices are used for DISKS
103 # and they support discard (TRIM/UNMAP).
105 trim_reason = 'DISKS must support discard (TRIM/UNMAP)'
108 # Some tests on FreeBSD require the fspacectl(2) system call and the
109 # truncate(1) utility supporting the -d option. The system call was first
110 # introduced in FreeBSD version 1400032.
112 fspacectl_reason = 'fspacectl(2) and truncate -d support required'
115 # Some tests are not applicable to a platform or need to be updated to operate
116 # in the manor required by the platform. Any tests which are skipped for this
117 # reason will be suppressed in the final analysis output.
119 na_reason = "Not applicable"
122 # Idmapped mount is only supported in kernel version >= 5.12
124 idmap_reason = 'Idmapped mount needs kernel 5.12+'
127 # copy_file_range() is not supported by all kernels
129 cfr_reason = 'Kernel copy_file_range support required'
131 if sys.platform.startswith('freebsd'):
132 cfr_cross_reason = 'copy_file_range(2) cross-filesystem needs FreeBSD 14+'
133 else:
134 cfr_cross_reason = 'copy_file_range(2) cross-filesystem needs kernel 5.3+'
137 # These tests are known to fail, thus we use this list to prevent these
138 # failures from failing the job as a whole; only unexpected failures
139 # bubble up to cause this script to exit with a non-zero exit status.
141 # Format: { 'test-name': ['expected result', 'issue-number | reason'] }
143 # For each known failure it is recommended to link to a GitHub issue by
144 # setting the reason to the issue number. Alternately, one of the generic
145 # reasons listed above can be used.
147 known = {
148 'casenorm/mixed_none_lookup_ci': ['FAIL', 7633],
149 'casenorm/mixed_formd_lookup_ci': ['FAIL', 7633],
150 'cli_root/zpool_import/import_rewind_device_replaced':
151 ['FAIL', rewind_reason],
152 'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason],
153 'cli_user/misc/zfs_unshare_001_neg': ['SKIP', na_reason],
154 'pool_checkpoint/checkpoint_discard_busy': ['SKIP', 12053],
155 'privilege/setup': ['SKIP', na_reason],
156 'refreserv/refreserv_004_pos': ['FAIL', known_reason],
157 'rootpool/setup': ['SKIP', na_reason],
158 'rsend/rsend_008_pos': ['SKIP', 6066],
159 'vdev_zaps/vdev_zaps_007_pos': ['FAIL', known_reason],
162 if sys.platform.startswith('freebsd'):
163 known.update({
164 'cli_root/zfs_receive/receive-o-x_props_override':
165 ['FAIL', known_reason],
166 'cli_root/zpool_resilver/zpool_resilver_concurrent':
167 ['SKIP', na_reason],
168 'cli_root/zpool_wait/zpool_wait_trim_basic': ['SKIP', trim_reason],
169 'cli_root/zpool_wait/zpool_wait_trim_cancel': ['SKIP', trim_reason],
170 'cli_root/zpool_wait/zpool_wait_trim_flag': ['SKIP', trim_reason],
171 'cli_root/zfs_unshare/zfs_unshare_008_pos': ['SKIP', na_reason],
172 'cp_files/cp_files_002_pos': ['SKIP', na_reason],
173 'link_count/link_count_001': ['SKIP', na_reason],
174 'mmap/mmap_sync_001_pos': ['SKIP', na_reason],
175 'rsend/send_raw_ashift': ['SKIP', 14961],
177 elif sys.platform.startswith('linux'):
178 known.update({
179 'casenorm/mixed_formd_lookup': ['FAIL', 7633],
180 'casenorm/mixed_formd_delete': ['FAIL', 7633],
181 'casenorm/sensitive_formd_lookup': ['FAIL', 7633],
182 'casenorm/sensitive_formd_delete': ['FAIL', 7633],
183 'removal/removal_with_zdb': ['SKIP', known_reason],
184 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason],
189 # These tests may occasionally fail or be skipped. We want there failures
190 # to be reported but only unexpected failures should bubble up to cause
191 # this script to exit with a non-zero exit status.
193 # Format: { 'test-name': ['expected result', 'issue-number | reason'] }
195 # For each known failure it is recommended to link to a GitHub issue by
196 # setting the reason to the issue number. Alternately, one of the generic
197 # reasons listed above can be used.
199 maybe = {
200 'append/threadsappend_001_pos': ['FAIL', 6136],
201 'chattr/setup': ['SKIP', exec_reason],
202 'crtime/crtime_001_pos': ['SKIP', statx_reason],
203 'cli_root/zdb/zdb_006_pos': ['FAIL', known_reason],
204 'cli_root/zfs_copies/zfs_copies_006_pos': ['FAIL', known_reason],
205 'cli_root/zfs_destroy/zfs_destroy_dev_removal_condense':
206 ['FAIL', known_reason],
207 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason],
208 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', 5479],
209 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason],
210 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason],
211 'cli_root/zfs_share/zfs_share_concurrent_shares': ['FAIL', known_reason],
212 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason],
213 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason],
214 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason],
215 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', 6145],
216 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', 6839],
217 'cli_root/zpool_initialize/zpool_initialize_import_export':
218 ['FAIL', 11948],
219 'cli_root/zpool_initialize/zpool_initialize_suspend_resume':
220 ['FAIL', known_reason],
221 'cli_root/zpool_labelclear/zpool_labelclear_removed':
222 ['FAIL', known_reason],
223 'cli_root/zpool_trim/setup': ['SKIP', trim_reason],
224 'cli_root/zpool_trim/zpool_trim_fault_export_import_online':
225 ['FAIL', known_reason],
226 'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', 6141],
227 'cli_user/misc/arc_summary_001_pos': ['FAIL', known_reason],
228 'delegate/setup': ['SKIP', exec_reason],
229 'events/zed_cksum_config': ['FAIL', known_reason],
230 'fault/auto_replace_002_pos': ['FAIL', known_reason],
231 'fallocate/fallocate_punch-hole': ['SKIP', fspacectl_reason],
232 'history/history_004_pos': ['FAIL', 7026],
233 'history/history_005_neg': ['FAIL', 6680],
234 'history/history_006_neg': ['FAIL', 5657],
235 'history/history_008_pos': ['FAIL', known_reason],
236 'history/history_010_pos': ['SKIP', exec_reason],
237 'io/mmap': ['SKIP', fio_reason],
238 'l2arc/l2arc_l2miss_pos': ['FAIL', known_reason],
239 'l2arc/persist_l2arc_005_pos': ['FAIL', known_reason],
240 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason],
241 'mmap/mmap_sync_001_pos': ['FAIL', known_reason],
242 'mmp/mmp_on_uberblocks': ['FAIL', known_reason],
243 'pam/setup': ['SKIP', "pamtester might be not available"],
244 'pool_checkpoint/checkpoint_discard_busy': ['FAIL', 11946],
245 'projectquota/setup': ['SKIP', exec_reason],
246 'raidz/raidz_002_pos': ['FAIL', known_reason],
247 'raidz/raidz_expand_001_pos': ['FAIL', 16421],
248 'redundancy/redundancy_draid_spare1': ['FAIL', known_reason],
249 'redundancy/redundancy_draid_spare3': ['FAIL', known_reason],
250 'removal/removal_condense_export': ['FAIL', known_reason],
251 'renameat2/setup': ['SKIP', renameat2_reason],
252 'reservation/reservation_008_pos': ['FAIL', 7741],
253 'reservation/reservation_018_pos': ['FAIL', 5642],
254 'snapshot/clone_001_pos': ['FAIL', known_reason],
255 'snapshot/snapshot_006_pos': ['FAIL', known_reason],
256 'snapshot/snapshot_009_pos': ['FAIL', 7961],
257 'snapshot/snapshot_010_pos': ['FAIL', 7961],
258 'snapused/snapused_004_pos': ['FAIL', 5513],
259 'trim/setup': ['SKIP', trim_reason],
260 'upgrade/upgrade_projectquota_001_pos': ['SKIP', project_id_reason],
261 'upgrade/upgrade_projectquota_002_pos': ['SKIP', project_id_reason],
262 'user_namespace/setup': ['SKIP', user_ns_reason],
263 'userquota/setup': ['SKIP', exec_reason],
264 'vdev_zaps/vdev_zaps_004_pos': ['FAIL', known_reason],
265 'zvol/zvol_ENOSPC/zvol_ENOSPC_001_pos': ['FAIL', 5848],
268 if sys.platform.startswith('freebsd'):
269 maybe.update({
270 'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason],
271 'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason],
272 'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason],
273 'delegate/zfs_allow_003_pos': ['FAIL', known_reason],
274 'inheritance/inherit_001_pos': ['FAIL', 11829],
275 'pool_checkpoint/checkpoint_big_rewind': ['FAIL', 12622],
276 'pool_checkpoint/checkpoint_indirect': ['FAIL', 12623],
277 'resilver/resilver_restart_001': ['FAIL', known_reason],
278 'snapshot/snapshot_002_pos': ['FAIL', '14831'],
279 'bclone/bclone_crossfs_corner_cases': ['SKIP', cfr_cross_reason],
280 'bclone/bclone_crossfs_corner_cases_limited':
281 ['SKIP', cfr_cross_reason],
282 'bclone/bclone_crossfs_data': ['SKIP', cfr_cross_reason],
283 'bclone/bclone_crossfs_embedded': ['SKIP', cfr_cross_reason],
284 'bclone/bclone_crossfs_hole': ['SKIP', cfr_cross_reason],
285 'bclone/bclone_diffprops_all': ['SKIP', cfr_cross_reason],
286 'bclone/bclone_diffprops_checksum': ['SKIP', cfr_cross_reason],
287 'bclone/bclone_diffprops_compress': ['SKIP', cfr_cross_reason],
288 'bclone/bclone_diffprops_copies': ['SKIP', cfr_cross_reason],
289 'bclone/bclone_diffprops_recordsize': ['SKIP', cfr_cross_reason],
290 'bclone/bclone_prop_sync': ['SKIP', cfr_cross_reason],
291 'block_cloning/block_cloning_cross_enc_dataset':
292 ['SKIP', cfr_cross_reason],
293 'block_cloning/block_cloning_copyfilerange_cross_dataset':
294 ['SKIP', cfr_cross_reason]
296 elif sys.platform.startswith('linux'):
297 maybe.update({
298 'bclone/bclone_crossfs_corner_cases': ['SKIP', cfr_cross_reason],
299 'bclone/bclone_crossfs_corner_cases_limited':
300 ['SKIP', cfr_cross_reason],
301 'bclone/bclone_crossfs_data': ['SKIP', cfr_cross_reason],
302 'bclone/bclone_crossfs_embedded': ['SKIP', cfr_cross_reason],
303 'bclone/bclone_crossfs_hole': ['SKIP', cfr_cross_reason],
304 'bclone/bclone_diffprops_all': ['SKIP', cfr_cross_reason],
305 'bclone/bclone_diffprops_checksum': ['SKIP', cfr_cross_reason],
306 'bclone/bclone_diffprops_compress': ['SKIP', cfr_cross_reason],
307 'bclone/bclone_diffprops_copies': ['SKIP', cfr_cross_reason],
308 'bclone/bclone_diffprops_recordsize': ['SKIP', cfr_cross_reason],
309 'bclone/bclone_prop_sync': ['SKIP', cfr_cross_reason],
310 'bclone/bclone_samefs_corner_cases': ['SKIP', cfr_reason],
311 'bclone/bclone_samefs_corner_cases_limited': ['SKIP', cfr_reason],
312 'bclone/bclone_samefs_data': ['SKIP', cfr_reason],
313 'bclone/bclone_samefs_embedded': ['SKIP', cfr_reason],
314 'bclone/bclone_samefs_hole': ['SKIP', cfr_reason],
315 'block_cloning/block_cloning_clone_mmap_cached': ['SKIP', cfr_reason],
316 'block_cloning/block_cloning_clone_mmap_write':
317 ['SKIP', cfr_reason],
318 'block_cloning/block_cloning_copyfilerange':
319 ['SKIP', cfr_reason],
320 'block_cloning/block_cloning_copyfilerange_cross_dataset':
321 ['SKIP', cfr_cross_reason],
322 'block_cloning/block_cloning_copyfilerange_fallback':
323 ['SKIP', cfr_reason],
324 'block_cloning/block_cloning_copyfilerange_fallback_same_txg':
325 ['SKIP', cfr_cross_reason],
326 'block_cloning/block_cloning_copyfilerange_partial':
327 ['SKIP', cfr_reason],
328 'block_cloning/block_cloning_cross_enc_dataset':
329 ['SKIP', cfr_cross_reason],
330 'block_cloning/block_cloning_disabled_copyfilerange':
331 ['SKIP', cfr_reason],
332 'block_cloning/block_cloning_lwb_buffer_overflow':
333 ['SKIP', cfr_reason],
334 'block_cloning/block_cloning_replay':
335 ['SKIP', cfr_reason],
336 'block_cloning/block_cloning_replay_encrypted':
337 ['SKIP', cfr_reason],
338 'block_cloning/block_cloning_rlimit_fsize':
339 ['SKIP', cfr_reason],
340 'cli_root/zfs_rename/zfs_rename_002_pos': ['FAIL', known_reason],
341 'cli_root/zpool_reopen/zpool_reopen_003_pos': ['FAIL', known_reason],
342 'cp_files/cp_files_002_pos': ['SKIP', cfr_reason],
343 'fault/auto_online_002_pos': ['FAIL', 11889],
344 'fault/auto_replace_001_pos': ['FAIL', 14851],
345 'fault/auto_spare_002_pos': ['FAIL', 11889],
346 'fault/auto_spare_multiple': ['FAIL', 11889],
347 'fault/auto_spare_shared': ['FAIL', 11889],
348 'fault/decompress_fault': ['FAIL', 11889],
349 'idmap_mount/idmap_mount_001': ['SKIP', idmap_reason],
350 'idmap_mount/idmap_mount_002': ['SKIP', idmap_reason],
351 'idmap_mount/idmap_mount_003': ['SKIP', idmap_reason],
352 'idmap_mount/idmap_mount_004': ['SKIP', idmap_reason],
353 'idmap_mount/idmap_mount_005': ['SKIP', idmap_reason],
354 'io/io_uring': ['SKIP', 'io_uring support required'],
355 'limits/filesystem_limit': ['SKIP', known_reason],
356 'limits/snapshot_limit': ['SKIP', known_reason],
357 'mmp/mmp_active_import': ['FAIL', known_reason],
358 'mmp/mmp_exported_import': ['FAIL', known_reason],
359 'mmp/mmp_inactive_import': ['FAIL', known_reason],
363 def process_results(pathname):
364 try:
365 f = open(pathname, errors='replace')
366 except IOError as e:
367 print('Error opening file:', e)
368 sys.exit(1)
370 prefix = '/zfs-tests/tests/(?:functional|perf/regression)/'
371 pattern = \
372 r'^Test(?:\s+\(\S+\))?:' + \
373 rf'\s*\S*{prefix}(\S+)' + \
374 r'\s*\(run as (\S+)\)\s*\[(\S+)\]\s*\[(\S+)\]'
375 pattern_log = r'^\s*Log directory:\s*(\S*)'
377 d = {}
378 logdir = 'Could not determine log directory.'
379 for line in f.readlines():
380 m = re.match(pattern, line)
381 if m and len(m.groups()) == 4:
382 d[m.group(1)] = m.group(4)
383 continue
385 m = re.match(pattern_log, line)
386 if m:
387 logdir = m.group(1)
389 return d, logdir
392 class ListMaybesAction(argparse.Action):
393 def __init__(self,
394 option_strings,
395 dest="SUPPRESS",
396 default="SUPPRESS",
397 help="list flaky tests and exit"):
398 super(ListMaybesAction, self).__init__(
399 option_strings=option_strings,
400 dest=dest,
401 default=default,
402 nargs=0,
403 help=help)
405 def __call__(self, parser, namespace, values, option_string=None):
406 for test in maybe:
407 print(test)
408 sys.exit(0)
411 if __name__ == "__main__":
412 parser = argparse.ArgumentParser(description='Analyze ZTS logs')
413 parser.add_argument('logfile')
414 parser.add_argument('--list-maybes', action=ListMaybesAction)
415 parser.add_argument('--no-maybes', action='store_false', dest='maybes')
416 args = parser.parse_args()
418 results, logdir = process_results(args.logfile)
420 if not results:
421 print("\n\nNo test results were found.")
422 print("Log directory:", logdir)
423 sys.exit(0)
425 expected = []
426 unexpected = []
427 all_maybes = True
429 for test in list(results.keys()):
430 if results[test] == "PASS":
431 continue
433 setup = test.replace(os.path.basename(test), "setup")
434 if results[test] == "SKIP" and test != setup:
435 if setup in known and known[setup][0] == "SKIP":
436 continue
437 if setup in maybe and maybe[setup][0] == "SKIP":
438 continue
440 if (test in known and results[test] in known[test][0]):
441 expected.append(test)
442 elif test in maybe and results[test] in maybe[test][0]:
443 if results[test] == 'SKIP' or args.maybes:
444 expected.append(test)
445 elif not args.maybes:
446 unexpected.append(test)
447 else:
448 unexpected.append(test)
449 all_maybes = False
451 print("\nTests with results other than PASS that are expected:")
452 for test in sorted(expected):
453 issue_url = 'https://github.com/openzfs/zfs/issues/'
455 # Include the reason why the result is expected, given the following:
456 # 1. Suppress test results which set the "Not applicable" reason.
457 # 2. Numerical reasons are assumed to be GitHub issue numbers.
458 # 3. When an entire test group is skipped only report the setup reason.
459 if test in known:
460 if known[test][1] == na_reason:
461 continue
462 elif isinstance(known[test][1], int):
463 expect = f"{issue_url}{known[test][1]}"
464 else:
465 expect = known[test][1]
466 elif test in maybe:
467 if isinstance(maybe[test][1], int):
468 expect = f"{issue_url}{maybe[test][1]}"
469 else:
470 expect = maybe[test][1]
471 elif setup in known and known[setup][0] == "SKIP" and setup != test:
472 continue
473 elif setup in maybe and maybe[setup][0] == "SKIP" and setup != test:
474 continue
475 else:
476 expect = "UNKNOWN REASON"
477 print(f" {results[test]} {test} ({expect})")
479 print("\nTests with result of PASS that are unexpected:")
480 for test in sorted(known.keys()):
481 # We probably should not be silently ignoring the case
482 # where "test" is not in "results".
483 if test not in results or results[test] != "PASS":
484 continue
485 print(f" {results[test]} {test} (expected {known[test][0]})")
487 print("\nTests with results other than PASS that are unexpected:")
488 for test in sorted(unexpected):
489 expect = "PASS" if test not in known else known[test][0]
490 print(f" {results[test]} {test} (expected {expect})")
492 if len(unexpected) == 0:
493 sys.exit(0)
494 elif not args.maybes and all_maybes:
495 sys.exit(2)
496 else:
497 sys.exit(1)