aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/tests/skimage/README1
-rw-r--r--tools/tests/skimage/input/README1
-rw-r--r--tools/tests/skimage/input/images-with-known-hashes/1209453360120438698.pngbin0 -> 756 bytes
-rw-r--r--tools/tests/skimage/input/images-with-known-hashes/12927999507540085554.pngbin0 -> 652 bytes
-rw-r--r--tools/tests/skimage/output-actual/README1
-rw-r--r--tools/tests/skimage/output-expected/README1
-rw-r--r--tools/tests/skimage/output-expected/create-expectations/expectations.json22
-rwxr-xr-xtools/tests/skimage_self_test.py43
8 files changed, 53 insertions, 16 deletions
diff --git a/tools/tests/skimage/README b/tools/tests/skimage/README
deleted file mode 100644
index 0680184c19..0000000000
--- a/tools/tests/skimage/README
+++ /dev/null
@@ -1 +0,0 @@
-This directory is for the output of skimage_self_test.
diff --git a/tools/tests/skimage/input/README b/tools/tests/skimage/input/README
new file mode 100644
index 0000000000..053785087f
--- /dev/null
+++ b/tools/tests/skimage/input/README
@@ -0,0 +1 @@
+Resources needed for skimage self-tests go here.
diff --git a/tools/tests/skimage/input/images-with-known-hashes/1209453360120438698.png b/tools/tests/skimage/input/images-with-known-hashes/1209453360120438698.png
new file mode 100644
index 0000000000..37874e9464
--- /dev/null
+++ b/tools/tests/skimage/input/images-with-known-hashes/1209453360120438698.png
Binary files differ
diff --git a/tools/tests/skimage/input/images-with-known-hashes/12927999507540085554.png b/tools/tests/skimage/input/images-with-known-hashes/12927999507540085554.png
new file mode 100644
index 0000000000..8513f529ff
--- /dev/null
+++ b/tools/tests/skimage/input/images-with-known-hashes/12927999507540085554.png
Binary files differ
diff --git a/tools/tests/skimage/output-actual/README b/tools/tests/skimage/output-actual/README
new file mode 100644
index 0000000000..d8839b715f
--- /dev/null
+++ b/tools/tests/skimage/output-actual/README
@@ -0,0 +1 @@
+Actual output of skimage self-tests goes here.
diff --git a/tools/tests/skimage/output-expected/README b/tools/tests/skimage/output-expected/README
new file mode 100644
index 0000000000..4807b70be1
--- /dev/null
+++ b/tools/tests/skimage/output-expected/README
@@ -0,0 +1 @@
+Expected output of skimage self-tests goes here.
diff --git a/tools/tests/skimage/output-expected/create-expectations/expectations.json b/tools/tests/skimage/output-expected/create-expectations/expectations.json
new file mode 100644
index 0000000000..c143c1bfa2
--- /dev/null
+++ b/tools/tests/skimage/output-expected/create-expectations/expectations.json
@@ -0,0 +1,22 @@
+{
+ "actual-results" : {
+ "failed" : null,
+ "failure-ignored" : null,
+ "no-comparison" : null,
+ "succeeded" : null
+ },
+ "expected-results" : {
+ "1209453360120438698.png" : {
+ "allowed-digests" : [
+ [ "bitmap-64bitMD5", 1209453360120438698 ]
+ ],
+ "ignore-failure" : false
+ },
+ "12927999507540085554.png" : {
+ "allowed-digests" : [
+ [ "bitmap-64bitMD5", 12927999507540085554 ]
+ ],
+ "ignore-failure" : false
+ }
+ }
+}
diff --git a/tools/tests/skimage_self_test.py b/tools/tests/skimage_self_test.py
index d2d072ff41..cb66fe1729 100755
--- a/tools/tests/skimage_self_test.py
+++ b/tools/tests/skimage_self_test.py
@@ -5,6 +5,7 @@
# Self-test for skimage.
+import filecmp
import os
import subprocess
import sys
@@ -30,6 +31,13 @@ def PickBinaryPath(base_dir):
return binary_full_path
raise BinaryNotFoundException
+# Quit early if two files have different content.
+def DieIfFilesMismatch(expected, actual):
+ if not filecmp.cmp(expected, actual):
+ print 'Error: file mismatch! expected=%s , actual=%s' % (
+ expected, actual)
+ exit(1)
+
def main():
# Use the directory of this file as the out directory
file_dir = os.path.abspath(os.path.dirname(__file__))
@@ -40,24 +48,29 @@ def main():
skimage_binary = PickBinaryPath(trunk_dir)
print "Running " + skimage_binary
- # Run skimage twice, first to create an expectations file, and then
- # comparing to it.
+ # Generate an expectations file from known images.
+ images_dir = os.path.join(file_dir, "skimage", "input",
+ "images-with-known-hashes")
+ expectations_path = os.path.join(file_dir, "skimage", "output-actual",
+ "create-expectations", "expectations.json")
+ subprocess.check_call([skimage_binary, "--readPath", images_dir,
+ "--createExpectationsPath", expectations_path])
+
+ # Make sure the expectations file was generated correctly.
+ golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
+ "create-expectations",
+ "expectations.json")
+ DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
- # Both commands will run the binary, reading from resources.
- cmd_line = [skimage_binary]
- resources_dir = os.path.join(trunk_dir, 'resources')
- cmd_line.extend(["-r", resources_dir])
+ # Tell skimage to read back the expectations file it just wrote, and
+ # confirm that the images in images_dir match it.
+ subprocess.check_call([skimage_binary, "--readPath", images_dir,
+ "--readExpectationsPath", expectations_path])
- # Create the expectations file
- results_file = os.path.join(file_dir, "skimage", "self_test_results.json")
- create_expectations_cmd = cmd_line + ["--createExpectationsPath",
- results_file]
- subprocess.check_call(create_expectations_cmd)
+ # TODO(scroggo): Add a test that compares expectations and image files that
+ # are known to NOT match, and make sure it returns an error.
- # Now read from the expectations file
- check_expectations_cmd = cmd_line + ["--readExpectationsPath",
- results_file]
- subprocess.check_call(check_expectations_cmd)
+ # Done with all tests.
print "Self tests succeeded!"
if __name__ == "__main__":