Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: third_party/qcms/src/tests/qcms_test_main.c

Issue 1374953003: Expand QCMS tests. Add Munsell test for transform accuracy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the Chromium LICENSE file.
4
5 #include "qcms.h"
6 #include "qcms_test_util.h"
7 #include "timing.h"
8
9 #include <math.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 // Manually update the items below to add more tests.
15 extern struct qcms_test_case qcms_test_tetra_clut_rgba_info;
16 extern struct qcms_test_case qcms_test_munsell_info;
17
18 struct qcms_test_case qcms_test[2];
19 #define TEST_CASES (sizeof(qcms_test) / sizeof(qcms_test[0]))
20
21 static void initialize_tests()
22 {
23 qcms_test[0] = qcms_test_tetra_clut_rgba_info;
24 qcms_test[1] = qcms_test_munsell_info;
25 }
26
27 static void list_tests()
28 {
29 int i;
30 printf("Available QCMS tests:\n");
Noel Gordon 2015/10/08 03:12:49 QCMS -> qcms
radu.velea 2015/10/08 09:39:13 Done.
31
32 for (i = 0; i < TEST_CASES; ++i) {
33 printf("\t%s\n", qcms_test[i].test_name);
34 }
35
36 exit(1);
37 }
38
39 static void print_usage()
40 {
41 printf("Usage:\n\tqcms_test -w WIDTH -h HEIGHT -n ITERATIONS -t TEST\n");
42 printf("\t-w INT\t\ttest image width\n");
43 printf("\t-h INT\t\ttest image height\n");
44 printf("\t-n INT\t\tnumber of iterations for each test\n");
45 printf("\t-a\t\trun all tests\n");
46 printf("\t-l\t\tlist available tests\n");
47 printf("\t-s \t\tforce software(non-sse) transform function, where available \n");
48 printf("\t-i STRING\tspecify input icc color profile\n");
49 printf("\t-o STRING\tspecify output icc color profile\n");
50 printf("\t-t STRING\trun specific test - use \"-l\" to list possible values\ n");
51 printf("\n");
52 exit(1);
53 }
54
55 int enable_test(const char *args)
56 {
57 int i;
58
59 for (i = 0; i < TEST_CASES; ++i) {
Noel Gordon 2015/10/08 03:12:49 % ./out/Release/qcms_tests -t Segmentation fault
radu.velea 2015/10/08 09:39:12 Done.
60 if (strcmp(qcms_test[i].test_name, args) == 0) {
61 qcms_test[i].status = QCMS_TEST_ENABLED;
62 return 1;
63 }
64 }
65
66 return 0;
67 }
68
69 void generate_source_uint8_t(unsigned char *src, const size_t length, const size _t pixel_size)
70 {
71 size_t bytes = length * pixel_size;
72 size_t i;
73
74 for (i = 0; i < bytes; ++i) {
75 *src++ = rand() & 255;
76 }
77 }
78
79 int main(int argc, const char **argv)
80 {
81 int iterations = 1;
82 size_t height = 2000;
83 size_t width = 2000;
84 int run_all = 0;
85 const char *in = NULL, *out = NULL;
86 int force_software = 0;
87 int exit_status;
88 int enabled_tests = 0;
89 int i;
90
91 initialize_tests();
92
93 if (argc == 1) {
94 print_usage();
95 }
96
97 while (argc > 1) {
98 if (strcmp(argv[1], "-n") == 0)
99 iterations = abs(atoi(argv[2]));
100 else if (strcmp(argv[1], "-w") == 0)
101 width = (size_t) abs(atoi(argv[2]));
102 else if (strcmp(argv[1], "-h") == 0)
103 height = (size_t) abs(atoi(argv[2]));
104 else if (strcmp(argv[1], "-l") == 0)
105 list_tests();
106 else if (strcmp(argv[1], "-t") == 0)
107 enabled_tests += enable_test(argv[2]);
Noel Gordon 2015/10/08 03:12:49 Use spaces (not tabs) here. (git apply complains).
radu.velea 2015/10/08 09:39:13 Done.
108 else if (strcmp(argv[1], "-a") == 0)
109 run_all = 1;
110 else if (strcmp(argv[1], "-i") == 0)
111 in = argv[2];
112 else if (strcmp(argv[1], "-o") == 0)
113 out = argv[2];
114 else if (strcmp(argv[1], "-s") == 0)
115 force_software = 1;
116 (--argc, ++argv);
117 }
118
119 if (!run_all && !enabled_tests) {
120 print_usage();
Noel Gordon 2015/10/08 03:12:49 Use spaces (not tabs) here. (git apply complains).
radu.velea 2015/10/08 09:39:12 Done.
121 }
122
123 exit_status = 0;
124
125 for (i = 0; i < TEST_CASES; ++i) {
126 if (run_all || QCMS_TEST_ENABLED == qcms_test[i].status)
127 exit_status += qcms_test[i].test_fn(width, height, iterations, i n, out, force_software);
Noel Gordon 2015/10/08 03:12:49 Use spaces (not tabs) here. (git apply complains).
radu.velea 2015/10/08 09:39:12 Done.
128 }
129
130 return exit_status;
131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698