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

[Libguestfs] [PATCH 3/3] Add tests for CoreOS



Signed-off-by: Nikos Skalkotos <skalkoto grnet gr>
---
 .gitignore                                |  1 +
 inspector/Makefile.am                     |  1 +
 inspector/expected-coreos.img.xml         | 30 +++++++++++
 tests/guests/Makefile.am                  |  6 +++
 tests/guests/guest-aux/make-coreos-img.sh | 83 +++++++++++++++++++++++++++++++
 tests/guests/guests.xml.in                | 16 ++++++
 6 files changed, 137 insertions(+)
 create mode 100644 inspector/expected-coreos.img.xml
 create mode 100755 tests/guests/guest-aux/make-coreos-img.sh

diff --git a/.gitignore b/.gitignore
index 29f9d6d..096cdfc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -536,6 +536,7 @@ Makefile.in
 /tests/guests/stamp-fedora-md.img
 /tests/guests/ubuntu.img
 /tests/guests/archlinux.img
+/tests/guests/coreos.img
 /tests/guests/windows.img
 /tests/mount-local/test-parallel-mount-local
 /tests/mountable/test-internal-parse-mountable
diff --git a/inspector/Makefile.am b/inspector/Makefile.am
index 9d8303c..9c79bed 100644
--- a/inspector/Makefile.am
+++ b/inspector/Makefile.am
@@ -38,6 +38,7 @@ EXTRA_DIST = \
 	expected-fedora.img.xml \
 	expected-ubuntu.img.xml \
 	expected-archlinux.img.xml \
+	expected-coreos.img.xml \
 	expected-windows.img.xml \
 	test-virt-inspector.sh \
 	test-xmllint.sh.in \
diff --git a/inspector/expected-coreos.img.xml b/inspector/expected-coreos.img.xml
new file mode 100644
index 0000000..723a853
--- /dev/null
+++ b/inspector/expected-coreos.img.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<operatingsystems>
+  <operatingsystem>
+    <root>/dev/sda5</root>
+    <name>linux</name>
+    <distro>coreos</distro>
+    <product_name>CoreOS 647.0.0</product_name>
+    <major_version>647</major_version>
+    <minor_version>0</minor_version>
+    <hostname>coreos.invalid</hostname>
+    <format>installed</format>
+    <mountpoints>
+      <mountpoint dev="/dev/sda5">/</mountpoint>
+      <mountpoint dev="/dev/sda3">/usr</mountpoint>
+    </mountpoints>
+    <filesystems>
+      <filesystem dev="/dev/sda3">
+        <type>ext4</type>
+        <label>USR-A</label>
+        <uuid>01234567-0123-0123-0123-012345678901</uuid>
+      </filesystem>
+      <filesystem dev="/dev/sda5">
+        <type>ext4</type>
+        <label>ROOT</label>
+        <uuid>01234567-0123-0123-0123-012345678902</uuid>
+      </filesystem>
+    </filesystems>
+    <applications/>
+  </operatingsystem>
+</operatingsystems>
diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am
index b752bb1..6ada4ec 100644
--- a/tests/guests/Makefile.am
+++ b/tests/guests/Makefile.am
@@ -30,6 +30,7 @@ EXTRA_DIST = \
 	guest-aux/make-ubuntu-img.sh \
 	guest-aux/make-archlinux-img.sh \
 	guest-aux/archlinux-package \
+	guest-aux/make-coreos-img.sh \
 	guest-aux/make-windows-img.sh \
 	guest-aux/windows-software \
 	guest-aux/windows-software.reg \
@@ -52,6 +53,7 @@ disk_images = \
 	fedora-btrfs.img \
 	ubuntu.img \
 	archlinux.img \
+	coreos.img \
 	windows.img
 
 # This is 'check_DATA' because we don't need it until 'make check'
@@ -109,6 +111,10 @@ ubuntu.img: guest-aux/make-ubuntu-img.sh
 archlinux.img: guest-aux/make-archlinux-img.sh
 	SRCDIR=$(srcdir) $(top_builddir)/run --test $<
 
+# Make a (dummy) CoreOS image.
+coreos.img: guest-aux/make-coreos-img.sh
+	SRCDIR=$(srcdir) $(top_builddir)/run --test $<
+
 # Make a (dummy) Windows image.
 windows.img: guest-aux/make-windows-img.sh \
 	     guest-aux/windows-software guest-aux/windows-system
diff --git a/tests/guests/guest-aux/make-coreos-img.sh b/tests/guests/guest-aux/make-coreos-img.sh
new file mode 100755
index 0000000..b8e0816
--- /dev/null
+++ b/tests/guests/guest-aux/make-coreos-img.sh
@@ -0,0 +1,83 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2015 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Make a CoreOS image which is enough to fool the inspection heuristics.
+
+export LANG=C
+set -e
+
+# lsb-release file.
+cat > release.tmp.$$ <<'EOF'
+DISTRIB_ID=CoreOS
+DISTRIB_RELEASE=647.0.0
+DISTRIB_CODENAME="Red Dog"
+DISTRIB_DESCRIPTION="CoreOS 647.0.0"
+EOF
+
+# Create a disk image.
+guestfish <<EOF
+sparse coreos.img.tmp.$$ 512M
+run
+
+part-init /dev/sda gpt
+part-add /dev/sda p 4096 266239
+part-add /dev/sda p 266240 270335
+part-add /dev/sda p 270336 532479
+part-add /dev/sda p 532480 794623
+part-add /dev/sda p 794624 -4096
+
+part-set-name /dev/sda 1 EFI_SYSTEM
+part-set-bootable /dev/sda 1 true
+part-set-name /dev/sda 2 BIOS-BOOT
+part-set-name /dev/sda 3 USR-A
+part-set-name /dev/sda 4 USR-B
+part-set-name /dev/sda 5 ROOT
+
+mkfs fat /dev/sda1
+mkfs ext4 /dev/sda3
+set-label /dev/sda3 USR-A
+set-uuid /dev/sda3 01234567-0123-0123-0123-012345678901
+mkfs ext4 /dev/sda5
+set-label /dev/sda5 ROOT
+set-uuid /dev/sda5 01234567-0123-0123-0123-012345678902
+
+# Enough to fool inspection API.
+mount /dev/sda5 /
+mkdir-p /etc/coreos
+mkdir /usr
+mount /dev/sda3 /usr
+mkdir /usr/bin
+mkdir /usr/lib64
+mkdir /usr/local
+mkdir-p /usr/share/coreos/
+
+ln-s usr/bin /bin
+ln-s usr/lib64 /lib64
+ln-s lib64 /lib
+mkdir /root
+mkdir /home
+
+write /etc/coreos/update.conf "GROUP=stable"
+upload release.tmp.$$ /usr/share/coreos/lsb-release
+ln-s ../usr/share/coreos/lsb-release /etc/lsb-release
+write /etc/hostname "coreos.invalid"
+
+EOF
+
+rm release.tmp.$$
+mv coreos.img.tmp.$$ coreos.img
diff --git a/tests/guests/guests.xml.in b/tests/guests/guests.xml.in
index 451d3fa..8f7ac81 100644
--- a/tests/guests/guests.xml.in
+++ b/tests/guests/guests.xml.in
@@ -248,6 +248,22 @@
   </domain>
 
   <domain type='test'>
+    <name>coreos</name>
+    <memory>1048576</memory>
+    <os>
+      <type>hvm</type>
+      <boot dev='hd'/>
+    </os>
+    <devices>
+      <disk type='file' device='disk'>
+        <driver name='qemu' type='raw'/>
+        <source file='@abs_builddir@/coreos.img'/>
+        <target dev='vda' bus='virtio'/>
+      </disk>
+    </devices>
+  </domain>
+
+  <domain type='test'>
     <name>windows</name>
     <memory>1048576</memory>
     <os>
-- 
2.1.0


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