Skip to content

Commit f74601f

Browse files
committed
cmake: Specify reference outputs in llvm_test_data()
Specify reference outputs in llvm_test_data() so they get copied to the builddir and used from there. Differential Revision: https://reviews.llvm.org/D51048 llvm-svn: 341255
1 parent 5b54aad commit f74601f

File tree

10 files changed

+91
-39
lines changed

10 files changed

+91
-39
lines changed

MicroBenchmarks/ImageProcessing/AnisotropicDiffusion/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
33
list(APPEND CXXFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
44
list(APPEND LDFLAGS -lm)
55

6-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/anisotropicDiffusionOutput.txt")
7-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/anisotropicDiffusionOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/anisotropicDiffusion.reference_output")
6+
llvm_test_verify_hash_program_output(anisotropicDiffusionOutput.txt)
7+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
8+
${FPCMP} anisotropicDiffusion.reference_output anisotropicDiffusionOutput.txt
9+
)
810

911
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
1012
llvm_test_executable(AnisotropicDiffusion ../utils/ImageHelper.cpp ../utils/glibc_compat_rand.c main.cpp anisotropicDiffusionKernel.c)
13+
llvm_test_data(AnisotropicDiffusion anisotropicDiffusion.reference_output)
1114

1215
target_link_libraries(AnisotropicDiffusion benchmark)

MicroBenchmarks/ImageProcessing/BilateralFiltering/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
22
list(APPEND CPPFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
33
list(APPEND LDFLAGS -lm)
44

5-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/bilateralFilterOutput.txt")
6-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/bilateralFilterOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/bilateralFilter.reference_output")
5+
llvm_test_verify_hash_program_output(bilateralFilterOutput.txt)
6+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
7+
${FPCMP} bilateralFilter.reference_output bilateralFilterOutput.txt
8+
)
79

810
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
911
llvm_test_executable(BilateralFilter ../utils/ImageHelper.cpp ../utils/glibc_compat_rand.c main.cpp bilateralFilterKernel.c)
12+
llvm_test_data(BilateralFilter bilateralFilter.reference_output)
1013

1114
target_link_libraries(BilateralFilter benchmark)

MicroBenchmarks/ImageProcessing/Blur/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
33
list(APPEND CPPFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
44
list(APPEND LDFLAGS -lm)
55

6-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/boxBlurOutput.txt")
7-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/boxBlurOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/boxBlur.reference_output")
6+
llvm_test_verify_hash_program_output(boxBlurOutput.txt)
7+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
8+
${FPCMP} boxBlur.reference_output boxBlurOutput.txt
9+
)
810

9-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/gaussianBlurOutput.txt")
10-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/gaussianBlurOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/gaussianBlur.reference_output")
11+
llvm_test_verify_hash_program_output(gaussianBlurOutput.txt)
12+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
13+
${FPCMP} gaussianBlur.reference_output gaussianBlurOutput.txt
14+
)
1115

1216
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
1317
llvm_test_executable(blur ../utils/ImageHelper.cpp ../utils/glibc_compat_rand.c main.cpp boxBlurKernel.c gaussianBlurKernel.c)
18+
llvm_test_data(blur boxBlur.reference_output gaussianBlur.reference_output)
1419

1520
target_link_libraries(blur benchmark)
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
22
list(APPEND CPPFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
33

4-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/dilateOutput.txt")
5-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/dilateOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/dilate.reference_output")
4+
llvm_test_verify_hash_program_output(dilateOutput.txt)
5+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
6+
${FPCMP} dilate.reference_output dilateOutput.txt
7+
)
68

79
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
810

911
llvm_test_executable(Dilate ../utils/ImageHelper.cpp ../utils/glibc_compat_rand.c main.cpp dilateKernel.c)
12+
llvm_test_data(Dilate dilate.reference_output)
1013

1114
target_link_libraries(Dilate benchmark)

MicroBenchmarks/ImageProcessing/Dither/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
22
list(APPEND CPPFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
33
list(APPEND LDFLAGS -lm)
44

5-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/orderedOutput.txt")
6-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/orderedOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/orderedDither.reference_output")
5+
llvm_test_verify_hash_program_output(orderedOutput.txt)
6+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
7+
${FPCMP} orderedDither.reference_output orderedOutput.txt
8+
)
79

8-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/floydOutput.txt")
9-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/floydOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/floydDither.reference_output")
10+
llvm_test_verify_hash_program_output(floydOutput.txt)
11+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
12+
${FPCMP} floydDither.reference_output floydOutput.txt
13+
)
1014

