From f7df24d9b950271d0eacec835c415e4f43fa5a30 Mon Sep 17 00:00:00 2001 From: Frederich Munch Date: Sun, 17 Dec 2017 17:55:29 -0500 Subject: [PATCH 1/2] Add ability for testsuite to pass tests that fail diffs. --- testsuite/runtest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/testsuite/runtest.py b/testsuite/runtest.py index a4ad60fae..fac236fb7 100755 --- a/testsuite/runtest.py +++ b/testsuite/runtest.py @@ -52,6 +52,11 @@ hardfail = 0.01 failpercent = 0.02 +# Fail on stage1 : oslc +failstage1 = 1 +# Fail on stage2 : diff / ref comaprison +failstage2 = 2 + image_extensions = [ ".tif", ".tx", ".exr", ".jpg", ".png", ".rla", ".dpx", ".iff", ".psd" ] @@ -232,7 +237,7 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) : for sub_command in command.split(splitsymbol): cmdret = subprocess.call (sub_command, shell=True, env=test_environ) - if cmdret != 0 and failureok == 0 : + if cmdret != 0 and failureok != failstage1 : print "#### Error: this command failed: ", sub_command print "FAIL" return (1) @@ -257,7 +262,8 @@ def runtest (command, outputs, failureok=0, failthresh=0, failpercent=0) : else : # anything else cmpresult = 0 if filecmp.cmp (out, testfile) else 1 - if cmpresult == 0 : + # cmpresult should be 0 (no error), unless expected to fail the diff + if cmpresult == 0 if failureok != failstage2 else cmpresult != 0: ok = 1 break # we're done From c52a27e28f9a3514540aa5e98d39e6c5b97f599b Mon Sep 17 00:00:00 2001 From: Frederich Munch Date: Sun, 17 Dec 2017 17:51:52 -0500 Subject: [PATCH 2/2] Add test for indexed structure assignment bug. --- CMakeLists.txt | 1 + testsuite/bug-struct-assign/ref/out.txt | 3 +++ testsuite/bug-struct-assign/run.py | 4 ++++ testsuite/bug-struct-assign/test.osl | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 testsuite/bug-struct-assign/ref/out.txt create mode 100755 testsuite/bug-struct-assign/run.py create mode 100644 testsuite/bug-struct-assign/test.osl diff --git a/CMakeLists.txt b/CMakeLists.txt index cc0097dd3..44ab90c30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,7 @@ TESTSUITE ( and-or-not-synonyms aastep arithmetic array array-derivs array-range blackbody blendmath breakcont bug-array-heapoffsets bug-locallifetime bug-outputinit bug-param-duplicate bug-peep + bug-struct-assign cellnoise closure closure-array color comparison compile-buffer component-range const-array-params const-array-fill diff --git a/testsuite/bug-struct-assign/ref/out.txt b/testsuite/bug-struct-assign/ref/out.txt new file mode 100644 index 000000000..7eaeed931 --- /dev/null +++ b/testsuite/bug-struct-assign/ref/out.txt @@ -0,0 +1,3 @@ +Compiled test.osl -> test.oso +c[0].rgb: 1 2 3 +(-1 2 3) == (-1 2 3) diff --git a/testsuite/bug-struct-assign/run.py b/testsuite/bug-struct-assign/run.py new file mode 100755 index 000000000..f6d2f6260 --- /dev/null +++ b/testsuite/bug-struct-assign/run.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python + +command = testshade("-g 1 1 test") +failureok = failstage2 # diff should fail, bug still exists! diff --git a/testsuite/bug-struct-assign/test.osl b/testsuite/bug-struct-assign/test.osl new file mode 100644 index 000000000..86cb3ce61 --- /dev/null +++ b/testsuite/bug-struct-assign/test.osl @@ -0,0 +1,19 @@ +// Assignemnt to indexed struct element currently broken + +struct custom { + color rgb; +}; + +shader test () +{ + custom c[2]; + c[0].rgb = color(1,2,3); + + // Broken: + c[0].rgb[0] = -c[0].rgb[0]; + + // Works: + c[1].rgb = color(-c[0].rgb[0], c[0].rgb[1], c[0].rgb[2]); + + printf("(%g) == (%g)\n", c[0].rgb, c[1].rgb); +}