diff --git a/run-fstests/config.gce b/run-fstests/config.gce index 00f3b249..71fa433d 100644 --- a/run-fstests/config.gce +++ b/run-fstests/config.gce @@ -40,13 +40,13 @@ GCE_MIN_SCR_SIZE=100 # Enable serial port access by default # GCE_SERIAL_PORT_ACCESS=TRUE -GIT_REPO=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git # GIT_REPOS can be used to define user-specific git repository aliases # in ~/.config/gce-xfstests. It will override any default mappings defined # by DEF_GIT_REPOS declare -A GIT_REPOS declare -A DEF_GIT_REPOS +DEF_GIT_REPOS[linux.git]=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git DEF_GIT_REPOS[stable.git]=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git DEF_GIT_REPOS[next.git]=https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git DEF_GIT_REPOS[next-history.git]=https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next-history.git diff --git a/run-fstests/util/parse_cli b/run-fstests/util/parse_cli index d5847caa..1418a8e7 100644 --- a/run-fstests/util/parse_cli +++ b/run-fstests/util/parse_cli @@ -239,6 +239,58 @@ validate_branch_name() fi } +function set_git_repo () +{ + if test -n "${GIT_REPOS[$1]}" ; then + GIT_REPO="${GIT_REPOS[$1]}" + elif test -n "${DEF_GIT_REPOS[$1]}" ; then + GIT_REPO="${DEF_GIT_REPOS[$1]}" + else + GIT_REPO="$1" + fi + case "$GIT_REPO" in + http://*|https://*|git://*) ;; + *) + echo "Invalid git repo: $GIT_REPO" + exit 1 + esac + local host=$(echo "$GIT_REPO" | sed -e 's;[a-z]*://;;' -e 's;/.*$;;') + if type host >& /dev/null && ! host "$host" >& /dev/null ; then + echo "Invalid hostname in git repo: $GIT_REPO" + exit 1 + fi +} + +function get_default_repo_branch () +{ + case "$1" in + fs-next|fs-current|pending-fixes) + echo "next.git" + ;; + linux-[0-9].*.y) + echo "stable-rc.git" + ;; + *) + echo "linux.git" + ;; + esac +} + +function get_default_repo_commit () +{ + case "$1" in + next-[12]*) + echo "next-history.git" + ;; + v[0-9].*.*) + echo "stable.git" + ;; + *) + get_default_repo_branch "$1" + ;; + esac +} + SKIP_KERNEL_ARCH_PROBE= shortopts="ac:C:g:hI:m:n:No:O:r:vx:X:" @@ -673,13 +725,7 @@ while (( $# >= 1 )); do ;; --repo) shift supported_flavors gce - if test -n "${GIT_REPOS[$1]}" ; then - GIT_REPO="${GIT_REPOS[$1]}" - elif test -n "${DEF_GIT_REPOS[$1]}" ; then - GIT_REPO="${DEF_GIT_REPOS[$1]}" - else - GIT_REPO="$1" - fi + set_git_repo "$1" ;; --commit) shift supported_flavors gce @@ -1010,6 +1056,27 @@ then exit 1 fi +if test -z "$GIT_REPO" -a -n "$COMMIT" ; then + set_git_repo $(get_default_repo_commit "$COMMIT") +fi + +if test -z "$GIT_REPO" -a -n "$BISECT_BAD" ; then + set_git_repo $(get_default_repo_commit "$BISECT_BAD") +fi + +if test -z "$GIT_REPO" -a -n "$BISECT_GOOD" ; then + b=$(echo "$BISECT_GOOD" | sed -e 's/|.*//') + set_git_repo $(get_default_repo_commit "$b") +fi + +if test -z "$GIT_REPO" -a -n "$BRANCH" ; then + set_git_repo $(get_default_repo_branch "$BRANCH") +fi + +if test -n "$NO_ACTION" ; then + echo "GIT_REPO: $GIT_REPO" +fi + if test -n "$COMMIT" then validate_commit_name $COMMIT @@ -1044,8 +1111,6 @@ fi if test -n "$GIT_REPO" -a -z "$RUN_ON_LTM" -a -z "$RUN_ON_KCS" then - echo "GIT_REPO: $GIT_REPO" - echo "" echo "Specifying a git repository only makes sense with LTM or KCS" exit 1 fi