Commit 0e12f6ce authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

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: default avatarFabio Utzig <utzig@apache.org>
parent a3c2f057
Loading
Loading
Loading
Loading
+41 −10
Changes for .travis.yml: 41 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -2,17 +2,48 @@

language: rust

cache: cargo

matrix:
  include:
    # Runs each value defined in $SINGLE_FEATURES by itself in the order
    # the were defined.
    - os: linux
      env: SINGLE_FEATURES="sig-ecdsa enc-kw"
    - os: linux
      env: SINGLE_FEATURES="none sig-rsa overwrite-only validate-slot0"
    - os: linux
      env: SINGLE_FEATURES="enc-rsa"

    # Values defined in $MULTI_FEATURES consist of any number of features
    # to be enabled at the same time. The list of multi-values should be
    # separated by ',' and each list of values is run sequentially in the
    # defined order.
    - os: linux
      env: MULTI_FEATURES="sig-rsa overwrite-only,sig-ecdsa overwrite-only"
    - os: linux
      env: MULTI_FEATURES="sig-rsa validate-slot0,sig-ecdsa validate-slot0"

    # FIXME: this test actually fails and must be fixed
    #- os: linux
    #  env: MULTI_FEATURES="sig-rsa validate-slot0 overwrite-only"

before_install:
  - |
    if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
      ./scripts/check-signed-off-by.sh
      if [ $? -ne 0 ]; then
        exit 1
      fi
    fi

install:
  - pushd sim
  - cargo fetch
  - popd

script:
  - set -e
  - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then ./scripts/check-signed-off-by.sh; fi
  - cd sim
  - cargo test
  - cargo test --features sig-rsa
  - cargo test --features sig-ecdsa
  - cargo test --features overwrite-only
  - cargo test --features validate-slot0
  - cargo test --features enc-rsa
  - cargo test --features enc-kw
  - ./scripts/run_tests.sh

notifications:
  slack:
+x+48
Changes for scripts/run_tests.sh: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/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