Skip to content

Commit

Permalink
Add DEBUG build and test to the Travis-CI matrix.
Browse files Browse the repository at this point in the history
And fix any warnings or tests that fail only in debug mode.
Spruce up the testsuite/runtests.py script to make it easier to discern
what's going wrong just from the console output that Travis prints.
  • Loading branch information
lgritz committed Jan 11, 2016
1 parent 1dd3fcf commit d8d7465
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
- WHICHGCC=5 BUILD_FLAGS="USE_CPP11=1"
- WHICHGCC=4.8 OIIOBRANCH=release BUILD_FLAGS=""
- WHICHGCC=4.8 OIIOBRANCH=release BUILD_FLAGS="USE_CPP11=1"
- WHICHGCC=4.8 BUILD_FLAGS="" DEBUG=1

# Add-ons: specify apt packages for Linux
addons:
Expand Down Expand Up @@ -55,6 +56,7 @@ before_install:
export PLATFORM=linux64 ;
cat /proc/cpuinfo ;
fi
- if [ $DEBUG == 1 ] ; then export PLATFORM=${PLATFORM}.debug ; fi
- echo "Build platform name is $PLATFORM"

install:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,18 @@ endif
# 'make dist' is just a synonym for 'make cmakeinstall'
dist : cmakeinstall

TEST_FLAGS += --force-new-ctest-process --output-on-failure

# 'make test' does a full build and then runs all tests
test: cmake
${CMAKE} -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests ${TEST_FLAGS}..."
( cd ${build_dir} ; ctest --force-new-ctest-process -E broken ${TEST_FLAGS} )
( cd ${build_dir} ; ctest -E broken ${TEST_FLAGS} )

# 'make testall' does a full build and then runs all tests (even the ones
# that are expected to fail on some platforms)
testall: cmake
${CMAKE} -E cmake_echo_color --switch=$(COLOR) --cyan "Running all tests ${TEST_FLAGS}..."
( cd ${build_dir} ; ctest --force-new-ctest-process ${TEST_FLAGS} )
( cd ${build_dir} ; ctest ${TEST_FLAGS} )

#clean: testclean
# 'make clean' clears out the build directory for this platform
Expand Down
10 changes: 5 additions & 5 deletions src/liboslexec/shadingsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2094,11 +2094,11 @@ ShadingSystemImpl::ShaderGroupBegin (string_view groupname,
}
string_view paramname (paramname_string);
int lockgeom = true;
// For speed, reserve space. Note that for "unsized" arrays,
// numelements() will return 1, so we only preallocate 1 slot
// and let it grow as needed. That's ok. For everything else, we
// will reserve the right amount up front.
int vals_to_preallocate = type.numelements() * type.aggregate;
// For speed, reserve space. Note that for "unsized" arrays, we only
// preallocate 1 slot and let it grow as needed. That's ok. For
// everything else, we will reserve the right amount up front.
int vals_to_preallocate = type.is_unsized_array()
? 1 : type.numelements() * type.aggregate;
// Stop parsing values when we hit the limit based on the
// declaration.
int max_vals = type.is_unsized_array() ? 1<<28 : vals_to_preallocate;
Expand Down
Binary file modified testsuite/common/textures/mandrill.tif
Binary file not shown.
2 changes: 1 addition & 1 deletion testsuite/render-cornell/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python

failthresh = 0.005 # allow a little more LSB noise between platforms
failthresh = max (failthresh, 0.005) # allow a little more LSB noise between platforms
outputs = [ "out.exr" ]
command = testrender("-r 256 256 -aa 4 cornell.xml out.exr")
66 changes: 52 additions & 14 deletions testsuite/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@
hardfail = 0.01
failpercent = 0.02

if "TRAVIS" in os.environ and os.environ["TRAVIS"] :
failthresh *= 2.0
hardfail *= 2.0
failpercent *= 2.0

compile_osl_files = True
splitsymbol = ';'

Expand Down Expand Up @@ -109,6 +104,12 @@ def osl_app (app):
return path + "/src/" + app + "/" + app + " "


