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

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

Issue 2014023003: Add exact version of qcms used by Chrome for testing and comparison (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 extern struct qcms_test_case qcms_test_internal_srgb_info;
18 extern struct qcms_test_case qcms_test_ntsc_gamut_info;
19 extern struct qcms_test_case qcms_test_output_trc_info;
20
21 struct qcms_test_case qcms_test[5];
22 #define TEST_CASES (sizeof(qcms_test) / sizeof(qcms_test[0]))
23
24 static void initialize_tests()
25 {
26 qcms_test[0] = qcms_test_tetra_clut_rgba_info;
27 qcms_test[1] = qcms_test_munsell_info;
28 qcms_test[2] = qcms_test_internal_srgb_info;
29 qcms_test[3] = qcms_test_ntsc_gamut_info;
30 qcms_test[4] = qcms_test_output_trc_info;
31 }
32
33 static void list_tests()
34 {
35 int i;
36 printf("Available qcms tests:\n");
37
38 for (i = 0; i < TEST_CASES; ++i) {
39 printf("\t%s\n", qcms_test[i].test_name);
40 }
41
42 exit(EXIT_FAILURE);
43 }
44
45 static void print_usage()
46 {
47 printf("Usage:\n\tqcms_test -w WIDTH -h HEIGHT -n ITERATIONS -t TEST\n");
48 printf("\t-w INT\t\ttest image width\n");
49 printf("\t-h INT\t\ttest image height\n");
50 printf("\t-n INT\t\tnumber of iterations for each test\n");
51 printf("\t-a\t\trun all tests\n");
52 printf("\t-l\t\tlist available tests\n");
53 printf("\t-s \t\tforce software(non-sse) transform function, where available \n");
54 printf("\t-i STRING\tspecify input icc color profile\n");
55 printf("\t-o STRING\tspecify output icc color profile\n");
56 printf("\t-t STRING\trun specific test - use \"-l\" to list possible values\ n");
57 printf("\n");
58 exit(1);
59 }
60
61 int enable_test(const char *args)
62 {
63 int i;
64
65 if (!args)
66 return 0;
67
68 for (i = 0; i < TEST_CASES; ++i) {
69 if (strcmp(qcms_test[i].test_name, args) == 0) {
70 qcms_test[i].status = QCMS_TEST_ENABLED;
71 return 1;
72 }
73 }
74
75 return 0;
76 }
77
78 int main(int argc, const char **argv)
79 {
80 int iterations = 1;
81 size_t height = 2000;
82 size_t width = 2000;
83 int run_all = 0;
84 const char *in = NULL, *out = NULL;
85 int force_software = 0;
86 int exit_status;
87 int enabled_tests = 0;
88 int i;
89
90 initialize_tests();
91 seconds();
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]);
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();
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, in, o ut, force_software);
128 }
129
130 return exit_status;
131 }
OLDNEW
« no previous file with comments | « third_party/qcms/src/tests/qcms_test_internal_srgb.c ('k') | third_party/qcms/src/tests/qcms_test_munsell.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698