[waffle] [PATCH 05/29] tests/gl_basic: use actual/expect arrays for the pixel storage
Emil Velikov
emil.l.velikov at gmail.com
Wed Jan 6 13:27:31 PST 2016
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
tests/functional/gl_basic_test.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index c95ae39..55d078d 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -69,7 +69,8 @@ static const uint8_t GREEN_UB = 0x00;
static const uint8_t BLUE_UB = 0xff;
static const uint8_t ALPHA_UB = 0xff;
-static uint8_t pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT];
+static uint8_t actual_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT];
+static uint8_t expect_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT];
#define ASSERT_GL(statement) \
do { \
@@ -136,7 +137,17 @@ static void (APIENTRY *glReadPixels)(GLint x, GLint y,
static void
testgroup_gl_basic_setup(void)
{
- memset(pixels, 0, sizeof(pixels));
+ for (int y = 0 ; y < WINDOW_HEIGHT; ++y) {
+ for (int x = 0; x < WINDOW_WIDTH; ++x) {
+ uint8_t *p = &expect_pixels[4 * (y * WINDOW_WIDTH + x)];
+ p[0] = RED_UB;
+ p[1] = GREEN_UB;
+ p[2] = BLUE_UB;
+ p[3] = ALPHA_UB;
+ }
+ }
+
+ memset(actual_pixels, 0x99, sizeof(actual_pixels));
}
static void
@@ -321,21 +332,15 @@ gl_basic_draw__(struct gl_basic_draw_args__ args)
ASSERT_GL(glClear(GL_COLOR_BUFFER_BIT));
ASSERT_GL(glReadPixels(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT,
GL_RGBA, GL_UNSIGNED_BYTE,
- pixels));
+ actual_pixels));
ASSERT_TRUE(waffle_window_swap_buffers(window));
// Probe color buffer.
//
// Fail at first failing pixel. If the draw fails, we don't want a terminal
// filled with error messages.
- for (int y = 0 ; y < WINDOW_HEIGHT; ++y) {
- for (int x = 0; x < WINDOW_WIDTH; ++x) {
- uint8_t *p = &pixels[4 * (y * WINDOW_WIDTH + x)];
- ASSERT_TRUE(p[0] == RED_UB);
- ASSERT_TRUE(p[1] == GREEN_UB);
- ASSERT_TRUE(p[2] == BLUE_UB);
- ASSERT_TRUE(p[3] == ALPHA_UB);
- }
+ for (i = 0 ; i < sizeof(actual_pixels); ++i) {
+ ASSERT_TRUE(actual_pixels[i] == expect_pixels[i]);
}
// Teardown.
--
2.6.2
More information about the waffle
mailing list