From 2b187c30d0fab4489c859524d33e02daa10bdd5e Mon Sep 17 00:00:00 2001 From: Marco Vedovati Date: Mon, 10 Sep 2018 16:32:30 +0200 Subject: [PATCH] tests: Reformat usage output in test_image.sh Reformat the usage output displayed with `help` command or `-h` option. Trap exit codes only after options parsing, as that is used to generate a test report. Fixes: #169 Signed-off-by: Marco Vedovati --- tests/test_images.sh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/test_images.sh b/tests/test_images.sh index 00498517e6..5464c6215f 100755 --- a/tests/test_images.sh +++ b/tests/test_images.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (c) 2018 Intel Corporation # @@ -36,27 +36,21 @@ test_initrds_only="false" usage() { cat <] - $script_name [options] +Usage: $script_name [options] [command | ] Options: - -h | --help # Show usage. --distro # Only run tests for specified distro. --list # List all distros that can be tested. --test-images-only # Only run images tests for the list of distros under test. --test-initrds-only # Only run initrds tests for the list of distros under test. -Parameters: - - +Commands: help : Show usage. - : Only run tests for specified distro. -Notes: - -- If no options or parameters are specified, all tests will be run. +When is specified, tests are run only for the specified distribution. +Otherwise, tests are be run on all distros. EOT } @@ -99,8 +93,6 @@ exit_handler() sudo -E ps -efwww | egrep "docker|kata" >&2 } -trap exit_handler EXIT ERR - die() { msg="$*" @@ -504,10 +496,12 @@ main() [ "$1" = "--" ] && shift case "$1" in - help) usage && exit 0;; + help) usage; exit 0;; + *) distro="$1";; esac + trap exit_handler EXIT ERR setup if [ -n "$distro" ]