| 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 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"); |
| 31 |
| 32 for (i = 0; i < TEST_CASES; ++i) { |
| 33 printf("\t%s\n", qcms_test[i].test_name); |
| 34 } |
| 35 |
| 36 exit(EXIT_FAILURE); |
| 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 if (!args) |
| 60 return 0; |
| 61 |
| 62 for (i = 0; i < TEST_CASES; ++i) { |
| 63 if (strcmp(qcms_test[i].test_name, args) == 0) { |
| 64 qcms_test[i].status = QCMS_TEST_ENABLED; |
| 65 return 1; |
| 66 } |
| 67 } |
| 68 |
| 69 return 0; |
| 70 } |
| 71 |
| 72 void generate_source_uint8_t(unsigned char *src, const size_t length, const size
_t pixel_size) |
| 73 { |
| 74 size_t bytes = length * pixel_size; |
| 75 size_t i; |
| 76 |
| 77 for (i = 0; i < bytes; ++i) { |
| 78 *src++ = rand() & 255; |
| 79 } |
| 80 } |
| 81 |
| 82 int main(int argc, const char **argv) |
| 83 { |
| 84 int iterations = 1; |
| 85 size_t height = 2000; |
| 86 size_t width = 2000; |
| 87 int run_all = 0; |
| 88 const char *in = NULL, *out = NULL; |
| 89 int force_software = 0; |
| 90 int exit_status; |
| 91 int enabled_tests = 0; |
| 92 int i; |
| 93 |
| 94 initialize_tests(); |
| 95 |
| 96 if (argc == 1) { |
| 97 print_usage(); |
| 98 } |
| 99 |
| 100 while (argc > 1) { |
| 101 if (strcmp(argv[1], "-n") == 0) |
| 102 iterations = abs(atoi(argv[2])); |
| 103 else if (strcmp(argv[1], "-w") == 0) |
| 104 width = (size_t) abs(atoi(argv[2])); |
| 105 else if (strcmp(argv[1], "-h") == 0) |
| 106 height = (size_t) abs(atoi(argv[2])); |
| 107 else if (strcmp(argv[1], "-l") == 0) |
| 108 list_tests(); |
| 109 else if (strcmp(argv[1], "-t") == 0) |
| 110 enabled_tests += enable_test(argv[2]); |
| 111 else if (strcmp(argv[1], "-a") == 0) |
| 112 run_all = 1; |
| 113 else if (strcmp(argv[1], "-i") == 0) |
| 114 in = argv[2]; |
| 115 else if (strcmp(argv[1], "-o") == 0) |
| 116 out = argv[2]; |
| 117 else if (strcmp(argv[1], "-s") == 0) |
| 118 force_software = 1; |
| 119 (--argc, ++argv); |
| 120 } |
| 121 |
| 122 if (!run_all && !enabled_tests) { |
| 123 print_usage(); |
| 124 } |
| 125 |
| 126 exit_status = 0; |
| 127 |
| 128 for (i = 0; i < TEST_CASES; ++i) { |
| 129 if (run_all || QCMS_TEST_ENABLED == qcms_test[i].status) |
| 130 exit_status += qcms_test[i].test_fn(width, height, iterations, in, o
ut, force_software); |
| 131 } |
| 132 |
| 133 return exit_status; |
| 134 } |
| OLD | NEW |