11cb0ef41Sopenharmony_ci// Copyright 2020 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci/** 61cb0ef41Sopenharmony_ci * @fileoverview Blacklists for fuzzer. 71cb0ef41Sopenharmony_ci */ 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci'use strict'; 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst fs = require('fs'); 121cb0ef41Sopenharmony_ciconst path = require('path'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst random = require('./random.js'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst {generatedSloppy, generatedSoftSkipped, generatedSkipped} = require( 171cb0ef41Sopenharmony_ci './generated/exceptions.js'); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciconst SKIPPED_FILES = [ 201cb0ef41Sopenharmony_ci // Disabled for unexpected test behavior, specific to d8 shell. 211cb0ef41Sopenharmony_ci 'd8-os.js', 221cb0ef41Sopenharmony_ci 'd8-readbuffer.js', 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci // Passes JS flags. 251cb0ef41Sopenharmony_ci 'd8-arguments.js', 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci // Slow tests or tests that are too large to be used as input. 281cb0ef41Sopenharmony_ci /numops-fuzz-part.*.js/, 291cb0ef41Sopenharmony_ci 'regexp-pcre.js', 301cb0ef41Sopenharmony_ci 'unicode-test.js', 311cb0ef41Sopenharmony_ci 'unicodelctest.js', 321cb0ef41Sopenharmony_ci 'unicodelctest-no-optimization.js', 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci // Unsupported modules. 351cb0ef41Sopenharmony_ci /^modules.*\.js/, 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci // Unsupported property escapes. 381cb0ef41Sopenharmony_ci /^regexp-property-.*\.js/, 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci // Bad testcases that just loads a script that always throws errors. 411cb0ef41Sopenharmony_ci 'regress-444805.js', 421cb0ef41Sopenharmony_ci 'regress-crbug-489597.js', 431cb0ef41Sopenharmony_ci 'regress-crbug-620253.js', 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci // Just recursively loads itself. 461cb0ef41Sopenharmony_ci 'regress-8510.js', 471cb0ef41Sopenharmony_ci]; 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciconst SKIPPED_DIRECTORIES = [ 501cb0ef41Sopenharmony_ci // Slow tests or tests that are too large to be used as input. 511cb0ef41Sopenharmony_ci 'embenchen', 521cb0ef41Sopenharmony_ci 'poppler', 531cb0ef41Sopenharmony_ci 'sqlite', 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci // Causes lots of failures. 561cb0ef41Sopenharmony_ci 'test262', 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci // Unavailable debug.Debug. 591cb0ef41Sopenharmony_ci 'v8/test/debugger', 601cb0ef41Sopenharmony_ci 'v8/test/inspector', 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci // Unsupported modules. 631cb0ef41Sopenharmony_ci 'v8/test/js-perf-test/Modules', 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ci // Contains tests expected to error out on parsing. 661cb0ef41Sopenharmony_ci 'v8/test/message', 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci // Needs specific dependencies for load of various tests. 691cb0ef41Sopenharmony_ci 'v8/test/mjsunit/tools', 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_ci // Unsupported e4x standard. 721cb0ef41Sopenharmony_ci 'mozilla/data/e4x', 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci // Bails out fast without ReadableStream support. 751cb0ef41Sopenharmony_ci 'spidermonkey/non262/ReadableStream', 761cb0ef41Sopenharmony_ci]; 771cb0ef41Sopenharmony_ci 781cb0ef41Sopenharmony_ci// Files used with a lower probability. 791cb0ef41Sopenharmony_ciconst SOFT_SKIPPED_FILES = [ 801cb0ef41Sopenharmony_ci // Tests with large binary content. 811cb0ef41Sopenharmony_ci /^binaryen.*\.js/, 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci // Tests slow to parse. 841cb0ef41Sopenharmony_ci // CrashTests: 851cb0ef41Sopenharmony_ci /^jquery.*\.js/, 861cb0ef41Sopenharmony_ci // Spidermonkey: 871cb0ef41Sopenharmony_ci 'regress-308085.js', 881cb0ef41Sopenharmony_ci 'regress-74474-002.js', 891cb0ef41Sopenharmony_ci 'regress-74474-003.js', 901cb0ef41Sopenharmony_ci // V8: 911cb0ef41Sopenharmony_ci 'object-literal.js', 921cb0ef41Sopenharmony_ci]; 931cb0ef41Sopenharmony_ci 941cb0ef41Sopenharmony_ci// Flags that lead to false positives or that are already passed by default. 951cb0ef41Sopenharmony_ciconst DISALLOWED_FLAGS = [ 961cb0ef41Sopenharmony_ci // Disallowed because features prefixed with "experimental" are not 971cb0ef41Sopenharmony_ci // stabilized yet and would cause too much noise when enabled. 981cb0ef41Sopenharmony_ci /^--experimental-.*/, 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_ci // Disallowed due to noise. We explicitly add --harmony to job 1011cb0ef41Sopenharmony_ci // definitions, and all of these features are staged before launch. 1021cb0ef41Sopenharmony_ci /^--harmony-.*/, 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ci // Disallowed because they are passed explicitly on the command line. 1051cb0ef41Sopenharmony_ci '--allow-natives-syntax', 1061cb0ef41Sopenharmony_ci '--debug-code', 1071cb0ef41Sopenharmony_ci '--harmony', 1081cb0ef41Sopenharmony_ci '--wasm-staging', 1091cb0ef41Sopenharmony_ci '--expose-gc', 1101cb0ef41Sopenharmony_ci '--expose_gc', 1111cb0ef41Sopenharmony_ci '--icu-data-file', 1121cb0ef41Sopenharmony_ci '--random-seed', 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ci // Disallowed due to false positives. 1151cb0ef41Sopenharmony_ci '--check-handle-count', 1161cb0ef41Sopenharmony_ci '--correctness-fuzzer-suppressions', 1171cb0ef41Sopenharmony_ci '--expose-debug-as', 1181cb0ef41Sopenharmony_ci '--expose-natives-as', 1191cb0ef41Sopenharmony_ci '--expose-trigger-failure', 1201cb0ef41Sopenharmony_ci '--mock-arraybuffer-allocator', 1211cb0ef41Sopenharmony_ci 'natives', // Used in conjuction with --expose-natives-as. 1221cb0ef41Sopenharmony_ci /^--trace-path.*/, 1231cb0ef41Sopenharmony_ci]; 1241cb0ef41Sopenharmony_ci 1251cb0ef41Sopenharmony_ci// Flags only used with 25% probability. 1261cb0ef41Sopenharmony_ciconst LOW_PROB_FLAGS_PROB = 0.25; 1271cb0ef41Sopenharmony_ciconst LOW_PROB_FLAGS = [ 1281cb0ef41Sopenharmony_ci // Flags that lead to slow test performance. 1291cb0ef41Sopenharmony_ci /^--gc-interval.*/, 1301cb0ef41Sopenharmony_ci /^--deopt-every-n-times.*/, 1311cb0ef41Sopenharmony_ci]; 1321cb0ef41Sopenharmony_ci 1331cb0ef41Sopenharmony_ci 1341cb0ef41Sopenharmony_ci// Flags printing data, leading to false positives in differential fuzzing. 1351cb0ef41Sopenharmony_ciconst DISALLOWED_DIFFERENTIAL_FUZZ_FLAGS = [ 1361cb0ef41Sopenharmony_ci /^--gc-interval.*/, 1371cb0ef41Sopenharmony_ci /^--perf.*/, 1381cb0ef41Sopenharmony_ci /^--print.*/, 1391cb0ef41Sopenharmony_ci /^--stress-runs.*/, 1401cb0ef41Sopenharmony_ci /^--trace.*/, 1411cb0ef41Sopenharmony_ci '--expose-externalize-string', 1421cb0ef41Sopenharmony_ci '--interpreted-frames-native-stack', 1431cb0ef41Sopenharmony_ci '--stress-opt', 1441cb0ef41Sopenharmony_ci '--validate-asm', 1451cb0ef41Sopenharmony_ci]; 1461cb0ef41Sopenharmony_ci 1471cb0ef41Sopenharmony_ciconst MAX_FILE_SIZE_BYTES = 128 * 1024; // 128KB 1481cb0ef41Sopenharmony_ciconst MEDIUM_FILE_SIZE_BYTES = 32 * 1024; // 32KB 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_cifunction _findMatch(iterable, candidate) { 1511cb0ef41Sopenharmony_ci for (const entry of iterable) { 1521cb0ef41Sopenharmony_ci if (typeof entry === 'string') { 1531cb0ef41Sopenharmony_ci if (entry === candidate) { 1541cb0ef41Sopenharmony_ci return true; 1551cb0ef41Sopenharmony_ci } 1561cb0ef41Sopenharmony_ci } else { 1571cb0ef41Sopenharmony_ci if (entry.test(candidate)) { 1581cb0ef41Sopenharmony_ci return true; 1591cb0ef41Sopenharmony_ci } 1601cb0ef41Sopenharmony_ci } 1611cb0ef41Sopenharmony_ci } 1621cb0ef41Sopenharmony_ci 1631cb0ef41Sopenharmony_ci return false; 1641cb0ef41Sopenharmony_ci} 1651cb0ef41Sopenharmony_ci 1661cb0ef41Sopenharmony_cifunction _doesntMatch(iterable, candidate) { 1671cb0ef41Sopenharmony_ci return !_findMatch(iterable, candidate); 1681cb0ef41Sopenharmony_ci} 1691cb0ef41Sopenharmony_ci 1701cb0ef41Sopenharmony_ci// Convert Windows path separators. 1711cb0ef41Sopenharmony_cifunction normalize(testPath) { 1721cb0ef41Sopenharmony_ci return path.normalize(testPath).replace(/\\/g, '/'); 1731cb0ef41Sopenharmony_ci} 1741cb0ef41Sopenharmony_ci 1751cb0ef41Sopenharmony_cifunction isTestSkippedAbs(absPath) { 1761cb0ef41Sopenharmony_ci const basename = path.basename(absPath); 1771cb0ef41Sopenharmony_ci if (_findMatch(SKIPPED_FILES, basename)) { 1781cb0ef41Sopenharmony_ci return true; 1791cb0ef41Sopenharmony_ci } 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ci const normalizedTestPath = normalize(absPath); 1821cb0ef41Sopenharmony_ci for (const entry of SKIPPED_DIRECTORIES) { 1831cb0ef41Sopenharmony_ci if (normalizedTestPath.includes(entry)) { 1841cb0ef41Sopenharmony_ci return true; 1851cb0ef41Sopenharmony_ci } 1861cb0ef41Sopenharmony_ci } 1871cb0ef41Sopenharmony_ci 1881cb0ef41Sopenharmony_ci // Avoid OOM/hangs through huge inputs. 1891cb0ef41Sopenharmony_ci const stat = fs.statSync(absPath); 1901cb0ef41Sopenharmony_ci return (stat && stat.size >= MAX_FILE_SIZE_BYTES); 1911cb0ef41Sopenharmony_ci} 1921cb0ef41Sopenharmony_ci 1931cb0ef41Sopenharmony_cifunction isTestSkippedRel(relPath) { 1941cb0ef41Sopenharmony_ci return generatedSkipped.has(normalize(relPath)); 1951cb0ef41Sopenharmony_ci} 1961cb0ef41Sopenharmony_ci 1971cb0ef41Sopenharmony_ci// For testing. 1981cb0ef41Sopenharmony_cifunction getSoftSkipped() { 1991cb0ef41Sopenharmony_ci return SOFT_SKIPPED_FILES; 2001cb0ef41Sopenharmony_ci} 2011cb0ef41Sopenharmony_ci 2021cb0ef41Sopenharmony_ci// For testing. 2031cb0ef41Sopenharmony_cifunction getGeneratedSoftSkipped() { 2041cb0ef41Sopenharmony_ci return generatedSoftSkipped; 2051cb0ef41Sopenharmony_ci} 2061cb0ef41Sopenharmony_ci 2071cb0ef41Sopenharmony_ci// For testing. 2081cb0ef41Sopenharmony_cifunction getGeneratedSloppy() { 2091cb0ef41Sopenharmony_ci return generatedSloppy; 2101cb0ef41Sopenharmony_ci} 2111cb0ef41Sopenharmony_ci 2121cb0ef41Sopenharmony_cifunction isTestSoftSkippedAbs(absPath) { 2131cb0ef41Sopenharmony_ci const basename = path.basename(absPath); 2141cb0ef41Sopenharmony_ci if (_findMatch(this.getSoftSkipped(), basename)) { 2151cb0ef41Sopenharmony_ci return true; 2161cb0ef41Sopenharmony_ci } 2171cb0ef41Sopenharmony_ci 2181cb0ef41Sopenharmony_ci // Graylist medium size files. 2191cb0ef41Sopenharmony_ci const stat = fs.statSync(absPath); 2201cb0ef41Sopenharmony_ci return (stat && stat.size >= MEDIUM_FILE_SIZE_BYTES); 2211cb0ef41Sopenharmony_ci} 2221cb0ef41Sopenharmony_ci 2231cb0ef41Sopenharmony_cifunction isTestSoftSkippedRel(relPath) { 2241cb0ef41Sopenharmony_ci return this.getGeneratedSoftSkipped().has(normalize(relPath)); 2251cb0ef41Sopenharmony_ci} 2261cb0ef41Sopenharmony_ci 2271cb0ef41Sopenharmony_cifunction isTestSloppyRel(relPath) { 2281cb0ef41Sopenharmony_ci return this.getGeneratedSloppy().has(normalize(relPath)); 2291cb0ef41Sopenharmony_ci} 2301cb0ef41Sopenharmony_ci 2311cb0ef41Sopenharmony_cifunction filterFlags(flags) { 2321cb0ef41Sopenharmony_ci return flags.filter(flag => { 2331cb0ef41Sopenharmony_ci return ( 2341cb0ef41Sopenharmony_ci _doesntMatch(DISALLOWED_FLAGS, flag) && 2351cb0ef41Sopenharmony_ci (_doesntMatch(LOW_PROB_FLAGS, flag) || 2361cb0ef41Sopenharmony_ci random.choose(LOW_PROB_FLAGS_PROB))); 2371cb0ef41Sopenharmony_ci }); 2381cb0ef41Sopenharmony_ci} 2391cb0ef41Sopenharmony_ci 2401cb0ef41Sopenharmony_cifunction filterDifferentialFuzzFlags(flags) { 2411cb0ef41Sopenharmony_ci return flags.filter( 2421cb0ef41Sopenharmony_ci flag => _doesntMatch(DISALLOWED_DIFFERENTIAL_FUZZ_FLAGS, flag)); 2431cb0ef41Sopenharmony_ci} 2441cb0ef41Sopenharmony_ci 2451cb0ef41Sopenharmony_ci 2461cb0ef41Sopenharmony_cimodule.exports = { 2471cb0ef41Sopenharmony_ci filterDifferentialFuzzFlags: filterDifferentialFuzzFlags, 2481cb0ef41Sopenharmony_ci filterFlags: filterFlags, 2491cb0ef41Sopenharmony_ci getGeneratedSoftSkipped: getGeneratedSoftSkipped, 2501cb0ef41Sopenharmony_ci getGeneratedSloppy: getGeneratedSloppy, 2511cb0ef41Sopenharmony_ci getSoftSkipped: getSoftSkipped, 2521cb0ef41Sopenharmony_ci isTestSkippedAbs: isTestSkippedAbs, 2531cb0ef41Sopenharmony_ci isTestSkippedRel: isTestSkippedRel, 2541cb0ef41Sopenharmony_ci isTestSoftSkippedAbs: isTestSoftSkippedAbs, 2551cb0ef41Sopenharmony_ci isTestSoftSkippedRel: isTestSoftSkippedRel, 2561cb0ef41Sopenharmony_ci isTestSloppyRel: isTestSloppyRel, 2571cb0ef41Sopenharmony_ci} 258