def oiio_relpath (path, start=os.curdir):
"Wrapper around os.path.relpath which always uses '/' as the separator."
p = os.path.relpath (path, start)
return p if sys.platform != "win32" else p.replace ('\\', '/')


def oiio_app (app):
if os.environ.__contains__('OPENIMAGEIOHOME') :
return os.path.join (os.environ['OPENIMAGEIOHOME'], "bin", app) + " "
Expand Down Expand Up @@ -139,6 +140,25 @@ def oiiotool (args) :
def maketx (args) :
return (oiio_app("maketx") + args + " >> out.txt 2>&1 ;\n")

# Construct a command that will compare two images, appending output to
# the file "out.txt". We allow a small number of pixels to have up to
# 1 LSB (8 bit) error, it's very hard to make different platforms and
# compilers always match to every last floating point bit.
def oiiodiff (fileA, fileB, extraargs="", silent=True, concat=True) :
command = (oiio_app("idiff") + "-a"
+ " -fail " + str(failthresh)
+ " -failpercent " + str(failpercent)
+ " -hardfail " + str(hardfail)
+ " -warn " + str(2*failthresh)
+ " -warnpercent " + str(failpercent)
+ " " + extraargs + " " + oiio_relpath(fileA,tmpdir)
+ " " + oiio_relpath(fileB,tmpdir))
if not silent :
command += " >> out.txt 2>&1 "
if concat:
command += " ;\n"
return command


# Construct a command that run testshade with the specified arguments,
# appending output to the file "out.txt".
Expand Down Expand Up @@ -204,12 +224,7 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) :
# print ("comparing " + out + " to " + testfile)
if extension == ".tif" or extension == ".exr" :
# images -- use idiff
cmpcommand = (os.path.join (os.environ['OPENIMAGEIOHOME'], "bin", "idiff")
+ " -fail " + str(failthresh)
+ " -failpercent " + str(failpercent)
+ " -hardfail " + str(hardfail)
+ " -warn " + str(2*failthresh)
+ " " + out + " " + testfile)
cmpcommand = oiiodiff (out, testfile, concat=False, silent=True)
# print "cmpcommand = " + cmpcommand
cmpresult = os.system (cmpcommand)
elif extension == ".txt" :
Expand All @@ -218,14 +233,29 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) :
# anything else
cmpresult = 0 if filecmp.cmp (out, testfile) else 1
if cmpresult == 0 :
print ("PASS: " + out + " matches " + testfile)
ok = 1
break # we're done

if ok == 0:

if ok :
# if extension == ".tif" or extension == ".exr" or extension == ".jpg" or extension == ".png":
# # If we got a match for an image, save the idiff results
# os.system (oiiodiff (out, testfile, silent=False))
print ("PASS: " + out + " matches " + testfile)
else :
err = 1
print "NO MATCH for " + out
print "FAIL " + out
if extension == ".txt" :
# If we failed to get a match for a text file, print the
# file and the diff, for easy debugging.
print ("-----" + out + "----->")
print (open(out,'r').read() + "<----------")
print ("Diff was:\n-------")
print (open (out+".diff", 'rU').read())
if extension == ".tif" or extension == ".exr" or extension == ".jpg" or extension == ".png":
# If we failed to get a match for an image, send the idiff
# results to the console
os.system (oiiodiff (out, os.path.join ("ref", out), silent=False))

return (err)

Expand All @@ -241,6 +271,14 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) :
if os.path.exists("run.py") :
execfile ("run.py")

# Allow a little more slop for slight pixel differences when in DEBUG
# mode or when running on remote Travis-CI machines.
if (("TRAVIS" in os.environ and os.environ["TRAVIS"]) or
("DEBUG" in os.environ and os.environ["DEBUG"])) :
failthresh *= 2.0
hardfail *= 2.0
failpercent *= 2.0

# Force out.txt to be in the outputs
##if "out.txt" not in outputs :
## outputs.append ("out.txt")
Expand Down

0 comments on commit d8d7465

Please sign in to comment.