All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Testcase for checking lvm module
@ 2010-03-16 19:05 BVK Chaitanya
  2010-03-16 19:06 ` BVK Chaitanya
  2010-04-09 13:43 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 2 replies; 4+ messages in thread
From: BVK Chaitanya @ 2010-03-16 19:05 UTC (permalink / raw)
  To: The development of GRUB 2

Hi,


Attached patch adds a testcase to check for GRUB's lvm module
functionality.  It configures lvm volumes on-the-fly on temporary disk
images, and tests to see whether grub-shell ls command identifies them
or not.

Since all of the LVM operations need root privilege, this real test is
performed only when it is executed as root (or sudo make check); test
simply passes otherwise.  In future we may add sudo-check Makefile
target to execute these type of tests automatically sing "sudo"
feature.



-- 
bvk.chaitanya



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Testcase for checking lvm module
  2010-03-16 19:05 [PATCH] Testcase for checking lvm module BVK Chaitanya
@ 2010-03-16 19:06 ` BVK Chaitanya
  2010-04-09 13:50   ` Vladimir 'φ-coder/phcoder' Serbinenko
  2010-04-09 13:43 ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 1 reply; 4+ messages in thread
From: BVK Chaitanya @ 2010-03-16 19:06 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 31 bytes --]

Attached!



-- 
bvk.chaitanya

[-- Attachment #2: lvm_test.patch.txt --]
[-- Type: text/plain, Size: 4851 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: bvk.groups@gmail.com-20100317021252-1cts9bjol2lkd2a2
# target_branch: file:///home/bvk/work/grub2/mainline/
# testament_sha1: 9b533426627983a43022b8a2918a3b40f00984a0
# timestamp: 2010-03-17 07:43:03 +0530
# base_revision_id: bvk.groups@gmail.com-20100314170717-\
#   q8ppihzgyjyifcke
# 
# Begin patch
=== modified file 'conf/tests.rmk'
--- conf/tests.rmk	2010-01-22 13:37:27 +0000
+++ conf/tests.rmk	2010-03-17 02:12:52 +0000
@@ -50,6 +50,9 @@
 check_SCRIPTS += grub_script_vars1
 grub_script_vars1_SOURCES = tests/grub_script_vars1.in
 
+check_SCRIPTS += lvm_test
+lvm_test_SOURCES = tests/lvm_test.in
+
 # List of tests to execute on "make check"
 # SCRIPTED_TESTS    = example_scripted_test
 # SCRIPTED_TESTS   += example_grub_script_test
@@ -59,6 +62,7 @@
 SCRIPTED_TESTS  = grub_script_echo1
 SCRIPTED_TESTS += grub_script_echo_keywords
 SCRIPTED_TESTS += grub_script_vars1
+SCRIPTED_TESTS += lvm_test
 
 # dependencies between tests and testing-tools
 $(SCRIPTED_TESTS): grub-shell grub-shell-tester

=== added file 'tests/lvm_test.in'
--- tests/lvm_test.in	1970-01-01 00:00:00 +0000
+++ tests/lvm_test.in	2010-03-17 02:12:52 +0000
@@ -0,0 +1,56 @@
+#! /bin/bash -e
+
+lvm=/sbin/lvmn
+parted=/sbin/parted
+losetup=/sbin/losetup
+grubshell=@builddir@/grub-shell
+
+if test `id -u` != "0"; then
+    exit 0
+fi
+
+check_output () {
+    outfile=$1
+    shift
+
+    for disk in $@; do
+	if ! grep "($disk)" ${outfile} >/dev/null
+	then
+	    echo "($disk): disk/partiton not found"
+	    exit 1
+	fi
+    done
+}
+
+size=128M
+disk1=`mktemp`
+disk2=`mktemp`
+
+qemu-img create ${disk1} ${size} >/dev/null
+qemu-img create ${disk2} ${size} >/dev/null
+
+${parted} -s ${disk1} mklabel msdos mkpart primary 0 100%
+${parted} -s ${disk2} mklabel msdos mkpart primary 0 100%
+
+dev1=`${losetup} -f --show ${disk1}`
+dev2=`${losetup} -f --show ${disk2}`
+
+${lvm} pvcreate --quiet ${dev1} ${dev2}
+${lvm} vgcreate --quiet vol1 ${dev1} ${dev2}
+${lvm} lvcreate --quiet -n foo -L 20M vol1
+${lvm} lvcreate --quiet -n bar -L 20M vol1
+${lvm} lvcreate --quiet -n baz -L 20M vol1
+
+${lvm} lvchange --quiet -a n /dev/vol1/foo
+${lvm} lvchange --quiet -a n /dev/vol1/bar
+${lvm} lvchange --quiet -a n /dev/vol1/baz
+${lvm} vgchange --quiet -a n vol1
+
+${losetup} -d ${dev1}
+${losetup} -d ${dev2}
+
+outfile=`mktemp`
+echo "insmod lvm; ls" | ${grubshell} --boot=cd --qemu-opts="-hda ${disk1} -hdb ${disk2}" --modules=lvm | tee ${outfile}
+check_output ${outfile} hd0 hd1 vol1-foo vol1-bar vol1-baz
+
+rm -f ${disk1} ${disk2} ${outfile}

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWUDUA8sAAtDfgEAwfmv//14u
3wD////+YAZuL4adKLOcrroCQADSaJqYKeCanlD2pDaNQGgGR6mMoDJo8oJRFJ6n5DQm0JqDQAAG
gAAABocZMmmmEyMgYEYmjBGEGjTAAIMSaTQCNTARPJhR6aT1NAAM1NqHqAaHGTJpphMjIGBGJowR
hBo0wACCSIIBGI0BqYU2SJ5MghNMQB6gNCSJJCxcdtivpQ8lX0ZA7gOx1ziCMLbHkaX97+N6GG59
5K4NkIh2oZrXLc+q53B1SYm96kNc65baZMzC/FvosywrLawydBBDZ0ke+/ey+ZVWYrWxCizh+f5F
4cX8Ix2UwCq4CD1zECsdN7TSBOOX6YwKFFI3YDHlnXgEyLv1AJ+ZDcZnaTVShlSa1nStnBGVr8kA
2ib0rYGt0zk78bT7igTaaRA9x8DEOJRe5cUOuvXlZELplXoqutmfxqs+noapW/mUmWh4bPcdjdYa
2ZSk4oMj0Z/wGQED4jIHBhiZiOVzuIAH++Y3XpcBnQadoahgPlYlrD8nE97zz/T/p91M16xkoiIl
/zgXRwNreSFihXBipmF7O1eMe8uY8JpVN/iqtBdzP6AgRspy3B4EgS0IgByw0H2COIxFC8/3EFMK
F4ztCKqUxigz5UT0H7aOBmfq5AGZUzkriQsZlaA+VjqRT9+igIR10FCvEH3NimjNDzcrXjDEGunX
R0ccMzPRRC1CiDbvHJmlV+EvOXPecywCfvpoVCKSRqHT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G1d6zCFKGXX7oKo3i9MCipC+fh4B2Nhw37dh
B1w4sMHYzssHmtOsPZV1lboUsiMA1/TcuGgfJkGHIsY1LwgjOpKSXW+zSqt2ojWvVapSqQpVgUs8
E460jGNIlOhCfrtUdpppFzLLIq4fEzc1oiY8DyIgF66N0vBWoZDdNRDwGSpL445kqohKTwPQJkKJ
pRiHGR0V2JFkNq7m9oI454C9o6MNGsbC9GKqGdHMDlOITyFyWMlu+aDk9K4adxodCcLhwLRLJQZU
LURRWhREiAG1UET1LvjSXjIvXdi3suCkbw2C8lC/8RIGH6+P4uQdONlsB+BIOIpxdOP/8XckU4UJ
BA1APLA=

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Testcase for checking lvm module
  2010-03-16 19:05 [PATCH] Testcase for checking lvm module BVK Chaitanya
  2010-03-16 19:06 ` BVK Chaitanya
