[kvm-unit-tests PATCH 2/2 v2] x86: Create ISO images according to unittests.cfg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Create ISO image according to the configure file unittests.cfg,
where describes the parameters of each test case.

The grub.cfg in ios/boot/grub/ looks as following, taking case
'vmx_apicv_test' as an example:

set timeout=0
set default=0

menuentry "vmx.elf" {
    multiboot /boot/vmx.elf apic_reg_virt_test virt_x2apic_mode_test
    module   /boot/module
    boot
}

[1] All parameters are from '-append xxx' in the unittests.cfg.
[2] The file 'module' is a fixed file that can be passed by paramters
of script ./create_iso.sh.

Signed-off-by: Yi Sun <yi.sun@xxxxxxxxx>

diff --git a/x86/create_iso.sh b/x86/create_iso.sh
new file mode 100755
index 0000000..e55ee9e
--- /dev/null
+++ b/x86/create_iso.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+set -e
+config_file=$1
+module_file=$2
+
+opts=
+extra_params=" "
+kernel=
+smp=
+testname=
+
+grub_cfg() {
+	local kernel_elf=$1
+	local kernel_para=$2
+	local module_file=$3
+
+	if [[ "${module_file}" != "" ]]; then
+		module_cmd="module   /boot/${module_file}"
+	fi
+
+	cat << EOF
+set timeout=0
+set default=0
+
+menuentry "${kernel_elf}" {
+    multiboot /boot/${kernel_elf} ${kernel_para}
+    ${module_cmd}
+    boot
+}
+EOF
+}
+
+create_iso() {
+	local case_name=$1
+	local kernel_elf=$2
+	local kernel_params=$3
+	local module_file=$4
+
+	if [ -f $kernel_elf ]; then
+		rm -rf build/isofiles
+		mkdir -p build/isofiles/boot/grub
+
+		cp $kernel_elf build/isofiles/boot/
+		[[ -f $module_file ]] && cp $module_file build/isofiles/boot/
+
+		grub_cfg ${kernel_elf##*/} "${kernel_params}" ${module_file##*/} > build/isofiles/boot/grub/grub.cfg
+
+		rm -rf ${testname}.iso
+		grub-mkrescue -o ${case_name}.iso build/isofiles 2> /dev/null
+		[ $? == 0 ] && echo "Creating ISO for case: ${case_name}"
+	fi
+}
+
+nline=`wc $config_file | cut -d' ' -f 2`
+
+while read -r line; do
+	if [[ "$line" =~ ^\[(.*)\]$ || $nline == 1 ]]; then
+		rematch=${BASH_REMATCH[1]}
+		if [[ "${testname}" != "" ]]; then
+			create_iso $testname ${kernel}.elf "${extra_params}" $module_file
+		fi
+		testname=$rematch
+		extra_params=" "
+		smp=1
+		kernel=""
+		opts=""
+		groups=""
+	elif [[ $line =~ ^file\ *=\ *(.*)\.flat$ ]]; then
+		kernel=${BASH_REMATCH[1]}
+	elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
+		smp=${BASH_REMATCH[1]}
+	elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
+		opts=${BASH_REMATCH[1]}
+		if [[ "$opts" =~ .*append\ (.*)$ ]]; then
+			extra_params=${BASH_REMATCH[1]}
+			extra_params=`echo $extra_params | sed 's/\"//g'`
+		fi
+	elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
+		groups=${BASH_REMATCH[1]}
+	fi
+	(( nline -= 1))
+
+done < $config_file
-- 
2.27.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux