--- /dev/null
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * Pathologically simple drawing tests, designed to generate consistent
+ * output images across platforms for gm/tests/run.sh
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkPaint.h"
+
+class SelfTestGM : public skiagm::GM {
+public:
+ SelfTestGM(const char name[], SkColor color) : fName(name), fColor(color) {}
+ const static int kWidth = 300;
+ const static int kHeight = 200;
+
+protected:
+ SkString onShortName() {
+ return fName;
+ }
+
+ SkISize onISize() { return skiagm::make_isize(kWidth, kHeight); }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(fColor);
+ canvas->drawRectCoords(0, 0, SkIntToScalar(kWidth), SkIntToScalar(kHeight), paint);
+ }
+
+private:
+ const SkString fName;
+ const SkColor fColor;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static skiagm::GM* F1(void*) { return new SelfTestGM("selftest1", SK_ColorGREEN); }
+static skiagm::GM* F2(void*) { return new SelfTestGM("selftest2", SK_ColorBLUE); }
+
+static skiagm::GMRegistry gR1(F1);
+static skiagm::GMRegistry gR2(F2);
"no-comparison" : null,
"succeeded" : {
"simpleaaclip_path_565" : {
- "checksum" : FAKE
+ "checksum" : 8375148850964385904
},
"simpleaaclip_path_8888" : {
- "checksum" : FAKE
+ "checksum" : 4719056555285640269
}
}
},
"expected-results" : {
"simpleaaclip_path_565" : {
- "checksums" : [ FAKE ],
+ "checksums" : [ 8375148850964385904 ],
"ignore-failure" : false
},
"simpleaaclip_path_8888" : {
- "checksums" : [ FAKE ],
+ "checksums" : [ 4719056555285640269 ],
"ignore-failure" : false
}
}
"failure-ignored" : null,
"no-comparison" : {
"simpleaaclip_path_565" : {
- "checksum" : FAKE
+ "checksum" : 8375148850964385904
},
"simpleaaclip_path_8888" : {
- "checksum" : FAKE
+ "checksum" : 4719056555285640269
}
},
"succeeded" : null
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/images/different-pixels --writeJsonSummary gm/tests/outputs/compared-against-different-pixels-images/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/images/different-pixels --writeJsonSummary gm/tests/outputs/compared-against-different-pixels-images/output-actual/json-summary.txt
{
"actual-results" : {
"failed" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
},
"failure-ignored" : null,
"succeeded" : null
},
"expected-results" : {
- "565/dashing2" : {
- "checksums" : [ FAKE ],
+ "565/selftest1" : {
+ "checksums" : [ 8143889227369140487 ],
"ignore-failure" : false
},
- "8888/dashing2" : {
- "checksums" : [ FAKE ],
+ "8888/selftest1" : {
+ "checksums" : [ 8143889227369140487 ],
"ignore-failure" : false
}
}
reading from gm/tests/inputs/images/different-pixels
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 0 passed, 1 failed, 0 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/json/different-pixels.json --writeJsonSummary gm/tests/outputs/compared-against-different-pixels-json/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/json/different-pixels.json --writeJsonSummary gm/tests/outputs/compared-against-different-pixels-json/output-actual/json-summary.txt
{
"actual-results" : {
"failed" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
},
"failure-ignored" : null,
"succeeded" : null
},
"expected-results" : {
- "565/dashing2" : {
- "checksums" : [ FAKE ],
+ "565/selftest1" : {
+ "checksums" : [ 8143889227369140487 ],
"ignore-failure" : false
},
- "8888/dashing2" : {
- "checksums" : [ FAKE ],
+ "8888/selftest1" : {
+ "checksums" : [ 8143889227369140487 ],
"ignore-failure" : false
}
}
reading expectations from JSON summary file gm/tests/inputs/json/different-pixels.json
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 0 passed, 1 failed, 0 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/images/empty-dir --writeJsonSummary gm/tests/outputs/compared-against-empty-dir/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/images/empty-dir --writeJsonSummary gm/tests/outputs/compared-against-empty-dir/output-actual/json-summary.txt
"failed" : null,
"failure-ignored" : null,
"no-comparison" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
},
"succeeded" : null
},
"expected-results" : {
- "565/dashing2" : {
+ "565/selftest1" : {
"checksums" : null,
"ignore-failure" : false
},
- "8888/dashing2" : {
+ "8888/selftest1" : {
"checksums" : null,
"ignore-failure" : false
}
reading from gm/tests/inputs/images/empty-dir
-drawing... dashing2 [640 480]
-FAILED to read gm/tests/inputs/images/empty-dir/8888/dashing2.png
-FAILED to read gm/tests/inputs/images/empty-dir/565/dashing2.png
+drawing... selftest1 [300 200]
+FAILED to read gm/tests/inputs/images/empty-dir/8888/selftest1.png
+FAILED to read gm/tests/inputs/images/empty-dir/565/selftest1.png
Ran 1 tests: 1 passed, 0 failed, 1 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/images/identical-bytes --writeJsonSummary gm/tests/outputs/compared-against-identical-bytes-images/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/images/identical-bytes --writeJsonSummary gm/tests/outputs/compared-against-identical-bytes-images/output-actual/json-summary.txt
"failure-ignored" : null,
"no-comparison" : null,
"succeeded" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
}
},
"expected-results" : {
- "565/dashing2" : {
- "checksums" : [ FAKE ],
+ "565/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
},
- "8888/dashing2" : {
- "checksums" : [ FAKE ],
+ "8888/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
}
}
reading from gm/tests/inputs/images/identical-bytes
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 1 passed, 0 failed, 0 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/json/identical-bytes.json --writeJsonSummary gm/tests/outputs/compared-against-identical-bytes-json/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/json/identical-bytes.json --writeJsonSummary gm/tests/outputs/compared-against-identical-bytes-json/output-actual/json-summary.txt
"failure-ignored" : null,
"no-comparison" : null,
"succeeded" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
}
},
"expected-results" : {
- "565/dashing2" : {
- "checksums" : [ FAKE ],
+ "565/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
},
- "8888/dashing2" : {
- "checksums" : [ FAKE ],
+ "8888/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
}
}
reading expectations from JSON summary file gm/tests/inputs/json/identical-bytes.json
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 1 passed, 0 failed, 0 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/images/identical-pixels --writeJsonSummary gm/tests/outputs/compared-against-identical-pixels-images/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/images/identical-pixels --writeJsonSummary gm/tests/outputs/compared-against-identical-pixels-images/output-actual/json-summary.txt
"failure-ignored" : null,
"no-comparison" : null,
"succeeded" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
}
},
"expected-results" : {
- "565/dashing2" : {
- "checksums" : [ FAKE ],
+ "565/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
},
- "8888/dashing2" : {
- "checksums" : [ FAKE ],
+ "8888/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
}
}
reading from gm/tests/inputs/images/identical-pixels
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 1 passed, 0 failed, 0 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 -r gm/tests/inputs/json/identical-pixels.json --writeJsonSummary gm/tests/outputs/compared-against-identical-pixels-json/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 -r gm/tests/inputs/json/identical-pixels.json --writeJsonSummary gm/tests/outputs/compared-against-identical-pixels-json/output-actual/json-summary.txt
"failure-ignored" : null,
"no-comparison" : null,
"succeeded" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
}
},
"expected-results" : {
- "565/dashing2" : {
- "checksums" : [ FAKE ],
+ "565/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
},
- "8888/dashing2" : {
- "checksums" : [ FAKE ],
+ "8888/selftest1" : {
+ "checksums" : [ 9948284449770991531 ],
"ignore-failure" : false
}
}
reading expectations from JSON summary file gm/tests/inputs/json/identical-pixels.json
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 1 passed, 0 failed, 0 missing reference images
-out/Debug/gm --hierarchy --match dashing2 --config 8888 --config 565 --writeJsonSummary gm/tests/outputs/no-readpath/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 --config 565 --writeJsonSummary gm/tests/outputs/no-readpath/output-actual/json-summary.txt
"failed" : null,
"failure-ignored" : null,
"no-comparison" : {
- "565/dashing2" : {
- "checksum" : FAKE
+ "565/selftest1" : {
+ "checksum" : 9948284449770991531
},
- "8888/dashing2" : {
- "checksum" : FAKE
+ "8888/selftest1" : {
+ "checksum" : 9948284449770991531
}
},
"succeeded" : null
-drawing... dashing2 [640 480]
+drawing... selftest1 [300 200]
Ran 1 tests: 1 passed, 0 failed, 1 missing reference images
# These tests are run by the Skia_PerCommit_House_Keeping bot at every commit,
# so make sure that they still pass when you make changes to gm!
#
-# TODO: currently, this only passes on Linux (which is the platform that
-# the housekeeper bot runs on, e.g.
-# http://70.32.156.51:10117/builders/Skia_PerCommit_House_Keeping/builds/1417/steps/RunGmSelfTests/logs/stdio )
+# TODO: because this is written as a shell script (instead of, say, Python)
+# it only runs on Linux and Mac.
# See https://code.google.com/p/skia/issues/detail?id=677
# ('make tools/tests/run.sh work cross-platform')
# Ideally, these tests should pass on all development platforms...
>$ACTUAL_OUTPUT_DIR/stdout-tmp
mv $ACTUAL_OUTPUT_DIR/stdout-tmp $ACTUAL_OUTPUT_DIR/stdout
- # Replace particular checksums in json summary with a placeholder, so
- # we don't need to rebaseline these json files when our drawing routines
- # change.
- sed -e 's/"checksum" : [0-9]*/"checksum" : FAKE/g' \
- --in-place $JSON_SUMMARY_FILE
- sed -e 's/"checksums" : \[ [0-9]* \]/"checksums" : [ FAKE ]/g' \
- --in-place $JSON_SUMMARY_FILE
-
compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
}
mkdir -p $IMAGES_DIR/identical-bytes
# Run GM to write out the images actually generated.
- $GM_BINARY --hierarchy --match dashing2 $CONFIGS \
+ $GM_BINARY --hierarchy --match selftest1 $CONFIGS \
-w $IMAGES_DIR/identical-bytes
# Run GM again to read in those images and write them out as a JSON summary.
- $GM_BINARY --hierarchy --match dashing2 $CONFIGS \
+ $GM_BINARY --hierarchy --match selftest1 $CONFIGS \
-r $IMAGES_DIR/identical-bytes \
--writeJsonSummary $JSON_DIR/identical-bytes.json
mkdir -p $IMAGES_DIR/identical-pixels
- $GM_BINARY --hierarchy --match dashing2 $CONFIGS \
+ $GM_BINARY --hierarchy --match selftest1 $CONFIGS \
-w $IMAGES_DIR/identical-pixels
echo "more bytes that do not change the image pixels" \
- >> $IMAGES_DIR/identical-pixels/8888/dashing2.png
+ >> $IMAGES_DIR/identical-pixels/8888/selftest1.png
echo "more bytes that do not change the image pixels" \
- >> $IMAGES_DIR/identical-pixels/565/dashing2.png
- $GM_BINARY --hierarchy --match dashing2 $CONFIGS \
+ >> $IMAGES_DIR/identical-pixels/565/selftest1.png
+ $GM_BINARY --hierarchy --match selftest1 $CONFIGS \
-r $IMAGES_DIR/identical-pixels \
--writeJsonSummary $JSON_DIR/identical-pixels.json
mkdir -p $IMAGES_DIR/different-pixels
- $GM_BINARY --hierarchy --match dashing3 $CONFIGS \
+ $GM_BINARY --hierarchy --match selftest2 $CONFIGS \
-w $IMAGES_DIR/different-pixels
- mv $IMAGES_DIR/different-pixels/8888/dashing3.png \
- $IMAGES_DIR/different-pixels/8888/dashing2.png
- mv $IMAGES_DIR/different-pixels/565/dashing3.png \
- $IMAGES_DIR/different-pixels/565/dashing2.png
- $GM_BINARY --hierarchy --match dashing2 $CONFIGS \
+ mv $IMAGES_DIR/different-pixels/8888/selftest2.png \
+ $IMAGES_DIR/different-pixels/8888/selftest1.png
+ mv $IMAGES_DIR/different-pixels/565/selftest2.png \
+ $IMAGES_DIR/different-pixels/565/selftest1.png
+ $GM_BINARY --hierarchy --match selftest1 $CONFIGS \
-r $IMAGES_DIR/different-pixels \
--writeJsonSummary $JSON_DIR/different-pixels.json
create_inputs_dir $GM_INPUTS
# Compare generated image against an input image file with identical bytes.
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/identical-bytes" "$GM_OUTPUTS/compared-against-identical-bytes-images"
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/json/identical-bytes.json" "$GM_OUTPUTS/compared-against-identical-bytes-json"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/identical-bytes" "$GM_OUTPUTS/compared-against-identical-bytes-images"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/identical-bytes.json" "$GM_OUTPUTS/compared-against-identical-bytes-json"
# Compare generated image against an input image file with identical pixels but different PNG encoding.
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/identical-pixels" "$GM_OUTPUTS/compared-against-identical-pixels-images"
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/json/identical-pixels.json" "$GM_OUTPUTS/compared-against-identical-pixels-json"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/identical-pixels" "$GM_OUTPUTS/compared-against-identical-pixels-images"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/identical-pixels.json" "$GM_OUTPUTS/compared-against-identical-pixels-json"
# Compare generated image against an input image file with different pixels.
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/different-pixels" "$GM_OUTPUTS/compared-against-different-pixels-images"
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OUTPUTS/compared-against-different-pixels-json"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/different-pixels" "$GM_OUTPUTS/compared-against-different-pixels-images"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/json/different-pixels.json" "$GM_OUTPUTS/compared-against-different-pixels-json"
# Compare generated image against an empty "expected image" dir.
-gm_test "--hierarchy --match dashing2 $CONFIGS -r $GM_INPUTS/images/empty-dir" "$GM_OUTPUTS/compared-against-empty-dir"
+gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/empty-dir" "$GM_OUTPUTS/compared-against-empty-dir"
# If run without "-r", the JSON's "actual-results" section should contain
# actual checksums marked as "failure-ignored", but the "expected-results"
# section should be empty.
-gm_test "--hierarchy --match dashing2 $CONFIGS" "$GM_OUTPUTS/no-readpath"
+gm_test "--hierarchy --match selftest1 $CONFIGS" "$GM_OUTPUTS/no-readpath"
# Run a test which generates partially transparent images, write out those
# images, and read them back in.
'../gm/rrects.cpp',
'../gm/samplerstress.cpp',
'../gm/shaderbounds.cpp',
+ '../gm/selftest.cpp',
'../gm/shadertext.cpp',
'../gm/shadertext2.cpp',
'../gm/shadertext3.cpp',