11cb0ef41Sopenharmony_ci// Copyright 2018 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// Wrapper loading javascript tests passed as arguments used by gc fuzzer. 71cb0ef41Sopenharmony_ci// It ignores all exceptions and run tests in a separate namespaces. 81cb0ef41Sopenharmony_ci// 91cb0ef41Sopenharmony_ci// It can't prevent %AbortJS function from aborting execution, so it should be 101cb0ef41Sopenharmony_ci// used with d8's --disable-abortjs flag to ignore all possible errors inside 111cb0ef41Sopenharmony_ci// tests. 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci// We use -- as an additional separator for test preamble files and test files. 141cb0ef41Sopenharmony_ci// The preamble files (before --) will be loaded in each realm before each 151cb0ef41Sopenharmony_ci// test. 161cb0ef41Sopenharmony_civar separator = arguments.indexOf("--") 171cb0ef41Sopenharmony_civar preamble = arguments.slice(0, separator) 181cb0ef41Sopenharmony_civar tests = arguments.slice(separator + 1) 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_civar preambleString = "" 211cb0ef41Sopenharmony_cifor (let jstest of preamble) { 221cb0ef41Sopenharmony_ci preambleString += "d8.file.execute(\"" + jstest + "\");" 231cb0ef41Sopenharmony_ci} 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cifor (let jstest of tests) { 261cb0ef41Sopenharmony_ci print("Loading " + jstest); 271cb0ef41Sopenharmony_ci let start = performance.now(); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci // anonymous function to not populate global namespace. 301cb0ef41Sopenharmony_ci (function () { 311cb0ef41Sopenharmony_ci let realm = Realm.create(); 321cb0ef41Sopenharmony_ci try { 331cb0ef41Sopenharmony_ci Realm.eval(realm, preambleString + "d8.file.execute(\"" + jstest + "\");"); 341cb0ef41Sopenharmony_ci } catch (err) { 351cb0ef41Sopenharmony_ci // ignore all errors 361cb0ef41Sopenharmony_ci } 371cb0ef41Sopenharmony_ci Realm.dispose(realm); 381cb0ef41Sopenharmony_ci })(); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci let durationSec = ((performance.now() - start) / 1000.0).toFixed(2); 411cb0ef41Sopenharmony_ci print("Duration " + durationSec + "s"); 421cb0ef41Sopenharmony_ci} 43