diff mbox

[v2,4/6] overlay/017: create helpers to record and check inode numbers

Message ID 1493367888-26550-5-git-send-email-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Amir Goldstein April 28, 2017, 8:24 a.m. UTC
Use helpers to records and check inode numbers so we can repeat
the same test after rename and mount cycle.

Suggested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/overlay/017 | 57 ++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 15 deletions(-)

Comments

Eryu Guan April 28, 2017, 9:24 a.m. UTC | #1
On Fri, Apr 28, 2017 at 11:24:46AM +0300, Amir Goldstein wrote:
> Use helpers to records and check inode numbers so we can repeat
> the same test after rename and mount cycle.
> 
> Suggested-by: Eryu Guan <eguan@redhat.com>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  tests/overlay/017 | 57 ++++++++++++++++++++++++++++++++++++++++---------------
>  1 file changed, 42 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/overlay/017 b/tests/overlay/017
> index 779907d..3ff429f 100755
> --- a/tests/overlay/017
> +++ b/tests/overlay/017
> @@ -72,32 +72,59 @@ mknod $lowerdir/blkdev b 1 1
>  mknod $lowerdir/fifo p
>  $here/src/af_unix $lowerdir/socket
>  
> +FILES="dir file symlink chrdev blkdev fifo socket"
> +
> +# Record inode numbers in format <ino> <basename>
> +function record_inode_numbers()
> +{
> +	dir=$1
> +	outfile=$2
> +
> +	for f in $FILES; do
> +		ls -id $dir/$f
> +	done | \
> +	while read ino file; do
> +		echo $ino `basename $file` >> $outfile
> +	done
> +}
> +
> +# Check inode numbers match recorder inode numbers
> +function check_inode_numbers()
> +{
> +	dir=$1
> +	before=$2
> +	after=$2
             ^^^ $3
Otherwise looks good to me. I can fix this typo at commit time.

But I've already kicked off release testing for this week's update,
I'll queue these patches for next update.

Thanks,
Eryu
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Amir Goldstein April 28, 2017, 10:04 a.m. UTC | #2
On Fri, Apr 28, 2017 at 12:24 PM, Eryu Guan <eguan@redhat.com> wrote:
> On Fri, Apr 28, 2017 at 11:24:46AM +0300, Amir Goldstein wrote:
>> Use helpers to records and check inode numbers so we can repeat
>> the same test after rename and mount cycle.
>>
>> Suggested-by: Eryu Guan <eguan@redhat.com>
>> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>> ---
>>  tests/overlay/017 | 57 ++++++++++++++++++++++++++++++++++++++++---------------
>>  1 file changed, 42 insertions(+), 15 deletions(-)
>>
>> diff --git a/tests/overlay/017 b/tests/overlay/017
>> index 779907d..3ff429f 100755
>> --- a/tests/overlay/017
>> +++ b/tests/overlay/017
>> @@ -72,32 +72,59 @@ mknod $lowerdir/blkdev b 1 1
>>  mknod $lowerdir/fifo p
>>  $here/src/af_unix $lowerdir/socket
>>
>> +FILES="dir file symlink chrdev blkdev fifo socket"
>> +
>> +# Record inode numbers in format <ino> <basename>
>> +function record_inode_numbers()
>> +{
>> +     dir=$1
>> +     outfile=$2
>> +
>> +     for f in $FILES; do
>> +             ls -id $dir/$f
>> +     done | \
>> +     while read ino file; do
>> +             echo $ino `basename $file` >> $outfile
>> +     done
>> +}
>> +
>> +# Check inode numbers match recorder inode numbers
>> +function check_inode_numbers()
>> +{
>> +     dir=$1
>> +     before=$2
>> +     after=$2
>              ^^^ $3
> Otherwise looks good to me. I can fix this typo at commit time.

Oh boy! That's a lousy test :-)
Now I wonder why the test failed when I ran it on kernel v4.10
(when feeding after to find -inum)... something for me to check.

>
> But I've already kicked off release testing for this week's update,
> I'll queue these patches for next update.
>

Sure. No rush on my end.

Thanks,
Amir.
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Amir Goldstein April 28, 2017, 10:53 a.m. UTC | #3
On Fri, Apr 28, 2017 at 1:04 PM, Amir Goldstein <amir73il@gmail.com> wrote:
> On Fri, Apr 28, 2017 at 12:24 PM, Eryu Guan <eguan@redhat.com> wrote:
>> On Fri, Apr 28, 2017 at 11:24:46AM +0300, Amir Goldstein wrote:
>>> Use helpers to records and check inode numbers so we can repeat
>>> the same test after rename and mount cycle.
>>>
>>> Suggested-by: Eryu Guan <eguan@redhat.com>
>>> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>>> ---
>>>  tests/overlay/017 | 57 ++++++++++++++++++++++++++++++++++++++++---------------
>>>  1 file changed, 42 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/tests/overlay/017 b/tests/overlay/017
>>> index 779907d..3ff429f 100755
>>> --- a/tests/overlay/017
>>> +++ b/tests/overlay/017
>>> @@ -72,32 +72,59 @@ mknod $lowerdir/blkdev b 1 1
>>>  mknod $lowerdir/fifo p
>>>  $here/src/af_unix $lowerdir/socket
>>>
>>> +FILES="dir file symlink chrdev blkdev fifo socket"
>>> +
>>> +# Record inode numbers in format <ino> <basename>
>>> +function record_inode_numbers()
>>> +{
>>> +     dir=$1
>>> +     outfile=$2
>>> +
>>> +     for f in $FILES; do
>>> +             ls -id $dir/$f
>>> +     done | \
>>> +     while read ino file; do
>>> +             echo $ino `basename $file` >> $outfile
>>> +     done
>>> +}
>>> +
>>> +# Check inode numbers match recorder inode numbers
>>> +function check_inode_numbers()
>>> +{
>>> +     dir=$1
>>> +     before=$2
>>> +     after=$2
>>              ^^^ $3
>> Otherwise looks good to me. I can fix this typo at commit time.
>
> Oh boy! That's a lousy test :-)
> Now I wonder why the test failed when I ran it on kernel v4.10
> (when feeding after to find -inum)... something for me to check.
>

Ah. got it. 'after' inode number where appended to $tmp.before,
so find was also looking by the before inodes.
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/overlay/017 b/tests/overlay/017
index 779907d..3ff429f 100755
--- a/tests/overlay/017
+++ b/tests/overlay/017
@@ -72,32 +72,59 @@  mknod $lowerdir/blkdev b 1 1
 mknod $lowerdir/fifo p
 $here/src/af_unix $lowerdir/socket
 
+FILES="dir file symlink chrdev blkdev fifo socket"
+
+# Record inode numbers in format <ino> <basename>
+function record_inode_numbers()
+{
+	dir=$1
+	outfile=$2
+
+	for f in $FILES; do
+		ls -id $dir/$f
+	done | \
+	while read ino file; do
+		echo $ino `basename $file` >> $outfile
+	done
+}
+
+# Check inode numbers match recorder inode numbers
+function check_inode_numbers()
+{
+	dir=$1
+	before=$2
+	after=$2
+
+	record_inode_numbers $dir $after
+
+	# Test constant stat(2) st_ino -
+	#   Compare before..after - expect silence
+	# We use diff -u so out.bad will tell us which stage failed
+	diff -u $before $after
+
+	# Test constant readdir(3)/getdents(2) d_ino -
+	#   Expect to find file by inode number
+	cat $before | while read ino f; do
+		find $dir/ -maxdepth 1 -inum $ino | grep -q $f || \
+			echo "$f not found by ino $ino (from $before)"
+	done
+}
 
 _scratch_mount
 
 
 rm -f $tmp.*
 
-# Test stable stat(2) st_ino
+# Record inode numbers before copy up
+record_inode_numbers $SCRATCH_MNT $tmp.before
 
-# Record inode numbers before and after copy up
-for f in dir file symlink chrdev blkdev fifo socket; do
-	ls -id $SCRATCH_MNT/$f >> $tmp.before
+for f in $FILES; do
 	# chown -h modifies all those file types
 	chown -h 100 $SCRATCH_MNT/$f
-	ls -id $SCRATCH_MNT/$f >> $tmp.after
-done
-
-# Test stable readdir(3)/getdents(2) d_ino
-
-# find by inode number - expect to find file by inode number
-cat $tmp.before | while read ino f; do
-	find $SCRATCH_MNT/ -maxdepth 1 -inum $ino | grep -q $f || \
-		echo "$f not found by ino $ino"
 done
 
-# Compare before..after - expect silence
-diff $tmp.before $tmp.after
+# Compare inode numbers before/after copy up
+check_inode_numbers $SCRATCH_MNT $tmp.before $tmp.after_copyup
 
 echo "Silence is golden"
 status=0