2016-01-07 18:44:22 +00:00
|
|
|
// Copyright (c) 2015-2016 The Khronos Group Inc.
|
2015-11-18 20:43:43 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2015-11-18 20:43:43 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2015-11-18 20:43:43 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2015-11-18 20:43:43 +00:00
|
|
|
|
|
|
|
// Common validation fixtures for unit tests
|
|
|
|
|
2015-12-14 13:21:08 +00:00
|
|
|
#ifndef LIBSPIRV_TEST_VALIDATE_FIXTURES_H_
|
|
|
|
#define LIBSPIRV_TEST_VALIDATE_FIXTURES_H_
|
|
|
|
|
2016-09-22 15:05:30 +00:00
|
|
|
#include "unit_spirv.h"
|
2015-11-18 20:43:43 +00:00
|
|
|
|
|
|
|
namespace spvtest {
|
|
|
|
|
2016-02-22 20:25:50 +00:00
|
|
|
template <typename T>
|
2015-11-18 20:43:43 +00:00
|
|
|
class ValidateBase : public ::testing::Test,
|
|
|
|
public ::testing::WithParamInterface<T> {
|
|
|
|
public:
|
|
|
|
ValidateBase();
|
|
|
|
|
|
|
|
virtual void TearDown();
|
|
|
|
|
|
|
|
// Returns the a spv_const_binary struct
|
|
|
|
spv_const_binary get_const_binary();
|
|
|
|
|
2016-04-21 19:46:08 +00:00
|
|
|
void CompileSuccessfully(std::string code,
|
|
|
|
spv_target_env env = SPV_ENV_UNIVERSAL_1_0);
|
2015-11-18 20:43:43 +00:00
|
|
|
|
2016-11-24 20:37:22 +00:00
|
|
|
// Overwrites the word at index 'index' with the given word.
|
|
|
|
// For testing purposes, it is often useful to be able to manipulate the
|
|
|
|
// assembled binary before running the validator on it.
|
|
|
|
// This function overwrites the word at the given index with a new word.
|
|
|
|
void OverwriteAssembledBinary(uint32_t index, uint32_t word);
|
|
|
|
|
2015-11-18 20:43:43 +00:00
|
|
|
// Performs validation on the SPIR-V code and compares the result of the
|
|
|
|
// spvValidate function
|
2016-04-21 19:46:08 +00:00
|
|
|
spv_result_t ValidateInstructions(spv_target_env env = SPV_ENV_UNIVERSAL_1_0);
|
2015-11-18 20:43:43 +00:00
|
|
|
|
|
|
|
std::string getDiagnosticString();
|
2015-12-16 02:44:21 +00:00
|
|
|
spv_position_t getErrorPosition();
|
2015-11-18 20:43:43 +00:00
|
|
|
|
|
|
|
spv_binary binary_;
|
|
|
|
spv_diagnostic diagnostic_;
|
|
|
|
};
|
|
|
|
}
|
2015-12-14 13:21:08 +00:00
|
|
|
#endif
|