[PATCH kvm-unit-tests 03/12] scripts/mkstandalone: refactor temp file creation

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

 



Using the cleanup variable is ugly, but I couldn't come up with a better
idea.

Signed-off-by: Radim Krčmář <rkrcmar@xxxxxxxxxx>
---
 scripts/mkstandalone.sh | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 47d6e279d212..a187adc856b7 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -20,6 +20,21 @@ fi
 unittests=$TEST_DIR/unittests.cfg
 mkdir -p tests
 
+temp_file ()
+{
+	local var="$1"
+	local file="$2"
+
+	echo "cleanup=\"\$$var \$cleanup\""
+	echo "$var=\`mktemp\`"
+	echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 1"
+
+	gzip - < $file | base64
+
+	echo "BIN_EOF"
+	echo "chmod +x \$$var"
+}
+
 function mkstandalone()
 {
 	local testname="$1"
@@ -74,14 +89,11 @@ echo "skip $testname (test kernel not present)" 1>&2
 exit 1
 EOF
 else
+	echo "trap 'rm -f \$cleanup; exit 1' HUP INT TERM"
+
+	temp_file bin "$kernel"
+
 	cat <<EOF
-trap 'rm -f \$bin; exit 1' HUP INT TERM
-bin=\`mktemp\`
-base64 -d << 'BIN_EOF' | zcat > \$bin &&
-EOF
-gzip - < $kernel | base64
-	cat <<EOF
-BIN_EOF
 
 qemu="$qemu"
 if [ "\$QEMU" ]; then
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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