1115
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
1216
llvm_test_executable(Dither main.cpp orderedDitherKernel.c floydDitherKernel.c ../utils/ImageHelper.cpp ../utils/glibc_compat_rand.c)
17+
llvm_test_data(Dither orderedDither.reference_output floydDither.reference_output)
1318

1419
target_link_libraries(Dither benchmark)
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
set(IMAGEPROC_UTILS MicroBenchmarks/ImageProcessing/utils)
22
list(APPEND CXXFLAGS -I ${CMAKE_SOURCE_DIR}/${IMAGEPROC_UTILS})
33

4-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/bicubicOutput.txt")
5-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/bicubicOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/bicubic.reference_output")
4+
llvm_test_verify_hash_program_output(bicubicOutput.txt)
5+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
6+
${FPCMP} bicubic.reference_output bicubicOutput.txt
7+
)
68

7-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/bilinearOutput.txt")
8-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/bilinearOutput.txt ${CMAKE_CURRENT_SOURCE_DIR}/bilinear.reference_output")
9+
llvm_test_verify_hash_program_output(bilinearOutput.txt)
10+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
11+
${FPCMP} bilinear.reference_output bilinearOutput.txt
12+
)
913

1014
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
1115
llvm_test_executable(Interpolation bicubicKernel.c bilinearKernel.c main.cpp ../utils/ImageHelper.cpp ../utils/glibc_compat_rand.c)
16+
llvm_test_data(Interpolation bicubic.reference_output bilinear.reference_output)
1217

1318
target_link_libraries(Interpolation benchmark)

MicroBenchmarks/harris/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
list(APPEND CPPFLAGS -std=c++11 -ffast-math)
22

3-
set(REFERENCE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/harris.reference_output)
4-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${CMAKE_CURRENT_BINARY_DIR}/output.txt")
5-
llvm_test_verify("${FPCMP} ${CMAKE_CURRENT_BINARY_DIR}/output.txt ${REFERENCE_OUTPUT}")
3+
llvm_test_verify_hash_program_output(output.txt)
4+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
5+
${FPCMP} harris.reference_output output.txt
6+
)
67
llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
7-
llvm_test_executable(harris harrisKernel.cpp main.cpp)
8+
llvm_test_executable(harris harrisKernel.cpp main.cpp)
89
target_link_libraries(harris benchmark)
10+
llvm_test_data(harris harris.reference_output)

cmake/modules/SingleMultiSource.cmake

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ function(llvm_singlesource)
3737
endif()
3838
foreach(source ${sources})
3939
basename(name ${source})
40-
llvm_test_traditional(${name})
4140
set(_target ${_LSARG_PREFIX}${name})
42-
llvm_test_executable(${_target} ${source})
41+
llvm_test_executable_no_test(${_target} ${source})
42+
set_property(TARGET ${_target} PROPERTY TEST_NAME ${name})
43+
llvm_test_traditional(${_target})
44+
llvm_add_test_for_target(${_target})
4345
endforeach()
4446
endfunction()
4547

@@ -52,10 +54,17 @@ function(llvm_multisource target)
5254
file(GLOB sources *.c *.cpp *.cc)
5355
endif()
5456

57+
llvm_test_executable_no_test(${target} ${sources})
5558
llvm_test_traditional(${target})
56-
llvm_test_executable(${target} ${sources})
59+
llvm_add_test_for_target(${target})
5760
endfunction()
5861

