Commit 13a7d786 authored by Martin Storsjö's avatar Martin Storsjö

checkasm: cdef: Add verbose prints for output data (and relevant input)

For the cdef_filter tests, one could also extend the buffer to
contain 16*11 pixels, to simplify printing it as one rectangular
section.

Extend the common hex_dump function to allow dumping to an arbitrary
FILE* pointer, to reuse it for printing the source pixel buffer in
case of errors.
parent 7107c2f1
......@@ -45,19 +45,25 @@ static inline void append_plane_to_file(const pixel *buf, ptrdiff_t stride,
fclose(f);
}
static inline void hex_dump(const pixel *buf, ptrdiff_t stride,
int w, int h, const char *what)
static inline void hex_fdump(FILE *out, const pixel *buf, ptrdiff_t stride,
int w, int h, const char *what)
{
printf("%s\n", what);
fprintf(out, "%s\n", what);
while (h--) {
int x;
for (x = 0; x < w; x++)
printf(" " PIX_HEX_FMT, buf[x]);
fprintf(out, " " PIX_HEX_FMT, buf[x]);
buf += PXSTRIDE(stride);
printf("\n");
fprintf(out, "\n");
}
}
static inline void hex_dump(const pixel *buf, ptrdiff_t stride,
int w, int h, const char *what)
{
hex_fdump(stdout, buf, stride, w, h, what);
}
static inline void coef_dump(const coef *buf, const int w, const int h,
const int len, const char *what)
{
......
......@@ -28,6 +28,9 @@
#include "tests/checkasm/checkasm.h"
#include <string.h>
#include <stdio.h>
#include "common/dump.h"
#include "src/levels.h"
#include "src/cdef.h"
......@@ -80,7 +83,12 @@ static void check_cdef_filter(const cdef_fn fn, const int w, const int h,
(pixel *[2]) { top_ptr, top_ptr + 16 },
pri_strength, sec_strength, dir, damping, edges
HIGHBD_TAIL_SUFFIX);
if (memcmp(a_src, c_src, (10 * 16 + 8) * sizeof(pixel))) fail();
checkasm_check_pixel(c_src, 16 * sizeof(pixel),
a_src, 16 * sizeof(pixel),
16, 10, "src");
checkasm_check_pixel(c_src + 16 * 10, 16 * sizeof(pixel),
a_src + 16 * 10, 16 * sizeof(pixel),
8, 1, "src last row");
bench_new(a_src_ptr, 16 * sizeof(pixel), left,
(pixel *[2]) { top_ptr, top_ptr + 16 },
pri_strength, sec_strength, dir, damping, edges
......@@ -108,7 +116,12 @@ static void check_cdef_direction(const cdef_dir_fn fn) {
const int c_dir = call_ref(src, 8 * sizeof(pixel), &c_var HIGHBD_TAIL_SUFFIX);
const int a_dir = call_new(src, 8 * sizeof(pixel), &a_var HIGHBD_TAIL_SUFFIX);
if (c_var != a_var || c_dir != a_dir) fail();
if (c_var != a_var || c_dir != a_dir) {
if (fail()) {
hex_fdump(stderr, src, 8 * sizeof(pixel), 8, 8, "src");
fprintf(stderr, "c_dir %d a_dir %d\n", c_dir, a_dir);
}
}
bench_new(src, 8 * sizeof(pixel), &a_var HIGHBD_TAIL_SUFFIX);
}
report("cdef_dir");
......
......@@ -629,8 +629,9 @@ int checkasm_bench_func(void) {
state.bench_pattern_len);
}
/* Indicate that the current test has failed */
void checkasm_fail_func(const char *const msg, ...) {
/* Indicate that the current test has failed, return whether verbose printing
* is requested. */
int checkasm_fail_func(const char *const msg, ...) {
if (state.current_func_ver->cpu && state.current_func_ver->ok) {
va_list arg;
......@@ -645,6 +646,7 @@ void checkasm_fail_func(const char *const msg, ...) {
state.current_func_ver->ok = 0;
state.num_failed++;
}
return state.verbose;
}
/* Update benchmark results of the current function */
......@@ -721,8 +723,7 @@ int checkasm_check_##type(const char *const file, const int line, \
break; \
if (y == h) \
return 0; \
checkasm_fail_func("%s:%d", file, line); \
if (!state.verbose) \
if (!checkasm_fail_func("%s:%d", file, line)) \
return 1; \
fprintf(stderr, "%s:\n", name); \
while (h--) { \
......
......@@ -68,7 +68,7 @@ decl_check_bitfns(void checkasm_check_mc);
void *checkasm_check_func(void *func, const char *name, ...);
int checkasm_bench_func(void);
void checkasm_fail_func(const char *msg, ...);
int checkasm_fail_func(const char *msg, ...);
void checkasm_update_bench(int iterations, uint64_t cycles);
void checkasm_report(const char *name, ...);
void checkasm_set_signal_handler_state(int enabled);
......
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