1 /* Public domain */ 2 3 #ifndef _AGARTEST_H_ 4 #define _AGARTEST_H_ 5 6 #include <agar/core.h> 7 #include <agar/gui.h> 8 #include <agar/dev.h> 9 10 #include <agar/config/ag_debug.h> 11 #include <agar/config/have_64bit.h> 12 #include <agar/config/have_opengl.h> 13 #include <agar/config/enable_au.h> 14 #include <agar/config/enable_vg.h> 15 16 /* Test case definition */ 17 typedef struct ag_test_case { 18 const char *name; /* Test name */ 19 const char *descr; /* Short description */ 20 const char *minVer; /* Minimum Agar version */ 21 Uint flags; 22 #define AG_TEST_THREADS 0x01 /* Require multithreading */ 23 #define AG_TEST_OPENGL 0x02 /* Require OpenGL support */ 24 #define AG_TEST_SDL 0x04 /* Require SDL 1.x support */ 25 #define AG_TEST_AUDIO 0x08 /* Require the Agar-AU library */ 26 size_t size; /* Instance structure size */ 27 int (*init)(void *); /* Initialize instance */ 28 void (*destroy)(void *); /* Free instance */ 29 int (*test)(void *); /* Non-interactive test */ 30 int (*testGUI)(void *, AG_Window *); /* Interactive test */ 31 int (*bench)(void *); /* Run benchmark */ 32 } AG_TestCase; 33 34 /* Test case instance */ 35 typedef struct ag_test_instance { 36 const AG_TestCase *tc; 37 const char *name; 38 Uint flags; 39 float score; /* Numerical result */ 40 AG_Console *console; /* Output console */ 41 AG_Window *win; /* Main (control) window */ 42 AG_Button *closeBtn; /* "Close this test" */ 43 AG_TAILQ_ENTRY(ag_test_instance) instances; 44 } AG_TestInstance; 45 46 typedef struct ag_benchmark_fn { 47 char *name; 48 void (*run)(void *ti); 49 #if defined(AG_HAVE_64BIT) 50 Uint64 clksMin, clksAvg, clksMax; 51 #else 52 Uint32 clksMin, clksAvg, clksMax; 53 #endif 54 } AG_BenchmarkFn; 55 56 typedef struct ag_benchmark { 57 char *name; 58 AG_BenchmarkFn *funcs; 59 Uint nFuncs; 60 Uint runs; /* Number of loop cycles */ 61 Uint iterations; /* Iterations in loop */ 62 Uint maximum; /* If tests exceed value, assume 63 preemption and retry (0=disable) */ 64 } AG_Benchmark; 65 66 void TestWindowClose(AG_Event *); 67 void TestMsg(void *, const char *, ...); 68 void TestMsgS(void *, const char *); 69 void TestExecBenchmark(void *, AG_Benchmark *); 70 71 #include "config/enable_nls.h" 72 #ifdef ENABLE_NLS 73 # include <libintl.h> 74 # define _(String) gettext(String) 75 # define gettext_noop(String) (String) 76 # define N_(String) gettext_noop(String) 77 #else 78 # undef _ 79 # undef N_ 80 # define _(s) (s) 81 # define N_(s) (s) 82 #endif 83 84 #endif /* _AGARTEST_H_ */ 85