Skip to content

Commit fd3c305

Browse files
committed
tests: allow out-of-tree builds
1 parent cc12b8d commit fd3c305

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ add_custom_target(cscope cscope -bv ${ALL_SOURCES})
231231
add_custom_target(ctags ctags ${ALL_SOURCES})
232232
add_custom_target(universal-ctags ctags-universal ${ALL_SOURCES})
233233

234-
add_test(NAME unittests COMMAND make -C test/unit LIBDIR=${CMAKE_BINARY_DIR} CPATH=${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/include LIBRARY_PATH=${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/lib64
234+
add_test(NAME unittests COMMAND make -C test/unit BUILD_DIR=${CMAKE_BINARY_DIR}
235+
LIBDIR=${CMAKE_BINARY_DIR} CPATH=${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/include
236+
LIBRARY_PATH=${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/lib64
235237
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
236238
add_test(NAME test-colors COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/colors/run_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/${GPUJPEG_BIN_OUTPUT_NAME})
237239
add_test(NAME regression COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/regression/run_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/${GPUJPEG_BIN_OUTPUT_NAME})

colors/test_common.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -eu
1+
#!/bin/bash -euxv
22
#
33
# Requires FFmpeg (convert), ImageMagick (compare)
44
# Parameters
@@ -16,6 +16,7 @@ DIR=`dirname $0`
1616
GPUJPEG=${1:-$DIR/../gpujpegtool}
1717
REQUESTED_PSNR=40
1818
IMAGE=image_bt709_422.yuv
19+
TMPDIR=.
1920
#IMAGE=camera_bt709_422.yuv
2021

2122
. "$DIR/../test/common.sh" # for magick_compare
@@ -28,22 +29,27 @@ fi
2829
# Create an image from source in specified mode ()
2930
#$GPUJPEG --size=1920x1080 --colorspace=ycbcr-bt709 --pixel-format=422-u8-p1020 \
3031
# --convert $MODE $DIR/$IMAGE $DIR/$NAME.$EXTENSION
31-
ffmpeg -y -f rawvideo -pixel_format uyvy422 -video_size 1920x1080 -i $DIR/$IMAGE -f rawvideo -pix_fmt $FF_FORMAT -video_size 1920x1080 $DIR/$NAME.$EXTENSION
32+
ffmpeg -y -f rawvideo -pixel_format uyvy422 -video_size 1920x1080 -i $DIR/$IMAGE\
33+
-f rawvideo -pix_fmt $FF_FORMAT -video_size 1920x1080 $TMPDIR/$NAME.$EXTENSION
3234

3335
# Encode and Decode the image
3436
$GPUJPEG --size 1920x1080 $MODE \
35-
--encode --quality 100 $DIR/$NAME.$EXTENSION $DIR/$NAME.encoded.jpg
37+
--encode --quality 100 $TMPDIR/$NAME.$EXTENSION $TMPDIR/$NAME.encoded.jpg
3638
$GPUJPEG $MODE \
37-
--decode $DIR/$NAME.encoded.jpg $DIR/$NAME.decoded.$EXTENSION
39+
--decode $TMPDIR/$NAME.encoded.jpg $TMPDIR/$NAME.decoded.$EXTENSION
3840

3941
# Convert the Original and the Processed Image to RGB444
4042
#$GPUJPEG --size=1920x1080 $MODE \
4143
# --convert --colorspace=rgb $DIR/$NAME.$EXTENSION $DIR/$NAME.rgb
4244
#$GPUJPEG --size=1920x1080 $MODE \
4345
# --convert --colorspace=rgb $DIR/$NAME.decoded.$EXTENSION $DIR/$NAME.decoded.rgb
4446
if [ $EXTENSION != rgb ]; then
45-
ffmpeg -y -f rawvideo -pixel_format $FF_FORMAT -video_size 1920x1080 -i $DIR/$NAME.$EXTENSION -f rawvideo -pix_fmt rgb24 -video_size 1920x1080 $DIR/$NAME.rgb
46-
ffmpeg -y -f rawvideo -pixel_format $FF_FORMAT -video_size 1920x1080 -i $DIR/$NAME.decoded.$EXTENSION -f rawvideo -pix_fmt rgb24 -video_size 1920x1080 $DIR/$NAME.decoded.rgb
47+
ffmpeg -y -f rawvideo -pixel_format $FF_FORMAT -video_size 1920x1080 -i\
48+
$TMPDIR/$NAME.$EXTENSION -f rawvideo -pix_fmt rgb24 -video_size 1920x1080\
49+
$TMPDIR/$NAME.rgb
50+
ffmpeg -y -f rawvideo -pixel_format $FF_FORMAT -video_size 1920x1080 -i\
51+
$TMPDIR/$NAME.decoded.$EXTENSION -f rawvideo -pix_fmt rgb24 -video_size 1920x1080\
52+
$TMPDIR/$NAME.decoded.rgb
4753
fi
4854

4955
# Display Left/Right Diff of the Original and the Processed Image
@@ -54,5 +60,6 @@ if ! magick_compare "$DIR/$NAME.rgb" "$DIR/$NAME.decoded.rgb" \
5460
fi
5561

5662
# Delete Created Files
57-
rm -f $DIR/$NAME.$EXTENSION $DIR/$NAME.rgb $DIR/$NAME.encoded.jpg $DIR/$NAME.decoded.$EXTENSION $DIR/$NAME.decoded.rgb
63+
rm -f $TMPDIR/$NAME.$EXTENSION $TMPDIR/$NAME.rgb $TMPDIR/$NAME.encoded.jpg\
64+
$TMPDIR/$NAME.decoded.$EXTENSION $TMPDIR/$NAME.decoded.rgb
5865

test/unit/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
BUILD_DIR ?= .
12
LIBDIR ?= ../../build
23

34
all: run_tests
4-
LD_LIBRARY_PATH=$(LIBDIR) ./$<
5+
LD_LIBRARY_PATH=$(LIBDIR) $(BUILD_DIR)/$<
56

67
run_tests: $(wildcard *.c)
7-
$(CC) -g -I../.. $^ -L$(LIBDIR) -lgpujpeg -lcudart -o $@
8+
$(CC) -g -I../.. $^ -L$(LIBDIR) -lgpujpeg -lcudart -o $(BUILD_DIR)/$@
89

0 commit comments

Comments
 (0)