~darkxst/ubuntu/raring/cogl/lp1163025

« back to all changes in this revision

Viewing changes to tests/conform/test-conform-main.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-13 19:11:11 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120313191111-3hgk529qkh9m6uk2
Tags: 1.9.8-0ubuntu1
* New upstream release (LP: #941617)
* Updated symbols & library name for soname update
* debian/control.in: Bump minimum glib to 2.28
* debian/patches/02_disable_armv5t_specific_optimization.patch: Disabled

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <glib.h>
6
6
#include <locale.h>
7
7
#include <stdlib.h>
 
8
#include <string.h>
8
9
 
9
10
#include "test-utils.h"
10
11
 
11
 
#if 0
12
 
void
13
 
skip_init (TestUtilsGTestFixture *fixture,
14
 
           const void *data)
15
 
{
16
 
  /* void */
17
 
}
18
 
 
19
 
static void
20
 
skip_test (TestUtilsGTestFixture *fixture,
21
 
           const void *data)
22
 
{
23
 
  /* void */
24
 
}
25
 
 
26
 
void
27
 
skip_fini (TestUtilsGTestFixture *fixture,
28
 
           const void *data)
29
 
{
30
 
  /* void */
31
 
}
32
 
#endif
33
 
 
34
 
static void
35
 
run_todo_test (TestUtilsGTestFixture *fixture,
36
 
               void *data)
37
 
{
38
 
#ifdef G_OS_UNIX
39
 
  TestUtilsSharedState *state = data;
40
 
 
41
 
  if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
42
 
    {
43
 
      state->todo_func (fixture, data);
44
 
      exit (0);
45
 
    }
46
 
 
47
 
  g_test_trap_assert_failed ();
48
 
#endif
49
 
}
50
 
 
51
 
void
52
 
verify_failure (TestUtilsGTestFixture *fixture,
53
 
                void *data)
54
 
{
55
 
  g_assert (FALSE);
56
 
}
57
 
 
58
12
static TestUtilsSharedState *shared_state = NULL;
59
13
 
60
 
/* This is a bit of sugar for adding new conformance tests:
61
 
 *
62
 
 * - It adds an extern function definition just to save maintaining a header
63
 
 *   that lists test entry points.
64
 
 * - It sets up callbacks for a fixture, which lets us share initialization
65
 
 *   code between tests. (see test-utils.c)
66
 
 * - It passes in a shared data pointer that is initialised once in main(),
67
 
 *   that gets passed to the fixture setup and test functions. (See the
68
 
 *   definition in test-utils.h)
69
 
 */
70
 
#define ADD_TEST(NAMESPACE, FUNC)            G_STMT_START {             \
71
 
  extern void FUNC (TestUtilsGTestFixture *, void *);                   \
72
 
  g_test_add ("/conform" NAMESPACE "/" #FUNC,                           \
73
 
              TestUtilsGTestFixture,                                    \
74
 
              shared_state, /* data argument for test */                \
75
 
              test_utils_init,                                          \
76
 
              (void *)(FUNC),                                           \
77
 
              test_utils_fini);    } G_STMT_END
78
 
 
79
 
/* this is a macro that conditionally executes a test if CONDITION
80
 
 * evaluates to TRUE; otherwise, it will put the test under the
81
 
 * "/skip" namespace and execute a dummy function that will always
82
 
 * pass.
83
 
 */
84
 
#define ADD_CONDITIONAL_TEST(CONDITION, NAMESPACE, FUNC)   G_STMT_START {   \
85
 
  if (!(CONDITION)) {                                                       \
86
 
    g_test_add ("/skipped" NAMESPACE "/" #FUNC,                             \
87
 
                TestUtilsGTestFixture,                                      \
88
 
                shared_state, /* data argument for test */                  \
89
 
                skip_init,                                                  \
90
 
                skip_test,                                                  \
91
 
                skip_fini);                                                 \
92
 
  } else { ADD_TEST (NAMESPACE, FUNC); }     } G_STMT_END
93
 
 
94
 
