--- /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
+
+ # cut down the arm64 tests temporarily, due to lack of capacity
+ case "$branch" in
+ *arm*|*libvirt*) ;;
+ *)
+ case "$job" in
+ test-arm64-arm64-xl-multivcpu) return 1 ;;
+ test-arm64-arm64-xl-rtds) return 1 ;;
+ test-arm64-arm64-libvirt) return 1 ;;
+ test-arm64-arm64-libvirt-qcow2) return 1 ;;
+ esac
+ ;;
+ esac
+
+ case "$branch" in
+ xen-unstable-smoke)
+ case "$job" in
+ test-amd64-amd64-libvirt) return 0 ;;
+ test-armhf-armhf-xl) return 0 ;;
+ test-arm64-arm64-xl-xsm) return 0 ;;
+ test-amd64-amd64-xl-qemuu-debianhvm-i386) return 0 ;;
+ *) return 1 ;;
+ esac
+ ;;
+ qemu-upstream-4.2-testing)
+ case " $* " in
+ *" device_model_version=qemu-xen "*)
+ ;;
+ *)
+ : "suppressed $job"
+ return 1;;
+ esac
+ ;;
+ libvirt)
+ if [ x$toolstack != xlibvirt ] ; then return 1; fi
+ ;;
+ rumprun)
+ case "$job" in
+ *-rumprun-*)
+ ;;
+ *)
+ : "suppressed $job"
+ return 1;;
+ esac
+ ;;
+ xtf)
+ case "$xenarch:$dom0arch" in
+ amd64:amd64) ;;
+ *) return 1;;
+ esac
+ case $job in
+ *-xtf-*) ;;
+ *) return 1;;
+ esac
+ ;;
+ seabios)
+ case $xenarch in
+ amd64|i386) ;;
+ *) return 1;;
+ esac
+ case $job in
+ *-qemuu-ovmf-*) return 1;;
+ *-qemuu-*) ;;
+ *) return 1;;
+ esac
+ ;;
+ ovmf)
+ case $xenarch in
+ amd64|i386) ;;
+ *) return 1;;
+ esac
+ case $job in
+ *-qemuu-*) ;;
+ *) return 1;;
+ esac
+ 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_winxp_tests () {
+ case $xenbranch in
+ xen-3.*-testing) ;;
+ xen-4.0-testing) ;;
+ xen-4.1-testing) ;;
+ xen-4.2-testing) ;;
+ xen-4.3-testing) ;;
+ xen-4.4-testing) ;;
+ xen-4.5-testing) ;;
+ *) return;;
+ esac
+
+ for vcpus in '' 1; do
+ case "$vcpus" in
+ '') vcpus_runvars=''; vcpus_suffix='' ;;
+ *) vcpus_runvars=guests_vcpus=$vcpus; vcpus_suffix=-vcpus$vcpus ;;
+ esac
+
+ if [ "x$vcpus" != x ] && \
+ [ "$xenarch$kern-$dom0arch" != "amd64-i386" ]; then
+ continue
+ fi
+
+ toolstack="xl"
+
+ if [ x$toolstack = x ] ; then
+ stripy toolstack xend xl \
+ "$vcpus" 1 \
+ "$kern" '' \
+ "$xenarch" i386 \
+ "$dom0arch" i386
+ fi
+
+ toolstack_runvars="toolstack=$toolstack"
+
+ job_create_test \
+ test-$xenarch$kern-$dom0arch-$toolstack$qemuu_suffix-winxpsp3$vcpus_suffix \
+ test-win $toolstack $xenarch $dom0arch $qemuu_runvar \
+ win_image=winxpsp3.iso $vcpus_runvars \
+ win_acpi_shutdown=true \
+ $centos_test_runvars \
+ all_hostflags=$most_hostflags,hvm
+
+ done
+}
+
+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
+ do_hvm_win_test_one win10 win10v1703 i386 guests_memsize=3584
+}
+
+branch_debianhvm_arch () {
+ case $branch in
+ xen-unstable-smoke) echo i386;;
+ *) echo amd64;;
+ esac
+}
+
+do_hvm_debian_test_one () {
+ testname=$1
+ toolstack=$2
+ bios=$3
+ xsm=$4 # 'false' or 'true'
+ stubdom=$5 # '' (or unset) or 'true'
+
+ local arch=$(branch_debianhvm_arch)
+ 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
+}
+
+do_centos_cbs_package () {
+ case "$branch" in
+ centos) ;;
+ *) return ;;
+ esac
+ # test-centos doesn't do anything
+ # This could be a guest test.
+ job_create_test test-$xenarch$kern-$dom0arch-centos-devel \
+ test-centos xl $xenarch $dom0arch \
+ centos_cbs_repo=candidate \
+ bios=seabios \
+ $centos_test_runvars \
+ all_hostflags=$most_hostflags \
+ all_host_os=centos
+}
+
+# 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
+
+ # RTDS came in 4.5
+ case "$xenbranch" in
+ xen-3.*-testing) test_rtds=n ;;
+ xen-4.0-testing) test_rtds=n ;;
+ xen-4.1-testing) test_rtds=n ;;
+ xen-4.2-testing) test_rtds=n ;;
+ xen-4.3-testing) test_rtds=n ;;
+ xen-4.4-testing) test_rtds=n ;;
+ xen-4.5-testing) test_rtds=y ;;
+ *) test_rtds=y ;;
+ esac
+
+ for qemuu_suffix in '' -qemut -qemuu; do
+ case "$qemuu_suffix" in
+ '')
+ case $xenbranch in
+ xen-3.*-testing) ;;
+ xen-4.0-testing) ;;
+ xen-4.1-testing) ;;
+ xen-4.2-testing) ;;
+ *) continue ;;
+ esac
+ qemuu_runvar=''
+ ;;
+ -qemut)
+ qemuu_runvar=device_model_version=qemu-xen-traditional
+ case $branch in
+ qemu-mainline*) continue ;;
+ qemu-upstream*) continue ;;
+ esac
+ ;;
+ -qemuu)
+ case $xenbranch in
+ xen-3.*-testing) continue;;
+ xen-4.0-testing) continue;;
+ xen-4.1-testing) continue;;
+ esac
+ qemuu_runvar=device_model_version=qemu-xen
+ ;;
+ esac
+
+ do_hvm_winxp_tests
+ 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"
+
+hostos_runvars="
+ all_host_os=centos \
+ "
+
+eval "
+ arch_runvars=\"\$ARCH_RUNVARS_$dom0arch\"
+"
+kernkind=pvops
+debian_runvars="debian_kernkind=$kernkind \
+ debian_arch=$dom0arch \
+ debian_suite=$guestsuite \
+ "
+most_hostflags="arch-$dom0arch,arch-xen-$xenarch,purpose-test"
+most_runvars="
+ arch=$dom0arch \
+ kernkind=$kernkind \
+ $arch_runvars $hostos_runvars
+ "
+
+test_matrix_do_one
+
+echo $flight
+
+# Local variables:
+# mode: sh
+# sh-basic-offset: 2
+# indent-tabs-mode: nil
+# End: