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