Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 bellow to add more tests. | |
|
Noel Gordon
2015/10/07 12:26:31
bellow -> below.
radu.velea
2015/10/07 13:22:36
Done.
| |
| 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_SIZE (sizeof(qcms_test) / sizeof(qcms_test[0])) | |
|
Noel Gordon
2015/10/07 12:26:31
TEST_SIZE -> TEST_CASES
radu.velea
2015/10/07 13:22:36
Done.
| |
| 20 | |
| 21 static void init_tests() | |
|
Noel Gordon
2015/10/07 12:26:31
initialize_tests
radu.velea
2015/10/07 13:22:36
Done.
| |
| 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"); | |
| 31 | |
| 32 for (i = 0; i < TEST_SIZE; ++i) { | |
| 33 printf("\t%s\n", qcms_test[i].test_name); | |
| 34 } | |
| 35 | |
| 36 exit(0); | |
| 37 } | |
| 38 | |
| 39 static void print_usage() | |
| 40 { | |
| 41 printf("Usage:\n\tqcms_test -w WIDTH -h HEIGHT -n ITERATIONS -t TEST\n"); | |
|
Noel Gordon
2015/10/07 12:26:31
Could you make this usage match that given in the
radu.velea
2015/10/07 13:22:35
Done.
| |
| 42 printf("\t-w INT\t\tauto-generated image width\n"); | |
| 43 printf("\t-h INT\t\tauto-generated image height\n"); | |
| 44 printf("\t-n INT\t\tnumber of iterations to run the test(s) on\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(0); | |
| 53 } | |
| 54 | |
| 55 void enable_test(const char *args) | |
| 56 { | |
| 57 int i; | |
| 58 for (i = 0; i < TEST_SIZE; ++i) { | |
|
Noel Gordon
2015/10/07 12:26:31
space before this "for" line.
radu.velea
2015/10/07 13:22:35
Done.
| |
| 59 if (strcmp(qcms_test[i].test_name, args) == 0) { | |
| 60 qcms_test[i].status = QCMS_TEST_ENABLED; | |
|
Noel Gordon
2015/10/07 12:26:31
Perhaps count the number of tests enabled here ...
radu.velea
2015/10/07 13:22:35
Done.
| |
| 61 } | |
| 62 } | |
|
Noel Gordon
2015/10/07 12:26:31
... and if no tests were enabled, should you maybe
radu.velea
2015/10/07 13:22:35
Done.
| |
| 63 } | |
| 64 | |
| 65 void generate_source_uint8_t(unsigned char *src, const size_t length, const size _t pixel_size) | |
| 66 { | |
| 67 size_t bytes = length * pixel_size; | |
| 68 size_t i; | |
| 69 | |
| 70 for (i = 0; i < bytes; ++i) { | |
| 71 *src++ = rand() & 255; | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 int main(int argc, const char **argv) | |
| 76 { | |
| 77 int iterations = 1; | |
| 78 size_t height = 2000; | |
| 79 size_t width = 2000; | |
| 80 int run_all = 0; | |
| 81 const char *in = NULL, *out = NULL; | |
| 82 int force_software = 0; | |
|
Noel Gordon
2015/10/07 12:26:31
int force_software = 0;
int i;
initialize_tests()
radu.velea
2015/10/07 13:22:35
Done.
| |
| 83 | |
| 84 int i; | |
| 85 init_tests(); | |
| 86 | |
| 87 if (argc == 1) { | |
| 88 print_usage(); | |
| 89 } | |
| 90 | |
| 91 while (argc > 1) { | |
| 92 if (strcmp(argv[1], "-n") == 0) | |
| 93 iterations = abs(atoi(argv[2])); | |
| 94 else if (strcmp(argv[1], "-w") == 0) | |
| 95 width = (size_t) abs(atoi(argv[2])); | |
| 96 else if (strcmp(argv[1], "-h") == 0) | |
| 97 height = (size_t) abs(atoi(argv[2])); | |
| 98 else if (strcmp(argv[1], "-l") == 0) | |
| 99 list_tests(); | |
| 100 else if (strcmp(argv[1], "-t") == 0) | |
| 101 enable_test(argv[2]); | |
| 102 else if (strcmp(argv[1], "-a") == 0) | |
| 103 run_all = 1; | |
| 104 else if (strcmp(argv[1], "-i") == 0) | |
| 105 in = argv[2]; | |
| 106 else if (strcmp(argv[1], "-o") == 0) | |
| 107 out = argv[2]; | |
| 108 else if (strcmp(argv[1], "-s") == 0) | |
| 109 force_software = 1; | |
| 110 (--argc, ++argv); | |
| 111 } | |
| 112 | |
|
Noel Gordon
2015/10/07 12:26:31
Define |int exit_status| in the usual place, and i
radu.velea
2015/10/07 13:22:35
Done.
| |
| 113 for (i = 0; i < TEST_SIZE; ++i) { | |
| 114 if (run_all || QCMS_TEST_ENABLED == qcms_test[i].status) | |
| 115 qcms_test[i].test_fn(width, height, iterations, in, out, force_softw are); | |
|
Noel Gordon
2015/10/07 12:26:31
exit_status += qcms_test[i].test_fn(...
radu.velea
2015/10/07 13:22:36
Done.
| |
| 116 } | |
| 117 | |
| 118 return EXIT_SUCCESS; | |
|
Noel Gordon
2015/10/07 12:26:31
return exit_status;
radu.velea
2015/10/07 13:22:35
Done.
| |
| 119 } | |
| OLD | NEW |