62+
macro(llvm_test_verify_hash_program_output _file)
63+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
64+
${CMAKE_SOURCE_DIR}/HashProgramOutput.sh ${_file}
65+
)
66+
endmacro()
67+
5968
# Sets Var to ${name} with directory and shortest extension removed.
6069
macro(basename Var name)
6170
# strip directory name
@@ -67,14 +76,19 @@ endmacro()
6776
# Traditionally CMakeLists.txt files would set RUN_OPTIONS, SMALL_PROBLEM_SIZE,
6877
# HASH_PROGRAM_OUTPUT, etc.
6978
# Create llvm_test_run() and llvm_test_verify() invocation for that.
70-
function(llvm_test_traditional name)
79+
function(llvm_test_traditional target)
80+
get_property(name TARGET ${target} PROPERTY TEST_NAME)
81+
if(NOT name)
82+
set(name ${target})
83+
endif()
84+
7185
# Always run in the same directory as the executable
7286
list(INSERT RUN_OPTIONS 0 WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
7387
llvm_test_run(${RUN_OPTIONS})
7488

7589
# Hash if we've been asked to.
7690
if(HASH_PROGRAM_OUTPUT)
77-
llvm_test_verify("${CMAKE_SOURCE_DIR}/HashProgramOutput.sh %o")
91+
llvm_test_verify_hash_program_output(%o)
7892
endif()
7993

8094
# Find the reference output file key name.
@@ -88,13 +102,13 @@ function(llvm_test_traditional name)
88102
endif()
89103

90104
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output.${ENDIAN}-endian.${SIZE_SUFFIX})
91-
set(REFERENCE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output.${ENDIAN}-endian.${SIZE_SUFFIX})
105+
set(REFERENCE_OUTPUT ${name}.reference_output.${ENDIAN}-endian.${SIZE_SUFFIX})
92106
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output.${SIZE_SUFFIX})
93-
set(REFERENCE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output.${SIZE_SUFFIX})
107+
set(REFERENCE_OUTPUT ${name}.reference_output.${SIZE_SUFFIX})
94108
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output.${ENDIAN}-endian)
95-
set(REFERENCE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output.${ENDIAN}-endian)
109+
set(REFERENCE_OUTPUT ${name}.reference_output.${ENDIAN}-endian)
96110
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output)
97-
set(REFERENCE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${name}.reference_output)
111+
set(REFERENCE_OUTPUT ${name}.reference_output)
98112
else()
99113
message("-- No reference output found for test ${name}")
100114
endif()
@@ -108,7 +122,10 @@ function(llvm_test_traditional name)
108122
if(FP_ABSTOLERANCE)
109123
set(DIFFPROG "${DIFFPROG} -a ${FP_ABSTOLERANCE}")
110124
endif()
111-
llvm_test_verify("${DIFFPROG} %o ${REFERENCE_OUTPUT}")
125+
llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
126+
${DIFFPROG} %o ${REFERENCE_OUTPUT}
127+
)
128+
llvm_test_data(${target} ${REFERENCE_OUTPUT})
112129
endif()
113130
set(TESTSCRIPT "${TESTSCRIPT}" PARENT_SCOPE)
114131
endfunction()

cmake/modules/TestFile.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ function(llvm_add_test testfile executable)
8888
# flush the test script
8989
set(TESTSCRIPT "" PARENT_SCOPE)
9090
endfunction()
91+
92+
function(llvm_add_test_for_target target)
93+
llvm_add_test($<TARGET_FILE:${target}>.test $<TARGET_FILE:${target}>)
94+
set(TESTSCRIPT "" PARENT_SCOPE)
95+
endfunction()

cmake/modules/TestSuite.cmake

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ function(llvm_test_data target)
3434
endforeach()
3535
endfunction()
3636

37-
# Creates a new executable build target. Use this instead of `add_executable`.
38-
# It applies CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS. Creates a .test file if
39-
# necessary, registers the target with the TEST_SUITE_TARGETS list and makes
40-
# sure we build the required dependencies for compiletime measurements
41-
# and support the TEST_SUITE_PROFILE_USE mode.
42-
function(llvm_test_executable target)
37+
function(llvm_test_executable_no_test target)
4338
add_executable(${target} ${ARGN})
4439
append_target_flags(COMPILE_FLAGS ${target} ${CFLAGS})
4540
append_target_flags(COMPILE_FLAGS ${target} ${CPPFLAGS})
@@ -54,8 +49,17 @@ function(llvm_test_executable target)
5449
endif()
5550

5651
set_property(GLOBAL APPEND PROPERTY TEST_SUITE_TARGETS ${target})
57-
llvm_add_test(${CMAKE_CURRENT_BINARY_DIR}/${target}.test ${target_path})
5852
test_suite_add_build_dependencies(${target})
53+
endfunction()
54+
55+
# Creates a new executable build target. Use this instead of `add_executable`.
56+
# It applies CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS. Creates a .test file if
57+
# necessary, registers the target with the TEST_SUITE_TARGETS list and makes
58+
# sure we build the required dependencies for compiletime measurements
59+
# and support the TEST_SUITE_PROFILE_USE mode.
60+
function(llvm_test_executable target)
61+
llvm_test_executable_no_test(${target} ${ARGN})
62+
llvm_add_test_for_target(${target})
5963
set(TESTSCRIPT "" PARENT_SCOPE)
6064
endfunction()
6165

0 commit comments

Comments
 (0)