Add more structure constructor tests.
[piglit/hramrach.git] / tests / util / piglit-framework.c
blob23b1ef65a6e698576813f956ca142dad7e1751ee
1 /*
2 * Copyright © 2009 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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * Simple test case framework.
27 * \author Ian Romanick <ian.d.romanick@intel.com>
29 #include <assert.h>
30 #include <string.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <math.h>
35 #include "piglit-util.h"
36 #include "piglit-framework.h"
37 #ifdef USE_GLX
38 #include "piglit-glx-util.h"
39 #endif
41 #ifdef FREEGLUT
42 #include "GL/freeglut_ext.h"
43 #endif
45 int piglit_automatic = 0;
46 static int piglit_window;
47 static enum piglit_result result;
49 static void
50 display(void)
52 result = piglit_display();
54 if (piglit_automatic) {
55 glutDestroyWindow(piglit_window);
56 #ifdef FREEGLUT
57 /* Tell GLUT to clean up and exit, so that we can
58 * reasonably valgrind our testcases for memory
59 * leaks by the GL.
61 glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,
62 GLUT_ACTION_GLUTMAINLOOP_RETURNS);
63 glutLeaveMainLoop();
64 #else
65 piglit_report_result(result);
66 #endif
70 static void
71 reshape(int w, int h)
73 piglit_width = w;
74 piglit_height = h;
76 glViewport(0, 0, w, h);
79 int main(int argc, char *argv[])
81 int j;
83 glutInit(&argc, argv);
85 /* Find/remove "-auto" from the argument vector.
87 for (j = 1; j < argc; j++) {
88 if (!strcmp(argv[j], "-auto")) {
89 int i;
91 piglit_automatic = 1;
93 for (i = j + 1; i < argc; i++) {
94 argv[i - 1] = argv[i];
96 argc--;
97 j--;
100 glutInitWindowPosition(0, 0);
101 glutInitWindowSize(piglit_width, piglit_height);
102 glutInitDisplayMode(piglit_window_mode);
103 piglit_window = glutCreateWindow(argv[0]);
105 #ifdef USE_GLX
106 if (piglit_automatic)
107 piglit_glx_set_no_input();
108 #endif
110 glutDisplayFunc(display);
111 glutReshapeFunc(reshape);
112 glutKeyboardFunc(piglit_escape_exit_key);
114 glewInit();
116 piglit_init(argc, argv);
118 glutMainLoop();
120 piglit_report_result(result);
121 /* UNREACHED */
122 return 0;