aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/tests
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-12 18:04:51 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-12 18:04:51 +0000
commita413a53cb2fcdfcd6d8b83adfe29e19e374d4e78 (patch)
treeef7739afa798ec8314f69caf21c3d967e79860d6 /gm/tests
parent4e4d75b06bdb484e4e7628461fe5d63088386e91 (diff)
Add a self-test for gm, similar to our self-test for skdiff.
Review URL: https://codereview.appspot.com/6827068 git-svn-id: http://skia.googlecode.com/svn/trunk@6380 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/tests')
-rw-r--r--gm/tests/inputs/dashing-correct-images/4444/dashing.pngbin0 -> 1875 bytes
-rw-r--r--gm/tests/inputs/dashing-correct-images/4444/dashing2.pngbin0 -> 23808 bytes
-rw-r--r--gm/tests/inputs/dashing-incorrect-images/4444/dashing.pngbin0 -> 2797 bytes
-rw-r--r--gm/tests/inputs/dashing-incorrect-images/4444/dashing2.pngbin0 -> 22723 bytes
-rw-r--r--gm/tests/outputs/dashing-compared-against-correct/output-expected/command_line1
-rw-r--r--gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing.pngbin0 -> 1875 bytes
-rw-r--r--gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing2.pngbin0 -> 23808 bytes
-rw-r--r--gm/tests/outputs/dashing-compared-against-correct/output-expected/return_value1
-rw-r--r--gm/tests/outputs/dashing-compared-against-correct/output-expected/stdout5
-rw-r--r--gm/tests/outputs/dashing-compared-against-incorrect/output-expected/command_line1
-rw-r--r--gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing.pngbin0 -> 1875 bytes
-rw-r--r--gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing2.pngbin0 -> 23808 bytes
-rw-r--r--gm/tests/outputs/dashing-compared-against-incorrect/output-expected/return_value1
-rw-r--r--gm/tests/outputs/dashing-compared-against-incorrect/output-expected/stdout7
-rwxr-xr-xgm/tests/run.sh62
15 files changed, 78 insertions, 0 deletions
diff --git a/gm/tests/inputs/dashing-correct-images/4444/dashing.png b/gm/tests/inputs/dashing-correct-images/4444/dashing.png
new file mode 100644
index 0000000000..e201a72d68
--- /dev/null
+++ b/gm/tests/inputs/dashing-correct-images/4444/dashing.png
Binary files differ
diff --git a/gm/tests/inputs/dashing-correct-images/4444/dashing2.png b/gm/tests/inputs/dashing-correct-images/4444/dashing2.png
new file mode 100644
index 0000000000..91d37eb901
--- /dev/null
+++ b/gm/tests/inputs/dashing-correct-images/4444/dashing2.png
Binary files differ
diff --git a/gm/tests/inputs/dashing-incorrect-images/4444/dashing.png b/gm/tests/inputs/dashing-incorrect-images/4444/dashing.png
new file mode 100644
index 0000000000..c319eabb2e
--- /dev/null
+++ b/gm/tests/inputs/dashing-incorrect-images/4444/dashing.png
Binary files differ
diff --git a/gm/tests/inputs/dashing-incorrect-images/4444/dashing2.png b/gm/tests/inputs/dashing-incorrect-images/4444/dashing2.png
new file mode 100644
index 0000000000..ed37a88211
--- /dev/null
+++ b/gm/tests/inputs/dashing-incorrect-images/4444/dashing2.png
Binary files differ
diff --git a/gm/tests/outputs/dashing-compared-against-correct/output-expected/command_line b/gm/tests/outputs/dashing-compared-against-correct/output-expected/command_line
new file mode 100644
index 0000000000..8a95ecd2bc
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-correct/output-expected/command_line
@@ -0,0 +1 @@
+out/Debug/gm --hierarchy --match dashing --config 4444 -r gm/tests/inputs/dashing-correct-images -w gm/tests/outputs/dashing-compared-against-correct/output-actual/images
diff --git a/gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing.png b/gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing.png
new file mode 100644
index 0000000000..e201a72d68
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing.png
Binary files differ
diff --git a/gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing2.png b/gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing2.png
new file mode 100644
index 0000000000..91d37eb901
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-correct/output-expected/images/4444/dashing2.png
Binary files differ
diff --git a/gm/tests/outputs/dashing-compared-against-correct/output-expected/return_value b/gm/tests/outputs/dashing-compared-against-correct/output-expected/return_value
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-correct/output-expected/return_value
@@ -0,0 +1 @@
+0
diff --git a/gm/tests/outputs/dashing-compared-against-correct/output-expected/stdout b/gm/tests/outputs/dashing-compared-against-correct/output-expected/stdout
new file mode 100644
index 0000000000..d7f2c6bb08
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-correct/output-expected/stdout
@@ -0,0 +1,5 @@
+reading from gm/tests/inputs/dashing-correct-images
+writing to gm/tests/outputs/dashing-compared-against-correct/output-actual/images
+drawing... dashing2 [640 480]
+drawing... dashing [640 300]
+Ran 2 tests: 2 passed, 0 failed, 0 missing reference images
diff --git a/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/command_line b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/command_line
new file mode 100644
index 0000000000..423a7f1ba8
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/command_line
@@ -0,0 +1 @@
+out/Debug/gm --hierarchy --match dashing --config 4444 -r gm/tests/inputs/dashing-incorrect-images -w gm/tests/outputs/dashing-compared-against-incorrect/output-actual/images
diff --git a/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing.png b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing.png
new file mode 100644
index 0000000000..e201a72d68
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing.png
Binary files differ
diff --git a/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing2.png b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing2.png
new file mode 100644
index 0000000000..91d37eb901
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/images/4444/dashing2.png
Binary files differ
diff --git a/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/return_value b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/return_value
new file mode 100644
index 0000000000..ace9d03621
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/return_value
@@ -0,0 +1 @@
+255
diff --git a/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/stdout b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/stdout
new file mode 100644
index 0000000000..10956becc8
--- /dev/null
+++ b/gm/tests/outputs/dashing-compared-against-incorrect/output-expected/stdout
@@ -0,0 +1,7 @@
+reading from gm/tests/inputs/dashing-incorrect-images
+writing to gm/tests/outputs/dashing-compared-against-incorrect/output-actual/images
+drawing... dashing2 [640 480]
+drawing... dashing [640 300]
+----- max pixel mismatch for 4444/dashing is 51
+Ran 2 tests: 1 passed, 1 failed, 0 missing reference images
+ 4444/dashing pixel_error 51
diff --git a/gm/tests/run.sh b/gm/tests/run.sh
new file mode 100755
index 0000000000..276a77522a
--- /dev/null
+++ b/gm/tests/run.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Self-tests for gm, based on tools/tests/run.sh
+
+# cd into .../trunk so all the paths will work
+cd $(dirname $0)/../..
+
+# TODO(epoger): make it look in Release and/or Debug
+GM_BINARY=out/Debug/gm
+
+# Compare contents of all files within directories $1 and $2,
+# EXCEPT for any dotfiles.
+# If there are any differences, a description is written to stdout and
+# we exit with a nonzero return value.
+# Otherwise, we write nothing to stdout and return.
+function compare_directories {
+ if [ $# != 2 ]; then
+ echo "compare_directories requires exactly 2 parameters, got $#"
+ exit 1
+ fi
+ diff -r --exclude=.* $1 $2
+ if [ $? != 0 ]; then
+ echo "failed in: compare_directories $1 $2"
+ exit 1
+ fi
+}
+
+# Run gm...
+# - with the arguments in $1
+# - writing resulting images into $2/output-actual/images
+# - writing stdout into $2/output-actual/stdout
+# - writing return value into $2/output-actual/return_value
+# Then compare all of those against $2/output-expected .
+function gm_test {
+ if [ $# != 2 ]; then
+ echo "gm_test requires exactly 2 parameters, got $#"
+ exit 1
+ fi
+ GM_ARGS="$1"
+ ACTUAL_OUTPUT_DIR="$2/output-actual"
+ EXPECTED_OUTPUT_DIR="$2/output-expected"
+
+ rm -rf $ACTUAL_OUTPUT_DIR
+ mkdir -p $ACTUAL_OUTPUT_DIR
+ COMMAND="$GM_BINARY $GM_ARGS -w $ACTUAL_OUTPUT_DIR/images"
+ echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
+ $COMMAND &>$ACTUAL_OUTPUT_DIR/stdout
+ echo $? >$ACTUAL_OUTPUT_DIR/return_value
+
+ compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
+}
+
+GM_TESTDIR=gm/tests
+GM_INPUTS=$GM_TESTDIR/inputs
+GM_OUTPUTS=$GM_TESTDIR/outputs
+
+gm_test "--hierarchy --match dashing --config 4444 -r $GM_INPUTS/dashing-correct-images" "$GM_OUTPUTS/dashing-compared-against-correct"
+
+# In this case, dashing.png has different pixels, but dashing2.png differs only in PNG encoding (identical pixels)
+gm_test "--hierarchy --match dashing --config 4444 -r $GM_INPUTS/dashing-incorrect-images" "$GM_OUTPUTS/dashing-compared-against-incorrect"
+
+echo "All tests passed."