[LTP] [PATCH 0/2] tst_find_backing_dev: fix stat fails /dev/root

Alessandro Carminati
2022-10-26T14:10:16Z

Working on minor fixes, I noticed a strong dependency from the test suite
and sysfs.
Many tests, including the one that triggered the mail in the first place,
simply terminate broken when no sysfs is there.
The motivation that kept the old montinfo at its place, do not stand, and
in my opinion, the montinfocan be dropped altogether.

The following is an example of what happen to a test that supports both
methods:
in this first, the test uses the uevent strategy

% /usr/lib/ltp-testsuite/testcases/bin/ioctl_loop05
tst_test.c:1363: TINFO: Timeout per run is 0h 05m 00s
tst_test.c:1115: TINFO: ext2/ext3/ext4 is supported by the test
tst_device.c:91: TINFO: Found free device 0 '/dev/loop0'
loop0: detected capacity change from 0 to 2048
tst_device.c:570: TINFO: Device name retrived through uevent
ioctl_loop05.c:126: TINFO: backing dev(/dev/sda) logical_block_size is 512
ioctl_loop05.c:62: TINFO: Without setting lo_offset or sizelimit
ioctl_loop05.c:45: TINFO: In dio mode
ioctl_loop05.c:48: TPASS: lo_flags has LO_FLAGS_DIRECT_IO flag
ioctl_loop05.c:52: TPASS: /sys/block/loop0/loop/dio = 1
ioctl_loop05.c:45: TINFO: In non dio mode
ioctl_loop05.c:50: TPASS: lo_flags doesn't have LO_FLAGS_DIRECT_IO flag
ioctl_loop05.c:52: TPASS: /sys/block/loop0/loop/dio = 0
ioctl_loop05.c:69: TINFO: With offset equal to logical_block_size
loop0: detected capacity change from 2048 to 2047
ioctl_loop05.c:74: TPASS: LOOP_SET_DIRECT_IO succeeded
ioctl_loop05.c:45: TINFO: In dio mode
ioctl_loop05.c:48: TPASS: lo_flags has LO_FLAGS_DIRECT_IO flag
ioctl_loop05.c:52: TPASS: /sys/block/loop0/loop/dio = 1
ioctl_loop05.c:81: TINFO: With nonzero offset less than logical_block_size
ioctl_loop05.c:92: TPASS: LOOP_SET_DIRECT_IO failed as expected: EINVAL (22)

Summary:
passed 8
failed 0
broken 0
skipped 0
warnings 0

in this second, the sysfs is unmounted, and the test uses the backup
mountinfo strategy

% ln -s /dev/sda /dev/root
% umount /sys
% /usr/lib/ltp-testsuite/testcases/bin/ioctl_loop05
tst_test.c:1363: TINFO: Timeout per run is 0h 05m 00s
tst_test.c:1115: TINFO: ext2/ext3/ext4 is supported by the test
tst_device.c:91: TINFO: Found free device 0 '/dev/loop0'
loop0: detected capacity change from 0 to 2048
tst_device.c:570: TINFO: Device name retrived through mountinfo
ioctl_loop05.c:126: TINFO: backing dev(/dev/root) logical_block_size is 512
ioctl_loop05.c:62: TINFO: Without setting lo_offset or sizelimit
ioctl_loop05.c:45: TINFO: In dio mode
ioctl_loop05.c:48: TPASS: lo_flags has LO_FLAGS_DIRECT_IO flag
ioctl_loop05.c:52: TBROK: Failed to open FILE '/sys/block/loop0/loop/dio' for reading: ENOENT (2)

Summary:
passed 1
failed 0
broken 1
skipped 0
warnings 0
%

The fact that whithout sysfs the backing device can't be found is not
relevant since the test fails with broken.

As a consequence of the drop of the mountinfo strategy, the API
documentation needs to be updated.

Alessandro Carminati (2):
tst_find_backing_dev: Get dev name from /sys/dev/block/*/uevent
c-test-api: Documentation updated

doc/c-test-api.txt | 7 +++----
lib/tst_device.c | 41 ++++++++++-------------------------------
2 files changed, 13 insertions(+), 35 deletions(-)