Commit dea1d6b3 authored by Kenneth Moreland's avatar Kenneth Moreland

Add ability to write tests that do not depend on OpenGL.

Also converted the CompressionSize test to no longer depend on OpenGL.
parent 2be73b4d
......@@ -169,16 +169,11 @@ INCLUDE_DIRECTORIES(${ICET_BINARY_DIR}/src/include)
ADD_SUBDIRECTORY(src)
IF (BUILD_TESTING AND ICET_BUILD_TESTING)
IF (ICET_USE_OPENGL AND ICET_USE_MPI)
FIND_PACKAGE(GLUT)
IF (GLUT_FOUND)
ADD_SUBDIRECTORY(tests)
ELSE (GLUT_FOUND)
MESSAGE(STATUS "Tests require Glut, which is not found. Disabling tests.")
ENDIF (GLUT_FOUND)
ELSE (ICET_USE_OPENGL AND ICET_USE_MPI)
MESSAGE(STATUS "Tests require ICET_USE_OPENGL and ICET_USE_MPI. Disabling tests.")
ENDIF (ICET_USE_OPENGL AND ICET_USE_MPI)
IF (ICET_USE_MPI)
ADD_SUBDIRECTORY(tests)
ELSE (ICET_USE_MPI)
MESSAGE(STATUS "Tests require ICET_USE_MPI. Disabling tests.")
ENDIF (ICET_USE_MPI)
ENDIF (BUILD_TESTING AND ICET_BUILD_TESTING)
ADD_SUBDIRECTORY(doc)
......
......@@ -5,19 +5,43 @@
## This source code is released under the New BSD License.
#
IF (ICET_USE_OPENGL)
FIND_PACKAGE(GLUT)
IF (GLUT_FOUND)
SET(ICET_TESTS_USE_OPENGL 1)
ENDIF (GLUT_FOUND)
ENDIF (ICET_USE_OPENGL)
IF (NOT ICET_TESTS_USE_OPENGL)
MESSAGE(STATUS "Most tests require ICET_USE_OPENGL and Glut. Those tests are disabled.")
ENDIF (NOT ICET_TESTS_USE_OPENGL)
SET(MyTests
BlankTiles.c
BoundsBehindViewer.c
CompressionSize.c
DisplayNoDraw.c
RandomTransform.c
SimpleExample.c
SimpleTiming.c
)
IF (ICET_TESTS_USE_OPENGL)
SET(MyTests ${MyTests}
BlankTiles.c
BoundsBehindViewer.c
DisplayNoDraw.c
RandomTransform.c
SimpleExample.c
SimpleTiming.c
)
ENDIF (ICET_TESTS_USE_OPENGL)
SET(UTIL_SRCS init.c ppm.c)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/test-config.h.in
${CMAKE_CURRENT_BINARY_DIR}/test-config.h
)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
CREATE_TEST_SOURCELIST(Tests icetTests_mpi.c ${MyTests}
EXTRA_INCLUDE mpi_comm.h
......@@ -26,11 +50,15 @@ CREATE_TEST_SOURCELIST(Tests icetTests_mpi.c ${MyTests}
ADD_EXECUTABLE(icetTests_mpi ${Tests} ${UTIL_SRCS})
TARGET_LINK_LIBRARIES(icetTests_mpi
IceTCore
IceTGL
IceTMPI
${OPENGL_glu_LIBRARY}
${GLUT_LIBRARIES}
)
IF (ICET_TESTS_USE_OPENGL)
TARGET_LINK_LIBRARIES(icetTests_mpi
IceTGL
${OPENGL_glu_LIBRARY}
${GLUT_LIBRARIES}
)
ENDIF (ICET_TESTS_USE_OPENGL)
IF (ICET_MPIRUN_EXE)
SET(PRE_TEST_FLAGS ${ICET_MPIRUN_EXE} ${ICET_MPI_NUMPROC_FLAG} ${ICET_MPI_MAX_NUMPROCS} ${ICET_MPI_PREFLAGS})
......
......@@ -9,8 +9,6 @@
** exceeds the advertised maximum buffer size.
*****************************************************************************/
/*TODO: Eventually we should probably remove OpenGL dependence in this test.*/
#include <IceTGL.h>
#include "test_codes.h"
#include "test-util.h"
......@@ -139,8 +137,7 @@ static void drawCallback(const IceTDouble *projection_matrix,
static int DoCompressionTest(IceTEnum color_format, IceTEnum depth_format,
IceTEnum composite_mode)
{
GLint viewport[4];
int width, height;
IceTInt viewport[4];
IceTSizeType pixels;
IceTImage image;
IceTVoid *imagebuffer;
......@@ -164,20 +161,19 @@ static int DoCompressionTest(IceTEnum color_format, IceTEnum depth_format,
icetSetDepthFormat(depth_format);
icetCompositeMode(composite_mode);
glGetIntegerv(GL_VIEWPORT, viewport);
width = viewport[2];
height = viewport[3];
pixels = width*height;
pixels = SCREEN_WIDTH*SCREEN_HEIGHT;
printf("Allocating memory for %dx%x pixel image.\n", width, height);
imagesize = icetImageBufferSize(width, height);
printf("Allocating memory for %dx%x pixel image.\n",
SCREEN_WIDTH, SCREEN_HEIGHT);
imagesize = icetImageBufferSize(SCREEN_WIDTH, SCREEN_HEIGHT);
imagebuffer = malloc(imagesize);
image = icetImageAssignBuffer(imagebuffer, width, height);
image = icetImageAssignBuffer(imagebuffer, SCREEN_WIDTH, SCREEN_HEIGHT);
compressedsize = icetSparseImageBufferSize(width, height);
compressedsize = icetSparseImageBufferSize(SCREEN_WIDTH, SCREEN_HEIGHT);
compressedbuffer = malloc(compressedsize);
compressedimage = icetSparseImageAssignBuffer(compressedbuffer,
width, height);
SCREEN_WIDTH,
SCREEN_HEIGHT);
/* Get the number of bytes per pixel. This is used in checking the
size of compressed images. */
......@@ -233,10 +229,12 @@ static int DoCompressionTest(IceTEnum color_format, IceTEnum depth_format,
* this scaffolding is not updated correctly. */
printf("\nSetup for actual render.\n");
icetResetTiles();
icetAddTile(viewport[0], viewport[1], viewport[2], viewport[3], 0);
icetAddTile(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
icetDrawCallback(drawCallback);
/* Do a perfunctory draw to set other state variables. */
icetDrawFrame(IdentityMatrix, IdentityMatrix, Black);
viewport[0] = viewport[1] = 0;
viewport[2] = SCREEN_WIDTH; viewport[3] = SCREEN_HEIGHT;
icetStateSetIntegerv(ICET_CONTAINED_VIEWPORT, 4, viewport);
printf("Now render and get compressed image.\n");
icetGetCompressedTileImage(0, compressedimage);
......
......@@ -10,7 +10,9 @@
#include "test-util.h"
#include "test_codes.h"
#ifdef ICET_TESTS_USE_OPENGL
#include <IceTGL.h>
#endif
#define __USE_POSIX
......@@ -23,6 +25,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#ifdef ICET_TESTS_USE_OPENGL
#ifndef __APPLE__
#include <GL/glut.h>
#include <GL/gl.h>
......@@ -30,6 +33,7 @@
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#endif
#endif
#ifndef WIN32
#include <unistd.h>
......@@ -50,10 +54,13 @@ int SINGLE_IMAGE_STRATEGY_LIST_SIZE = 3;
IceTSizeType SCREEN_WIDTH;
IceTSizeType SCREEN_HEIGHT;
#ifdef ICET_TESTS_USE_OPENGL
static int windowId;
static int (*test_function)(void);
#endif /* ICET_TESTS_USE_OPENGL */
#ifdef ICET_TESTS_USE_OPENGL
static void checkOglError(void)
{
GLenum error = glGetError();
......@@ -76,6 +83,7 @@ static void checkOglError(void)
printf("## UNKNOWN OPENGL ERROR CODE!!!!!!\n");
#undef TRY_ERROR
}
#endif /* ICET_TESTS_USE_OPENGL */
static void checkIceTError(void)
{
......@@ -152,8 +160,10 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
/* while (i == 0) sleep(1); */
/* } */
#ifdef ICET_TESTS_USE_OPENGL
/* Let Glut have first pass at the arguments to grab any that it can use. */
glutInit(argcp, *argvp);
#endif
/* Parse my arguments. */
for (arg = 1; arg < argc; arg++) {
......@@ -199,6 +209,7 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
exit(1);
}
#ifdef ICET_TESTS_USE_OPENGL
/* Create a renderable window. */
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA);
glutInitWindowPosition(0, 0);
......@@ -209,6 +220,7 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
sprintf(title, "IceT Test %d of %d", rank, num_proc);
windowId = glutCreateWindow(title);
}
#endif /* ICET_TESTS_USE_OPENGL */
SCREEN_WIDTH = width;
SCREEN_HEIGHT = height;
......@@ -216,7 +228,9 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
/* Create an IceT context. */
context = icetCreateContext(comm);
icetDiagnostics(diag_level);
#ifdef ICET_TESTS_USE_OPENGL
icetGLInitialize();
#endif
/* Redirect standard output on demand. */
if (redirect) {
......@@ -263,6 +277,8 @@ IceTBoolean strategy_uses_single_image_strategy(IceTEnum strategy)
}
}
#ifdef ICET_TESTS_USE_OPENGL
static void no_op()
{
}
......@@ -302,17 +318,36 @@ int run_test(int (*tf)(void))
return TEST_NOT_PASSED;
}
#else /* ICET_TESTS_USE_OPENGL */
int run_test(int (*tf)(void))
{
int result;
result = tf();
finalize_test(result);
return result;
}
#endif /* ICET_TESTS_USE_OPENGL */
#ifdef ICET_TESTS_USE_OPENGL
void swap_buffers(void)
{
glutSwapBuffers();
}
#endif
extern void finalize_communication(void);
void finalize_test(int result)
{
IceTInt rank;
#ifdef ICET_TESTS_USE_OPENGL
checkOglError();
#endif
checkIceTError();
icetGetIntegerv(ICET_RANK, &rank);
......@@ -335,5 +370,7 @@ void finalize_test(int result)
icetDestroyContext(context);
finalize_communication();
#ifdef ICET_TESTS_USE_OPENGL
glutDestroyWindow(windowId);
#endif
}
/* -*- c -*- *******************************************************/
/*
* Copyright (C) 2010 Sandia Corporation
* Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
* the U.S. Government retains certain rights in this software.
*
* This source code is released under the New BSD License.
*/
#cmakedefine ICET_TESTS_USE_OPENGL
......@@ -10,6 +10,8 @@
#ifndef _TEST_UTIL_H_
#define _TEST_UTIL_H_
#include "test-config.h"
#ifdef __cplusplus
extern "C" {
#endif
......@@ -32,7 +34,9 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm);
int run_test(int (*test_function)(void));
#ifdef ICET_TESTS_USE_OPENGL
void swap_buffers(void);
#endif
void finalize_test(int result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment