1 # Copyright 2014 the V8 project authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 6 import os 7 import shutil 8 import sys 9 10 from testrunner.local import testsuite 11 from testrunner.objects import testcase 12 13 SIMDJS_SUITE_PATH = ["data", "src"] 14 15 16 class SimdJsTestSuite(testsuite.TestSuite): 17 18 def __init__(self, name, root): 19 super(SimdJsTestSuite, self).__init__(name, root) 20 self.testroot = os.path.join(self.root, *SIMDJS_SUITE_PATH) 21 self.ParseTestRecord = None 22 23 def ListTests(self, context): 24 tests = [ 25 testcase.TestCase(self, 'shell_test_runner'), 26 ] 27 for filename in os.listdir(os.path.join(self.testroot, 'benchmarks')): 28 if (not filename.endswith('.js') or 29 filename in ['run.js', 'run_browser.js', 'base.js']): 30 continue 31 name = filename.rsplit('.')[0] 32 tests.append( 33 testcase.TestCase(self, 'benchmarks/' + name)) 34 return tests 35 36 def GetFlagsForTestCase(self, testcase, context): 37 return (testcase.flags + context.mode_flags + 38 [os.path.join(self.root, "harness-adapt.js"), 39 "--harmony", "--harmony-simd", 40 os.path.join(self.testroot, testcase.path + ".js"), 41 os.path.join(self.root, "harness-finish.js")]) 42 43 def GetSourceForTest(self, testcase): 44 filename = os.path.join(self.testroot, testcase.path + ".js") 45 with open(filename) as f: 46 return f.read() 47 48 def IsNegativeTest(self, testcase): 49 return False 50 51 def IsFailureOutput(self, testcase): 52 if testcase.output.exit_code != 0: 53 return True 54 return "FAILED!" in testcase.output.stdout 55 56 def DownloadData(self): 57 print "SimdJs download is deprecated. It's part of DEPS." 58 59 # Clean up old directories and archive files. 60 directory_old_name = os.path.join(self.root, "data.old") 61 if os.path.exists(directory_old_name): 62 shutil.rmtree(directory_old_name) 63 64 archive_files = [f for f in os.listdir(self.root) 65 if f.startswith("ecmascript_simd-")] 66 if len(archive_files) > 0: 67 print "Clobber outdated test archives ..." 68 for f in archive_files: 69 os.remove(os.path.join(self.root, f)) 70 71 72 def GetSuite(name, root): 73 return SimdJsTestSuite(name, root) 74