* [LTP] [PATCH] du01: create the temp file outside of the working directory
@ 2016-07-25 12:52 Stanislav Kholmanskikh
2016-08-16 15:57 ` Cyril Hrubis
2016-08-17 12:32 ` Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Stanislav Kholmanskikh @ 2016-07-25 12:52 UTC (permalink / raw)
To: ltp
I noticed that with older kernels and with XFS the 'du -B 512'
scenario of this test case may fail:
[root@kholmanskikh du01]# uname -r
3.8.13-98.2.2.el6uek.x86_64
[root@kholmanskikh du01]# ls -l
total 10240
drwxr-xr-x 2 root root 24 Jul 25 14:48 testdir
-rw-r--r-- 1 root root 10485760 Jul 25 14:48 testfile
[root@kholmanskikh du01]# du -B 512
0 ./testdir
20480 .
[root@kholmanskikh du01]# du -B 512 > temp; cat temp
0 ./testdir
20608 .
[root@kholmanskikh du01]#
This happens because we create 'temp' file in the working directory,
i.e. 'temp' may already contain some data at the moment 'du' tries
to 'fstat' it.
So let's keep the working directory clean and create any extra
files outside of it.
Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
testcases/commands/du/du01.sh | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/testcases/commands/du/du01.sh b/testcases/commands/du/du01.sh
index 799099e..df0fea9 100755
--- a/testcases/commands/du/du01.sh
+++ b/testcases/commands/du/du01.sh
@@ -31,6 +31,9 @@ setup()
tst_tmpdir
TST_CLEANUP=cleanup
+ ROD_SILENT mkdir basedir
+ ROD_SILENT cd basedir
+
ROD_SILENT dd if=/dev/zero of=testfile bs=1M count=10
ROD_SILENT mkdir -p testdir
@@ -53,11 +56,11 @@ du_test()
{
local test_return
- $1 > temp 2>&1
+ $1 > ../temp 2>&1
test_return=$?
if [ ${test_return} -ne 0 ]; then
- grep -q -E "unrecognized option|invalid option" temp
+ grep -q -E "unrecognized option|invalid option" ../temp
if [ $? -eq 0 ]; then
tst_resm TCONF "'$1' not supported"
else
@@ -66,13 +69,13 @@ du_test()
return
fi
- grep -q $2 temp
+ grep -q $2 ../temp
if [ $? -eq 0 ]; then
tst_resm TPASS "'$1' passed"
else
tst_resm TFAIL "'$1' failed"
tst_resm TINFO "Looking for '$2' in:"
- cat temp
+ cat ../temp
fi
}
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] du01: create the temp file outside of the working directory
2016-07-25 12:52 [LTP] [PATCH] du01: create the temp file outside of the working directory Stanislav Kholmanskikh
@ 2016-08-16 15:57 ` Cyril Hrubis
2016-08-17 12:32 ` Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2016-08-16 15:57 UTC (permalink / raw)
To: ltp
Hi!
> I noticed that with older kernels and with XFS the 'du -B 512'
> scenario of this test case may fail:
>
> [root@kholmanskikh du01]# uname -r
> 3.8.13-98.2.2.el6uek.x86_64
> [root@kholmanskikh du01]# ls -l
> total 10240
> drwxr-xr-x 2 root root 24 Jul 25 14:48 testdir
> -rw-r--r-- 1 root root 10485760 Jul 25 14:48 testfile
> [root@kholmanskikh du01]# du -B 512
> 0 ./testdir
> 20480 .
> [root@kholmanskikh du01]# du -B 512 > temp; cat temp
> 0 ./testdir
> 20608 .
> [root@kholmanskikh du01]#
>
> This happens because we create 'temp' file in the working directory,
> i.e. 'temp' may already contain some data at the moment 'du' tries
> to 'fstat' it.
>
> So let's keep the working directory clean and create any extra
> files outside of it.
Looks good to me, acked.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] du01: create the temp file outside of the working directory
2016-07-25 12:52 [LTP] [PATCH] du01: create the temp file outside of the working directory Stanislav Kholmanskikh
2016-08-16 15:57 ` Cyril Hrubis
@ 2016-08-17 12:32 ` Cyril Hrubis
2016-08-17 13:07 ` Stanislav Kholmanskikh
1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2016-08-17 12:32 UTC (permalink / raw)
To: ltp
Hi!
FYI: I've reproduced this on ppc64le with Btrfs as well.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] du01: create the temp file outside of the working directory
2016-08-17 12:32 ` Cyril Hrubis
@ 2016-08-17 13:07 ` Stanislav Kholmanskikh
0 siblings, 0 replies; 4+ messages in thread
From: Stanislav Kholmanskikh @ 2016-08-17 13:07 UTC (permalink / raw)
To: ltp
On 08/17/2016 03:32 PM, Cyril Hrubis wrote:
> Hi!
> FYI: I've reproduced this on ppc64le with Btrfs as well.
>
Thank you. Pushed the patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-17 13:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-25 12:52 [LTP] [PATCH] du01: create the temp file outside of the working directory Stanislav Kholmanskikh
2016-08-16 15:57 ` Cyril Hrubis
2016-08-17 12:32 ` Cyril Hrubis
2016-08-17 13:07 ` Stanislav Kholmanskikh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox