--- /dev/null
+#!/bin/bash
+
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2017 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e -o posix
+
+branch=$1
+xenbranch=$2
+blessing=$3
+
+flight=`./cs-flight-create $blessing $branch`
+
+. ./cri-common
+. ./cri-getplatforms # getplatforms()
+. ./ap-common
+. ./mfi-common
+
+# Older versions of Xen may not build with the current default. Note
+# that branches older than 4.3 might need something even older than
+# Wheezy, but we have not done the archaeology to figure out what they
+# require.
+case "$xenbranch" in
+ *)
+ defsuite=`getconfig DebianSuite`
+ defguestsuite=`getconfig GuestDebianSuite`
+ ;;
+esac
+
+# Pick default Debian Installer version to correspond to the chosen
+# suite.
+if [ -z "$defdi_version" ] ; then
+ defdi_version=`getconfig_TftpDiVersion_suite $defsuite`
+fi
+
+guest_di_version=$defdi_version
+
+job_create_test_filter_callback () {
+ local job=$1; shift
+ local recipe=$1; shift
+ local toolstack=$1; shift
+ local xenarch=$1; shift
+ local dom0arch=$1; shift
+
+ case "$branch" in
+ centos6*)
+ # OVMF isn't available on CentOS6 for Xen
+ case " $* " in
+ *" bios=ovmf "*) return 1 ;;
+ esac
+ ;;
+ *)
+ case "$job" in
+ *-qemuu-*)
+ if [ x$toolstack != xxl -a x$toolstack != xlibvirt ];then
+ return 1;
+ fi
+ ;;
+ esac
+ ;;
+ esac
+
+ return 0;
+}
+
+do_hvm_win_test_one () {
+ local testidpart=$1
+ local isobase=$2
+ local guestarch=$3
+ shift;shift;shift
+
+ if [ $xenarch != amd64 ]; then
+ return
+ fi
+
+ case "$guestarch" in
+ amd64) win_arch=x64 ;;
+ i386) win_arch=x86 ;;
+ *) win_arch=$guestarch ;; # probably wrong
+ esac
+
+ local iso=$isobase-$win_arch.iso
+
+ job_create_test \
+ test-$xenarch$kern-$dom0arch-xl$qemuu_suffix-$testidpart-$guestarch \
+ test-win xl $xenarch $dom0arch $qemuu_runvar \
+ win_image=$iso \
+ win_acpi_shutdown=true \
+ $centos_test_runvars \
+ all_hostflags=$most_hostflags,hvm \
+ "$@"
+ }
+
+do_hvm_win7_x64_tests () {
+ do_hvm_win_test_one win7 win7 amd64
+}
+
+do_hvm_win_2017_tests () {
+ do_hvm_win_test_one ws16 ws16 amd64 guests_memsize=3584
+ # Win10 tests fails installation, upststream too, don't even try
+ #do_hvm_win_test_one win10 win10v1703 i386 guests_memsize=3584
+}
+
+do_hvm_debian_test_one () {
+ testname=$1
+ toolstack=$2
+ bios=$3
+ xsm=$4 # 'false' or 'true'
+ stubdom=$5 # '' (or unset) or 'true'
+
+ local arch=amd64
+ local testvars
+
+ case "$arch" in
+ amd64) iso_dir='install.amd' ;;
+ i386) iso_dir='install.386'
+ testvars+=' debianhvm_install_timeoutfactor=1.5'
+ testvars+=' debianhvm_diskdevice=/dev/sda' ;;
+ *) iso_dir="install.$arch" ;;
+ esac
+
+ stubdom_suffix=""
+ stubdom_runvar=""
+ if [ x$stubdom = xtrue ]; then
+ stubdom_suffix="-stubdom"
+ stubdom_runvar="debianhvm_stubdom=$stubdom"
+ fi
+
+ job_create_test \
+ test-$xenarch$kern-$dom0arch-$toolstack$qemuu_suffix$stubdom_suffix-$testname-$arch \
+ test-debianhvm $toolstack $xenarch $dom0arch $qemuu_runvar \
+ $stubdom_runvar $testvars \
+ debianhvm_suite=$guestsuite \
+ debianhvm_image=$(usual_debianhvm_image $arch) \
+ debianhvm_iso_kernel=/$iso_dir/vmlinuz \
+ debianhvm_iso_ramdisk=/$iso_dir/initrd.gz \
+ bios=$bios \
+ $centos_test_runvars \
+ all_hostflags=$most_hostflags,hvm
+ }
+
+do_hvm_debian_tests() {
+ if [ $xenarch != amd64 ]; then
+ return
+ fi
+
+ # QEMU upstream supports
+ # 1. ovmf + xl
+ # 2. seabios + xl
+ # 3. seabios + libvirt
+ # For libvirt we only generate -xsm test case.
+ if [ "x$qemuu_suffix" == "x-qemuu" ]; then
+ do_hvm_debian_test_one ovmf xl ovmf false
+ do_hvm_debian_test_one debianhvm xl seabios false
+ fi
+
+ # QEMU traditional supports rombios and stubdom
+ # Only test xl with QEMU traditional
+ if [ "x$qemuu_suffix" == "x-qemut" ]; then
+ do_hvm_debian_test_one debianhvm xl rombios false
+ fi
+}
+
+do_hvm_rhel6_tests () {
+ if [ $xenarch != amd64 -o $dom0arch != i386 -o "$kern" != "" ]; then
+ return
+ fi
+
+ for cpuvendor in amd intel; do
+
+ job_create_test \
+ test-$xenarch$kern-$dom0arch$qemuu_suffix-rhel6hvm-$cpuvendor \
+ test-rhelhvm xl $xenarch $dom0arch \
+ redhat_image=rhel-server-6.1-i386-dvd.iso \
+ $centos_test_runvars \
+ all_hostflags=$most_hostflags,hvm-$cpuvendor \
+ $qemuu_runvar
+
+ done
+}
+
+do_pygrub_tests () {
+ if [ $xenarch != amd64 -o $dom0arch != amd64 -o "$kern" != "" ]; then
+ return
+ fi
+
+ job_create_test test-$xenarch$kern-$dom0arch-pygrub \
+ test-debian-di xl $xenarch $dom0arch \
+ debian_arch=amd64 \
+ debian_suite=$guestsuite \
+ debian_di_version=$guest_di_version \
+ debian_method=netboot \
+ debian_bootloader=pygrub \
+ $centos_test_runvars \
+ all_hostflags=$most_hostflags
+ }
+
+do_pv_debian_test_one () {
+ testname=$1; shift
+ recipe_sfx=$1; shift
+ toolstack=$1; shift
+ platform=$1; shift
+
+ case "$recipe_sfx" in
+ # test-debian recipe requires xen-tools
+ '') return ;;
+ esac
+
+ suffix=${platform:+-$platform}
+ hostflags=${most_hostflags}${platform:+,platform-$platform}
+
+ job_create_test test-$xenarch$kern-$dom0arch-$testname$suffix \
+ test-debian$recipe_sfx $toolstack \
+ $xenarch $dom0arch \
+ $centos_test_runvars \
+ $debian_runvars all_hostflags=$hostflags $@
+ }
+
+do_pv_debian_tests () {
+ # Basic PV Linux test with xl
+ for platform in '' `getplatforms $xenarch` ; do
+ do_pv_debian_test_one xl '' xl "$platform"
+ done
+
+ do_pv_debian_test_one libvirt '' libvirt ''
+
+ # We compute a desired architecture for each combination of ts and fmt
+ # Within each fmt we rotate through the list of arches
+ # The starting list rotates once per ts, so that we try to
+ # exercise each fmt on each arch family.
+ local fmtarches_outer="i386 armhf amd64"
+ local endfmt="do_pv_debian_tests-missing-ts-fmt-for-dom0arch="
+
+ for ts in xl libvirt ; do
+
+ local fmtarches=$fmtarches_outer
+ fmtarches_outer="${fmtarches_outer#* } ${fmtarches_outer%% *}"
+
+ for fmt in raw vhd qcow2 ; do
+
+ local fmtarch="${fmtarches%% *}"
+ fmtarches="${fmtarches#* } $fmtarch"
+
+ if [ "x$fmtarch" != "x$dom0arch" ]; then
+ continue
+ else
+ endfmt=": "
+ fi
+
+ fmt_runvar="debian_diskfmt=$fmt"
+
+ do_pv_debian_test_one $ts-$fmt '-di' $ts '' \
+ debian_arch=$dom0arch \
+ debian_suite=$guestsuite \
+ debian_method=netboot \
+ debian_bootloader=pygrub \
+ $fmt_runvar
+
+ done
+ done
+
+ $endfmt$dom0arch
+}
+
+# Override job_create_test from mfi-common
+job_create_test () {
+ local job=$1; shift
+ local recipe=$1; shift
+ local toolstack=$1; shift
+ local xenarch=$1; shift
+ local dom0arch=$1; shift
+
+ job="$job"
+
+ job_create_test_filter_callback \
+ "$job" "$recipe" "$toolstack" "$xenarch" "$dom0arch" "$@" || return 0
+
+ ./cs-job-create $flight $job $recipe toolstack=$toolstack \
+ $RUNVARS $TEST_RUNVARS $global_runvars $most_runvars \
+ "$@"
+ }
+
+test_matrix_do_one () {
+
+ do_pv_debian_tests
+
+ for qemuu_suffix in -qemut -qemuu; do
+ case "$qemuu_suffix" in
+ -qemut)
+ qemuu_runvar=device_model_version=qemu-xen-traditional
+ ;;
+ -qemuu)
+ qemuu_runvar=device_model_version=qemu-xen
+ ;;
+ esac
+
+ do_hvm_win7_x64_tests
+ do_hvm_win_2017_tests
+ do_hvm_rhel6_tests
+
+ do_hvm_debian_tests
+
+ done # qemuu_suffix
+
+ do_pygrub_tests
+}
+
+xenarch=amd64
+dom0arch=amd64
+guestsuite=$defguestsuite
+di_version=$defdi_version
+pairtoolstack="xl libvirt"
+
+# Branch parsing
+## For centos$release-xen$release
+
+if [[ "$branch" =~ ^centos([67])-xen([4-9])\.([0-9]+)$ ]]; then
+ centos_release="${BASH_REMATCH[1]}"
+ centos_xenver="${BASH_REMATCH[2]}${BASH_REMATCH[3]}"
+else
+ echo >&2 "Unknown branch '$branch', e.g. of accepted: 'centos6-xen4.10'"
+ exit 1
+fi
+case $centos_xenver in
+ 46|48|410)
+ ;;
+ *)
+ echo >&2 "Unknown version of Xen $centos_xenver to use with CentOS"
+ exit 1
+ ;;
+esac
+cbs_repo_url=http://cbs.centos.org/repos
+centos_repo_urls="$cbs_repo_url/virt\$releasever-xen-$centos_xenver-candidate/\$basearch/os/"
+centos_repo_urls+=",$cbs_repo_url/virt\$releasever-xen-common-candidate/\$basearch/os/"
+hostos_runvars=" \
+ all_host_os=centos \
+ redhat_release=$centos_release \
+ redhat_repos_url=$centos_repo_urls \
+ "
+
+eval "
+arch_runvars=\"\$ARCH_RUNVARS_$dom0arch\"
+"
+debian_runvars=" \
+ debian_kernkind=pvops \
+ debian_arch=$dom0arch \
+ debian_suite=$guestsuite \
+ "
+
+most_hostflags="arch-$dom0arch,arch-xen-$xenarch,purpose-test"
+most_runvars=" \
+ arch=$dom0arch \
+ $arch_runvars $hostos_runvars \
+ "
+
+test_matrix_do_one
+
+echo $flight
+
+# Local variables:
+# mode: sh
+# sh-basic-offset: 2
+# indent-tabs-mode: nil
+# End: