tests: for mktemp the exes must be the final characters of the name
PATCH 1/1 tests: for mktemp the exes must be the final characters of the name
--- tests/scripts/resize_test | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
tests/scripts/resize_test +1 -1
@@ -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
Signature · 1 line
1.7.0.4
Quoted 13 lines · Benno Schulenberg
Signed-off-by Benno Schulenberg <[email protected]>---
tests/scripts/resize_test | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)tests/scripts/resize_test +0
-0@@ -21,7 +21,7 @@ if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then echo "using $TMPFILE" >> $LOGelse
rm $TMPFILE
tests/scripts/resize_test if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then · line 24
Quoted 2 lines
tests/scripts/resize_test +1
-1- 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
Quoted 6 lines · Andreas Dilger
Quoted 5 lines · Benno Schulenberg
Signed-off-by Benno Schulenberg <[email protected]>---
tests/scripts/resize_test | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 14 lines
tests/scripts/resize_test if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then · line 24
Quoted 10 lines
tests/scripts/resize_test +0
-0@@ -21,7 +21,7 @@ if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then echo "using $TMPFILE" >> $LOGelse
rm $TMPFILEtests/scripts/resize_test +1
-1- 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
Quoted 4 lines · Andreas Dilger
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
PATCH 1/2 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.
--- 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(-)
tests/f_mmp/script +0 -3
@@ -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
tests/f_mmp_garbage/script +0 -3
@@ -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
tests/m_mmp/script +0 -2
@@ -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
tests/t_mmp_1on/script +0 -3
@@ -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
tests/t_mmp_2off/script +0 -3
@@ -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
tests/test_one.in +0 -1
@@ -28,9 +28,10 @@ fi . $TEST_CONFIG -TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX)
PATCH 2/2 tests: clean up the temp file if test_one is interrupted
--- tests/test_one.in | 1 + 1 file changed, 1 insertion(+)
tests/test_one.in +1 -0
@@ -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;
Signature · 1 line
2.0.0
Re: [PATCH 1/2] tests: fix left-over e2fsprogs-tmp files not getting clean up
In reply to Theodore Ts'oQuoted 10 lines · Theodore Ts'o
tests/f_mmp/script +0
-0@@ -1,8 +1,5 @@FSCK_OPT=-yf
tests/f_mmp/script +0
-3-TMPFILE=$test_name.tmp -> $TMPFILE -
Quoted 6 lines
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILE
echo "$test_name: $test_description: skipped for tmpfs (noO_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
Quoted 67 lines
tests/f_mmp_garbage/script +0
-0@@ -1,8 +1,5 @@FSCK_OPT=-yf
tests/f_mmp_garbage/script +0
-3-TMPFILE=$test_name.tmp -> $TMPFILE -stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ] ; then
rm -f $TMPFILEtests/m_mmp/script +0
-0@@ -2,8 +2,6 @@ DESCRIPTION="enable MMP during mke2fs"FS_SIZE=65536
MKE2FS_DEVICE_SECTSIZE=2048
exportMKE2FS_DEVICE_SECTSIZE
-TMPFILE=$test_name.tmp
-> $TMPFILE
stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILEtests/t_mmp_1on/script +0
-0@@ -1,8 +1,5 @@FSCK_OPT=-yf
tests/t_mmp_1on/script +0
-3-TMPFILE=$test_name.tmp -> $TMPFILE -stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ] ; then
rm -f $TMPFILEtests/t_mmp_2off/script +0
-0@@ -1,8 +1,5 @@FSCK_OPT=-yf
tests/t_mmp_2off/script +0
-3-TMPFILE=$test_name.tmp -> $TMPFILE -stat -f $TMPFILE | grep -q "Type: tmpfs"
if [ $? = 0 ]; then
rm -f $TMPFILEtests/test_one.in +0
-0@@ -28,9 +28,10 @@ fi. $TEST_CONFIG
tests/test_one.in +0
-2-TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX) -test_name=
echo $test_dir | sed -e 's;.*/;;'tests/test_one.in +3
-0+ +TMPFILE=$(mktemp -t e2fsprogs-tmp-$test_name.XXXXXX) +if [ -f $test_dir ] ; then
Quoted 9 lines
exit 0;fi
Signature · 6 lines
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
Re: [PATCH 1/2] tests: fix left-over e2fsprogs-tmp files not getting clean up
Quoted 4 lines · Andreas Dilger
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
Quoted 1 line
From
c34e6a131f049f008945967f2272b7c8efc1b282Mon 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.
--- 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(-)
tests/f_mmp/script +3 -2
@@ -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
tests/f_mmp_garbage/script +3 -2
@@ -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
tests/m_mmp/script +5 -2
@@ -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
tests/t_mmp_1on/script +3 -2
@@ -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
tests/t_mmp_2off/script +3 -2
@@ -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
tests/test_one.in +0 -1
@@ -28,9 +28,10 @@ fi . $TEST_CONFIG -TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX)
Re: [PATCH 1/2] tests: fix left-over e2fsprogs-tmp files not getting clean up
This looks better.
It would also be good to fix the "make clean" rule to clean up these temp files.
Cheers, Andreas
Quoted 128 lines · Theodore Ts'o
Quoted 6 lines · Andreas Dilger
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
c34e6a131f049f008945967f2272b7c8efc1b282Mon 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 upIn 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(-)tests/f_mmp/script +0
-0@@ -1,7 +1,8 @@FSCK_OPT=-yf
tests/f_mmp/script +3
-2-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 ]; thentests/f_mmp_garbage/script +0
-0@@ -1,7 +1,8 @@FSCK_OPT=-yf
tests/f_mmp_garbage/script +3
-2-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 ] ; thentests/m_mmp/script +0
-0@@ -2,8 +2,11 @@ DESCRIPTION="enable MMP during mke2fs"FS_SIZE=65536
MKE2FS_DEVICE_SECTSIZE=2048
exportMKE2FS_DEVICE_SECTSIZEtests/m_mmp/script +5
-2-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 $TMPFILEtests/t_mmp_1on/script +0
-0@@ -1,7 +1,8 @@FSCK_OPT=-yf
tests/t_mmp_1on/script +3
-2-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 ] ; thentests/t_mmp_2off/script +0
-0@@ -1,7 +1,8 @@FSCK_OPT=-yf
tests/t_mmp_2off/script +3
-2-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 ]; thentests/test_one.in +0
-0@@ -28,9 +28,10 @@ fi. $TEST_CONFIG
tests/test_one.in +0
-2-TMPFILE=$(mktemp -t e2fsprogs-tmp.XXXXXX) -test_name=
echo $test_dir | sed -e 's;.*/;;'tests/test_one.in +3
-0+ +TMPFILE=$(mktemp -t e2fsprogs-tmp-$test_name.XXXXXX) +if [ -f $test_dir ] ; then
exit 0;
fiSignature · 1 line
2.0.0
Re: [PATCH 1/2] tests: fix left-over e2fsprogs-tmp files not getting clean up
Quoted 3 lines · Andreas Dilger
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