add support for running 'alive-tv' tests within 'ninja check'
RENAME
tests/memcpy/1-src.ll
tests/alive-tv/memcpy-1.src.ll
RENAME
tests/memcpy/2-tgt.ll
tests/alive-tv/memcpy-1.tgt.ll
RENAME
tests/memcpy/3-src.ll
tests/alive-tv/memcpy-memset-1.src.ll
RENAME
tests/memcpy/1-tgt.ll
tests/alive-tv/memcpy-memset-1.tgt.ll
RENAME
tests/memcpy/4-src.ll
tests/alive-tv/memcpy-memset-2.src.ll
RENAME
tests/memcpy/4-tgt.ll
tests/alive-tv/memcpy-memset-2.tgt.ll
RENAME
tests/memcpy/2-src.ll
tests/alive-tv/memset-1.src.ll
RENAME
tests/memcpy/3-tgt.ll
tests/alive-tv/memset-1.tgt.ll
define i8 @f() {
- ret i8 1
+ ret i8 3
}

MODIFY
tests/lit.cfg.py
tests/lit.cfg.py
import os
-import sys
import lit.formats
config.name = 'Alive2'
-
config.test_format = lit.formats.Alive2Test()
-config.suffixes = ['.opt']
config.test_source_root = os.path.dirname(__file__)

MODIFY
tests/lit/lit/formats/alive2test.py
tests/lit/lit/formats/alive2test.py
import lit.TestRunner
import lit.util
-from .base import FileBasedTest
-import re, signal, string, subprocess
+from .base import TestFormat
+import os, re, signal, string, subprocess
def executeCommand(command):
@@ -35,14 +35,35 @@ def readFile(path):
return fd.read()
-class Alive2Test(FileBasedTest):
+class Alive2Test(TestFormat):
def __init__(self):
self.regex_errs = re.compile(r";\s*(ERROR:.*)")
self.regex_args = re.compile(r";\s*TEST-ARGS:(.*)")
+ def getTestsInDirectory(self, testSuite, path_in_suite,
+ litConfig, localConfig):
+ source_path = testSuite.getSourcePath(path_in_suite)
+ for filename in os.listdir(source_path):
+ filepath = os.path.join(source_path, filename)
+ if not filename.startswith('.') and \
+ not os.path.isdir(filepath) and \
+ (filename.endswith('.opt') or filename.endswith('.src.ll')):
+ yield lit.Test.Test(testSuite, path_in_suite + (filename,), localConfig)
+
+
def execute(self, test, litConfig):
test = test.getSourcePath()
+
+ alive_tv = test.endswith('.src.ll')
+ if alive_tv:
+ cmd = ['./alive-tv']
+ ok_string = 'Transformation seems to be correct!'
+ if not os.path.isfile('alive-tv'):
+ return lit.Test.UNSUPPORTED, ''
+ else:
cmd = ['./alive']
+ ok_string = 'Optimization is correct!'
+
input = readFile(test)
# add test-specific args
@@ -51,11 +72,13 @@ class Alive2Test(FileBasedTest):
cmd += m.group(1).split()
cmd.append(test)
+ if alive_tv:
+ cmd.append(test.replace('.src.ll', '.tgt.ll'))
out, err, exitCode = executeCommand(cmd)
m = self.regex_errs.search(input)
if m == None:
- if exitCode == 0 and string.find(out, 'Optimization is correct!') != -1:
+ if exitCode == 0 and string.find(out + err, ok_string) != -1:
return lit.Test.PASS, ''
return lit.Test.FAIL, out + err

add support for running 'alive-tv' tests within 'ninja check'