#define ADD_TODO_TEST(NAMESPACE, FUNC)              G_STMT_START {          \
95
 
   extern void FUNC (TestUtilsGTestFixture *, void *);                      \
96
 
   shared_state->todo_func = FUNC;                                          \
97
 
   g_test_add ("/todo" NAMESPACE "/" #FUNC,                                 \
98
 
              TestUtilsGTestFixture,                                        \
99
 
              shared_state,                                                 \
100
 
              test_utils_init,                                              \
101
 
              (void *)(run_todo_test),                                      \
102
 
              test_utils_fini);    } G_STMT_END
103
 
 
104
 
#define UNPORTED_TEST(NAMESPACE, FUNC)
105
 
 
106
 
gchar *
107
 
clutter_test_get_data_file (const gchar *filename)
108
 
{
109
 
  return g_build_filename (TESTS_DATADIR, filename, NULL);
110
 
}
 
14
/* A bit of sugar for adding new conformance tests */
 
15
#define ADD_TEST(FUNC, REQUIREMENTS)  G_STMT_START {      \
 
16
  extern void FUNC (TestUtilsGTestFixture *, void *);     \
 
17
  if (strcmp (#FUNC, argv[1]) == 0)                       \
 
18
    {                                                     \
 
19
      test_utils_init (shared_state, REQUIREMENTS);       \
 
20
      FUNC (NULL, shared_state);                          \
 
21
      test_utils_fini (shared_state);                     \
 
22
      exit (0);                                           \
 
23
    }                                                     \
 
24
} G_STMT_END
 
25
 
 
26
#define UNPORTED_TEST(FUNC)
111
27
 
112
28
int
113
29
main (int argc, char **argv)
114
30
{
115
 
  g_test_init (&argc, &argv, NULL);
116
 
 
117
 
  g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=%s");
 
31
  int i;
 
32
 
 
33
  if (argc != 2)
 
34
    {
 
35
      g_printerr ("usage %s UNIT_TEST\n", argv[0]);
 
36
      exit (1);
 
37
    }
 
38
 
 
39
  /* Just for convenience in case people try passing the wrapper
 
40
   * filenames for the UNIT_TEST argument we normalize '-' characters
 
41
   * to '_' characters... */
 
42
  for (i = 0; argv[1][i]; i++)
 
43
    {
 
44
      if (argv[1][i] == '-')
 
45
        argv[1][i] = '_';
 
46
    }
118
47
 
119
48
  /* Initialise the state you need to share with everything.
120
49
   */
124
53
 
125
54
  /* This file is run through a sed script during the make step so the
126
55
   * lines containing the tests need to be formatted on a single line
127
 
   * each. To comment out a test use the SKIP or TODO macros. Using
128
 
   * #if 0 would break the script. */
129
 
 
130
 
  /* sanity check for the test suite itself */
131
 
  ADD_TODO_TEST ("/suite", verify_failure);
132
 
 
133
 
  UNPORTED_TEST ("/cogl", test_cogl_object);
134
 
  UNPORTED_TEST ("/cogl", test_cogl_fixed);
135
 
  UNPORTED_TEST ("/cogl", test_cogl_materials);
136
 
  UNPORTED_TEST ("/cogl", test_cogl_pipeline_user_matrix);
137
 
  UNPORTED_TEST ("/cogl", test_cogl_blend_strings);
138
 
  UNPORTED_TEST ("/cogl", test_cogl_premult);
139
 
  UNPORTED_TEST ("/cogl", test_cogl_readpixels);
140
 
  UNPORTED_TEST ("/cogl", test_cogl_path);
141
 
  ADD_TEST ("/cogl", test_cogl_depth_test);
142
 
  ADD_TEST ("/cogl", test_cogl_color_mask);
143
 
  ADD_TEST ("/cogl", test_cogl_backface_culling);
144
 
 
145
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_npot_texture);
146
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_multitexture);
147
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_texture_mipmaps);
148
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_sub_texture);
149
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_pixel_array);
150
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_texture_rectangle);
151
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_texture_3d);
152
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_wrap_modes);
153
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_texture_pixmap_x11);
154
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_texture_get_set_data);
155
 
  UNPORTED_TEST ("/cogl/texture", test_cogl_atlas_migration);
