# -*- Python -*-
#
# Copyright (C) 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
### Configuration file for target side debugger integration tests
#

# Set up the suite name, extensions that are recognized as testcases, and
# the target triple string that must be used in cases marked expected failures
config.name = 'host_bcc_debugger_integration'
config.suffixes = ['.cpp', '.c']
config.target_triple = 'host-bcc'

# If the user is running an individual tests directory, we have to load
# the libbcc site configuration first
build_top = getattr(config, 'build_top', None)
if build_top is None:
  lit.load_config(config, os.path.join(os.getenv('ANDROID_BUILD_TOP',
    '../../../../../'), 'frameworks', 'compile', 'libbcc', 'tests',
    'debuginfo', 'lit.site.cfg'))
  build_top = config.build_top

# Output directory in the android source tree
config.test_exec_root = os.path.join(config.build_top, 'out', 'host',
  'tests', 'bcc-host')

#
## Set up environment variables
#

# - LD_LIBRARY_PATH for finding libbcc.so from the android build
config.environment['LD_LIBRARY_PATH'] = \
  os.path.join(config.base_build_path, 'lib') + ":" + \
    config.environment['LD_LIBRARY_PATH']

# - DEBUGGER and DEBUGGER_ARGS denote how to invoke the debugger
config.environment['DEBUGGER'] = config.gdb
config.environment['DEBUGGER_ARGS'] = '-q -batch -n --args ' \
                                    + config.bcc_driver + ' -R '

if not lit.quiet:
    lit.note('using clang: %r' % config.clang)
    lit.note('using bcc driver: %r' % config.bcc_driver)
    lit.note('LD_LIBRARY_PATH is %r' % config.environment['LD_LIBRARY_PATH'])

# Apply host-side test macro substitutions
config.substitutions.append( ('%clangxx', ' ' + config.clang + \
                                ' -ccc-clang-cxx -ccc-cxx ') )

config.substitutions.append( ('%extra-clang-opts', ' -emit-llvm -c ') )

config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )