Travis speed ups

Because the amount of features that the simulator is testing is growing,
the test time is taking a long time. This distributes simulator's tests
over three travis machines to decrease test time.

Add options to defined tests that run one-by-one in a sequential fashion
by defining them in $SINGLE_FEATURES, and allow defining features that
should run together by providing a string of ',' separated list of
multiple tests in $MULTI_FEATURES.

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh
new file mode 100755
index 0000000..58d1998
--- /dev/null
+++ b/scripts/run_tests.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+pushd sim
+
+EXIT_CODE=0
+
+if [[ ! -z $SINGLE_FEATURES ]]; then
+  all_features="sig-rsa sig-ecdsa overwrite-only validate-slot0 enc-rsa enc-kw"
+
+  if [[ $SINGLE_FEATURES =~ "none" ]]; then
+    echo "Running cargo with no features"
+    cargo test
+    rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
+  fi
+
+  for feature in $all_features; do
+    if [[ $SINGLE_FEATURES =~ $feature ]]; then
+      echo "Running cargo for feature=\"${feature}\""
+      cargo test --features $feature
+      rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
+    fi
+  done
+fi
+
+if [[ ! -z $MULTI_FEATURES ]]; then
+  IFS=','
+  read -ra multi_features <<< "$MULTI_FEATURES"
+  for features in "${multi_features[@]}"; do
+    echo "Running cargo for features=\"${features}\""
+    cargo test --features "$features"
+    rc=$? && [ $rc -ne 0 ] && EXIT_CODE=$rc
+  done
+fi
+
+popd
+exit $EXIT_CODE