RFC: testing framework
Subsystems (2)
Here's a patch to add a testing framework to lvm, along with a few tests to demonstrate what you can do and how.
I've put all of this in a sub-directory named "t/".
I chose that rather than test/something since things in test appear not ever to be built or run, and to be unit tests. The tests I'm adding here are run via "make check", and are more of an integration test suite than unit tests.
You can run "make check" as an ordinary (non-root) user, but it won't do much more than the version-comparing sanity check in t/t0000-basic. The other two tests are skipped, because they require root privileges.
You can also run each test by itself, e.g.
cd t && t3000-lvcreate-pvtags.sh
enable debug output:
cd t && t3000-lvcreate-pvtags.sh --verbose
stop immediately upon failure:
cd t && t3000-lvcreate-pvtags.sh --immediate
[if any of this looks familiar, it may be because it's modeled after the testing framework in git.git ]
There are kludges in t/Makefile.in (symlink creation and LD_LIBRARY_PATH setting), that are required to run the dynamically-linked lvm against the libraries in a just-compiled sibling device-mapper directory. Thanks to Dave Wysochanski for that tip. IMHO this is a very strong argument for pulling device-mapper into lvm. Alasdair, can we do that soon? I'll be happy to submit a patch.
Note that since the tools (other than lvm) aren't actually built anywhere, I have a rule in t/Makefile.in that creates a bunch of symlinks in t/bin/<tool_name>. Then, all of the test scripts use a PATH with that directory listed first.
The t4000 test has checks for the pvmove bug I fixed this week, as well as for the current behavior that should be changed when BZ 284771 is addressed.
t3000-lvcreate-pvtags.sh is derived from a script by Jun'ichi Nomura, and currently fails, but passes if you apply the patch he posted, build, and rerun the test.
IMHO, once the framework is in place, every time a bug is fixed, the bug-fixing change set should include a test suite addition to exercise the bug and fix -- assuming that it's feasible, of course.
Initially, the individual tests used mktemp, which wasn't ideal, since that program is not always available. Instead, since each test is run from its own temporary directory created by the portable, mkdtemp, wrapper script, I've eliminated those per-test uses of mktemp, and just use pwd-relative names like $(pwd)/1, $(pwd)/2. I suppose the VG names have to be relatively unique, system wide, so have added a -$$ (pid) suffix to those.
Jim
--- Makefile.in | 3 + configure | 3 +- configure.in | 3 +- t/Makefile.in | 73 ++++++++++++ t/lvm-utils.sh | 47 ++++++++ t/mkdtemp | 107 ++++++++++++++++++ t/t0000-basic.sh | 26 +++++ t/t3000-lvcreate-pvtags.sh | 70 ++++++++++++ t/t4000-pv-range-overflow.sh | 52 +++++++++ t/test-lib.sh | 251 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 633 insertions(+), 2 deletions(-) create mode 100644 t/Makefile.in create mode 100644 t/lvm-utils.sh create mode 100755 t/mkdtemp create mode 100755 t/t0000-basic.sh create mode 100755 t/t3000-lvcreate-pvtags.sh create mode 100755 t/t4000-pv-range-overflow.sh create mode 100644 t/test-lib.sh
Makefile.in +3 -0
@@ -68,3 +68,6 @@ cscope.out: tools @CSCOPE_CMD@ -b -R all: cscope.out endif + +check: all + $(MAKE) -C t/ all
configure +2 -1
@@ -11591,7 +11591,7 @@ fi ################################################################################ -ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile" +ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile t/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure
@@ -12206,6 +12206,7 @@ do "test/format1/Makefile") CONFIG_FILES="$CONFIG_FILES test/format1/Makefile" ;; "test/regex/Makefile") CONFIG_FILES="$CONFIG_FILES test/regex/Makefile" ;; "test/filters/Makefile") CONFIG_FILES="$CONFIG_FILES test/filters/Makefile" ;; + "t/Makefile") CONFIG_FILES="$CONFIG_FILES t/Makefile" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
configure.in +2 -1
@@ -1,6 +1,6 @@ ## ## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved. -## Copyright (C) 2004 Red Hat, Inc. All rights reserved. +## Copyright (C) 2004, 2007 Red Hat, Inc. All rights reserved. ## ## This file is part of the LVM2. ##
@@ -660,6 +660,7 @@ test/device/Makefile \ test/format1/Makefile \ test/regex/Makefile \ test/filters/Makefile \ +t/Makefile \ ]) AC_OUTPUT
t/Makefile.in new file +73 -0
73 lines not on this page · raw message
t/lvm-utils.sh new file +47 -0
47 lines not on this page · raw message
t/mkdtemp new file +107 -0
107 lines not on this page · raw message
t/t0000-basic.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/sh + +test_description='Basics: see if tools are built, etc.' + +. ./test-lib.sh + +lvm >/dev/null 2>&1 +if test $? != 3; then + echo >&2 'You do not seem to have built lvm yet.' + exit 1 +fi + +v=$abs_top_srcdir/tools/version.h +test_expect_success \ + "get version string from $v" \ + 'sed -n "/#define LVM_VERSION ./s///p" '"$v"'|sed "s/ .*//" > expected' + +test_expect_success \ + 'get version of a just-built binary, ensuring PATH is set properly' \ + 'lvm pvmove --version|sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" > actual' + +test_expect_success \ + 'ensure they are the same' \ + 'diff -u actual expected' + +test_done
t/t3000-lvcreate-pvtags.sh new file +70 -0
70 lines not on this page · raw message
t/t4000-pv-range-overflow.sh new file +52 -0
52 lines not on this page · raw message
t/test-lib.sh new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
1.5.3.1.19.gb5ef6-dirty
Hi,
It's very nice to have this sort of regression tests in the tree.
Quoted 6 lines · Jim Meyering
There are kludges in t/Makefile.in (symlink creation and
LD_LIBRARY_PATHsetting), that are required to run the dynamically-linked lvm against the libraries in a just-compiled sibling device-mapper directory. Thanks to Dave Wysochanski for that tip. IMHO this is a very strong argument for pulling device-mapper into lvm. Alasdair, can we do that soon? I'll be happy to submit a patch.
It didn't work for me because I have device-mapper source directory named '../device-mapper.work', instead of '../device-mapper' that Makefile assumes.
There is '--with-dmdir=DIR' option for configure.
Can the Makefile use it?
(A patch is attached.)
Thanks,
Signature · 9 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: make-check-use-DMDIR.patch Type: text/x-patch Size: 1177 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20070914/032c4b16/attachment.bin>
Quoted 8 lines · Jun'ichi Nomura
Quoted 6 lines · Jim Meyering
There are kludges in t/Makefile.in (symlink creation and
LD_LIBRARY_PATHsetting), that are required to run the dynamically-linked lvm against the libraries in a just-compiled sibling device-mapper directory. Thanks to Dave Wysochanski for that tip. IMHO this is a very strong argument for pulling device-mapper into lvm. Alasdair, can we do that soon? I'll be happy to submit a patch.
Quoted 6 lines
It didn't work for me because I have device-mapper source directory named '../device-mapper.work', instead of '../device-mapper' that
Makefileassumes.
There is '--with-dmdir=DIR' option for configure.
Can theMakefileuse it?
(A patch is attached.)
Also, this patch to allow relative path for '--with-dmdir' might be helpful.
Thanks,
Signature · 8 lines
Jun'ichi Nomura, NEC Corporation of America -------------- next part -------------- A non-text attachment was scrubbed... Name: lvm2-configure-allow-relative-path.patch Type: text/x-patch Size: 447 bytes Desc: not available URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20070914/7833087c/attachment.bin>
"Jun'ichi Nomura" <[email protected]> wrote:
...
Quoted 2 lines
Also, this patch to allow relative path for '--with-dmdir' might be helpful.
Good idea.
I've done this, to be checked in, once the testing framework goes in.
Allow relative dir name in: --with-dmdir=../device-mapper
* configure.in: Convert a relative dmdir directory name to the required absolute form, e.g. in ./configure --with-dmdir=../device-mapper Suggestion from Jun'ichi Nomura.
* configure: Regenerate.
--- configure | 10 ++++++++-- configure.in | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
configure +8 -2
@@ -9627,6 +9627,12 @@ else fi +# Convert a relative dir name to absolute. +case $DMDIR in + /*) ;; + *) DMDIR="`pwd`/$DMDIR" ;; +esac + ################################################################################ if test x$READLINE = xyes; then
@@ -11591,7 +11597,7 @@ fi ################################################################################ -ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile test/Makefile" +ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile test/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure
@@ -12195,6 +12201,7 @@ do "lib/locking/Makefile") CONFIG_FILES="$CONFIG_FILES lib/locking/Makefile" ;; "lib/mirror/Makefile") CONFIG_FILES="$CONFIG_FILES lib/mirror/Makefile" ;; "lib/snapshot/Makefile") CONFIG_FILES="$CONFIG_FILES lib/snapshot/Makefile" ;; + "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;; "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
@@ -12206,7 +12213,6 @@ do "test/format1/Makefile") CONFIG_FILES="$CONFIG_FILES test/format1/Makefile" ;; "test/regex/Makefile") CONFIG_FILES="$CONFIG_FILES test/regex/Makefile" ;; "test/filters/Makefile") CONFIG_FILES="$CONFIG_FILES test/filters/Makefile" ;; - "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
configure.in +6 -0
@@ -538,6 +538,12 @@ AC_ARG_WITH(dmdir, [ DMDIR="$withval" CPPFLAGS="$CPPFLAGS -I$DMDIR/include"], [ DMDIR= ]) +# Convert a relative dir name to absolute. +case $DMDIR in + /*) ;; + *) DMDIR="`pwd`/$DMDIR" ;; +esac + ################################################################################ dnl -- Ensure additional headers required if test x$READLINE = xyes; then
Signature · 1 line
1.5.3.1.19.gb5ef6-dirty
Quoted 4 lines · Jim Meyering
Here's a patch to add a testing framework to lvm, along with a few tests to demonstrate what you can do and how.
I've put all of this in a sub-directory named "t/".
At Alasdair's private suggestion, I've adjusted my patch to use the existing test/ directory instead.
If he agrees, I'll move the preexisting (unused) test/* subdirs "down" into a new test/unit/ dir, or into a new, top-level unit-test/ directory. But that will be a separate delta.
For now, here's my adjusted patch, followed by two smaller ones based on patches from Jun'ichi Nomura.
Normally I would have considered committing the changes already, but moving all of the files in a directory *twice* is best avoided.
Alasdair, may I commit these?
-----------------------------------------------
Quoted 1 line
From
0343c0decf222a8709ce31b494426cb2fb1c0023Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 17 Sep 2007 12:18:17 +0200
Subject: [PATCH] Add testing framework, along with first few tests.
* Makefile.in (check): New target.
* configure.in (AC_CONFIG_FILES): Add test/Makefile.
* configure: Regenerate.
* test/.gitignore: New file.
* test/Makefile.in: New file.
* test/lvm-utils.sh: New script.
* test/mkdtemp (die, rand_bytes, mkdtemp): New script.
* test/t0000-basic.sh: New tests.
* test/t3000-lvcreate-pvtags.sh: New, failing test. Derived from a script by Jun'ichi Nomura.
* test/t4000-pv-range-overflow.sh: New test.
* test/test-lib.sh: Testing framework, based on the one from git.
--- Makefile.in | 3 + configure | 3 +- configure.in | 3 +- test/.gitignore | 4 + test/Makefile.in | 75 ++++++++++++ test/lvm-utils.sh | 47 +++++++ test/mkdtemp | 107 +++++++++++++++++ test/t0000-basic.sh | 26 ++++ test/t3000-lvcreate-pvtags.sh | 70 +++++++++++ test/t4000-pv-range-overflow.sh | 52 ++++++++ test/test-lib.sh | 251 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 639 insertions(+), 2 deletions(-) create mode 100644 test/.gitignore create mode 100644 test/Makefile.in create mode 100644 test/lvm-utils.sh create mode 100755 test/mkdtemp create mode 100755 test/t0000-basic.sh create mode 100755 test/t3000-lvcreate-pvtags.sh create mode 100755 test/t4000-pv-range-overflow.sh create mode 100755 test/test-lib.sh
Makefile.in +3 -0
@@ -68,3 +68,6 @@ cscope.out: tools @CSCOPE_CMD@ -b -R all: cscope.out endif + +check: all + $(MAKE) -C test all
configure +2 -1
@@ -11591,7 +11591,7 @@ fi ################################################################################ -ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile" +ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile test/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure
@@ -12206,6 +12206,7 @@ do "test/format1/Makefile") CONFIG_FILES="$CONFIG_FILES test/format1/Makefile" ;; "test/regex/Makefile") CONFIG_FILES="$CONFIG_FILES test/regex/Makefile" ;; "test/filters/Makefile") CONFIG_FILES="$CONFIG_FILES test/filters/Makefile" ;; + "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
configure.in +2 -1
@@ -1,6 +1,6 @@ ## ## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved. -## Copyright (C) 2004 Red Hat, Inc. All rights reserved. +## Copyright (C) 2004, 2007 Red Hat, Inc. All rights reserved. ## ## This file is part of the LVM2. ##
@@ -649,6 +649,7 @@ lib/format_pool/Makefile \ lib/locking/Makefile \ lib/mirror/Makefile \ lib/snapshot/Makefile \ +test/Makefile \ man/Makefile \ po/Makefile \ scripts/Makefile \
test/.gitignore new file +4 -0
@@ -0,0 +1,4 @@ +.bin-dir-stamp +Makefile +bin +init.sh
test/Makefile.in new file +75 -0
75 lines not on this page · raw message
test/lvm-utils.sh new file +47 -0
47 lines not on this page · raw message
test/mkdtemp new file +107 -0
107 lines not on this page · raw message
test/t0000-basic.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/sh + +test_description='Basics: see if tools are built, etc.' + +. ./test-lib.sh + +lvm >/dev/null 2>&1 +if test $? != 3; then + echo >&2 'You do not seem to have built lvm yet.' + exit 1 +fi + +v=$abs_top_srcdir/tools/version.h +test_expect_success \ + "get version string from $v" \ + 'sed -n "/#define LVM_VERSION ./s///p" '"$v"'|sed "s/ .*//" > expected' + +test_expect_success \ + 'get version of a just-built binary, ensuring PATH is set properly' \ + 'lvm pvmove --version|sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" > actual' + +test_expect_success \ + 'ensure they are the same' \ + 'diff -u actual expected' + +test_done
test/t3000-lvcreate-pvtags.sh new file +70 -0
70 lines not on this page · raw message
test/t4000-pv-range-overflow.sh new file +52 -0
52 lines not on this page · raw message
test/test-lib.sh new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
1.5.3.1.19.gb5ef6-dirty
Quoted 6 lines · Jim Meyering
At Alasdair's private suggestion, I've adjusted my patch to use the existing test/ directory instead.
If he agrees, I'll move the preexisting (unused) test/* subdirs "down" into a new test/unit/ dir, or into a new, top-level unit-test/ directory. But that will be a separate delta.
Given the limitations of CVS, I've done this within the repository so as to preserve the file history. Repository users should remove their 'test' directory and check out 'test' and 'old-tests' afresh. (I'm leaving 'old-tests' for reference but I stopped maintaining it some time ago. Any new tests should be done within the new infrastructure.)
Alasdair
Signature · 1 line
agk at redhat.com
test/Makefile.in line 10
Quoted 12 lines · Jim Meyering
+++ b/test/Makefile.in
test/Makefile.in new file +10
-0@@ -0,0 +1,75 @@ +#TEST_OPTS=--verbose --debug +SHELL_PATH ?= $(SHELL) +TAR ?= $(TAR) +RM ?= rm -f + +subdir := $(shell pwd|sed 's,.*/,,') + +srcdir = . +top_srcdir = .. +top_builddir = ..
I'd prefer to see this handled consistently across all our Makefiles. Elsewhere we have srcdir = @srcdir@, for example.
test/Makefile.in line 46
Quoted 2 lines
test/Makefile.in new file +2
-0+dmdir = $(abs_top_srcdir)/../device-mapper +so_name = $(dmdir)/lib/ioctl/libdevmapper.so.1.02
Please avoid the 1.02 hard-coding:-)
(Include a symlink within the dm tree if you want at build time - maybe from lib/libdevmapper.so -> ioctl/libdevmapper.so.*)
test/Makefile.in line 74
Quoted 5 lines
test/Makefile.in new file +5
-0+clean: + rm -rf init.sh lvm-wrapper bin .bin-dir-stamp + +all: $(T) +.PHONY: $(T) clean
Last time I read the docs, they said .PHONY had to appear before 'clean:', not after it.
Review line 18
Quoted 1 line
(quoted diff) +1
-0+++ b/test/mkdtemp
Can these ugly infrastructure scripts be grouped together in a subdir?
test/mkdtemp line 3
Quoted 4 lines
test/mkdtemp new file +3
-0@@ -0,0 +1,107 @@ +#!/bin/sh +# Create a temporary directory, sort of like mktemp -d does. +# Usage: mkdtemp /tmp phoey.XXXXXXXXXX
Where has this come from and has it been audited? I get worried when I see scripts like this that don't include any comments indicating that security was the prime consideration, and doing our own audit would be an unnecessary distraction.
I'd prefer not to have to ship (i.e. take responsibility for) a script like this ourselves if we can avoid that.
Review line 5
Quoted 2 lines
(quoted diff) +2
-0+++ b/test/t0000-basic.sh +lvm >/dev/null 2>&1
(How about using $LVM set to include the full path?)
test/test-lib.sh line 14
Quoted 3 lines
test/test-lib.sh new file +3
-0+# Protect ourselves from common misconfiguration to export +# CDPATH into the environment +unset CDPATH
I'd feel safer if this approach was inverted: clear all environment variables except the few required for correct reproducible operation of the tests.
The test preparation also needs to take steps to insulate itself as far as possible from any 'real' lvm2 installation on the system. This will also aid reproducibility.
E.g. I suggest it uses private directories instead of /etc/lvm and /dev.
Alasdair
Signature · 1 line
agk at redhat.com
Quoted 15 lines · Alasdair G Kergon
test/Makefile.in line 10
Quoted 12 lines · Jim Meyering
+++ b/test/Makefile.in
test/Makefile.in new file +10
-0@@ -0,0 +1,75 @@ +#TEST_OPTS=--verbose --debug +SHELL_PATH ?= $(SHELL) +TAR ?= $(TAR) +RM ?= rm -f + +subdir := $(shell pwd|sed 's,.*/,,') + +srcdir = . +top_srcdir = .. +top_builddir = ..I'd prefer to see this handled consistently across all our Makefiles.
Well, that's what automake does.
Why bother, if no other rules use them?
IMHO, it's bad enough to add them in one place, but adding such duplication across all 24 Makefile.in files is bad for maintenance: it's just asking for some of them to get out of sync.
Quoted 1 line
Elsewhere we have srcdir = @srcdir@, for example.
Good point. Adjusted.
Oh! I see that I can use all of those @...dir@ names. Now, I have the following (this is all normally generated by automake, so people tend to use the $(*dir) form):
srcdir = @srcdir@top_srcdir = @top_srcdir@top_builddir = @top_builddir@abs_srcdir = @abs_srcdir@abs_top_builddir = @abs_top_builddir@abs_top_srcdir = @abs_top_srcdir@
Quoted 6 lines
test/Makefile.in line 46
Quoted 2 lines
test/Makefile.in new file +2
-0+dmdir = $(abs_top_srcdir)/../device-mapper +so_name = $(dmdir)/lib/ioctl/libdevmapper.so.1.02Please avoid the 1.02 hard-coding:-)
(Include a symlink within the dm tree if you want at build time - maybe fromlib/libdevmapper.so-> ioctl/libdevmapper.so.*)
Ok.
Quoted 8 lines
test/Makefile.in line 74
Quoted 5 lines
test/Makefile.in new file +5
-0+clean: + rm -rf init.sh lvm-wrapper bin .bin-dir-stamp + +all: $(T) +.PHONY: $(T) cleanLast time I read the docs, they said .PHONY had to appear before 'clean:', not after it.
Nope. Order doesn't matter, just existence of the dependency. Here's a tiny demo to show that:
$ printf 'x:;\n.PHONY: x'|make -t -f - x
make: Nothing to be done for `x'.Quoted 3 lines
Review line 18
Quoted 1 line
(quoted diff) +1
-0+++ b/test/mkdtempCan these ugly infrastructure scripts be grouped together in a subdir?
You mean test-lib.sh and mkdtemp?
Why bother just for two files?
Quoted 9 lines
test/mkdtemp line 3
Quoted 4 lines
test/mkdtemp new file +3
-0@@ -0,0 +1,107 @@ +#!/bin/sh +# Create a temporary directory, sort of like mktemp -d does. +# Usage: mkdtemp /tmp phoey.XXXXXXXXXXWhere has this come from and has it been audited? I get worried when I see scripts like this that don't include any comments indicating that security was the prime consideration, and doing our own audit would be an unnecessary distraction.
IMHO, it's not risky, here.
The usage here is far less risky than in parted, since here it's used only to create a directory in the build directory, which we can presume is not world writable.
I wrote it when I had to run tests in GNU Parted as root, and couldn't depend on having mktemp installed, and didn't want to subject other root invokers of "make check" to the slightest risk of race-condition exploits. Besides, even when mktemp is installed, there are multiple versions of it, with different options... mkdtemp is also being used in coreutils, now, and will probably soon migrate to gnulib.
Quoted 2 lines
I'd prefer not to have to ship (i.e. take responsibility for) a script like this ourselves if we can avoid that.
No need for you to take responsibility for it. I own it in coreutils. If there's any problem with it, it'll get plenty of exposure there. People are using it through Parted, too.
Quoted 4 lines
Review line 5
Quoted 2 lines
(quoted diff) +2
-0+++ b/test/t0000-basic.sh +lvm >/dev/null 2>&1(How about using $LVM set to include the full path?)
I deliberately rely on the $PATH setting there.
That's part of the test. If you use the full name of the binary, then you have to be careful with quoting (i.e., always use "$LVM"), in case there are shell meta-characters in the user's working directory name. That's risky and ugly, and besides, tends to pollute diagnostics if a program prints raw argv[0].
Quoted 7 lines
test/test-lib.sh line 14
Quoted 3 lines
test/test-lib.sh new file +3
-0+# Protect ourselves from common misconfiguration to export +# CDPATH into the environment +unset CDPATHI'd feel safer if this approach was inverted: clear all environment variables except the few required for correct reproducible operation of the tests.
How about clearing just those few that LVM is known to use?
Quoted 5 lines
The test preparation also needs to take steps to insulate itself as far as possible from any 'real' lvm2 installation on the system. This will also aid reproducibility.
E.g. I suggest it uses private directories instead of/etc/lvmand /dev.
Good idea. Do you mean by creating $PWD/lvm.conf and setting LVM_SYSTEM_DIR to that string? Can you suggest actual contents to use for that file?
How about if I commit the series of patches I have now, and add that in a separate patch, tomorrow?
BTW, with changes derived from your suggestions, I now have four patch sets. I prefer to keep them separate in order to better attribute the authorship/origin. BTW, that's another reason I prefer git: there's an official way to credit the author when s/he is not the same as the committer.
Yes, check in what you've got so far.
Make sure there's a copyright/licence line in each file - see existing Makefiles etc.
# This file is part of the LVM2.
Oops - there's an extra "the" in a handful of files!
For the numbering, 1000 between each item seems overkill - we'll soon want more than 10 top-level categories.
Perhaps 5 digits 00100 00200 etc.
Or 00100 00110 00120 etc.
Or place in subdirectories - an lvcreate subdir for lvcreate tests etc. and have the numbering within lvcreate
ie they report as lvcreate_0010 lvcreate_0020 etc.
Alasdair
Signature · 1 line
agk at redhat.com
Quoted 17 lines · Alasdair G Kergon
Review line 10
Quoted 12 lines · Jim Meyering
+++ b/test/Makefile.in
(quoted diff) +10
-0@@ -0,0 +1,75 @@ +#TEST_OPTS=--verbose --debug +SHELL_PATH ?= $(SHELL) +TAR ?= $(TAR) +RM ?= rm -f + +subdir := $(shell pwd|sed 's,.*/,,') + +srcdir = . +top_srcdir = .. +top_builddir = ..I'd prefer to see this handled consistently across all our Makefiles. Elsewhere we have srcdir = @srcdir@, for example.
Quoted 6 lines
Review line 12
Quoted 2 lines
(quoted diff) +2
-0+dmdir = $(abs_top_srcdir)/../device-mapper +so_name = $(dmdir)/lib/ioctl/libdevmapper.so.1.02Please avoid the 1.02 hard-coding:-)
(Include a symlink within the dm tree if you want at build time - maybe fromlib/libdevmapper.so-> ioctl/libdevmapper.so.*)
I've just checked this in:
Create a symlink, e.g., libdevmapper.so.1.02, in the build dir, alongside the .so file. This helps build dynamically linked LVM.
* lib/Makefile.in (VERSIONED_SHLIB): Define.
* make.tmpl.in (TARGETS): Append $(VERSIONED_SHLIB). ($(VERSIONED_SHLIB)): New rule.
--- WHATS_NEW | 1 + lib/Makefile.in | 1 + make.tmpl.in | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 1.02.23 - ================================== + Create e.g., libdevmapper.so.1.02, in build dir alongside the .so file. Avoid static link failure with some SELinux libraries. Remove obsolete dmfs code from tree and update INSTALL.
lib/Makefile.in +1 -0
@@ -41,6 +41,7 @@ ifeq ("@LIB_SUFFIX@","dylib") else LIB_SHARED = $(interface)/libdevmapper.so endif +VERSIONED_SHLIB = $(interface)/libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION) DEFS += -DDEVICE_UID=@DEVICE_UID@ -DDEVICE_GID=@DEVICE_GID@ \ -DDEVICE_MODE=@DEVICE_MODE@
make.tmpl.in +6 -2
@@ -1,7 +1,7 @@ # @configure_input@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004, 2007 Red Hat, Inc. All rights reserved. # # This file is part of the device-mapper userspace tools. #
@@ -123,7 +123,7 @@ SUBDIRS.distclean := $(SUBDIRS:=.distclean) .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean) .PHONY: $(SUBDIRS.pofile) -TARGETS += $(LIB_SHARED) $(LIB_STATIC) +TARGETS += $(LIB_SHARED) $(LIB_STATIC) $(VERSIONED_SHLIB) all: $(SUBDIRS) $(TARGETS)
@@ -172,6 +172,10 @@ $(LIB_SHARED): $(OBJECTS) $(LDDEPS) $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ endif +$(VERSIONED_SHLIB): %.$(LIB_SUFFIX).$(LIB_VERSION): %.$(LIB_SUFFIX) + rm -f $@ + $(LN_S) $< $@ + $(LIB_STATIC): $(OBJECTS) $(RM) $@ $(AR) rs $@ $(OBJECTS)
Signature · 1 line
1.5.3.1.19.gb5ef6-dirty