aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rwxr-xr-xscripts/run_tests38
2 files changed, 41 insertions, 0 deletions
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