ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / gles-2.0 / link-no-vsfs.c
blob46ce056a553dd8c80569ac8c8127805b2bdeed7c
1 /*
2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 /** @file link-no-vsfs.c
26 * From the GLES 2.0.25 spec (page 30):
28 * "Linking can fail for a variety of reasons as specified in the
29 * OpenGL ES Shading Language Specification. Linking will also
30 * fail if one or more of the shader objects, attached to program
31 * are not compiled successfully, if program does not contain
32 * both a vertex shader and a fragment shader, or if more active
33 * uniform or active sampler variables are used in program than
34 * allowed (see section 2.10.4).
36 * This also appears in the 3.0.2 spec, page 48.
39 #include "piglit-util-gl.h"
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config.supports_gl_es_version = 20;
45 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
47 PIGLIT_GL_TEST_CONFIG_END
49 enum piglit_result
50 piglit_display(void)
52 /* UNREACHED */
53 return PIGLIT_FAIL;
56 static bool
57 test_link_fail(GLenum target, const char *source)
59 GLuint shader, prog;
60 GLint ok;
62 shader = piglit_compile_shader_text(target, source);
64 prog = glCreateProgram();
65 glAttachShader(prog, shader);
66 glLinkProgram(prog);
67 glDeleteShader(shader);
69 glGetProgramiv(prog, GL_LINK_STATUS, &ok);
71 glDeleteProgram(prog);
72 if (ok) {
73 fprintf(stderr,
74 "Linking with only a %s succeeded when it should have "
75 "failed:\n",
76 piglit_get_gl_enum_name(target));
77 return false;
79 return true;
82 void
83 piglit_init(int argc, char **argv)
85 const char *vs_source =
86 "void main()\n"
87 "{"
88 " gl_Position = vec4(0);"
89 "}";
90 const char *fs_source =
91 "precision mediump float;\n"
92 "void main()\n"
93 "{"
94 " gl_FragColor = vec4(0);"
95 "}";
97 if (!test_link_fail(GL_VERTEX_SHADER, vs_source))
98 piglit_report_result(PIGLIT_FAIL);
99 if (!test_link_fail(GL_FRAGMENT_SHADER, fs_source))
100 piglit_report_result(PIGLIT_FAIL);
102 piglit_report_result(PIGLIT_PASS);