Signed-off-by: Benno Schulenberg <[email protected]>
---
tests/scripts/resize_test | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/scripts/resize_test b/tests/scripts/resize_test
index c9a7a1c..1e5756c 100755
--- a/tests/scripts/resize_test
+++ b/tests/scripts/resize_test
@@ -21,7 +21,7 @@ if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
echo "using $TMPFILE" >> $LOG
else
rm $TMPFILE
- export TMPFILE=$(TMPDIR=. mktemp -t $test_name.XXXXXX.tmp)
+ export TMPFILE=$(TMPDIR=. mktemp -t $test_name.tmp.XXXXXX)
touch $TMPFILE
echo "using $TMPFILE" >> $LOG
if ! truncate -s $SIZE_2 $TMPFILE >> $LOG 2>&1; then
--
1.7.0.4
On Jun 4, 2014, at 6:28 AM, Benno Schulenberg <[email protected]> wrote:
> Signed-off-by: Benno Schulenberg <[email protected]>
> ---
> tests/scripts/resize_test | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/tests/scripts/resize_test b/tests/scripts/resize_test
> index c9a7a1c..1e5756c 100755
> --- a/tests/scripts/resize_test
> +++ b/tests/scripts/resize_test
> @@ -21,7 +21,7 @@ if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
> echo "using $TMPFILE" >> $LOG
> else
> rm $TMPFILE
> - export TMPFILE=$(TMPDIR=. mktemp -t $test_name.XXXXXX.tmp)
> + export TMPFILE=$(TMPDIR=. mktemp -t $test_name.tmp.XXXXXX)
The goal was that the temporary file ended with ".tmp" so that it would
be removed by "make clean" in case the test fails or is interrupted, so
it would be good to update the "make clean" rules to find these files.
I also notice that there are occasional e2fsprogs-tmp.XXXXXX files left
behind in /tmp after testing, and it would be nice if they contained the
test name so they can be found if there is a problem.
It looks like the same could be done in tests/test_one.in:
TMPFILE=$(mktemp -t e2fsprogs-$test_name.tmp.XXXXXX)
Cheers, Andreas
On Wed, Jun 04, 2014 at 04:31:21PM -0600, Andreas Dilger wrote:
> On Jun 4, 2014, at 6:28 AM, Benno Schulenberg <[email protected]> wrote:
> > Signed-off-by: Benno Schulenberg <[email protected]>
> > ---
> > tests/scripts/resize_test | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/tests/scripts/resize_test b/tests/scripts/resize_test
> > index c9a7a1c..1e5756c 100755
> > --- a/tests/scripts/resize_test
> > +++ b/tests/scripts/resize_test
> > @@ -21,7 +21,7 @@ if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
> > echo "using $TMPFILE" >> $LOG
> > else
> > rm $TMPFILE
> > - export TMPFILE=$(TMPDIR=. mktemp -t $test_name.XXXXXX.tmp)
> > + export TMPFILE=$(TMPDIR=. mktemp -t $test_name.tmp.XXXXXX)
>
> The goal was that the temporary file ended with ".tmp" so that it would
> be removed by "make clean" in case the test fails or is interrupted, so
> it would be good to update the "make clean" rules to find these files.
The problem is that using a template where the XXXXXX is in the middle
of the file name is a GNU coreutils extension. It's not supported by
Mac OSX, *BSD's, and Ubuntu 10.04 and before (and presumably similar
vintage enterprise distros).
With older coreutils, "mktemp /tmp/foo.XXXXXX.bar" will out and out
fail. That's what Benno noticed. On OSX, "mktemp
/tmp/foo.XXXXXX.bar" will return /tmp/foo.XXXXXX.bar, unless that file
already exists, in which case it will bomb out.
If the goal is to make sure we remove temporary files, what we can do
is to use a template of "/tmp/e2fs-$test_name-tmp.XXXXXX", and then
include "rm /tmp/e2fs-*-tmp.???????" in the "make clean" rule.
Cheers,
- Ted
On Wed, Jun 04, 2014 at 04:31:21PM -0600, Andreas Dilger wrote:
>
> I also notice that there are occasional e2fsprogs-tmp.XXXXXX files left
> behind in /tmp after testing, and it would be nice if they contained the
> test name so they can be found if there is a problem.
I looked into this and it was caused by bugs in the mmp tests. They
were setting TMPFILE without using mktemp, and overriding the TMPFILE
already set up by the test infrastructure.
The other reason why we have left-over temp files is caused by someone
interrupting the "make check" run.
- Ted
Signed-off-by: Theodore Ts'o <[email protected]>
---
tests/test_one.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_one.in b/tests/test_one.in
index 01a9260..eb28313 100644
--- a/tests/test_one.in
+++ b/tests/test_one.in
@@ -31,6 +31,7 @@ fi
test_name=`echo $test_dir | sed -e 's;.*/;;'`
TMPFILE=$(mktemp -t e2fsprogs-tmp-$test_name.XXXXXX)
+trap 'rm -f $TMPFILE ; exit' 1 2 15
if [ -f $test_dir ] ; then
exit 0;
--
2.0.0
In addition, incorporate the test name into the e2fsprogs-tmp to make
it easier to debug left-over temp files in the future.
Signed-off-by: Theodore Ts'o <[email protected]>
---
tests/f_mmp/script | 3 ---
tests/f_mmp_garbage/script | 3 ---
tests/m_mmp/script | 2 --
tests/t_mmp_1on/script | 3 ---
tests/t_mmp_2off/script | 3 ---
tests/test_one.in | 5 +++--
6 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/tests/f_mmp/script b/tests/f_mmp/script
index d921672..8d7ab1f 100644
--- a/tests/f_mmp/script
+++ b/tests/f_mmp/script
@@ -1,8 +1,5 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
-
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
diff --git a/tests/f_mmp_garbage/script b/tests/f_mmp_garbage/script
index 02cc12a..9ff4d8e 100644
--- a/tests/f_mmp_garbage/script
+++ b/tests/f_mmp_garbage/script
@@ -1,8 +1,5 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
-
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ] ; then
rm -f $TMPFILE
diff --git a/tests/m_mmp/script b/tests/m_mmp/script
index 02b0b4b..1ed284d 100644
--- a/tests/m_mmp/script
+++ b/tests/m_mmp/script
@@ -2,8 +2,6 @@ DESCRIPTION="enable MMP during mke2fs"
FS_SIZE=65536
MKE2FS_DEVICE_SECTSIZE=2048
export MKE2FS_DEVICE_SECTSIZE
-TMPFILE=$test_name.tmp
-> $TMPFILE
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
diff --git a/tests/t_mmp_1on/script b/tests/t_mmp_1on/script
index 8fc8158..b99aad9 100644
--- a/tests/t_mmp_1on/script
+++ b/tests/t_mmp_1on/script
@@ -1,8 +1,5 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
-
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ] ; then
rm -f $TMPFILE
diff --git a/tests/t_mmp_2off/script b/tests/t_mmp_2off/script
index 1dee14e..6822278 100644
--- a/tests/t_mmp_2off/script
+++ b/tests/t_mmp_2off/script
@@ -1,8 +1,5 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
-
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
diff --git a/tests/test_one.in b/tests/test_one.in
index d053fd7..01a9260 100644
--- a/tests/test_one.in
+++ b/tests/test_one.in
@@ -28,9 +28,10 @@ fi
. $TEST_CONFIG
-TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX)
On Jun 9, 2014, at 8:50 AM, Theodore Ts'o <[email protected]> wrote:
> diff --git a/tests/f_mmp/script b/tests/f_mmp/script
> index d921672..8d7ab1f 100644
> --- a/tests/f_mmp/script
> +++ b/tests/f_mmp/script
> @@ -1,8 +1,5 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> -
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ]; then
> rm -f $TMPFILE
> echo "$test_name: $test_description: skipped for tmpfs (no O_DIRECT)"
> return 0
> fi
The reason I created these temp files on the local filesystem instead of
on /tmp where $TMPFILE normally is normally located is because tmpfs does
not support O_DIRECT. With the current patch all of these tests would be
skipped in the default test configuration.
I think it makes more sense to change the tests to just delete $TMPFILE
before creating the local TMPFILE.
Cheers, Andreas
> diff --git a/tests/f_mmp_garbage/script b/tests/f_mmp_garbage/script
> index 02cc12a..9ff4d8e 100644
> --- a/tests/f_mmp_garbage/script
> +++ b/tests/f_mmp_garbage/script
> @@ -1,8 +1,5 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> -
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ] ; then
> rm -f $TMPFILE
> diff --git a/tests/m_mmp/script b/tests/m_mmp/script
> index 02b0b4b..1ed284d 100644
> --- a/tests/m_mmp/script
> +++ b/tests/m_mmp/script
> @@ -2,8 +2,6 @@ DESCRIPTION="enable MMP during mke2fs"
> FS_SIZE=65536
> MKE2FS_DEVICE_SECTSIZE=2048
> export MKE2FS_DEVICE_SECTSIZE
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ]; then
> rm -f $TMPFILE
> diff --git a/tests/t_mmp_1on/script b/tests/t_mmp_1on/script
> index 8fc8158..b99aad9 100644
> --- a/tests/t_mmp_1on/script
> +++ b/tests/t_mmp_1on/script
> @@ -1,8 +1,5 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> -
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ] ; then
> rm -f $TMPFILE
> diff --git a/tests/t_mmp_2off/script b/tests/t_mmp_2off/script
> index 1dee14e..6822278 100644
> --- a/tests/t_mmp_2off/script
> +++ b/tests/t_mmp_2off/script
> @@ -1,8 +1,5 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> -
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ]; then
> rm -f $TMPFILE
> diff --git a/tests/test_one.in b/tests/test_one.in
> index d053fd7..01a9260 100644
> --- a/tests/test_one.in
> +++ b/tests/test_one.in
> @@ -28,9 +28,10 @@ fi
>
> . $TEST_CONFIG
>
> -TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX)
> -
> test_name=`echo $test_dir | sed -e 's;.*/;;'`
> +
> +TMPFILE=$(mktemp -t e2fsprogs-tmp-$test_name.XXXXXX)
> +
> if [ -f $test_dir ] ; then
> exit 0;
> fi
> --
> 2.0.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers, Andreas
On Mon, Jun 09, 2014 at 02:34:45PM -0600, Andreas Dilger wrote:
> The reason I created these temp files on the local filesystem instead of
> on /tmp where $TMPFILE normally is normally located is because tmpfs does
> not support O_DIRECT. With the current patch all of these tests would be
> skipped in the default test configuration.
Ah, ok. How about this then?
- Ted
>From c34e6a131f049f008945967f2272b7c8efc1b282 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Mon, 9 Jun 2014 10:34:17 -0400
Subject: [PATCH] tests: fix left-over e2fsprogs-tmp files not getting clean up
In addition, incorporate the test name into the e2fsprogs-tmp to make
it easier to debug left-over temp files in the future.
Signed-off-by: Theodore Ts'o <[email protected]>
---
tests/f_mmp/script | 5 +++--
tests/f_mmp_garbage/script | 5 +++--
tests/m_mmp/script | 7 +++++--
tests/t_mmp_1on/script | 5 +++--
tests/t_mmp_2off/script | 5 +++--
tests/test_one.in | 5 +++--
6 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/tests/f_mmp/script b/tests/f_mmp/script
index d921672..664f74f 100644
--- a/tests/f_mmp/script
+++ b/tests/f_mmp/script
@@ -1,7 +1,8 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
diff --git a/tests/f_mmp_garbage/script b/tests/f_mmp_garbage/script
index 02cc12a..6d451a6 100644
--- a/tests/f_mmp_garbage/script
+++ b/tests/f_mmp_garbage/script
@@ -1,7 +1,8 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ] ; then
diff --git a/tests/m_mmp/script b/tests/m_mmp/script
index 02b0b4b..6a9394d 100644
--- a/tests/m_mmp/script
+++ b/tests/m_mmp/script
@@ -2,8 +2,11 @@ DESCRIPTION="enable MMP during mke2fs"
FS_SIZE=65536
MKE2FS_DEVICE_SECTSIZE=2048
export MKE2FS_DEVICE_SECTSIZE
-TMPFILE=$test_name.tmp
-> $TMPFILE
+
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
+
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
diff --git a/tests/t_mmp_1on/script b/tests/t_mmp_1on/script
index 8fc8158..cfed2ca 100644
--- a/tests/t_mmp_1on/script
+++ b/tests/t_mmp_1on/script
@@ -1,7 +1,8 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ] ; then
diff --git a/tests/t_mmp_2off/script b/tests/t_mmp_2off/script
index 1dee14e..6556201 100644
--- a/tests/t_mmp_2off/script
+++ b/tests/t_mmp_2off/script
@@ -1,7 +1,8 @@
FSCK_OPT=-yf
-TMPFILE=$test_name.tmp
-> $TMPFILE
+# use current directory instead of /tmp becase tmpfs doesn't support DIO
+rm -f $TMPFILE
+TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
diff --git a/tests/test_one.in b/tests/test_one.in
index d053fd7..01a9260 100644
--- a/tests/test_one.in
+++ b/tests/test_one.in
@@ -28,9 +28,10 @@ fi
. $TEST_CONFIG
-TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX)
This looks better.
It would also be good to fix the "make clean" rule to clean up
these temp files.
Cheers, Andreas
> On Jun 9, 2014, at 17:45, Theodore Ts'o <[email protected]> wrote:
>
>> On Mon, Jun 09, 2014 at 02:34:45PM -0600, Andreas Dilger wrote:
>> The reason I created these temp files on the local filesystem instead of
>> on /tmp where $TMPFILE normally is normally located is because tmpfs does
>> not support O_DIRECT. With the current patch all of these tests would be
>> skipped in the default test configuration.
>
> Ah, ok. How about this then?
>
> - Ted
>
> From c34e6a131f049f008945967f2272b7c8efc1b282 Mon Sep 17 00:00:00 2001
> From: Theodore Ts'o <[email protected]>
> Date: Mon, 9 Jun 2014 10:34:17 -0400
> Subject: [PATCH] tests: fix left-over e2fsprogs-tmp files not getting clean up
>
> In addition, incorporate the test name into the e2fsprogs-tmp to make
> it easier to debug left-over temp files in the future.
>
> Signed-off-by: Theodore Ts'o <[email protected]>
> ---
> tests/f_mmp/script | 5 +++--
> tests/f_mmp_garbage/script | 5 +++--
> tests/m_mmp/script | 7 +++++--
> tests/t_mmp_1on/script | 5 +++--
> tests/t_mmp_2off/script | 5 +++--
> tests/test_one.in | 5 +++--
> 6 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/tests/f_mmp/script b/tests/f_mmp/script
> index d921672..664f74f 100644
> --- a/tests/f_mmp/script
> +++ b/tests/f_mmp/script
> @@ -1,7 +1,8 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> +# use current directory instead of /tmp becase tmpfs doesn't support DIO
> +rm -f $TMPFILE
> +TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
>
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ]; then
> diff --git a/tests/f_mmp_garbage/script b/tests/f_mmp_garbage/script
> index 02cc12a..6d451a6 100644
> --- a/tests/f_mmp_garbage/script
> +++ b/tests/f_mmp_garbage/script
> @@ -1,7 +1,8 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> +# use current directory instead of /tmp becase tmpfs doesn't support DIO
> +rm -f $TMPFILE
> +TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
>
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ] ; then
> diff --git a/tests/m_mmp/script b/tests/m_mmp/script
> index 02b0b4b..6a9394d 100644
> --- a/tests/m_mmp/script
> +++ b/tests/m_mmp/script
> @@ -2,8 +2,11 @@ DESCRIPTION="enable MMP during mke2fs"
> FS_SIZE=65536
> MKE2FS_DEVICE_SECTSIZE=2048
> export MKE2FS_DEVICE_SECTSIZE
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> +
> +# use current directory instead of /tmp becase tmpfs doesn't support DIO
> +rm -f $TMPFILE
> +TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
> +
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ]; then
> rm -f $TMPFILE
> diff --git a/tests/t_mmp_1on/script b/tests/t_mmp_1on/script
> index 8fc8158..cfed2ca 100644
> --- a/tests/t_mmp_1on/script
> +++ b/tests/t_mmp_1on/script
> @@ -1,7 +1,8 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> +# use current directory instead of /tmp becase tmpfs doesn't support DIO
> +rm -f $TMPFILE
> +TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
>
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ] ; then
> diff --git a/tests/t_mmp_2off/script b/tests/t_mmp_2off/script
> index 1dee14e..6556201 100644
> --- a/tests/t_mmp_2off/script
> +++ b/tests/t_mmp_2off/script
> @@ -1,7 +1,8 @@
> FSCK_OPT=-yf
>
> -TMPFILE=$test_name.tmp
> -> $TMPFILE
> +# use current directory instead of /tmp becase tmpfs doesn't support DIO
> +rm -f $TMPFILE
> +TMPFILE=$(mktemp ./tmp-$test_name.XXXXXX)
>
> stat -f $TMPFILE | grep -q "Type: tmpfs"
> if [ $? = 0 ]; then
> diff --git a/tests/test_one.in b/tests/test_one.in
> index d053fd7..01a9260 100644
> --- a/tests/test_one.in
> +++ b/tests/test_one.in
> @@ -28,9 +28,10 @@ fi
>
> . $TEST_CONFIG
>
> -TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX)
> -
> test_name=`echo $test_dir | sed -e 's;.*/;;'`
> +
> +TMPFILE=$(mktemp -t e2fsprogs-tmp-$test_name.XXXXXX)
> +
> if [ -f $test_dir ] ; then
> exit 0;
> fi
> --
> 2.0.0
>
On Mon, Jun 09, 2014 at 06:47:51PM -0600, Andreas Dilger wrote:
>
> It would also be good to fix the "make clean" rule to clean up
> these temp files.
The second patch should take care of nuking them the temp file when
the user types control-C. I wouldn't be against deleting tmp files in
the build directory, but I wouldn't want to delete files in /tmp as
part of a make clean rule --- consider what might happen if the the
user types "make clean" in one build tree while running "make check"
in another.
- Ted