diff --git a/Makefile b/Makefile index b6a57e0da..a22a9eb20 100644 --- a/Makefile +++ b/Makefile @@ -304,6 +304,11 @@ test-js.$(1).$(2): build.$$(NATIVE_SYSTEM) $$(Q) $$(call SHLOG,cd $$(OUT_DIR)/$(1)/check/$(2) && $$(ROOT_DIR)/tools/runners/run-test-suite.sh \ $$(OUT_DIR)/$(1)/jerry \ $(3),$$(OUT_DIR)/$(1)/check/$(2)/test.log,Testing) +test-js.$(1).$(2).snapshot: build.$$(NATIVE_SYSTEM) + $$(Q) mkdir -p $$(OUT_DIR)/$(1)/check/$(2) + $$(Q) $$(call SHLOG,cd $$(OUT_DIR)/$(1)/check/$(2) && $$(ROOT_DIR)/tools/runners/run-test-suite.sh \ + $$(OUT_DIR)/$(1)/jerry \ + $(3) --snapshot,$$(OUT_DIR)/$(1)/check/$(2)/snapshot.test.log,Testing) endef $(foreach __TARGET,$(JERRY_TEST_TARGETS), \ @@ -358,10 +363,12 @@ test-unit: unittests test-js: \ $(foreach __TARGET,$(JERRY_TEST_TARGETS), \ $(foreach __SUITE,$(JERRY_TEST_SUITE_J) $(JERRY_TEST_SUITE_JTS), \ - test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))))) \ + test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))) \ + test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))).snapshot)) \ $(foreach __TARGET,$(JERRY_TEST_TARGETS_CP), \ $(foreach __SUITE,$(JERRY_TEST_SUITE_JTS_CP), \ - test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))))) + test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))) \ + test-js.$(__TARGET).$(firstword $(subst :, ,$(__SUITE))).snapshot)) .PHONY: test-buildoptions test-buildoptions: \ diff --git a/tools/runners/run-test-suite.sh b/tools/runners/run-test-suite.sh index cb8435eb2..ee86ff79f 100755 --- a/tools/runners/run-test-suite.sh +++ b/tools/runners/run-test-suite.sh @@ -15,14 +15,30 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Usage: +# ./tools/runners/run-test-suite.sh ENGINE TESTS [--snapshot] ENGINE_ARGS.... + TIMEOUT=${TIMEOUT:=5} +TEST_FILES=test.files +TEST_FAILED=test.failed +TEST_PASSED=test.passed + ENGINE="$1" shift TESTS="$1" shift +if [ "$1" == "--snapshot" ] +then + TEST_FILES="snapshot.$TEST_FILES" + TEST_FAILED="snapshot.$TEST_FAILED" + TEST_PASSED="snapshot.$TEST_PASSED" + IS_SNAPSHOT=true; + shift +fi + ENGINE_ARGS="$@" if [ ! -x $ENGINE ] @@ -31,10 +47,6 @@ then exit 1 fi -TEST_FILES=test.files -TEST_FAILED=test.failed -TEST_PASSED=test.passed - if [ -d $TESTS ] then TESTS_DIR=$TESTS @@ -97,10 +109,34 @@ do full_test=$TESTS_DIR/${test#./} - echo -n "[$tested/$total] ${ENGINE#$ROOT_DIR} $ENGINE_ARGS ${full_test#$ROOT_DIR}: " + if [ "$IS_SNAPSHOT" == true ] + then + # Testing snapshot - ( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS $full_test &>$ENGINE_TEMP ) - status_code=$? + SNAPSHOT_TEMP=`mktemp snapshot-out.XXXXXXXXXX` + + echo -n "[$tested/$total] ${ENGINE#$ROOT_DIR} $ENGINE_ARGS " + echo -n "--save-snapshot-for-global $SNAPSHOT_TEMP ${full_test#$ROOT_DIR}: " + + ( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS --save-snapshot-for-global $SNAPSHOT_TEMP $full_test &> $ENGINE_TEMP ) + status_code=$? + + if [ $status_code -eq 0 ] + then + echo "$PASS" + echo -n "[$tested/$total] ${ENGINE#$ROOT_DIR} $ENGINE_ARGS --exec-snapshot $SNAPSHOT_TEMP: " + + ( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS --exec-snapshot $SNAPSHOT_TEMP &> $ENGINE_TEMP ) + status_code=$? + fi + + rm -f $SNAPSHOT_TEMP + else + echo -n "[$tested/$total] ${ENGINE#$ROOT_DIR} $ENGINE_ARGS ${full_test#$ROOT_DIR}: " + + ( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS $full_test &> $ENGINE_TEMP ) + status_code=$? + fi if [ $status_code -ne $error_code ] then