History

video: separate repacking code from zimg and make it independent

For whatever purpose. If anything, this makes the zimg wrapper cleaner. The added tests are not particular exhaustive, but nice to have. This also makes the scale_zimg.c test pretty useless, because it only tests repacking (going through the zimg wrapper). In theory, the repack_tests things could also be used on scalers, but I guess it doesn't matter. Some things are added over the previous zimg wrapper code. For example, some fringe formats can now be expanded to 8 bit per component for convenience.

wm4 committed 6 years ago

Commit d8002f11 parent d61ced39 files · +1688 −895Browse files

Showing the changes to test (4 of 9 files). Show all

Unified · Split

4 files
  1. test/ref/repack.txt +163 −0
  2. test/repack.c +249 −0
  3. test/tests.c +23 −0
  4. test/tests.h +7 −0
test/ref/repack.txt+163−0
@@ -0,0 +1,163 @@
10bgr => [pa] [un] gbrp | a=1:1 [tu] [tp]
20rgb => [pa] [un] gbrp | a=1:1 [tu] [tp]
3abgr => [pa] [un] gbrap | a=1:1 [tu] [tp]
4argb => [pa] [un] gbrap | a=1:1 [tu] [tp]
5ayuv64 => [pa] [un] yuva444p16 | a=1:1 [tu] [tp]
6ayuv64be => [pa] [un] yuva444p16 | a=1:1 [tu] [tp]
7bayer_bggr16 => no
8bayer_bggr16be => no
9bayer_bggr8 => no
10bayer_gbrg16 => no
11bayer_gbrg16be => no
12bayer_gbrg8 => no
13bayer_grbg16 => no
14bayer_grbg16be => no
15bayer_grbg8 => no
16bayer_rggb16 => no
17bayer_rggb16be => no
18bayer_rggb8 => no
19bgr0 => [pa] [un] gbrp | a=1:1 [tu] [tp]
20bgr24 => [pa] [un] gbrp | a=1:1
21bgr4 => no
22bgr444 => [pa] [un] gbrp4 | a=1:1
23bgr444 => [pa] [un] gbrp | a=1:1 [expand-8bit]
24bgr444be => [pa] [un] gbrp4 | a=1:1
25bgr444be => [pa] [un] gbrp | a=1:1 [expand-8bit]
26bgr48 => [pa] [un] gbrp16 | a=1:1
27bgr48be => [pa] [un] gbrp16 | a=1:1
28bgr4_byte => [pa] [un] gbrp2 | a=1:1
29bgr4_byte => [pa] [un] gbrp1 | a=1:1 [round-down]
30bgr4_byte => [pa] [un] gbrp | a=1:1 [expand-8bit]
31bgr555 => [pa] [un] gbrp5 | a=1:1
32bgr555 => [pa] [un] gbrp | a=1:1 [expand-8bit]
33bgr555be => [pa] [un] gbrp5 | a=1:1
34bgr555be => [pa] [un] gbrp | a=1:1 [expand-8bit]
35bgr565 => [pa] [un] gbrp6 | a=1:1
36bgr565 => [pa] [un] gbrp5 | a=1:1 [round-down]
37bgr565 => [pa] [un] gbrp | a=1:1 [expand-8bit]
38bgr565be => [pa] [un] gbrp6 | a=1:1
39bgr565be => [pa] [un] gbrp5 | a=1:1 [round-down]
40bgr565be => [pa] [un] gbrp | a=1:1 [expand-8bit]
41bgr8 => [pa] [un] gbrp3 | a=1:1
42bgr8 => [pa] [un] gbrp2 | a=1:1 [round-down]
43bgr8 => [pa] [un] gbrp | a=1:1 [expand-8bit]
44bgra => [pa] [un] gbrap | a=1:1 [tu] [tp]
45bgra64 => [pa] [un] gbrap16 | a=1:1
46bgra64be => [pa] [un] gbrap16 | a=1:1
47cuda => no
48d3d11 => no
49d3d11va_vld => no
50drm_prime => no
51dxva2_vld => no
52gbrap10be => [pa] [un] gbrap10 | a=1:1
53gbrap12be => [pa] [un] gbrap12 | a=1:1
54gbrap16be => [pa] [un] gbrap16 | a=1:1
55gbrapf32be => [pa] [un] gbrapf32 | a=1:1
56gbrp10be => [pa] [un] gbrp10 | a=1:1
57gbrp12be => [pa] [un] gbrp12 | a=1:1
58gbrp14be => [pa] [un] gbrp14 | a=1:1
59gbrp16be => [pa] [un] gbrp16 | a=1:1
60gbrp9be => [pa] [un] gbrp9 | a=1:1
61gbrpf32be => [pa] [un] gbrpf32 | a=1:1
62gray10be => [pa] [un] gray10 | a=1:1
63gray12be => [pa] [un] gray12 | a=1:1
64gray14be => [pa] [un] gray14 | a=1:1
65gray16be => [pa] [un] gray16 | a=1:1
66gray9be => [pa] [un] gray9 | a=1:1
67grayf32be => [pa] [un] grayf32 | a=1:1
68mediacodec => no
69mmal => no
70monob => [pa] [un] y1 | a=8:1 [tu] [tp]
71monob => [pa] [un] gray | a=8:1 [expand-8bit]
72monow => [pa] [un] y1 | a=8:1 [tu] [tp]
73monow => [pa] [un] gray | a=8:1 [expand-8bit]
74nv12 => [pa] [un] yuv420p | a=2:2 [tu] [tp]
75nv16 => [pa] [un] yuv422p | a=2:1
76nv20 => [pa] [un] yuv422p10 | a=2:1
77nv20be => [pa] [un] yuv422p10 | a=2:1
78nv21 => [pa] [un] yuv420p | a=2:2 [tu] [tp]
79nv24 => [pa] [un] yuv444p | a=1:1
80nv42 => [pa] [un] yuv444p | a=1:1
81opencl => no
82p010 => [pa] [un] yuv420p16 | a=2:2
83p010be => [pa] [un] yuv420p16 | a=2:2
84p016 => [pa] [un] yuv420p16 | a=2:2
85p016be => [pa] [un] yuv420p16 | a=2:2
86pal8 => [un] gbrap | a=1:1
87qsv => no
88rgb0 => [pa] [un] gbrp | a=1:1 [tu] [tp]
89rgb24 => [pa] [un] gbrp | a=1:1
90rgb30 => [pa] [un] gbrp10 | a=1:1
91rgb4 => no
92rgb444 => [pa] [un] gbrp4 | a=1:1
93rgb444 => [pa] [un] gbrp | a=1:1 [expand-8bit]
94rgb444be => [pa] [un] gbrp4 | a=1:1
95rgb444be => [pa] [un] gbrp | a=1:1 [expand-8bit]
96rgb48 => [pa] [un] gbrp16 | a=1:1
97rgb48be => [pa] [un] gbrp16 | a=1:1 [tu] [tp]
98rgb4_byte => [pa] [un] gbrp2 | a=1:1
99rgb4_byte => [pa] [un] gbrp1 | a=1:1 [round-down]
100rgb4_byte => [pa] [un] gbrp | a=1:1 [expand-8bit]
101rgb555 => [pa] [un] gbrp5 | a=1:1
102rgb555 => [pa] [un] gbrp | a=1:1 [expand-8bit]
103rgb555be => [pa] [un] gbrp5 | a=1:1
104rgb555be => [pa] [un] gbrp | a=1:1 [expand-8bit]
105rgb565 => [pa] [un] gbrp6 | a=1:1
106rgb565 => [pa] [un] gbrp5 | a=1:1 [round-down]
107rgb565 => [pa] [un] gbrp | a=1:1 [expand-8bit]
108rgb565be => [pa] [un] gbrp6 | a=1:1
109rgb565be => [pa] [un] gbrp5 | a=1:1 [round-down]
110rgb565be => [pa] [un] gbrp | a=1:1 [expand-8bit]
111rgb8 => [pa] [un] gbrp3 | a=1:1
112rgb8 => [pa] [un] gbrp2 | a=1:1 [round-down]
113rgb8 => [pa] [un] gbrp | a=1:1 [expand-8bit]
114rgba => [pa] [un] gbrap | a=1:1 [tu] [tp]
115rgba64 => [pa] [un] gbrap16 | a=1:1 [tu] [tp]
116rgba64be => [pa] [un] gbrap16 | a=1:1
117uyvy422 => [pa] [un] yuv422p | a=2:1
118uyyvyy411 => no
119vaapi => no
120vaapi_idct => no
121vaapi_moco => no
122vdpau => no
123vdpau_output => no
124videotoolbox => no
125vulkan => no
126xvmc => no
127xyz12 => [pa] [un] gbrp16 | a=1:1
128xyz12be => [pa] [un] gbrp16 | a=1:1
129y210 => [pa] [un] yuv422p16 | a=2:1
130y210be => [pa] [un] yuv422p16 | a=2:1
131ya16 => [pa] [un] yap16 | a=1:1 [tu] [tp]
132ya16be => [pa] [un] yap16 | a=1:1
133ya8 => [pa] [un] yap8 | a=1:1
134yuv420p10be => [pa] [un] yuv420p10 | a=2:2
135yuv420p12be => [pa] [un] yuv420p12 | a=2:2
136yuv420p14be => [pa] [un] yuv420p14 | a=2:2
137yuv420p16be => [pa] [un] yuv420p16 | a=2:2
138yuv420p9be => [pa] [un] yuv420p9 | a=2:2
139yuv422p10be => [pa] [un] yuv422p10 | a=2:1
140yuv422p12be => [pa] [un] yuv422p12 | a=2:1
141yuv422p14be => [pa] [un] yuv422p14 | a=2:1
142yuv422p16be => [pa] [un] yuv422p16 | a=2:1 [tu] [tp]
143yuv422p9be => [pa] [un] yuv422p9 | a=2:1
144yuv440p10be => [pa] [un] yuv440p10 | a=1:2
145yuv440p12be => [pa] [un] yuv440p12 | a=1:2
146yuv444p10be => [pa] [un] yuv444p10 | a=1:1
147yuv444p12be => [pa] [un] yuv444p12 | a=1:1
148yuv444p14be => [pa] [un] yuv444p14 | a=1:1
149yuv444p16be => [pa] [un] yuv444p16 | a=1:1
150yuv444p9be => [pa] [un] yuv444p9 | a=1:1
151yuva420p10be => [pa] [un] yuva420p10 | a=2:2
152yuva420p16be => [pa] [un] yuva420p16 | a=2:2
153yuva420p9be => [pa] [un] yuva420p9 | a=2:2
154yuva422p10be => [pa] [un] yuva422p10 | a=2:1
155yuva422p12be => [pa] [un] yuva422p12 | a=2:1
156yuva422p16be => [pa] [un] yuva422p16 | a=2:1
157yuva422p9be => [pa] [un] yuva422p9 | a=2:1
158yuva444p10be => [pa] [un] yuva444p10 | a=1:1
159yuva444p12be => [pa] [un] yuva444p12 | a=1:1
160yuva444p16be => [pa] [un] yuva444p16 | a=1:1
161yuva444p9be => [pa] [un] yuva444p9 | a=1:1
162yuyv422 => [pa] [un] yuv422p | a=2:1
163yvyu422 => [pa] [un] yuv422p | a=2:1 [tu] [tp]
test/repack.c+249−0
@@ -0,0 +1,249 @@
1#include <libavutil/pixfmt.h>
2
3#include "common/common.h"
4#include "tests.h"
5#include "video/fmt-conversion.h"
6#include "video/img_format.h"
7#include "video/repack.h"
8#include "video/zimg.h"
9
10// Excuse the utter stupidity.
11#define UNFUCK(v) ((v) > 0 ? (v) : pixfmt2imgfmt(-(v)))
12static_assert(IMGFMT_START > 0, "");
13#define IMGFMT_GBRP (-AV_PIX_FMT_GBRP)
14#define IMGFMT_GBRAP (-AV_PIX_FMT_GBRAP)
15
16struct entry {
17 int w, h;
18 int fmt_a;
19 const void *const a[4];
20 int fmt_b;
21 const void *const b[4];
22 int flags;
23};
24
25#define P8(...) (const uint8_t[]){__VA_ARGS__}
26#define P16(...) (const uint16_t[]){__VA_ARGS__}
27
28// Warning: only entries that match existing conversions are tested.
29static const struct entry repack_tests[] = {
30 // Note: the '0' tests rely on 0 being written, although by definition the
31 // contents of this padding is undefined. The repacker always writes
32 // it this way, though.
33 {1, 1, IMGFMT_RGB0, {P8(1, 2, 3, 0)},
34 IMGFMT_GBRP, {P8(2), P8(3), P8(1)}},
35 {1, 1, IMGFMT_BGR0, {P8(1, 2, 3, 0)},
36 IMGFMT_GBRP, {P8(2), P8(1), P8(3)}},
37 {1, 1, IMGFMT_0RGB, {P8(0, 1, 2, 3)},
38 IMGFMT_GBRP, {P8(2), P8(3), P8(1)}},
39 {1, 1, IMGFMT_0BGR, {P8(0, 1, 2, 3)},
40 IMGFMT_GBRP, {P8(2), P8(1), P8(3)}},
41 {1, 1, IMGFMT_RGBA, {P8(1, 2, 3, 4)},
42 IMGFMT_GBRAP, {P8(2), P8(3), P8(1), P8(4)}},
43 {1, 1, IMGFMT_BGRA, {P8(1, 2, 3, 4)},
44 IMGFMT_GBRAP, {P8(2), P8(1), P8(3), P8(4)}},
45 {1, 1, IMGFMT_ARGB, {P8(4, 1, 2, 3)},
46 IMGFMT_GBRAP, {P8(2), P8(3), P8(1), P8(4)}},
47 {1, 1, IMGFMT_ABGR, {P8(4, 1, 2, 3)},
48 IMGFMT_GBRAP, {P8(2), P8(1), P8(3), P8(4)}},
49 {1, 1, IMGFMT_RGBA64, {P16(0x1a1b, 0x2a2b, 0x3a3b, 0x4a4b)},
50 -AV_PIX_FMT_GBRAP16, {P16(0x2a2b), P16(0x3a3b),
51 P16(0x1a1b), P16(0x4a4b)}},
52 {1, 1, -AV_PIX_FMT_RGB48BE, {P16(0x1a1b, 0x2a2b, 0x3a3b)},
53 -AV_PIX_FMT_GBRP16, {P16(0x2b2a), P16(0x3b3a),
54 P16(0x1b1a)}},
55 {8, 1, -AV_PIX_FMT_MONOWHITE, {P8(0xAA)},
56 IMGFMT_Y1, {P8(0, 1, 0, 1, 0, 1, 0, 1)}},
57 {8, 1, -AV_PIX_FMT_MONOBLACK, {P8(0xAA)},
58 IMGFMT_Y1, {P8(1, 0, 1, 0, 1, 0, 1, 0)}},
59 {2, 2, IMGFMT_NV12, {P8(1, 2, 3, 4), P8(5, 6)},
60 IMGFMT_420P, {P8(1, 2, 3, 4), P8(5), P8(6)}},
61 {2, 2, -AV_PIX_FMT_NV21, {P8(1, 2, 3, 4), P8(5, 6)},
62 IMGFMT_420P, {P8(1, 2, 3, 4), P8(6), P8(5)}},
63 {1, 1, -AV_PIX_FMT_AYUV64, {P16(1, 2, 3, 4)},
64 -AV_PIX_FMT_YUVA444P16, {P16(2), P16(3), P16(4), P16(1)}},
65 {1, 1, -AV_PIX_FMT_AYUV64BE, {P16(0x0100, 0x0200, 0x0300, 0x0400)},
66 -AV_PIX_FMT_YUVA444P16, {P16(2), P16(3), P16(4), P16(1)}},
67 {2, 1, -AV_PIX_FMT_YVYU422, {P8(1, 2, 3, 4)},
68 -AV_PIX_FMT_YUV422P, {P8(1, 3), P8(4), P8(2)}},
69 {1, 1, -AV_PIX_FMT_YA16, {P16(1, 2)},
70 IMGFMT_YAP16, {P16(1), P16(2)}},
71 {2, 1, -AV_PIX_FMT_YUV422P16BE, {P16(0x1a1b, 0x2a2b), P16(0x3a3b),
72 P16(0x4a4b)},
73 -AV_PIX_FMT_YUV422P16, {P16(0x1b1a, 0x2b2a), P16(0x3b3a),
74 P16(0x4b4a)}},
75};
76
77static bool is_true_planar(int imgfmt)
78{
79 struct mp_regular_imgfmt desc;
80 if (!mp_get_regular_imgfmt(&desc, imgfmt))
81 return false;
82
83 for (int n = 0; n < desc.num_planes; n++) {
84 if (desc.planes[n].num_components != 1)
85 return false;
86 }
87
88 return true;
89}
90
91static int try_repack(struct test_ctx *ctx, FILE *f, int imgfmt, int flags,
92 int not_if_fmt)
93{
94 char *head = mp_tprintf(80, "%-15s =>", mp_imgfmt_to_name(imgfmt));
95 struct mp_repack *un = mp_repack_create_planar(imgfmt, false, flags);
96 struct mp_repack *pa = mp_repack_create_planar(imgfmt, true, flags);
97
98 // If both exists, they must be always symmetric.
99 if (un && pa) {
100 assert(mp_repack_get_format_src(pa) == mp_repack_get_format_dst(un));
101 assert(mp_repack_get_format_src(un) == mp_repack_get_format_dst(pa));
102 assert(mp_repack_get_align_x(pa) == mp_repack_get_align_x(un));
103 assert(mp_repack_get_align_y(pa) == mp_repack_get_align_y(un));
104 }
105
106 int a = 0;
107 int b = 0;
108 if (un) {
109 a = mp_repack_get_format_src(un);
110 b = mp_repack_get_format_dst(un);
111 } else if (pa) {
112 a = mp_repack_get_format_dst(pa);
113 b = mp_repack_get_format_src(pa);
114 }
115
116 // Skip the identity ones because they're uninteresting, and add too much
117 // noise. But still make sure they behave as expected.
118 if (is_true_planar(imgfmt)) {
119 // (note that we require alpha-enabled zimg)
120 assert(mp_zimg_supports_in_format(imgfmt));
121 assert(un && pa);
122 assert(a == imgfmt && b == imgfmt);
123 talloc_free(pa);
124 talloc_free(un);
125 return 0;
126 }
127
128 struct mp_repack *rp = pa ? pa : un;
129 if (!rp) {
130 if (!flags)
131 fprintf(f, "%s no\n", head);
132 return 0;
133 }
134
135 assert(a == imgfmt);
136 if (b && b == not_if_fmt) {
137 talloc_free(pa);
138 talloc_free(un);
139 return 0;
140 }
141
142 fprintf(f, "%s %4s %4s %-15s |", head, pa ? "[pa]" : "", un ? "[un]" : "",
143 mp_imgfmt_to_name(b));
144
145 fprintf(f, " a=%d:%d", mp_repack_get_align_x(rp), mp_repack_get_align_y(rp));
146
147 if (flags & REPACK_CREATE_ROUND_DOWN)
148 fprintf(f, " [round-down]");
149 if (flags & REPACK_CREATE_EXPAND_8BIT)
150 fprintf(f, " [expand-8bit]");
151
152 // LCM of alignment of all packers.
153 int ax = mp_repack_get_align_x(rp);
154 int ay = mp_repack_get_align_y(rp);
155 if (pa && un) {
156 ax = MPMAX(mp_repack_get_align_x(pa), mp_repack_get_align_x(un));
157 ay = MPMAX(mp_repack_get_align_y(pa), mp_repack_get_align_y(un));
158 }
159
160 for (int n = 0; n < MP_ARRAY_SIZE(repack_tests); n++) {
161 const struct entry *e = &repack_tests[n];
162 int fmt_a = UNFUCK(e->fmt_a);
163 int fmt_b = UNFUCK(e->fmt_b);
164 if (!(fmt_a == a && fmt_b == b && e->flags == flags))
165 continue;
166
167 // We convert a "random" macro pixel to catch potential addressing bugs
168 // that might be ignored with (0, 0) origins.
169 struct mp_image *ia = mp_image_alloc(fmt_a, e->w * 5 * ax, e->h * 5 * ay);
170 struct mp_image *ib = mp_image_alloc(fmt_b, e->w * 7 * ax, e->h * 6 * ay);
171 int sx = 4 * ax, sy = 3 * ay, dx = 3 * ax, dy = 2 * ay;
172
173 assert(ia && ib);
174
175 for (int pack = 0; pack < 2; pack++) {
176 struct mp_repack *repacker = pack ? pa : un;
177 if (!repacker)
178 continue;
179
180 mp_image_clear(ia, 0, 0, ia->w, ia->h);
181 mp_image_clear(ib, 0, 0, ib->w, ib->h);
182
183 const void *const *dstd = pack ? e->a : e->b;
184 const void *const *srcd = pack ? e->b : e->a;
185 struct mp_image *dsti = pack ? ia : ib;
186 struct mp_image *srci = pack ? ib : ia;
187
188 bool r = repack_config_buffers(repacker, 0, dsti, 0, srci, NULL);
189 assert(r);
190
191 for (int p = 0; p < srci->num_planes; p++) {
192 uint8_t *ptr = mp_image_pixel_ptr(srci, p, sx, sy);
193 for (int y = 0; y < e->h >> srci->fmt.ys[p]; y++) {
194 int w = e->w >> srci->fmt.xs[p];
195 int wb = (w * srci->fmt.bpp[p] + 7) / 8;
196 const void *cptr = (uint8_t *)srcd[p] + wb * y;
197 memcpy(ptr + srci->stride[p] * y, cptr, wb);
198 }
199 }
200
201 repack_line(repacker, dx, dy, sx, sy, e->w);
202
203 for (int p = 0; p < dsti->num_planes; p++) {
204 uint8_t *ptr = mp_image_pixel_ptr(dsti, p, dx, dy);
205 for (int y = 0; y < e->h >> dsti->fmt.ys[p]; y++) {
206 int w = e->w >> dsti->fmt.xs[p];
207 int wb = (w * dsti->fmt.bpp[p] + 7) / 8;
208 const void *cptr = (uint8_t *)dstd[p] + wb * y;
209 assert_memcmp(ptr + dsti->stride[p] * y, cptr, wb);
210 }
211 }
212
213 fprintf(f, " [t%s]", pack ? "p" : "u");
214 }
215
216 talloc_free(ia);
217 talloc_free(ib);
218 }
219
220 fprintf(f, "\n");
221
222 talloc_free(pa);
223 talloc_free(un);
224 return b;
225}
226
227static void run(struct test_ctx *ctx)
228{
229 FILE *f = test_open_out(ctx, "repack.txt");
230
231 init_imgfmts_list();
232 for (int n = 0; n < num_imgfmts; n++) {
233 int imgfmt = imgfmts[n];
234
235 int other = try_repack(ctx, f, imgfmt, 0, 0);
236 try_repack(ctx, f, imgfmt, REPACK_CREATE_ROUND_DOWN, other);
237 try_repack(ctx, f, imgfmt, REPACK_CREATE_EXPAND_8BIT, other);
238 }
239
240 fclose(f);
241
242 assert_text_files_equal(ctx, "repack.txt", "repack.txt",
243 "This can fail if FFmpeg/libswscale adds or removes pixfmts.");
244}
245
246const struct unittest test_repack = {
247 .name = "repack",
248 .run = run,
249};
test/tests.c+23−0
@@ -12,6 +12,7 @@ static const struct unittest *unittests[] = { · 11 unmodified lines
12 &test_paths,12 &test_paths,
13 &test_repack_sws,13 &test_repack_sws,
14#if HAVE_ZIMG14#if HAVE_ZIMG
15 &test_repack, // zimg only due to cross-checking with zimg.c
15 &test_repack_zimg,16 &test_repack_zimg,
16#endif17#endif
17 NULL18 NULL
@@ -128,3 +129,25 @@ void assert_text_files_equal_impl(const char *file, int line, · 110 unmodified lines
128 abort();129 abort();
129 }130 }
130}131}
132
133static void hexdump(const uint8_t *d, size_t size)
134{
135 printf("|");
136 while (size--) {
137 printf(" %02x", d[0]);
138 d++;
139 }
140 printf(" |\n");
141}
142
143void assert_memcmp_impl(const char *file, int line,
144 const void *a, const void *b, size_t size)
145{
146 if (memcmp(a, b, size) == 0)
147 return;
148
149 printf("%s:%d: mismatching data:\n", file, line);
150 hexdump(a, size);
151 hexdump(b, size);
152 abort();
153}
test/tests.h+7−0
@@ -43,6 +43,7 @@ extern const struct unittest test_json; · 42 unmodified lines
43extern const struct unittest test_linked_list;43extern const struct unittest test_linked_list;
44extern const struct unittest test_repack_sws;44extern const struct unittest test_repack_sws;
45extern const struct unittest test_repack_zimg;45extern const struct unittest test_repack_zimg;
46extern const struct unittest test_repack;
46extern const struct unittest test_paths;47extern const struct unittest test_paths;
47 48
48#define assert_true(x) assert(x)49#define assert_true(x) assert(x)
@@ -54,6 +55,10 @@ extern const struct unittest test_paths; · 5 unmodified lines
54#define assert_float_equal(a, b, tolerance) \55#define assert_float_equal(a, b, tolerance) \
55 assert_float_equal_impl(__FILE__, __LINE__, (a), (b), (tolerance))56 assert_float_equal_impl(__FILE__, __LINE__, (a), (b), (tolerance))
56 57
58// Assert that memcmp(a,b,s)==0, or hexdump output on failure.
59#define assert_memcmp(a, b, s) \
60 assert_memcmp_impl(__FILE__, __LINE__, (a), (b), (s))
61
57// Require that the files "ref" and "new" are the same. The paths can be62// Require that the files "ref" and "new" are the same. The paths can be
58// relative to ref_path and out_path respectively. If they're not the same,63// relative to ref_path and out_path respectively. If they're not the same,
59// the output of "diff" is shown, the err message (if not NULL), and the test64// the output of "diff" is shown, the err message (if not NULL), and the test
@@ -69,6 +74,8 @@ void assert_float_equal_impl(const char *file, int line, · 9 unmodified lines
69void assert_text_files_equal_impl(const char *file, int line,74void assert_text_files_equal_impl(const char *file, int line,
70 struct test_ctx *ctx, const char *ref,75 struct test_ctx *ctx, const char *ref,
71 const char *new, const char *err);76 const char *new, const char *err);
77void assert_memcmp_impl(const char *file, int line,
78 const void *a, const void *b, size_t size);
72 79
73// Open a new file in the out_path. Always succeeds.80// Open a new file in the out_path. Always succeeds.
74FILE *test_open_out(struct test_ctx *ctx, const char *name);81FILE *test_open_out(struct test_ctx *ctx, const char *name);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t