test.sh: make the loop device size can be increased
PATCH v4 1/1 test.sh: make the loop device size can be increased
For the purpose of satisfying specific requirements, here adding parameter '@size' to tst_acquire_device() to make the test device can be increased according to real need.
This change gives a limitation for the test device size, you can just set '-1' as default, it's requred that at least 150MB for the function.
And, updating test-writing-guidelines.txt documents.
--- doc/test-writing-guidelines.txt | 12 ++++++---- include/old/old_device.h | 4 ++-- lib/tests/tst_device.c | 2 +- lib/tst_device.c | 29 +++++++++++++++++------ lib/tst_test.c | 2 +- testcases/kernel/syscalls/access/access06.c | 2 +- testcases/kernel/syscalls/acct/acct01.c | 2 +- testcases/kernel/syscalls/chmod/chmod06.c | 2 +- testcases/kernel/syscalls/chown/chown04.c | 2 +- testcases/kernel/syscalls/fchmod/fchmod06.c | 2 +- testcases/kernel/syscalls/fchown/fchown04.c | 2 +- testcases/kernel/syscalls/ftruncate/ftruncate04.c | 2 +- testcases/kernel/syscalls/inotify/inotify03.c | 2 +- testcases/kernel/syscalls/lchown/lchown03.c | 2 +- testcases/kernel/syscalls/link/link08.c | 2 +- testcases/kernel/syscalls/linkat/linkat02.c | 2 +- testcases/kernel/syscalls/mkdir/mkdir03.c | 2 +- testcases/kernel/syscalls/mkdirat/mkdirat02.c | 2 +- testcases/kernel/syscalls/mknod/mknod07.c | 2 +- testcases/kernel/syscalls/mknodat/mknodat02.c | 2 +- testcases/kernel/syscalls/mmap/mmap16.c | 2 +- testcases/kernel/syscalls/mount/mount01.c | 2 +- testcases/kernel/syscalls/mount/mount02.c | 2 +- testcases/kernel/syscalls/mount/mount03.c | 2 +- testcases/kernel/syscalls/mount/mount04.c | 2 +- testcases/kernel/syscalls/mount/mount06.c | 2 +- testcases/kernel/syscalls/open/open12.c | 2 +- testcases/kernel/syscalls/quotactl/quotactl02.c | 2 +- testcases/kernel/syscalls/rename/rename11.c | 2 +- testcases/kernel/syscalls/renameat/renameat01.c | 2 +- testcases/kernel/syscalls/rmdir/rmdir02.c | 2 +- testcases/kernel/syscalls/umount/umount01.c | 2 +- testcases/kernel/syscalls/umount/umount02.c | 2 +- testcases/kernel/syscalls/umount/umount03.c | 2 +- testcases/kernel/syscalls/umount2/umount2_01.c | 2 +- testcases/kernel/syscalls/umount2/umount2_02.c | 2 +- testcases/kernel/syscalls/umount2/umount2_03.c | 2 +- testcases/kernel/syscalls/utime/utime06.c | 2 +- testcases/kernel/syscalls/utimes/utimes01.c | 2 +- testcases/lib/test.sh | 8 +++++-- 40 files changed, 74 insertions(+), 51 deletions(-)
doc/test-writing-guidelines.txt +8 -4
@@ -1318,12 +1318,16 @@ Following functions similar to the LTP C interface are available. * tst_rmdir() * tst_fs_has_free() * tst_mkfs() -* tst_acquire_device() * tst_release_device() -There is one more function called 'tst_check_cmds()' that gets unspecified -number of parameters and asserts that each parameter is a name of an -executable in '$PATH' and exits the test with 'TCONF' on first missing. +One more function called 'tst_check_cmds()' that gets unspecified number +of parameters and asserts that each parameter is a name of an executable +in '$PATH' and exits the test with 'TCONF' on first missing. + +Another one is 'tst_acquire_device()' that looks for LTP_DEV env variable +first (which may be passed by the test driver or by a user) and returns while +it's value greater than 150MB. It also does clear first sectors of $LTP_DEV +and makes the block device size can be increased according to real need. tst_sleep +++++++++
include/old/old_device.h +2 -2
@@ -36,13 +36,13 @@ const char *tst_dev_fs_type(void);* Looks for LTP_DEV env variable first (which may be passed by the test * driver or by a user) and returns just it's value if found. * -* Otherwise creates a temp file and loop device. +* Otherwise creates a temp file and loop device according to real need. * * Note that you have to call tst_tmpdir() beforehand. * * Returns path to the device or NULL if it cannot be created. */ -const char *tst_acquire_device (void (cleanup_fn )(void )); +const char *tst_acquire_device (void (cleanup_fn )(void ),const int size);/* * @dev: device path returned by the tst_acquire_device()
lib/tests/tst_device.c +1 -1
@@ -40,7 +40,7 @@ int main(void) {tst_tmpdir (); - dev =tst_acquire_device (cleanup); + dev =tst_acquire_device (cleanup,-1 );if (!dev)tst_brkm (TCONF , cleanup,"Failed to acquire test device" );
lib/tst_device.c +22 -7
@@ -182,10 +182,15 @@ static void detach_device(const char *dev) "ioctl(%s, LOOP_CLR_FD, 0) no ENXIO for too long", dev); } -const char *tst_acquire_device (void (cleanup_fn )(void )) +const char *tst_acquire_device (void (cleanup_fn )(void ),const int size) { +int fd;char *dev;struct stat st; +unsigned long acq_dev_size; +unsigned long ltp_dev_size; + + acq_dev_size = size >150 ? size :150 ;if (device_acquired)tst_brkm (TBROK , cleanup_fn,"Device allready acquired" );
@@ -204,18 +209,28 @@ const char *tst_acquire_device(void (cleanup_fn)(void))if (!S_ISBLK (st.st_mode)) {tst_brkm (TBROK , cleanup_fn, -"%s is not a block device" , dev); +"%s is not a block device" , dev); } -if (tst_fill_file (dev,0 ,1024 ,512 )) { -tst_brkm (TBROK |TERRNO , cleanup_fn, -"Failed to clear the first 512k of %s" , dev); + fd =SAFE_OPEN (cleanup_fn, dev,O_RDONLY ); +SAFE_IOCTL (cleanup_fn, fd,BLKGETSIZE64 , <p_dev_size); +SAFE_CLOSE (cleanup_fn, fd); + ltp_dev_size = ltp_dev_size/1024 /1024 ; + +if (acq_dev_size <= ltp_dev_size) { +if (tst_fill_file (dev,0 ,1024 ,512 )) { +tst_brkm (TBROK |TERRNO , cleanup_fn, +"Failed to clear the first 512k of %s" , dev); + } + +return dev; } -return dev; +tst_resm (TINFO ,"Skipping $LTP_DEV size %luMB, requested size %luMB" , + ltp_dev_size, acq_dev_size); } -if (tst_fill_file (DEV_FILE ,0 ,1024 ,153600 )) { +if (tst_fill_file (DEV_FILE ,0 ,1024 ,1024 * acq_dev_size)) {tst_brkm (TBROK |TERRNO , cleanup_fn,"Failed to create " DEV_FILE );
lib/tst_test.c +1 -1
@@ -596,7 +596,7 @@ static void do_setup(int argc, char *argv[]) }if (tst_test->needs_device) { - tdev.dev =tst_acquire_device (NULL ); + tdev.dev =tst_acquire_device (NULL ,-1 ); tdev.fs_type =tst_dev_fs_type ();if (!tdev.dev)
testcases/kernel/syscalls/access/access06.c +1 -1
@@ -88,7 +88,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/acct/acct01.c +1 -1
@@ -145,7 +145,7 @@ static void setup(void)/* EROFS SETTING */ fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/chmod/chmod06.c +1 -1
@@ -181,7 +181,7 @@ void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/chown/chown04.c +1 -1
@@ -145,7 +145,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/fchmod/fchmod06.c +1 -1
@@ -122,7 +122,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/fchown/fchown04.c +1 -1
@@ -104,7 +104,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/ftruncate/ftruncate04.c +1 -1
@@ -235,7 +235,7 @@ static void setup(void)tst_resm (TINFO ,"TMPDIR does not support mandatory locks" ); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/inotify/inotify03.c +1 -1
@@ -174,7 +174,7 @@ static void setup(void)tst_tmpdir (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/lchown/lchown03.c +1 -1
@@ -97,7 +97,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/link/link08.c +1 -1
@@ -131,7 +131,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/linkat/linkat02.c +1 -1
@@ -149,7 +149,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/mkdir/mkdir03.c +1 -1
@@ -106,7 +106,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/mkdirat/mkdirat02.c +1 -1
@@ -95,7 +95,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/mknod/mknod07.c +1 -1
@@ -118,7 +118,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/mknodat/mknodat02.c +1 -1
@@ -118,7 +118,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/mmap/mmap16.c +1 -1
@@ -156,7 +156,7 @@ static void setup(void) page_size =getpagesize (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );tst_mkfs (cleanup, device, fs_type, fs_opts,"10240" );
testcases/kernel/syscalls/mount/mount01.c +1 -1
@@ -78,7 +78,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/mount/mount02.c +1 -1
@@ -181,7 +181,7 @@ static void setup(void)SAFE_TOUCH (cleanup, file,FILE_MODE ,NULL ); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/mount/mount03.c +1 -1
@@ -355,7 +355,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/mount/mount04.c +1 -1
@@ -93,7 +93,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/mount/mount06.c +1 -1
@@ -124,7 +124,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/open/open12.c +1 -1
@@ -99,7 +99,7 @@ static void setup(void) } fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device) {tst_resm (TINFO ,"Failed to obtain block device" );
testcases/kernel/syscalls/quotactl/quotactl02.c +1 -1
@@ -202,7 +202,7 @@ static void setup(void)SAFE_MKDIR (cleanup, mntpoint,0755 ); - block_dev =tst_acquire_device (cleanup); + block_dev =tst_acquire_device (cleanup,-1 );if (!block_dev)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/rename/rename11.c +1 -1
@@ -99,7 +99,7 @@ static void setup(void)TEST_PAUSE ; fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/renameat/renameat01.c +1 -1
@@ -147,7 +147,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/rmdir/rmdir02.c +1 -1
@@ -132,7 +132,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" );
testcases/kernel/syscalls/umount/umount01.c +1 -1
@@ -88,7 +88,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/umount/umount02.c +1 -1
@@ -112,7 +112,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/umount/umount03.c +1 -1
@@ -95,7 +95,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/umount2/umount2_01.c +1 -1
@@ -73,7 +73,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/umount2/umount2_02.c +1 -1
@@ -113,7 +113,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/umount2/umount2_03.c +1 -1
@@ -93,7 +93,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/kernel/syscalls/utime/utime06.c +1 -1
@@ -115,7 +115,7 @@ static void setup(void)SAFE_TOUCH (cleanup,TEMP_FILE ,0644 ,NULL ); fs_type =tst_dev_fs_type (); - dev =tst_acquire_device (cleanup); + dev =tst_acquire_device (cleanup,-1 );if (!dev)tst_brkm (TCONF , cleanup,"Failed to acquire test device" );
testcases/kernel/syscalls/utimes/utimes01.c +1 -1
@@ -124,7 +124,7 @@ static void setup(void)tst_tmpdir (); fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + device =tst_acquire_device (cleanup,-1 );if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" );
testcases/lib/test.sh +6 -2
@@ -283,11 +283,15 @@ EXPECT_FAIL() tst_acquire_device() { + local acq_dev_size=${1:-150} + if [ -z ${TST_TMPDIR} ]; then tst_brkm "Use 'tst_tmpdir' before 'tst_acquire_device'" fi - if [ -n "${LTP_DEV}" ]; then + ltp_dev_size=$((`blockdev --getsize64 $LTP_DEV`/1024/1024)) + + if [ -n "${LTP_DEV}" ] && [ ${acq_dev_size} -le ${ltp_dev_size} ]; then tst_resm TINFO "Using test device LTP_DEV='${LTP_DEV}'" if [ ! -b ${LTP_DEV} ]; then tst_brkm TBROK "${LTP_DEV} is not a block device"
@@ -300,7 +304,7 @@ tst_acquire_device() return fi - ROD_SILENT dd if=/dev/zero of=test_dev.img bs=1024 count=153600 + ROD_SILENT dd if=/dev/zero of=test_dev.img bs=1024 count=$((1024*$acq_dev_size)) TST_DEVICE=$(losetup -f) if [ $? -ne 0 ]; then
Signature · 1 line
1.8.3.1
PATCH v4 1/1 test.sh: make the loop device size can be increased
Hi!
Quoted 34 lines
doc/test-writing-guidelines.txt +8
-4@@ -1318,12 +1318,16 @@ Following functions similar to the LTP C interface are available. * tst_rmdir() * tst_fs_has_free() * tst_mkfs() -* tst_acquire_device() * tst_release_device() -There is one more function called 'tst_check_cmds()' that gets unspecified -number of parameters and asserts that each parameter is a name of an -executable in '$PATH' and exits the test with 'TCONF' on first missing. +One more function called 'tst_check_cmds()' that gets unspecified number +of parameters and asserts that each parameter is a name of an executable +in '$PATH' and exits the test with 'TCONF' on first missing. + +Another one is 'tst_acquire_device()' that looks for LTP_DEV env variable +first (which may be passed by the test driver or by a user) and returns while +it's value greater than 150MB. It also does clear first sectors of $LTP_DEV +and makes the block device size can be increased according to real need.
tst_sleep
+++++++++include/old/old_device.h +0
-0@@ -36,13 +36,13 @@ const char *tst_dev_fs_type(void);* Looks for LTP_DEV env variable first (which may be passed by the test * driver or by a user) and returns just it's value if found.
include/old/old_device.h const char *tst_dev_fs_type(void); · line 45
Quoted 10 lines
include/old/old_device.h +2
-2* -* Otherwise creates a temp file and loop device. +* Otherwise creates a temp file and loop device according to real need. * * Note that you have to call tst_tmpdir() beforehand. * * Returns path to the device or NULL if it cannot be created. */ -const char *tst_acquire_device (void (cleanup_fn )(void )); +const char *tst_acquire_device (void (cleanup_fn )(void ),const int size);
This is the old API, that one should not be changed at all.
We should rather add unsigned int device_min_size to the tst_test structure and make use of that in case that it's > 0.
Quoted 37 lines
include/old/old_device.h +0
-0/* * @dev: device path returned by the tst_acquire_device() lib/tests/tst_device.c +1
-1@@ -40,7 +40,7 @@ int main(void) {tst_tmpdir (); - dev =tst_acquire_device (cleanup); + dev =tst_acquire_device (cleanup,-1 );if (!dev)tst_brkm (TCONF , cleanup,"Failed to acquire test device" );lib/tst_device.c +6
-1@@ -182,10 +182,15 @@ static void detach_device(const char *dev) "ioctl(%s, LOOP_CLR_FD, 0) no ENXIO for too long", dev); } -const char *tst_acquire_device (void (cleanup_fn )(void )) +const char *tst_acquire_device (void (cleanup_fn )(void ),const int size) { +int fd;char *dev;struct stat st; +unsigned long acq_dev_size; +unsigned long ltp_dev_size; + + acq_dev_size = size >150 ? size :150 ;if (device_acquired)tst_brkm (TBROK , cleanup_fn,"Device allready acquired" );
lib/tst_device.c const char *tst_acquire_device(void (cleanup_fn)(void)) · line 212
Quoted 5 lines
lib/tst_device.c +1
-1@@ -204,18 +209,28 @@ const char *tst_acquire_device(void (cleanup_fn)(void))if (!S_ISBLK (st.st_mode)) {tst_brkm (TBROK , cleanup_fn, -"%s is not a block device" , dev); +"%s is not a block device" , dev);
^
Useless whitespace change.
Quoted 18 lines
lib/tst_device.c +12
-3} -if (tst_fill_file (dev,0 ,1024 ,512 )) { -tst_brkm (TBROK |TERRNO , cleanup_fn, -"Failed to clear the first 512k of %s" , dev); + fd =SAFE_OPEN (cleanup_fn, dev,O_RDONLY ); +SAFE_IOCTL (cleanup_fn, fd,BLKGETSIZE64 , <p_dev_size); +SAFE_CLOSE (cleanup_fn, fd); + ltp_dev_size = ltp_dev_size/1024 /1024 ; + +if (acq_dev_size <= ltp_dev_size) { +if (tst_fill_file (dev,0 ,1024 ,512 )) { +tst_brkm (TBROK |TERRNO , cleanup_fn, +"Failed to clear the first 512k of %s" , dev); + } + +return dev; }
lib/tst_device.c const char *tst_acquire_device(void (cleanup_fn)(void)) · line 235
Quoted 10 lines
lib/tst_device.c +3
-2-return dev; +tst_resm (TINFO ,"Skipping $LTP_DEV size %luMB, requested size %luMB" , + ltp_dev_size, acq_dev_size); } -if (tst_fill_file (DEV_FILE ,0 ,1024 ,153600 )) { +if (tst_fill_file (DEV_FILE ,0 ,1024 ,1024 * acq_dev_size)) {tst_brkm (TBROK |TERRNO , cleanup_fn,"Failed to create " DEV_FILE );
This function has to be renamed to tst_acquire_device_() and the tst_acquire_device() from the old API header should call this function with zero as the size argument.
lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 600
Quoted 11 lines
lib/tst_test.c +1
-1@@ -596,7 +596,7 @@ static void do_setup(int argc, char *argv[]) }if (tst_test->needs_device) { - tdev.dev =tst_acquire_device (NULL ); + tdev.dev =tst_acquire_device (NULL ,-1 ); tdev.fs_type =tst_dev_fs_type ();
Here we should simply pass tst_test->device_min_size.
Signature · 2 lines
Cyril Hrubis [email protected]