[Piglit] [PATCH 10/14] util: Refactor testrunner logic for fbo and glut tests out of main()
Chad Versace
chad.versace at linux.intel.com
Tue Jun 12 16:02:56 PDT 2012
Move from main() the last remaining GLUT call and the last bit of logic
needed to run a piglit-framework-glut test into piglit-framework-glut.c.
For symmetry, also move from main() the last bit of logic needed to run
a piglit-framework-fbo test into piglit-framework-fbo.c
Now main() has a simple body and a well-defined purpose: to parse argv and
then dispatch the testrun to either piglit-framework-fbo or
piglit-framework-glut.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
tests/util/piglit-framework-fbo.c | 12 +++++++++++-
tests/util/piglit-framework-fbo.h | 2 +-
tests/util/piglit-framework-glut.c | 7 +++++++
tests/util/piglit-framework-glut.h | 1 +
tests/util/piglit-framework.c | 10 +++-------
5 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/tests/util/piglit-framework-fbo.c b/tests/util/piglit-framework-fbo.c
index 0b940f3..faf1ef7 100644
--- a/tests/util/piglit-framework-fbo.c
+++ b/tests/util/piglit-framework-fbo.c
@@ -61,6 +61,9 @@ static struct waffle_window *piglit_waffle_window;
static struct waffle_context *piglit_waffle_context;
#endif
+static void
+piglit_framework_fbo_destroy(void);
+
#ifdef PIGLIT_FRAMEWORK_FBO_USE_GLX
static void
piglit_framework_fbo_glx_init()
@@ -311,7 +314,7 @@ piglit_framework_fbo_init(void)
return piglit_framework_fbo_gl_init();
}
-void
+static void
piglit_framework_fbo_destroy(void)
{
#ifdef USE_OPENGL
@@ -326,3 +329,10 @@ piglit_framework_fbo_destroy(void)
piglit_framework_fbo_waffle_destroy();
#endif
}
+
+void piglit_framework_fbo_run(void)
+{
+ enum piglit_result result = piglit_display();
+ piglit_framework_fbo_destroy();
+ piglit_report_result(result);
+}
diff --git a/tests/util/piglit-framework-fbo.h b/tests/util/piglit-framework-fbo.h
index 2fdf79d..7e52e50 100644
--- a/tests/util/piglit-framework-fbo.h
+++ b/tests/util/piglit-framework-fbo.h
@@ -24,4 +24,4 @@
#include <stdbool.h>
bool piglit_framework_fbo_init(void);
-void piglit_framework_fbo_destroy(void);
+void piglit_framework_fbo_run(void);
diff --git a/tests/util/piglit-framework-glut.c b/tests/util/piglit-framework-glut.c
index f02860b..6e91ec4 100644
--- a/tests/util/piglit-framework-glut.c
+++ b/tests/util/piglit-framework-glut.c
@@ -118,3 +118,10 @@ piglit_framework_glut_init(int argc, char *argv[])
glewInit();
#endif
}
+
+void
+piglit_framework_glut_run(void)
+{
+ glutMainLoop();
+ piglit_report_result(result);
+}
diff --git a/tests/util/piglit-framework-glut.h b/tests/util/piglit-framework-glut.h
index 60bcc00..7116adc 100644
--- a/tests/util/piglit-framework-glut.h
+++ b/tests/util/piglit-framework-glut.h
@@ -26,3 +26,4 @@
#include "piglit-util.h"
void piglit_framework_glut_init(int argc, char *argv[]);
+void piglit_framework_glut_run(void);
diff --git a/tests/util/piglit-framework.c b/tests/util/piglit-framework.c
index a0ef496..16b8516 100644
--- a/tests/util/piglit-framework.c
+++ b/tests/util/piglit-framework.c
@@ -41,8 +41,6 @@ bool piglit_use_fbo = false;
int piglit_automatic = 0;
unsigned piglit_winsys_fbo = 0;
-static enum piglit_result result;
-
#ifndef _WIN32
__attribute__((weak)) int piglit_width = 100;
__attribute__((weak)) int piglit_height = 100;
@@ -135,13 +133,11 @@ int main(int argc, char *argv[])
piglit_init(argc, argv);
if (piglit_use_fbo) {
- result = piglit_display();
- piglit_framework_fbo_destroy();
+ piglit_framework_fbo_run();
} else {
- glutMainLoop();
+ piglit_framework_glut_run();
}
- piglit_report_result(result);
- /* UNREACHED */
+ assert(false);
return 0;
}
--
1.7.10.4
More information about the Piglit
mailing list