From: Yi Sun <yi.sun@intel.com>
To: yi.sun@linux.intel.com, yi.sun@intel.com, kvm@vger.kernel.org
Subject: [kvm-unit-tests PATCH RESEND v3 2/2] x86: Create ISO images according to unittests.cfg
Date: Tue, 7 Dec 2021 17:44:32 +0800 [thread overview]
Message-ID: <20211207094432.189576-3-yi.sun@intel.com> (raw)
In-Reply-To: <20211207094432.189576-1-yi.sun@intel.com>
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@intel.com>
diff --git a/x86/create_iso.sh b/x86/create_iso.sh
new file mode 100755
index 0000000..4fe8e5b
--- /dev/null
+++ b/x86/create_iso.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+config_file=$1
+module_file=$2
+
+opts=
+extra_params=" "
+kernel=
+smp=
+testname=
+
+dir_x86=`dirname $0`
+[[ ${dir_x86:0:1} != "/" ]] && dir_x86=`pwd`/$dir_x86
+
+usage() {
+ cat << EOF
+Usage: create_iso.sh <configure> [module_file]
+ configure:
+ Usually just pass unittests.cfg to the create_iso.sh.
+
+ module_file:
+ This is optional. You can pass some environment to the kernels
+ The module.file looks as following:
+ NR_CPUS=56
+ MEMSIZE=4096
+ TEST_DEVICE=0
+ BOOTLOADER=1
+EOF
+}
+
+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 ${dir_x86}/${case_name}.iso build/isofiles >& /dev/null
+ if [ $? == 0 ]; then
+ echo "Creating ISO for case: ${case_name}"
+ else
+ echo "[FAIL] grub-mkrescue: Please install grub-mkrescue and xorriso correctly."
+ exit 1
+ fi
+ fi
+}
+
+if [[ "$config_file" == "" || ! -f $config_file ]]; then
+ echo "[FAIL] A configure file is required, usually pass unittests.cfg as the first parameter"
+ usage
+ exit 1
+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 ${dir_x86}/${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
prev parent reply other threads:[~2021-12-07 9:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 9:44 [kvm-unit-tests PATCH RESEND v3 0/2] Wrap EFL binaries into ISO images Yi Sun
2021-12-07 9:44 ` [kvm-unit-tests PATCH RESEND v3 1/2] x86: Build ISO images from x86/*.elf Yi Sun
2021-12-07 9:44 ` Yi Sun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211207094432.189576-3-yi.sun@intel.com \
--to=yi.sun@intel.com \
--cc=kvm@vger.kernel.org \
--cc=yi.sun@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox