Added check and test routines for Docker
authorCharles Nguyen <chuckleb@gmail.com>
Sun, 22 Jun 2014 03:27:51 +0000 (22:27 -0500)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 20 Jun 2016 12:30:13 +0000 (08:30 -0400)
Makefile.am
tests/docker/.dockerinit [new file with mode: 0644]
tests/docker/proc/cpuinfo [new file with mode: 0644]
tests/docker/proc/self/status [new file with mode: 0644]
tests/docker/sbin/dmidecode [new file with mode: 0755]
tests/docker/sbin/uname [new file with mode: 0755]
tests/docker/sbin/virt-what-cpuid-helper [new file with mode: 0755]
tests/test-docker.sh [new file with mode: 0755]
virt-what.in

index 784d6db..24d1730 100644 (file)
@@ -40,6 +40,7 @@ endif
 
 TESTS = \
        tests/test-baremetal.sh \
+       tests/test-docker.sh \
        tests/test-esx4.1.sh \
        tests/test-hyperv.sh \
        tests/test-kvm.sh \
@@ -63,6 +64,12 @@ EXTRA_DIST = \
        tests/baremetal/sbin/dmidecode \
        tests/baremetal/sbin/uname \
        tests/baremetal/sbin/virt-what-cpuid-helper \
+       tests/docker/.dockerinit \
+       tests/docker/proc/cpuinfo \
+       tests/docker/proc/self/status \
+       tests/docker/sbin/dmidecode \
+       tests/docker/sbin/uname \
+       tests/docker/sbin/virt-what-cpuid-helper \
        tests/esx4.1/proc/cpuinfo \
        tests/esx4.1/proc/self/status \
        tests/esx4.1/sbin/dmidecode \
diff --git a/tests/docker/.dockerinit b/tests/docker/.dockerinit
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/docker/proc/cpuinfo b/tests/docker/proc/cpuinfo
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/docker/proc/self/status b/tests/docker/proc/self/status
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/docker/sbin/dmidecode b/tests/docker/sbin/dmidecode
new file mode 100755 (executable)
index 0000000..d9992ad
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh -
+cat <<'EOF'
+# dmidecode 2.11
+/dev/mem: Operation not permitted
+EOF
+exit 1
diff --git a/tests/docker/sbin/uname b/tests/docker/sbin/uname
new file mode 100755 (executable)
index 0000000..ab0ec89
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh -
+echo x86_64
diff --git a/tests/docker/sbin/virt-what-cpuid-helper b/tests/docker/sbin/virt-what-cpuid-helper
new file mode 100755 (executable)
index 0000000..ad82504
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh -
+echo @
diff --git a/tests/test-docker.sh b/tests/test-docker.sh
new file mode 100755 (executable)
index 0000000..4187f61
--- /dev/null
@@ -0,0 +1,34 @@
+# Test for Docker
+# Copyright (C) 2008-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+root=tests/docker
+
+output="$(./virt-what --test-root=$root 2>&1)"
+expected="docker"
+
+if [ "$output" != "$expected" ]; then
+    echo "$0: test failed because output did not match expected"
+    echo "Expected output was:"
+    echo "----------------------------------------"
+    echo "$expected"
+    echo "----------------------------------------"
+    echo "But the actual output of the program was:"
+    echo "----------------------------------------"
+    echo "$output"
+    echo "----------------------------------------"
+    exit 1
+fi
index fb399be..c04203e 100644 (file)
@@ -248,3 +248,8 @@ if ! "$skip_qemu_kvm"; then
        fi
     fi
 fi
+
+# Check for Docker.
+if [ -f "${root}/.dockerinit" ]; then
+       echo docker
+fi