From e038ba0c0c80a3aa2a884b08ecc47d479dafecf7 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 27 Mar 2017 22:05:25 +0300 Subject: [tests] Allow to run basic testsuite using "make test". This will run just quick tests on Linux build so far. --- Makefile | 3 +++ scripts/run_tests | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 scripts/run_tests diff --git a/Makefile b/Makefile index 8884ad1..99a5d01 100644 --- a/Makefile +++ b/Makefile @@ -354,6 +354,9 @@ arcgdb: linux: generate make -f Makefile.linux JS=$(JS) VARIANT=$(VARIANT) CB_STATS=$(CB_STATS) V=$(V) SNAPSHOT=$(SNAPSHOT) +test: + scripts/run_tests + .PHONY: help help: @echo "JavaScript Runtime for Zephyr OS - Build System" diff --git a/scripts/run_tests b/scripts/run_tests new file mode 100755 index 0000000..369d44d --- /dev/null +++ b/scripts/run_tests @@ -0,0 +1,38 @@ +#!/bin/bash + +TESTNUM=0 +START=1 +END=100000 + +# requires: first arg is a <=10-char label, second arg is command +# effects: runs banner with label, then runs the command; if it fails, prints +# label before exiting +function try_command() +{ + TESTNUM=$((TESTNUM + 1)) + if [ "$TESTNUM" -lt "$START" -o "$TESTNUM" -gt "$END" ]; then + echo "Skipping test #$TESTNUM" + return + fi + + LABEL=$1 + shift +# banner "$LABEL" + + # run the command + $* + CODE=$? + if [ $CODE -ne 0 ]; then + echo Error: Failed in $LABEL subtest \#$TESTNUM with code $CODE \(rerun with: trlite $VMNUM $TESTNUM\)! + exit $CODE + fi + echo Success: $LABEL +} + +# linux runtime tests +# TODO: Add buffer, it fails in Linux ATM +for i in error event promise; do + ./outdir/linux/release/jslinux tests/test-$i.js > /tmp/output + cat /tmp/output + try_command "run t-$i" test ! $(grep "FAIL" /tmp/output) +done -- cgit v1.2.3