Path: blob/main/libshaderc/src/shaderc_c_smoke_test.c
1558 views
// Copyright 2016 The Shaderc Authors. All rights reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314#include "shaderc/shaderc.h"15#include <assert.h>16#include <string.h>1718// Because we want to test this as a plain old C file, we cannot use19// gtest, so just run a simple smoke test.2021int main() {22const char* test_program =23"#version 310 es\n"24"layout(location = 0) in highp vec4 vtxColor;\n"25"layout(location = 0) out highp vec4 outColor;\n"26"void main() {\n"27" outColor = vtxColor;"28"}\n";29shaderc_compiler_t compiler;30shaderc_compilation_result_t result;31shaderc_compile_options_t options;3233compiler = shaderc_compiler_initialize();34options = shaderc_compile_options_initialize();35shaderc_compile_options_add_macro_definition(options, "FOO", 3, "1", 1);36result = shaderc_compile_into_spv(37compiler, test_program, strlen(test_program),38shaderc_glsl_fragment_shader, "a.glsl", "main", options);3940assert(result);4142if (shaderc_result_get_compilation_status(result) !=43shaderc_compilation_status_success) {44// Early exit on failure.45return -1;46}47shaderc_result_release(result);48shaderc_compile_options_release(options);49shaderc_compiler_release(compiler);5051return 0;52}53545556