mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-09 14:06:58 +02:00
A new command line script was introduced in this CL named autotest, which is intend to replace both build_autotest.sh and run_remote_tests.sh in the future. This change list should be reviewed with http://codereview.chromium.org/1513006 http://codereview.chromium.org/1595001 all together. autotest --board x86-generic --build=all will build all client tests. autotest --board x86-generic --build=unioxbench,ltp will build enlisted client tests. autotest --board x86-generic -c client/tests/sleeptest/control -m 12.34.56.78 ... will invoke autoserv inside emerge-x86-generic cross-compiling env, and do a prebuild of the client test before it got pushed onto client host. you could also: 1. bash complete the directory/file name from autotest directory after -c or -s args. 2. supply any autoserv commandline args transparently. Note: replace build_autotest.sh/run_remotes_test.sh is only a future plan. When all the three CLs got pushed, no existing use cases should be broken. I need to change: 1. build_packages script from third_party/chromiumos-overlay/chromeos/scripts/build_packages. 2. add "enable_server_precompile: False " to third_party/autotest/files/global_config.ini to activate it. Review URL: http://codereview.chromium.org/1595001
159 lines
3.4 KiB
Bash
159 lines
3.4 KiB
Bash
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# Add programmable completion to some Chromium OS build scripts
|
|
|
|
|
|
# Echo a list of -- flags that the current command accepts. The
|
|
# function assumes that the command supports shflags' --help flag.
|
|
#
|
|
_flags()
|
|
{
|
|
echo $(command "${COMP_WORDS[0]}" --help 2>&1 | \
|
|
egrep -o -- --\[^\ \]+: | \
|
|
sed 's/://; s/--\[no\]\(.\+\)/--\1 --no\1/')
|
|
}
|
|
|
|
|
|
# Complete flags, i.e., current words starting with --. Return 1 if
|
|
# the current word doesn't start with --, 0 otherwise.
|
|
#
|
|
_flag_complete()
|
|
{
|
|
COMPREPLY=()
|
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
|
if [[ "${cur}" == --* ]]; then
|
|
COMPREPLY=( $(compgen -W "$(_flags)" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
|
|
# Look for "--arg=foo" or "--arg foo" (where foo can be an empty string) in the
|
|
# word to be completed. If found, echo "--arg=foo".
|
|
#
|
|
_argeq()
|
|
{
|
|
local arg=$1
|
|
local w0="${COMP_WORDS[COMP_CWORD]}"
|
|
local w1="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
# Check for completing "--arg="
|
|
if [ "${w1}" == ${arg} -a "${w0}" == "=" ]; then
|
|
echo "${w1}${w0}"
|
|
return 0
|
|
fi
|
|
|
|
# Check for completing "--arg foo"
|
|
if [ "${w1}" == ${arg} ]; then
|
|
echo "${w1}=${w0}"
|
|
return 0
|
|
fi
|
|
|
|
# Check for completing "--arg=foo"
|
|
if [ ${COMP_CWORD} -gt 2 ]; then
|
|
local w2="${COMP_WORDS[COMP_CWORD-2]}"
|
|
if [ "${w2}" == ${arg} -a "${w1}" == "=" ]; then
|
|
echo "${w2}${w1}${w0}"
|
|
return 0
|
|
fi
|
|
fi
|
|
}
|
|
|
|
|
|
# echo the existing target board sysroots
|
|
#
|
|
_board_sysroots()
|
|
{
|
|
local builddir=/build
|
|
if [ -d ${builddir} ]; then
|
|
echo $(command ls "${builddir}")
|
|
fi
|
|
}
|
|
|
|
_complete_board_sysroot_flag()
|
|
{
|
|
COMPREPLY=()
|
|
local arg=$(_argeq --board)
|
|
if [[ ${arg} == --board=* ]]; then
|
|
COMPREPLY=( $(compgen -W "$(_board_sysroots)" -- ${arg#--board=}) )
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# Completion for --board= argument for existing board sysroots
|
|
#
|
|
_board_sysroot()
|
|
{
|
|
_flag_complete && return 0
|
|
_complete_board_flag && return 0
|
|
}
|
|
|
|
complete -o bashdefault -o default -F _board_sysroot \
|
|
build_autotest.sh \
|
|
build_image \
|
|
build_packages \
|
|
image_to_usb.sh \
|
|
mod_image_for_test.sh
|
|
|
|
|
|
# echo the existing target board overlays
|
|
#
|
|
_board_overlays()
|
|
{
|
|
local overlaydir=../overlays
|
|
if [ -d ${overlaydir} ]; then
|
|
echo $(command ls $overlaydir | grep overlay- | sed s,overlay-,,)
|
|
fi
|
|
}
|
|
|
|
# Completion for --board= argument for existing board overlays
|
|
#
|
|
_board_overlay()
|
|
{
|
|
_flag_complete && return 0
|
|
|
|
COMPREPLY=()
|
|
local arg=$(_argeq --board)
|
|
if [[ ${arg} == --board=* ]]; then
|
|
COMPREPLY=( $(compgen -W "$(_board_overlays)" -- ${arg#--board=}) )
|
|
fi
|
|
}
|
|
|
|
complete -o bashdefault -o default -F _board_overlay setup_board
|
|
|
|
# Completion for -c and -s argument for autotest script
|
|
_ls_autotest() {
|
|
local autotest_dir=../third_party/autotest/files
|
|
ls --color=never -dBFH ${autotest_dir}/$1* 2>/dev/null |\
|
|
sed s/"..\/third_party\/autotest\/files\/"//g
|
|
}
|
|
|
|
_autotest_complete()
|
|
{
|
|
_flag_complete && return 0
|
|
|
|
local arg=$(_argeq -c)
|
|
if [[ ${arg} == -c=* ]]; then
|
|
COMPREPLY=($(compgen -W "$(_ls_autotest ${arg#-c=})"))
|
|
return 0
|
|
fi
|
|
|
|
arg=$(_argeq -s)
|
|
if [[ ${arg} == -s=* ]]; then
|
|
COMPREPLY=($(compgen -W "$(_ls_autotest ${arg#-s=})"))
|
|
return 0
|
|
fi
|
|
|
|
_complete_board_sysroot_flag && return 0
|
|
}
|
|
|
|
complete -o bashdefault -o default -o nospace -F _autotest_complete autotest
|
|
|
|
### Local Variables:
|
|
### mode: shell-script
|
|
### End:
|