Index: LNTBased/XRay/CMakeLists.txt =================================================================== --- /dev/null +++ LNTBased/XRay/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.7) + +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-fxray-instrument COMPILER_HAS_FXRAY_INSTRUMENT) + +set(ARCH x86) + +if("${ARCH}" STREQUAL "x86" AND "${COMPILER_HAS_FXRAY_INSTRUMENT}") + add_subdirectory(benchmark-1.2.0) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wl,--gc-sections -fxray-instrument") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fxray-instrument") + add_executable(retref-bench XRay/retref-bench.cc) + target_link_libraries(retref-bench benchmark) +endif() + Index: LNTBased/XRay/TestModule =================================================================== --- /dev/null +++ LNTBased/XRay/TestModule @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -*- Python -*- + +import csv +import os +import StringIO +import subprocess + +from lnt.tests import nt +from lnt.testing import TestSamples, PASS, FAIL, XFAIL + +class Simple(nt.TestModule): + def execute_test(self, options, make_variables, config): + # build benchmark binary in obj dir + rc = subprocess.Popen( + ['cmake', options['SRCROOT']], + cwd=options['OBJROOT'], + env=os.environ.update({ + 'CXX': options['CXX'], + 'CXXFLAGS': options['CXXFLAGS'], + 'CC': options['CC'], + 'CFLAGS': options['CFLAGS']})).wait() + if rc != 0: + return TestSamples('nts.LNT/XRay/retref-bench.compile.status', [FAIL]) + + rc = subprocess.Popen( + ['make', '-j{}'.format(options['BUILD_THREADS'])], + cwd=options['OBJROOT']).wait() + if rc != 0: + return TestSamples('nts.LNT/XRay/retref-bench.compile.status', [FAIL]) + + # run benchmark binary and parse output + p = subprocess.Popen( + ['{}/{}'.format(options['OBJROOT'], 'retref-bench'), + '--benchmark_format=csv', '--benchmark_repetitions=10', + '--benchmark_report_aggregates_only=true'], + cwd=options['OBJROOT'], + env=os.environ.update({ + 'XRAY_OPTIONS': 'patch_premain=false xray_naive_log=false'}), + stdout=subprocess.PIPE) + bm_output = p.communicate() + if p.returncode != 0: + return TestSamples('nts.LNT/XRay/retref-bench.exec.status', [FAIL]) + + csv_lines = csv.reader(StringIO.StringIO(bm_output[0])) + results = [] + for line in csv_lines: + if line[0] == "name": + continue + results.append( + TestSamples('nts.LNT/XRay/retref-bench.{}.exec'.format(line[0]), + [float(line[3])])) + return results + +test_class = Simple + +if __name__ == '__main__': + test_class().main() Index: LNTBased/XRay/XRay =================================================================== --- /dev/null +++ LNTBased/XRay/XRay @@ -0,0 +1 @@ +../../MicroBenchmarks/XRay/ \ No newline at end of file Index: LNTBased/XRay/benchmark-1.2.0 =================================================================== --- /dev/null +++ LNTBased/XRay/benchmark-1.2.0 @@ -0,0 +1 @@ +../../MicroBenchmarks/libs/benchmark-1.2.0/ \ No newline at end of file