@ 2010-04-09 13:43 ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-04-09 13:43 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]

BVK Chaitanya wrote:
> Hi,
>
>
> Attached patch adds a testcase to check for GRUB's lvm module
> functionality.  It configures lvm volumes on-the-fly on temporary disk
> images, and tests to see whether grub-shell ls command identifies them
> or not.
>
> Since all of the LVM operations need root privilege, this real test is
> performed only when it is executed as root (or sudo make check); test
> simply passes otherwise.  In future we may add sudo-check Makefile
> target to execute these type of tests automatically sing "sudo"
> feature.
>
>   
Using sudo in any of the grub scripts isn't an option. Would you like
the programs you install silently acquiring root rights? At the limited
we can make a priviliged-tests target which user will execute like:
sudo make privelegied-tests
Or we can make a script generate-gnu-linux-images.sh which will create
all filesystem and lvm images needing root privelgies. This will also
make repeated make check faster
But it's way better to avoid needing root privelegies in the first
place. In particular operations with images shouldn't need root
privelegies. Have you looked into fakeroot program?
>
>   


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Testcase for checking lvm module
  2010-03-16 19:06 ` BVK Chaitanya
@ 2010-04-09 13:50   ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-04-09 13:50 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 750 bytes --]

BVK Chaitanya wrote:
> Attached!
>
>
>   

+size=128M
+disk1=`mktemp`
+disk2=`mktemp`
Plain mktemp will fail on FreeBSD. Idk for well freebsd supports linux lvm though
+lvm=/sbin/lvmn
+parted=/sbin/parted
+losetup=/sbin/losetup
You don't check for real existence of these files. And letting use $PATH is better IMO than hardcoding path to executables
+if test `id -u` != "0"; then
+    exit 0
+fi
+
There should be a warning here

>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-09 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-16 19:05 [PATCH] Testcase for checking lvm module BVK Chaitanya
2010-03-16 19:06 ` BVK Chaitanya
2010-04-09 13:50   ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-09 13:43 ` Vladimir 'φ-coder/phcoder' Serbinenko

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.