Родитель
033bb4d6b4
Коммит
f822049d6b
|
@ -5,7 +5,7 @@
|
|||
|
||||
if [[ $EUID -ne 0 ]];
|
||||
then
|
||||
echo "ERROR: $0 requires elevated privileges.. "
|
||||
echo "$(echo -en "\e[31m")ERROR: $(echo -en "\e[00m")$0 requires elevated privileges.. "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -145,3 +145,5 @@ then
|
|||
rm -rf iot-edge-installer
|
||||
log_info "Removed temporary directory files for iot-edge-installer."
|
||||
fi
|
||||
|
||||
announce_my_log_file "All logs were appended to" $OUTPUT_FILE
|
||||
|
|
31
src/utils.sh
31
src/utils.sh
|
@ -6,6 +6,14 @@
|
|||
# create flag:variable_name dictionary
|
||||
declare -A flag_to_variable_dict
|
||||
|
||||
RED=$(echo -en "\e[31m")
|
||||
GREEN=$(echo -en "\e[32m")
|
||||
MAGENTA=$(echo -en "\e[35m")
|
||||
DEFAULT=$(echo -en "\e[00m")
|
||||
BOLD=$(echo -en "\e[01m")
|
||||
BLINK=$(echo -en "\e[5m")
|
||||
|
||||
|
||||
######################################
|
||||
# add_option_args
|
||||
#
|
||||
|
@ -49,6 +57,20 @@ function clear_option_args() {
|
|||
flag_to_variable_dict=()
|
||||
}
|
||||
|
||||
######################################
|
||||
# cmd_parser
|
||||
#
|
||||
# populates a dictionary of arguments and values from
|
||||
# a given command line
|
||||
#
|
||||
# ARGUMENTS:
|
||||
# command line
|
||||
# OUTPUTS:
|
||||
#
|
||||
# RETURN:
|
||||
# dictionary
|
||||
######################################
|
||||
|
||||
function cmd_parser() {
|
||||
# create flag:variable_name dictionary and initialize to empty string
|
||||
declare -A parsed_cmd
|
||||
|
@ -124,6 +146,11 @@ log() {
|
|||
fi
|
||||
}
|
||||
|
||||
#
|
||||
function announce_my_log_file() {
|
||||
printf '\n------\n%s%s%s%s%s\n------\n\n' "$GREEN" "$BOLD" "$BLINK" "$1 '$2'" "$DEFAULT"
|
||||
}
|
||||
|
||||
#
|
||||
# logger
|
||||
log_init() {
|
||||
|
@ -136,7 +163,7 @@ log_init() {
|
|||
OUTPUT_FILE=$TD"/"$(echo ${BASE_NAME%.*})-$(echo `date '+%Y-%m-%d'`).log
|
||||
touch $OUTPUT_FILE
|
||||
|
||||
echo "All logs will be appended to this file '"$OUTPUT_FILE"'"
|
||||
announce_my_log_file "All logs will be appended to file" $OUTPUT_FILE
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -159,7 +186,7 @@ log_debug() {
|
|||
log "DEBUG" "$@"
|
||||
}
|
||||
|
||||
export -f log_init log_error log_info log_warn log_debug
|
||||
export -f announce_my_log_file log_init log_error log_info log_warn log_debug
|
||||
|
||||
######################################
|
||||
# prepare_apt
|
||||
|
|
|
@ -3,27 +3,13 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
if command -v tput &>/dev/null && tty -s; then
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
MAGENTA=$(tput setaf 5)
|
||||
NORMAL=$(tput sgr0)
|
||||
BOLD=$(tput bold)
|
||||
else
|
||||
RED=$(echo -en "\e[31m")
|
||||
GREEN=$(echo -en "\e[32m")
|
||||
MAGENTA=$(echo -en "\e[35m")
|
||||
NORMAL=$(echo -en "\e[00m")
|
||||
BOLD=$(echo -en "\e[01m")
|
||||
fi
|
||||
|
||||
#
|
||||
error_output() {
|
||||
printf "%b\n" "${RED:-}Error: $1${NORMAL:-}" >&2
|
||||
printf "%b\n" "${RED:-}Error: $1${DEFAULT:-}" >&2
|
||||
}
|
||||
|
||||
output() {
|
||||
printf "%b\n" "${BOLD:-}${NORMAL:-} $1" >&2
|
||||
printf "%b\n" "${BOLD:-}${DEFAULT:-} $1" >&2
|
||||
}
|
||||
|
||||
verbose_output() {
|
||||
|
@ -52,6 +38,20 @@ assert_eq() {
|
|||
fi
|
||||
}
|
||||
|
||||
assert_not_eq() {
|
||||
local expected=$1; shift
|
||||
local actual=$1; shift
|
||||
|
||||
NR_TOTALS=$(bc <<< $NR_TOTALS+1)
|
||||
if [ "$expected" != "$actual" ];
|
||||
then
|
||||
NR_PASSING=$(bc <<< $NR_PASSING+1)
|
||||
else
|
||||
NR_FAILING=$(bc <<< $NR_FAILING+1)
|
||||
error_output "expected: $expected; actual: $actual"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_file() {
|
||||
local file_name=$1; shift
|
||||
|
||||
|
@ -74,4 +74,4 @@ show_test_totals() {
|
|||
printf "\n\n"
|
||||
}
|
||||
|
||||
export -f assert_eq assert_file show_test_totals
|
||||
export -f assert_eq assert_not_eq assert_file show_test_totals
|
|
@ -42,4 +42,6 @@ test_service_running
|
|||
test_service_ready
|
||||
test_service_not_running
|
||||
test_service_missing
|
||||
test_service_casesensitive
|
||||
test_service_casesensitive
|
||||
|
||||
show_test_totals
|
||||
|
|
|
@ -31,4 +31,6 @@ test_tier2() {
|
|||
# run tests
|
||||
test_ubuntu1804
|
||||
test_raspbian
|
||||
test_tier2
|
||||
test_tier2
|
||||
|
||||
show_test_totals
|
||||
|
|
Загрузка…
Ссылка в новой задаче