-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests for bin programs Python-based tests for: - exr2aces - exrcheck - exrenvmap - exrheader - exrinfo - exrmakepreview - exrmaketiled - exrmultipart - exrmultiview - exrstdattr Also: - The tests require Python3 and are skipped if it's not available - The tests download test images at build time from https://github.com/AcademySoftwareFoundation/openexr-images - All programs capitialize "Usage" in their usage message - exrmultipart now prints its usage message to stderr rather than cout Signed-off-by: Cary Phillips <[email protected]> * More complete test for exrenvmap Signed-off-by: Cary Phillips <[email protected]> * Use OPENEXR_IMAGES_REPO and OPENEXR_IMAGES_TAG for test images And reference a tag on the openexr-images repo, for future-proofing Signed-off-by: Cary Phillips <[email protected]> * typo: remove main from OPENEXR_IMAGES_REPO Signed-off-by: Cary Phillips <[email protected]> --------- Signed-off-by: Cary Phillips <[email protected]>
- Loading branch information
Showing
22 changed files
with
852 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) Contributors to the OpenEXR Project. | ||
|
||
if(BUILD_TESTING) | ||
|
||
find_package(Python3 COMPONENTS Interpreter) | ||
if (NOT Python3_FOUND) | ||
message(STATUS "Python3 not found: skipping bin tests") | ||
return() | ||
endif() | ||
|
||
message(STATUS "adding bin tests") | ||
|
||
set(OPENEXR_IMAGES_REPO "https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr-images" CACHE STRING | ||
"Bin test Image repo") | ||
|
||
set(OPENEXR_IMAGES_TAG "v1.0" CACHE STRING "Bin test image repo tag") | ||
|
||
set(images_url ${OPENEXR_IMAGES_REPO}/${OPENEXR_IMAGES_TAG}) | ||
|
||
set(images | ||
TestImages/GrayRampsHorizontal.exr | ||
LuminanceChroma/Garden.exr | ||
MultiResolution/ColorCodedLevels.exr | ||
MultiResolution/WavyLinesLatLong.exr | ||
LuminanceChroma/Flowers.exr | ||
MultiView/Adjuster.exr | ||
Chromaticities/Rec709_YC.exr | ||
Chromaticities/Rec709.exr | ||
Chromaticities/XYZ_YC.exr | ||
Chromaticities/XYZ.exr | ||
TestImages/GammaChart.exr | ||
Beachball/singlepart.0001.exr | ||
v2/LeftView/Balls.exr | ||
v2/Stereo/Trunks.exr | ||
Beachball/multipart.0001.exr | ||
) | ||
|
||
foreach(image ${images}) | ||
message(STATUS "Downloading ${images_url}/${image}") | ||
file(DOWNLOAD ${images_url}/${image} ${CMAKE_CURRENT_BINARY_DIR}/${image}) | ||
endforeach() | ||
|
||
add_test(NAME OpenEXR.bin.exrinfo | ||
COMMAND ${Python3_EXECUTABLE} | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_exrinfo.py $<TARGET_FILE:exrinfo> ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
add_test(NAME OpenEXR.bin.exrheader | ||
COMMAND ${Python3_EXECUTABLE} | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_exrheader.py $<TARGET_FILE:exrheader> ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set(tests | ||
exr2aces | ||
exrenvmap | ||
exrmakepreview | ||
exrmaketiled | ||
exrmultiview | ||
exrmultipart | ||
exrstdattr | ||
) | ||
|
||
foreach(test ${tests}) | ||
|
||
add_test(NAME OpenEXR.bin.${test} | ||
COMMAND ${Python3_EXECUTABLE} | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_${test}.py $<TARGET_FILE:${test}> $<TARGET_FILE:exrinfo> ${CMAKE_CURRENT_BINARY_DIR}) | ||
endforeach() | ||
|
||
# run exrcheck on all images | ||
add_test(NAME OpenEXR.bin.exrcheck | ||
COMMAND ${Python3_EXECUTABLE} | ||
${CMAKE_CURRENT_SOURCE_DIR}/test_exrcheck.py | ||
$<TARGET_FILE:exrcheck> | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${images}) | ||
|
||
endif() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) Contributors to the OpenEXR Project. | ||
|
||
import sys, os, tempfile, atexit | ||
from subprocess import PIPE, run | ||
|
||
print(f"testing exr2aces: {sys.argv}") | ||
|
||
exr2aces = sys.argv[1] | ||
exrinfo = sys.argv[2] | ||
image_dir = sys.argv[3] | ||
|
||
# no args = usage message | ||
result = run ([exr2aces], stdout=PIPE, stderr=PIPE, universal_newlines=True) | ||
print(" ".join(result.args)) | ||
assert(result.returncode == 1) | ||
assert(result.stderr.startswith ("Usage: ")) | ||
|
||
# -h = usage message | ||
result = run ([exr2aces, "-h"], stdout=PIPE, stderr=PIPE, universal_newlines=True) | ||
print(" ".join(result.args)) | ||
assert(result.returncode == 1) | ||
assert(result.stderr.startswith ("Usage: ")) | ||
|
||
def find_line(keyword, lines): | ||
for line in lines: | ||
if line.startswith(keyword): | ||
return line | ||
return None | ||
|
||
fd, outimage = tempfile.mkstemp(".exr") | ||
os.close(fd) | ||
|
||
def cleanup(): | ||
print(f"deleting {outimage}") | ||
atexit.register(cleanup) | ||
|
||
image = f"{image_dir}/TestImages/GrayRampsHorizontal.exr" | ||
result = run ([exr2aces, "-v", image, outimage], stdout=PIPE, stderr=PIPE, universal_newlines=True) | ||
print(" ".join(result.args)) | ||
assert(result.returncode == 0) | ||
|
||
result = run ([exrinfo, "-v", outimage], stdout=PIPE, stderr=PIPE, universal_newlines=True) | ||
print(" ".join(result.args)) | ||
assert(result.returncode == 0) | ||
|
||
# confirm the output has the proper chromaticities | ||
assert("chromaticities: chromaticities r[0.7347, 0.2653] g[0, 1] b[0.0001, -0.077] w[0.32168, 0.33767]" in result.stdout) | ||
|
||
print("success") | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) Contributors to the OpenEXR Project. | ||
|
||
import sys, os | ||
from subprocess import PIPE, run | ||
|
||
print(f"testing exrcheck: {sys.argv}") | ||
|
||
exrcheck = sys.argv[1] | ||
image_dir = sys.argv[2] | ||
|
||
for exr_file in sys.argv[3:]: | ||
|
||
exr_path = f"{image_dir}/{exr_file}" | ||
|
||
result = run ([exrcheck, exr_path], stdout=PIPE, stderr=PIPE, universal_newlines=True) | ||
assert(result.returncode == 0) | ||
|
||
print("success.") | ||
|
Oops, something went wrong.