# -*- Python -*-

# Configuration file for the 'lit' test runner.

import os
import sys
import re
import platform

try:
   import lit.util
   import lit.formats
except ImportError:
   pass

# name: The name of this test suite.
config.name = 'OpenMPValidationSuite'

# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest(execute_external=False)

# suffixes: A list of file extensions to treat as test files
# Note this can be overridden by lit.local.cfg files
config.suffixes = ['.ll']

# test_source_root: The root path where tests are located.
#config.test_source_root = "/home/ichoyjx/install/openmp/testsuite/bin"
#os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
#mpvs_obj_root = getattr(config, 'mpvs_obj_root', None)
#if mpvs_obj_root is not None:
config.test_exec_root = "./"
#os.path.join(mpvs_obj_root, 'src')

# Discover the 'clang' and 'clangcc' to use.

import os

def inferClang(PATH):
    # Determine which clang to use.
    clang = os.getenv('CLANG')

    # If the user set clang in the environment, definitely use that and don't
    # try to validate.
    if clang:
        return clang

    # Otherwise look in the path.
    clang = lit.util.which('clang', PATH)

    if not clang:
        lit_config.fatal("couldn't find 'clang' program, try setting "
                         "CLANG in your environment")

    return clang

config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )

# Propogate some environment variable to test environment.
def addEnv(name):
    if name in os.environ:
        config.environment[name] = os.environ[name]

addEnv('HOME')
addEnv('PWD')


addEnv('C_INCLUDE_PATH')
addEnv('CPLUS_INCLUDE_PATH')
addEnv('LIBRARY_PATH')
addEnv('LD_LIBRARY_PATH')
addEnv('DYLD_LIBRARY_PATH')

# Check that the object root is known.
if config.test_exec_root is None:
    lit.fatal('test execution root not set!')
