Skip to content

Commit

Permalink
Added unit tests for editing halt conditions (issue #33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dade916 committed Jan 5, 2018
1 parent 828f2fb commit c7b555f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
7 changes: 5 additions & 2 deletions include/luxcore/luxcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,9 @@ CPP_EXPORT class CPP_API Scene {

/*!
* \brief Edits or creates camera, textures, materials and/or objects
* based on the Properties defined.
* based on the Properties defined. If the scene is in use by a
* RenderSession, it must be called between a RenderSession::BeginSceneEdit()
* and RenderSession::EndSceneEdit().
*
* \param props are the Properties with the definition of camera, textures,
* materials and/or objects.
Expand Down Expand Up @@ -1015,7 +1017,7 @@ CPP_EXPORT class CPP_API RenderSession {
virtual const luxrays::Properties &GetStats() const = 0;

/*!
* \brief Dynamic edit the definition of RenderConfig properties
* \brief Dynamic edit the definition of RenderConfig properties.
*
* \param props are the Properties with the definition of: film.imagepipeline(s).*,
* film.radiancescales.*, film.outputs.*, film.width or film.height.
Expand All @@ -1026,6 +1028,7 @@ CPP_EXPORT class CPP_API RenderSession {
* \brief Save all the rendering related information (the LuxCore RenderConfig,
* Scene, RenderState and Film) in a file for a later restart. The resume
* file extension must be ".rsm".
*
* \param fileName is the binary file used to save.
*/
virtual void SaveResumeFile(const std::string &fileName) = 0;
Expand Down
57 changes: 56 additions & 1 deletion pyunittests/pyluxcoreunittests/tests/halt/testhalt.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,59 @@ def test_Halt_SPP(self):
props = pyluxcore.Properties()
props.Set(pyluxcore.Property("batch.haltspp", 128))

self.RunHaltTest("Halt_SPP", props)
self.RunHaltTest("Halt_SPP", props)

def RunHaltEditTest(self, testName, haltProps):
# Load the configuration from file
props = pyluxcore.Properties("resources/scenes/simple/simple.cfg")

# Change the render engine to PATHCPU
props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"]))
props.Set(pyluxcore.Property("sampler.type", ["RANDOM"]))
props.Set(GetDefaultEngineProperties("PATHCPU"))

# Replace halt condition
props.Delete("batch.haltdebug")
# Run at full speed
props.Delete("native.threads.count")

config = pyluxcore.RenderConfig(props)
session = pyluxcore.RenderSession(config)

session.Start()
time.sleep(10.0)
session.Parse(haltProps)

while True:
time.sleep(0.5)

# Update statistics (and run the convergence test)
session.UpdateStats()

if session.HasDone():
# Time to stop the rendering
break
session.Stop()

image = GetImagePipelineImage(session.GetFilm())

CheckResult(self, image, testName, False)

def test_HaltEdit_Threshold(self):
props = pyluxcore.Properties()
props.Set(pyluxcore.Property("batch.haltthreshold", 0.075))
props.Set(pyluxcore.Property("batch.haltthreshold.step", 16))

self.RunHaltEditTest("HaltEdit_Threshold", props)

def test_HaltEdit_Time(self):
props = pyluxcore.Properties()
props.Set(pyluxcore.Property("batch.halttime", 20))

self.RunHaltTest("HaltEdit_Time", props)

def test_HaltEdit_SPP(self):
props = pyluxcore.Properties()
props.Set(pyluxcore.Property("batch.haltspp", 128))

self.RunHaltTest("HaltEdit_SPP", props)

0 comments on commit c7b555f

Please sign in to comment.