Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
tests: Reformat usage output in test_image.sh
Browse files Browse the repository at this point in the history
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 <mvedovati@suse.com>
  • Loading branch information
marcov committed Sep 12, 2018
1 parent 93ad049 commit 2b187c3
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions tests/test_images.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright (c) 2018 Intel Corporation
#
Expand Down Expand Up @@ -36,27 +36,21 @@ test_initrds_only="false"
usage()
{
cat <<EOT
Usage: $script_name [help|<distro>]
$script_name [options]
Usage: $script_name [options] [command | <distro>]
Options:
-h | --help # Show usage.
--distro <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.
<distro> : Only run tests for specified distro.
Notes:
- If no options or parameters are specified, all tests will be run.
When <distro> is specified, tests are run only for the specified <distro> distribution.
Otherwise, tests are be run on all distros.
EOT
}

Expand Down Expand Up @@ -99,8 +93,6 @@ exit_handler()
sudo -E ps -efwww | egrep "docker|kata" >&2
}

trap exit_handler EXIT ERR

die()
{
msg="$*"
Expand Down Expand Up @@ -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" ]
Expand Down

0 comments on commit 2b187c3

Please sign in to comment.