OSDN Git Service

Don't fail all tests when "." lacks O_DIRECT support.
authorJim Meyering <jim@meyering.net>
Wed, 23 May 2007 20:28:53 +0000 (22:28 +0200)
committerJim Meyering <jim@meyering.net>
Wed, 23 May 2007 20:30:15 +0000 (22:30 +0200)
commit873251291e04dec0f7ab0d5b7d65809981ed95b4
tree799101161149a00354dc9a5214afec650798f0ba
parentc1c80224d31fb1cfde26aa544790b307dccbb9a5
Don't fail all tests when "." lacks O_DIRECT support.

I often build tools on a tmpfs file system (it's faster), and
found that parted tests always failed there.  That's because it tries
to open the "device" (a file) with O_DIRECT, and at least the linux tmpfs
driver always fails with EINVAL in that case.

So here's a patch that makes it work.
Since the test may require writing in a directory like /tmp,
to which others typically have write access, it is particularly
careful about security (see the mkdtemp script below), in case
"make check" is run by e.g., root.

Don't fail all tests when "." lacks O_DIRECT support.
Before, running "make check" on a file system that doesn't support
O_DIRECT (e.g. tmpfs), would always fail.  Now, it works, as long as
the test machinery can find a writable directory in which open with
O_DIRECT *does* work.
* m4/o-direct.m4: New file.  Find a directory/FS with O_DIRECT support.
* configure.ac: Use the new macro.
* libparted/tests/t1000-label.sh: New file.  Wrap the binary, so
it can take advantage of the code that finds O_DIRECT supporting FS.
* tests/mkdtemp: New file.  Required, since when running tests as
root, we may have to create a temporary directory in a directory
like /tmp that's writable by others.
* tests/Makefile.am (EXTRA_DIST): Add mkdtemp.
* tests/test-lib.sh: When creating test subdir, and setting up "trap",
use the directory specified in $PARTED_USABLE_TEST_DIR.
Don't set PATH here.  Now, that's done via the generated, and always-
sourced, init.sh.  As a result, invoke parted via its full file name.
.gitignore
configure.ac
libparted/tests/Makefile.am
libparted/tests/t1000-label.sh [new file with mode: 0755]
m4/o-direct.m4 [new file with mode: 0644]
tests/Makefile.am
tests/mkdtemp [new file with mode: 0755]
tests/test-lib.sh