156
 
 
157
 
  UNPORTED_TEST ("/cogl/vertex-buffer", test_cogl_vertex_buffer_contiguous);
158
 
  UNPORTED_TEST ("/cogl/vertex-buffer", test_cogl_vertex_buffer_interleved);
159
 
  UNPORTED_TEST ("/cogl/vertex-buffer", test_cogl_vertex_buffer_mutability);
160
 
 
161
 
  UNPORTED_TEST ("/cogl/vertex-array", test_cogl_primitive);
162
 
 
163
 
  UNPORTED_TEST ("/cogl/shaders", test_cogl_just_vertex_shader);
164
 
 
165
 
  /* left to the end because they aren't currently very orthogonal and tend to
166
 
   * break subsequent tests! */
167
 
  UNPORTED_TEST ("/cogl", test_cogl_viewport);
168
 
  UNPORTED_TEST ("/cogl", test_cogl_offscreen);
169
 
 
170
 
  return g_test_run ();
 
56
   * each.
 
57
   */
 
58
 
 
59
  UNPORTED_TEST (test_cogl_object);
 
60
  UNPORTED_TEST (test_cogl_fixed);
 
61
  UNPORTED_TEST (test_cogl_materials);
 
62
  ADD_TEST (test_cogl_pipeline_user_matrix, 0);
 
63
  ADD_TEST (test_cogl_blend_strings, 0);
 
64
  UNPORTED_TEST (test_cogl_premult);
 
65
  UNPORTED_TEST (test_cogl_readpixels);
 
66
  ADD_TEST (test_cogl_path, 0);
 
67
  ADD_TEST (test_cogl_depth_test, 0);
 
68
  ADD_TEST (test_cogl_color_mask, 0);
 
69
  ADD_TEST (test_cogl_backface_culling, TEST_REQUIREMENT_NPOT);
 
70
 
 
71
  ADD_TEST (test_cogl_sparse_pipeline, 0);
 
72
 
 
73
  UNPORTED_TEST (test_cogl_npot_texture);
 
74
  UNPORTED_TEST (test_cogl_multitexture);
 
75
  UNPORTED_TEST (test_cogl_texture_mipmaps);
 
76
  ADD_TEST (test_cogl_sub_texture, 0);
 
77
  ADD_TEST (test_cogl_pixel_buffer, 0);
 
78
  UNPORTED_TEST (test_cogl_texture_rectangle);
 
79
  ADD_TEST (test_cogl_texture_3d, 0);
 
80
  ADD_TEST (test_cogl_wrap_modes, 0);
 
81
  UNPORTED_TEST (test_cogl_texture_pixmap_x11);
 
82
  UNPORTED_TEST (test_cogl_texture_get_set_data);
 
83
  UNPORTED_TEST (test_cogl_atlas_migration);
 
84
  ADD_TEST (test_cogl_read_texture_formats, 0);
 
85
  ADD_TEST (test_cogl_write_texture_formats, 0);
 
86
 
 
87
  UNPORTED_TEST (test_cogl_vertex_buffer_contiguous);
 
88
  UNPORTED_TEST (test_cogl_vertex_buffer_interleved);
 
89
  UNPORTED_TEST (test_cogl_vertex_buffer_mutability);
 
90
 
 
91
  ADD_TEST (test_cogl_primitive, 0);
 
92
 
 
93
  ADD_TEST (test_cogl_just_vertex_shader, 0);
 
94
  ADD_TEST (test_cogl_pipeline_uniforms, 0);
 
95
  ADD_TEST (test_cogl_snippets, 0);
 
96
  ADD_TEST (test_cogl_custom_attributes, 0);
 
97
 
 
98
  ADD_TEST (test_cogl_bitmask, 0);
 
99
 
 
100
  ADD_TEST (test_cogl_offscreen, 0);
 
101
 
 
102
  UNPORTED_TEST (test_cogl_viewport);
 
103
 
 
104
  g_printerr ("Unknown test name \"%s\"\n", argv[1]);
 
105
 
 
106
  return 1;
171
107
}