render: add html report generation
This commit is contained in:
@@ -56,18 +56,22 @@ static void imageFree(image_t *img) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 4) {
|
||||
fprintf(stderr, "Usage: %s infile1 infile2 out_diff.png\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s infile1 infile2 out_diff\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* const filename_gold = argv[1];
|
||||
const char* const filename_test = argv[2];
|
||||
const char* const filename_diff = argv[3];
|
||||
|
||||
const uint64_t start_ns = now();
|
||||
|
||||
image_t a, b;
|
||||
|
||||
if (!imageLoad(&a, argv[1]))
|
||||
if (!imageLoad(&a, filename_gold))
|
||||
return 1;
|
||||
|
||||
if (!imageLoad(&b, argv[2]))
|
||||
if (!imageLoad(&b, filename_test))
|
||||
return 1;
|
||||
|
||||
if (a.w != b.w || a.h != b.h || a.comp != b.comp) {
|
||||
@@ -130,13 +134,30 @@ int main(int argc, char *argv[]) {
|
||||
const float diff_pct_threshold = 1.f;
|
||||
const float diff_pct = diff_sum * 100.f / total;
|
||||
const int over = diff_pct_threshold < diff_pct;
|
||||
// TODO count of pixels with difference over the threshold
|
||||
|
||||
fprintf(stderr, "%s\"%s\" vs \"%s\": %d (%.03f%%)\033[0m\n",
|
||||
over ? "\033[31mFAIL" : (diff_sum == 0 ? "\033[32m" : ""),
|
||||
argv[1], argv[2], diff_sum, diff_pct
|
||||
);
|
||||
|
||||
if (!imageSave(&diff, argv[3]))
|
||||
// X(name, format, expression)
|
||||
#define LIST_PROPS(X) \
|
||||
X(diff_total, "%d, ", diff_sum) \
|
||||
X(diff_pct, "%.03f, ", diff_pct) \
|
||||
X(fail, "%d", over) \
|
||||
|
||||
fprintf(stdout, "{"
|
||||
#define X(name, format, expr) "\"" #name "\": " format
|
||||
LIST_PROPS(X)
|
||||
#undef X
|
||||
"}\n"
|
||||
#define X(name, format, expr) , (expr)
|
||||
LIST_PROPS(X)
|
||||
#undef X
|
||||
);
|
||||
|
||||
if (!imageSave(&diff, filename_diff))
|
||||
return 1;
|
||||
|
||||
const uint64_t end_ns = now();
|
||||
|
||||
Reference in New Issue
Block a user