MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / main

Function main

tests/osl/UnitTestMain.cpp:151–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151int main(int, const char **)
152{
153 const std::string oslShaderPath{OCIO::GetEnvVariable("OSL_SHADERS_DIR")};
154 const std::string newShaderPath{OCIO::GetEnvVariable("TMP_SHADERS_DIR")};
155 const std::string shaderName{"OSL_OCIOMain"};
156
157 const std::string oslShaderOption{"-I" + oslShaderPath};
158 const std::vector<std::string> options{ oslShaderOption, "-Werror" };
159
160 size_t failures = 0;
161 size_t noTest = 0;
162
163 std::cerr << "\n OpenColorIO_Core_OSL_Unit_Tests\n\n";
164
165 OCIO::SetLoggingFunction(logFunction);
166
167 for (const auto & test : GetUnitTests())
168 {
169 constexpr size_t maxCharToDisplay = 59;
170 if (test->m_name.size() > maxCharToDisplay)
171 {
172 test->m_name.resize(maxCharToDisplay);
173 }
174
175 std::cerr << "["
176 << std::right << std::setw(3)
177 << (noTest+1) << "/" << GetUnitTests().size() << "] ["
178 << std::left << std::setw(maxCharToDisplay+1)
179 << test->m_name
180 << "] - ";
181
182 std::string oslShaderString;
183
184 try
185 {
186 // Create the OSL shader.
187
188 OCIO::ConstProcessorRcPtr processor
189 = test->m_config->getProcessor(test->m_transform);
190 OCIO::ConstCPUProcessorRcPtr cpu
191 = processor->getOptimizedCPUProcessor(OCIO::OPTIMIZATION_NONE);
192
193 OCIO::ConstGPUProcessorRcPtr gpu
194 = processor->getOptimizedGPUProcessor(OCIO::OPTIMIZATION_NONE);
195
196 OCIO::GpuShaderCreatorRcPtr shaderDesc = MyOSLShaderCreator::Create(test);
197 gpu->extractGpuShaderInfo(shaderDesc);
198
199 oslShaderString = dynamic_cast<MyOSLShaderCreator*>(shaderDesc.get())->getShaderCode();
200
201 // Compute the expected output values for the following input values.
202
203 static const Image g_inValues{
204 { 0.00f, 0.02f, 0.04f, 0.06f},
205 { 0.08f, 0.10f, 0.12f, 0.14f},
206 { 0.16f, 0.18f, 0.20f, 0.22f},
207 { 0.24f, 0.26f, 0.28f, 0.30f},
208 { 0.32f, 0.34f, 0.36f, 0.38f},

Callers

nothing calls this directly

Calls 14

GetEnvVariableFunction · 0.85
SetLoggingFunctionFunction · 0.85
ExecuteOSLShaderFunction · 0.85
haserrorMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
getProcessorMethod · 0.45
extractGpuShaderInfoMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected