glx: don't fail test if the X server is inconsistent
[piglit.git] / tests / general / dlist-fdo31590.c
blob59f062a0032e909a133e2147087092bacf5da378
1 /*
2 * Copyright (c) 2011 VMware, Inc.
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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * Test related to fd.o bug 31590 involving glEvalCoord inside a display list
26 * when running the glut molehill test.
27 * The mesa-demos redbook/bezcurve.c test (when hacked to use a display list)
28 * also demonstrated the problem. This program is based on the later program.
30 * We test for two things:
31 * 1. an unexpected GL_INVALID_OPERATION error
32 * 2. a segfault/crash during display list compilation
36 #include "piglit-util-gl.h"
38 static const char *TestName = "dlist-fdo31590";
40 PIGLIT_GL_TEST_CONFIG_BEGIN
42 config.supports_gl_compat_version = 10;
44 config.window_width = 500;
45 config.window_height = 500;
46 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
48 PIGLIT_GL_TEST_CONFIG_END
50 static const GLfloat ctrlpoints[4][3] = {
51 { -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0},
52 {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}
56 static void
57 test1(void)
59 int i;
61 glNewList(5, GL_COMPILE);
62 glBegin(GL_LINE_STRIP);
63 glColor3f(1,1,0);
64 for (i = 0; i <= 30; i++) {
65 glEvalCoord1f((GLfloat) i/30.0);
67 glEnd();
68 glEndList();
70 glClear(GL_COLOR_BUFFER_BIT);
71 glColor3f(1.0, 1.0, 1.0);
72 glCallList(5);
76 /* As above, but with a glColor() call in the display list.
77 * This caused a segfault in Mesa.
79 static void
80 test2(void)
82 int i;
84 glNewList(5, GL_COMPILE);
85 glBegin(GL_LINE_STRIP);
86 glColor3f(1,1,0); /* <<<<< this is the only difference */
87 for (i = 0; i <= 30; i++) {
88 glEvalCoord1f((GLfloat) i/30.0);
90 glEnd();
91 glEndList();
93 glClear(GL_COLOR_BUFFER_BIT);
94 glColor3f(1.0, 1.0, 1.0);
95 glCallList(5);
99 enum piglit_result
100 piglit_display(void)
102 glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
103 glEnable(GL_MAP1_VERTEX_3);
105 #if 0
106 /* The following code displays the control points as dots. */
107 glPointSize(5.0);
108 glColor3f(1.0, 1.0, 0.0);
109 glBegin(GL_POINTS);
110 for (i = 0; i < 4; i++)
111 glVertex3fv(&ctrlpoints[i][0]);
112 glEnd();
113 #endif
115 test1();
117 if (glGetError() != GL_NO_ERROR) {
118 printf("%s: test1 generated an unexpected error\n", TestName);
119 return PIGLIT_FAIL;
122 test2();
124 if (glGetError() != GL_NO_ERROR) {
125 printf("%s: test2 generated an unexpected error\n", TestName);
126 return PIGLIT_FAIL;
129 piglit_present_results();
131 return PIGLIT_PASS;
135 void
136 piglit_init(int argc, char **argv)
138 glMatrixMode(GL_PROJECTION);
139 glLoadIdentity();
140 glOrtho(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0);
141 glMatrixMode(GL_MODELVIEW);