aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/xorg-lib/pixman-0.21.6/0003-test-Fix-tests-for-compilation-on-Windows.patch
blob: 33351a991c4026d40bbf8fdd9653d19d0b3ab590 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
From 11305b4ecdd36a17592c5c75de9157874853ab20 Mon Sep 17 00:00:00 2001
From: Andrea Canciani <ranma42@gmail.com>
Date: Tue, 22 Feb 2011 21:46:37 +0100
Subject: [PATCH 03/40] test: Fix tests for compilation on Windows

The Microsoft C compiler cannot handle subobject initialization and
Win32 does not provide snprintf.

Work around these limitations by using normal struct initialization
and using sprintf (a manual check shows that the buffer size is
sufficient).
---
 test/composite.c    |   29 +++++++++++++--------------
 test/fetch-test.c   |   52 ++++++++++++++++++++++----------------------------
 test/trap-crasher.c |   20 +++++++++---------
 3 files changed, 47 insertions(+), 54 deletions(-)

diff --git a/test/composite.c b/test/composite.c
index e14f954..08c6689 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -617,18 +617,18 @@ eval_diff (color_t *expected, color_t *test, pixman_format_code_t format)
 }
 
 static char *
-describe_image (image_t *info, char *buf, int buflen)
+describe_image (image_t *info, char *buf)
 {
     if (info->size)
     {
-	snprintf (buf, buflen, "%s %dx%d%s",
-		  info->format->name,
-		  info->size, info->size,
-		  info->repeat ? "R" :"");
+	sprintf (buf, "%s %dx%d%s",
+		 info->format->name,
+		 info->size, info->size,
+		 info->repeat ? "R" :"");
     }
     else
     {
-	snprintf (buf, buflen, "solid");
+	sprintf (buf, "solid");
     }
 
     return buf;
@@ -710,10 +710,9 @@ composite_test (image_t *dst,
     {
 	char buf[40];
 
-	snprintf (buf, sizeof (buf),
-		  "%s %scomposite",
-		  op->name,
-		  component_alpha ? "CA " : "");
+	sprintf (buf, "%s %scomposite",
+		 op->name,
+		 component_alpha ? "CA " : "");
 
 	printf ("%s test error of %.4f --\n"
 		"           R    G    B    A\n"
@@ -735,9 +734,9 @@ composite_test (image_t *dst,
 		    mask->color->b, mask->color->a,
 		    dst->color->r, dst->color->g,
 		    dst->color->b, dst->color->a);
-	    printf ("src: %s, ", describe_image (src, buf, sizeof (buf)));
-	    printf ("mask: %s, ", describe_image (mask, buf, sizeof (buf)));
-	    printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf)));
+	    printf ("src: %s, ", describe_image (src, buf));
+	    printf ("mask: %s, ", describe_image (mask, buf));
+	    printf ("dst: %s\n\n", describe_image (dst, buf));
 	}
 	else
 	{
@@ -747,8 +746,8 @@ composite_test (image_t *dst,
 		    src->color->b, src->color->a,
 		    dst->color->r, dst->color->g,
 		    dst->color->b, dst->color->a);
-	    printf ("src: %s, ", describe_image (src, buf, sizeof (buf)));
-	    printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf)));
+	    printf ("src: %s, ", describe_image (src, buf));
+	    printf ("dst: %s\n\n", describe_image (dst, buf));
 	}
 
 	success = FALSE;
diff --git a/test/fetch-test.c b/test/fetch-test.c
index 2ca16dd..314a072 100644
--- a/test/fetch-test.c
+++ b/test/fetch-test.c
@@ -8,7 +8,7 @@
 
 static pixman_indexed_t mono_palette =
 {
-    .rgba = { 0x00000000, 0x00ffffff },
+    0, { 0x00000000, 0x00ffffff },
 };
 
 
@@ -24,57 +24,53 @@ typedef struct {
 static testcase_t testcases[] =
 {
     {
-	.format = PIXMAN_a8r8g8b8,
-	.width = 2, .height = 2,
-	.stride = 8,
-	.src = { 0x00112233, 0x44556677,
-	         0x8899aabb, 0xccddeeff },
-	.dst = { 0x00112233, 0x44556677,
-	         0x8899aabb, 0xccddeeff },
-	.indexed = NULL,
+	PIXMAN_a8r8g8b8,
+	2, 2,
+	8,
+	{ 0x00112233, 0x44556677,
+	  0x8899aabb, 0xccddeeff },
+	{ 0x00112233, 0x44556677,
+	  0x8899aabb, 0xccddeeff },
+	NULL,
     },
     {
-	.format = PIXMAN_g1,
-	.width = 8, .height = 2,
-	.stride = 4,
+	PIXMAN_g1,
+	8, 2,
+	4,
 #ifdef WORDS_BIGENDIAN
-	.src =
 	{
 	    0xaa000000,
 	    0x55000000
 	},
 #else
-	.src =
 	{
 	    0x00000055,
 	    0x000000aa
 	},
 #endif
-	.dst =
 	{
 	    0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000,
 	    0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff
 	},
-	.indexed = &mono_palette,
+	&mono_palette,
     },
 #if 0
     {
-	.format = PIXMAN_g8,
-	.width = 4, .height = 2,
-	.stride = 4,
-	.src = { 0x01234567,
-	         0x89abcdef },
-	.dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767,
-	         0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
+	PIXMAN_g8,
+	4, 2,
+	4,
+	{ 0x01234567,
+	  0x89abcdef },
+	{ 0x00010101, 0x00232323, 0x00454545, 0x00676767,
+	  0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, },
     },
 #endif
     /* FIXME: make this work on big endian */
     {
-	.format = PIXMAN_yv12,
-	.width = 8, .height = 2,
-	.stride = 8,
+	PIXMAN_yv12,
+	8, 2,
+	8,
 #ifdef WORDS_BIGENDIAN
-	.src =
 	{
 	    0x00ff00ff, 0x00ff00ff,
 	    0xff00ff00, 0xff00ff00,
@@ -82,7 +78,6 @@ static testcase_t testcases[] =
 	    0x800080ff
 	},
 #else
-	.src =
 	{
 	    0xff00ff00, 0xff00ff00,
 	    0x00ff00ff, 0x00ff00ff,
@@ -90,7 +85,6 @@ static testcase_t testcases[] =
 	    0xff800080
 	},
 #endif
-	.dst =
 	{
 	    0xff000000, 0xffffffff, 0xffb80000, 0xffffe113,
 	    0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff,
diff --git a/test/trap-crasher.c b/test/trap-crasher.c
index 42b82f6..7485e62 100644
--- a/test/trap-crasher.c
+++ b/test/trap-crasher.c
@@ -7,21 +7,21 @@ main()
     pixman_image_t *dst;
     pixman_trapezoid_t traps[1] = {
 	{
-	    .top = 2147483646,
-	    .bottom = 2147483647,
-	    .left = {
-		.p1 = { .x = 0, .y = 0 },
-		.p2 = { .x = 0, .y = 2147483647 }
+	    2147483646,
+	    2147483647,
+	    {
+		{ 0, 0 },
+		{ 0, 2147483647 }
 	    },
-	    .right = {
-		.p1 = { .x = 65536, .y = 0 },
-		.p2 = { .x = 0, .y = 2147483647 }
+	    {
+		{ 65536, 0 },
+		{ 0, 2147483647 }
 	    }
 	},
     };
-    
+
     dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1);
-    
+
     pixman_add_trapezoids (dst, 0, 0, sizeof (traps)/sizeof (traps[0]), traps);
     return (0);
 }
-- 
1.6.6.1