Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
job-hash-test.cpp
Go to the documentation of this file.
1/*
2 JobHash(Test) - verify job definition and job identity hash
3
4 Copyright (C)
5 2013, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
20#include "lib/util.hpp"
21
22#include "vault/real-clock.hpp"
23#include "vault/gear/job.h"
25
26#include <boost/functional/hash.hpp>
27
28
29namespace steam {
30namespace engine{
31namespace test {
32
34 using vault::gear::Job;
36
37
38
39
40 /**********************************************************************/
50 class JobHash_test : public Test
51 {
52
53 virtual void
54 run (Arg)
55 {
56 seedRand();
59 }
60
61
62 void
64 {
65 MockJob job;
66 Time beforeInvocation = RealClock::now();
67 job.triggerJob();
68
69 CHECK (MockJob::was_invoked (job));
71 CHECK (beforeInvocation < MockJob::invocationTime (job));
72 }
73
74
75 void
77 {
78 MockJob job1;
79 MockJob job2;
80
81 CHECK (job1 != job2, "random test data clash");
82
83 CHECK (hash_value(job1) != hash_value(job2));
84
85 Job copy(job1);
86 CHECK (!isSameObject (job1, copy));
87
88 CHECK (copy == job1);
89 CHECK (hash_value(job1) == hash_value(copy));
90
91 copy.parameter.nominalTime++;
92 CHECK (hash_value(job1) != hash_value(copy)); // hash value depends on the concrete nominal job time
93
94 copy = job1;
95 copy.parameter.invoKey.part.a++;
96 CHECK (hash_value(job1) != hash_value(copy)); // hash value depends on the internal interpretation of the invocation key
97
98
99 class OtherClosure
100 : public JobClosure
101 {
102 void invokeJobOperation (JobParameter) { /* irrelevant */ }
103 JobKind getJobKind() const { return META_JOB; }
104 InvocationInstanceID buildInstanceID(HashVal) const { return InvocationInstanceID(); }
105
106 size_t
107 hashOfInstance(InvocationInstanceID invoKey) const
108 {
109 return boost::hash_value (invoKey.part.a);
110 }
111 };
112 OtherClosure someOtherClosure;
113
114 copy = job1;
115 copy.jobClosure = &someOtherClosure;
116 CHECK (hash_value(job1) != hash_value(copy)); // hash value indeed depends on the concrete job closure instance
117 }
118 };
119
120
122 LAUNCHER(JobHash_test, "unit engine");
123
124}}} // namespace steam::engine::test
Lumiera's internal time value datatype.
Mock setup for a render Job with NO action but built-in diagnostics.
static bool was_invoked(Job const &job)
static Time invocationTime(Job const &job)
static Time now()
Interface of the closure for frame rendering jobs.
Definition job.h:244
Individual frame rendering task, forwarding to a closure.
Definition job.h:276
void triggerJob() const
Definition job.cpp:70
Definition of a render job.
JobKind
Definition job.h:64
@ META_JOB
render process self organisation
Definition job.h:67
struct InvocationInstanceID::@62 part
opaque ID attached to each individual job invocation.
Definition job.h:105
Mock data structures to support implementation testing of render job planning and frame dispatch.
Steam-Layer implementation namespace root.
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Definition util.hpp:421
lumiera_jobParameter const & JobParameter
Definition job.h:205
Front-end for simplified access to the current wall clock time.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...