All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yi Sun <yi.sun@intel.com>
To: yi.sun@intel.com, kvm@vger.kernel.org
Subject: [kvm-unit-tests PATCH 2/2] x86: Create ISO images according to unittests.cfg
Date: Fri,  4 Jun 2021 10:34:53 +0800	[thread overview]
Message-ID: <20210604023453.905512-2-yi.sun@intel.com> (raw)
In-Reply-To: <20210604023453.905512-1-yi.sun@intel.com>

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

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..8486be7
--- /dev/null
+++ b/x86/create_iso.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+set -e
+config_file=$1
+
+opts=
+extra_params=
+kernel=
+smp=
+testname=
+
+
+grub_cfg() {
+
+	kernel_elf=$1
+	kernel_para=$2
+
+	cat << EOF
+set timeout=0
+set default=0
+
+
+menuentry "${kernel_elf}" {
+    multiboot /boot/${kernel_elf} ${kernel_para}
+    boot
+}
+EOF
+
+}
+
+create_iso() {
+	case_name=$1
+	kernel_elf=$2
+	kernel_params=$3
+	if [ -f $kernel_elf ]; then
+		rm -rf build/isofiles
+		mkdir -p build/isofiles/boot/grub
+
+		cp $kernel_elf build/isofiles/boot/
+		grub_cfg ${kernel_elf##*/} $kernel_params> 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
+		fi
+		testname=$rematch
+
+	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]}
+		fi
+	elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
+		groups=${BASH_REMATCH[1]}
+	fi
+	(( nline -= 1))
+
+done < $config_file
-- 
2.27.0


  reply	other threads:[~2021-06-04  2:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04  2:34 [kvm-unit-tests PATCH 1/2] x86: Build ISO images from x86/*.elf Yi Sun
2021-06-04  2:34 ` Yi Sun [this message]
2021-06-04  3:06   ` [kvm-unit-tests PATCH 2/2] x86: Create ISO images according to unittests.cfg Nadav Amit
2021-06-04 12:32     ` Sun, Yi
2021-06-04 17:08       ` Nadav Amit
2021-06-04 17:13         ` Sun, Yi

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=20210604023453.905512-2-yi.sun@intel.com \
    --to=yi.sun@intel.com \
    --cc=kvm@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.