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

Unified 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: Fix test size Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/qcms/src/tests/qcms_test_main.c
diff --git a/third_party/qcms/src/tests/qcms_test_main.c b/third_party/qcms/src/tests/qcms_test_main.c
new file mode 100644
index 0000000000000000000000000000000000000000..d46ff1d56ef6ee7d59e3bb7a82cdf6aab548362a
--- /dev/null
+++ b/third_party/qcms/src/tests/qcms_test_main.c
@@ -0,0 +1,119 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the Chromium LICENSE file.
+
+#include "qcms.h"
+#include "qcms_test_util.h"
+#include "timing.h"
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// 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.
+extern struct qcms_test_case qcms_test_tetra_clut_rgba_info;
+extern struct qcms_test_case qcms_test_munsell_info;
+
+struct qcms_test_case qcms_test[2];
+#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.
+
+static void init_tests()
Noel Gordon 2015/10/07 12:26:31 initialize_tests
radu.velea 2015/10/07 13:22:36 Done.
+{
+ qcms_test[0] = qcms_test_tetra_clut_rgba_info;
+ qcms_test[1] = qcms_test_munsell_info;
+}
+
+static void list_tests()
+{
+ int i;
+ printf("Available QCMS tests:\n");
+
+ for (i = 0; i < TEST_SIZE; ++i) {
+ printf("\t%s\n", qcms_test[i].test_name);
+ }
+
+ exit(0);
+}
+
+static void print_usage()
+{
+ 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.
+ printf("\t-w INT\t\tauto-generated image width\n");
+ printf("\t-h INT\t\tauto-generated image height\n");
+ printf("\t-n INT\t\tnumber of iterations to run the test(s) on\n");
+ printf("\t-a\t\trun all tests\n");
+ printf("\t-l\t\tlist available tests\n");
+ printf("\t-s \t\tforce software(non-sse) transform function, where available\n");
+ printf("\t-i STRING\tspecify input icc color profile\n");
+ printf("\t-o STRING\tspecify output icc color profile\n");
+ printf("\t-t STRING\trun specific test - use \"-l\" to list possible values\n");
+ printf("\n");
+ exit(0);
+}
+
+void enable_test(const char *args)
+{
+ int i;
+ 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.
+ if (strcmp(qcms_test[i].test_name, args) == 0) {
+ 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.
+ }
+ }
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.
+}
+
+void generate_source_uint8_t(unsigned char *src, const size_t length, const size_t pixel_size)
+{
+ size_t bytes = length * pixel_size;
+ size_t i;
+
+ for (i = 0; i < bytes; ++i) {
+ *src++ = rand() & 255;
+ }
+}
+
+int main(int argc, const char **argv)
+{
+ int iterations = 1;
+ size_t height = 2000;
+ size_t width = 2000;
+ int run_all = 0;
+ const char *in = NULL, *out = NULL;
+ 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.
+
+ int i;
+ init_tests();
+
+ if (argc == 1) {
+ print_usage();
+ }
+
+ while (argc > 1) {
+ if (strcmp(argv[1], "-n") == 0)
+ iterations = abs(atoi(argv[2]));
+ else if (strcmp(argv[1], "-w") == 0)
+ width = (size_t) abs(atoi(argv[2]));
+ else if (strcmp(argv[1], "-h") == 0)
+ height = (size_t) abs(atoi(argv[2]));
+ else if (strcmp(argv[1], "-l") == 0)
+ list_tests();
+ else if (strcmp(argv[1], "-t") == 0)
+ enable_test(argv[2]);
+ else if (strcmp(argv[1], "-a") == 0)
+ run_all = 1;
+ else if (strcmp(argv[1], "-i") == 0)
+ in = argv[2];
+ else if (strcmp(argv[1], "-o") == 0)
+ out = argv[2];
+ else if (strcmp(argv[1], "-s") == 0)
+ force_software = 1;
+ (--argc, ++argv);
+ }
+
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.
+ for (i = 0; i < TEST_SIZE; ++i) {
+ if (run_all || QCMS_TEST_ENABLED == qcms_test[i].status)
+ qcms_test[i].test_fn(width, height, iterations, in, out, force_software);
Noel Gordon 2015/10/07 12:26:31 exit_status += qcms_test[i].test_fn(...
radu.velea 2015/10/07 13:22:36 Done.
+ }
+
+ return EXIT_SUCCESS;
Noel Gordon 2015/10/07 12:26:31 return exit_status;
radu.velea 2015/10/07 13:22:35 Done.
+}

Powered by Google App Engine
This is Rietveld 408576698