improvement work on libswap library
v6 cover improvement work on libswap library
v5-->v6
* return bool for is_swap_supported
* test swap file on the MNTPOINT
* remove some unnecessary comments
CI: https://github.com/wangli5665/ltp/actions/runs/7724190252/job/21055841641
Test Env:
Fedora38(x86_64, Btrfs), RHEL9(s390x, XFS), RHEL8(aarch64, XFS)
Li Wang (7):
libswap: add known swap supported fs check
swapon01: Improving test with memory limits and swap reporting
libswap: add function to prealloc contiguous file
libswap: Introduce file contiguity check
libswap: customize swapfile size
swapon/off: enable all_filesystem in swap test
libswap: Refactor is_swap_supported function to return status
Petr Vorel (1):
swapon01: Test on all filesystems
include/libswap.h | 4 +- libs/libltpswap/libswap.c | 188 ++++++++++++++++-- testcases/kernel/syscalls/swapoff/swapoff01.c | 19 +- testcases/kernel/syscalls/swapoff/swapoff02.c | 20 +- testcases/kernel/syscalls/swapon/swapon01.c | 18 +- testcases/kernel/syscalls/swapon/swapon02.c | 27 ++- testcases/kernel/syscalls/swapon/swapon03.c | 12 +- 7 files changed, 234 insertions(+), 54 deletions(-)
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 1/8 libswap: add known swap supported fs check
This introduce an enhancement to the library's is_swap_supported function to check for filesystem compatibility before attempting to create and enable a swap file. A list of supported filesystems is added (ext2, ext3, ext4, xfs, vfat, exfat, ntfs), and a check against this list is performed to ensure that the swap operations are only attempted on known compatible filesystems.
If the make_swapfile function fails, the error handling is now more descriptive: it distinguishes between failures due to the filesystem not supporting swap files and other types of failures. Similarly, when attempting to enable the swap file with swapon, the patch ensures that clearer error messages are provided in cases where the operation is not supported by the filesystem.
--- libs/libltpswap/libswap.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
libs/libltpswap/libswap.c +23 -2
@@ -12,6 +12,17 @@#include "libswap.h" #include "lapi/syscalls.h" +static const char *const swap_supported_fs[] = { +"ext2" , +"ext3" , +"ext4" , +"xfs" , +"vfat" , +"exfat" , +"ntfs" , +NULL +}; +/* * Make a swap file */
@@ -26,6 +37,7 @@ int make_swapfile(const char *swapfile, int safe)/* make the file swapfile */ const char *argv[2 +1 ]; + argv[0 ] ="mkswap" ; argv[1 ] = swapfile; argv[2 ] =NULL ;
@@ -40,13 +52,22 @@ int make_swapfile(const char *swapfile, int safe)*/ void is_swap_supported (const char *filename) { +int i, sw_support =0 ;int fibmap =tst_fibmap (filename);long fs_type =tst_fs_type (filename);const char *fstype =tst_fs_type_name (fs_type); +for (i =0 ; swap_supported_fs[i]; i++) { +if (strstr (fstype, swap_supported_fs[i])) { + sw_support =1 ; +break ; + } + } +int ret =make_swapfile (filename,1 ); +if (ret !=0 ) { -if (fibmap ==1 ) +if (fibmap ==1 && sw_support ==0 )tst_brk (TCONF ,"mkswap on %s not supported" , fstype);else tst_brk (TFAIL ,"mkswap on %s failed" , fstype);
@@ -56,7 +77,7 @@ void is_swap_supported(const char *filename)if (TST_RET ==-1 ) {if (errno ==EPERM )tst_brk (TCONF ,"Permission denied for swapon()" ); -else if (fibmap ==1 && errno ==EINVAL ) +else if (fibmap ==1 && errno ==EINVAL && sw_support ==0 )tst_brk (TCONF ,"Swapfile on %s not implemented" , fstype);else tst_brk (TFAIL |TTERRNO ,"swapon() on %s failed" , fstype);
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 2/8 swapon01: Test on all filesystems
In reply to Li WangFrom: Petr Vorel <[email protected]>
Test on all filesystems to increase coverage.
Skip filesystems which does not support swap (currently bcachefs, btrfs and tmpfs).
Tested on 5.10, 6.6 and 6.7.
--- testcases/kernel/syscalls/swapon/swapon01.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/swapon/swapon01.c +6 -2
@@ -8,6 +8,7 @@* [Description] * * Checks that swapon() succeds with swapfile. +* Testing on all filesystems which support swap file. */ #include <unistd.h>
@@ -17,7 +18,8 @@#include "lapi/syscalls.h" #include "libswap.h" -#define SWAP_FILE "swapfile01" +#define MNTPOINT "mntpoint" +#define SWAP_FILE MNTPOINT"/swapfile01"static void verify_swapon (void ) {
@@ -36,8 +38,10 @@ static void setup(void) }static struct tst_test test = { + .mntpoint =MNTPOINT , + .mount_device =1 , .needs_root =1 , - .needs_tmpdir =1 , + .all_filesystems =1 , .test_all = verify_swapon, .setup = setup };
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 3/8 swapon01: Improving test with memory limits and swap reporting
In reply to Li WangThis is target to create a more robust and controlled environment to test the swapon system call. By introducing memory limits through cgroups and filling memory with a known pattern, the test can better assess swapon behavior when the system experiences memory pressure.
Additionally, the reporting of "SwapCached" memory before turning off the swap file provides a clearer understanding of the swap system's state in response to the test conditions.
--- testcases/kernel/syscalls/swapon/swapon01.c | 8 ++++++++ 1 file changed, 8 insertions(+)
testcases/kernel/syscalls/swapon/swapon01.c +8 -0
@@ -20,11 +20,15 @@#define MNTPOINT "mntpoint"#define SWAP_FILE MNTPOINT"/swapfile01" +#define TESTMEM (1UL<<30)static void verify_swapon (void ) {TST_EXP_PASS (tst_syscall (__NR_swapon,SWAP_FILE ,0 )); +tst_pollute_memory (TESTMEM ,0x41 ); +tst_res (TINFO ,"SwapCached: %ld Kb" ,SAFE_READ_MEMINFO ("SwapCached:" )); +if (TST_PASS &&tst_syscall (__NR_swapoff,SWAP_FILE ) !=0 ) {tst_brk (TBROK |TERRNO ,"Failed to turn off swapfile, system reboot recommended" );
@@ -35,6 +39,9 @@ static void setup(void) {is_swap_supported (SWAP_FILE );make_swapfile (SWAP_FILE ,0 ); + +SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ()); +SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM ); }static struct tst_test test = {
@@ -42,6 +49,7 @@ static struct tst_test test = { .mount_device = 1, .needs_root = 1, .all_filesystems = 1, + .needs_cgroup_ctrls = (const char *const []){ "memory", NULL }, .test_all = verify_swapon, .setup = setup };
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 4/8 libswap: add function to prealloc contiguous file
In reply to Li WangThe improve makes several key updates to the swap file handling in the libswap.c file:
It incorporates support for the Btrfs filesystem, which is now recognized as a valid filesystem for swap files.
A new function, set_nocow_attr, is added to apply the FS_NOCOW_FL flag to files on Btrfs filesystems.
Introduces a new prealloc_contiguous_file function. This method preallocates a contiguous block of space for the swap file during its creation, rather than filling the file with data as was done previously.
Modifications to the make_swapfile function are made to utilize prealloc_contiguous_file for creating the swap file, ensuring the file is created with contiguous space on the filesystem.
--- libs/libltpswap/libswap.c | 54 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
libs/libltpswap/libswap.c +53 -1
@@ -4,6 +4,7 @@* Author: Stanislav Kholmanskikh <[email protected]> */ +#include <linux/fs.h> #include <errno.h> #define TST_NO_DEFAULT_MAIN
@@ -13,6 +14,7 @@#include "lapi/syscalls.h" static const char *const swap_supported_fs[] = { +"btrfs" ,"ext2" ,"ext3" ,"ext4" ,
@@ -23,6 +25,50 @@ static const char *const swap_supported_fs[] = { NULL }; +static void set_nocow_attr (const char *filename) +{ +int fd; +int attrs; + +tst_res (TINFO ,"FS_NOCOW_FL attribute set on %s" , filename); + + fd =SAFE_OPEN (filename,O_RDONLY ); + +SAFE_IOCTL (fd,FS_IOC_GETFLAGS , &attrs); + + attrs |=FS_NOCOW_FL ; + +SAFE_IOCTL (fd,FS_IOC_SETFLAGS , &attrs); + +SAFE_CLOSE (fd); +} + +static int prealloc_contiguous_file (const char *path,size_t bs,size_t bcount) +{ +int fd; + + fd =open (path,O_CREAT |O_WRONLY |O_TRUNC ,0600 ); +if (fd <0 ) +return -1 ; + +/* Btrfs file need set 'nocow' attribute */ +if (tst_fs_type (path) ==TST_BTRFS_MAGIC ) +set_nocow_attr (path); + +if (tst_prealloc_size_fd (fd, bs, bcount)) { +close (fd); +unlink (path); +return -1 ; + } + +if (close (fd) <0 ) { +unlink (path); +return -1 ; + } + +return 0 ; +} +/* * Make a swap file */
@@ -32,9 +78,15 @@ int make_swapfile(const char *swapfile, int safe)tst_brk (TBROK ,"Insufficient disk space to create swap file" );/* create file */ -if (tst_fill_file (swapfile,0 ,sysconf (_SC_PAGESIZE),10 ) !=0 ) +if (prealloc_contiguous_file (swapfile,sysconf (_SC_PAGESIZE),10 ) !=0 )tst_brk (TBROK ,"Failed to create swapfile" ); +/* Full the file to make old xfs happy*/ +if (tst_fs_type (swapfile) ==TST_XFS_MAGIC ) { +if (tst_fill_file (swapfile,0 ,sysconf (_SC_PAGESIZE),10 ) !=0 ) +tst_brk (TBROK ,"Failed to create swapfile" ); + } +/* make the file swapfile */ const char *argv[2 +1 ];
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 5/8 libswap: Introduce file contiguity check
In reply to Li WangThis patch introduces a new function file_is_contiguous to the libltpswap library to determine if a swap file is stored in a contiguous block of disk space, which is a typical requirement for swap files in Linux. The function performs a series of checks using the fiemap structure to assess the contiguity of the file and logs the result.
It is integrated into the is_swap_supported function to replace the previous tst_fibmap check, providing a more reliable method for verifying that a file suitable for swap is indeed contiguous.
--- libs/libltpswap/libswap.c | 70 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 5 deletions(-)
libs/libltpswap/libswap.c +65 -5
@@ -6,6 +6,8 @@#include <linux/fs.h> #include <errno.h> +#include <linux/fiemap.h> +#include <stdlib.h> #define TST_NO_DEFAULT_MAIN
@@ -69,6 +71,61 @@ static int prealloc_contiguous_file(const char *path, size_t bs, size_t bcount)return 0 ; } +static int file_is_contiguous (const char *filename) +{ +int fd, contiguous =0 ; +struct fiemap *fiemap; + +if (tst_fibmap (filename) ==0 ) { + contiguous =1 ; + goto out; + } + +if (tst_fs_type (filename) ==TST_TMPFS_MAGIC ) + goto out; + + fd =SAFE_OPEN (filename,O_RDONLY ); + + fiemap = (struct fiemap *)SAFE_MALLOC (sizeof (struct fiemap ) +sizeof (struct fiemap_extent )); +memset (fiemap,0 ,sizeof (struct fiemap ) +sizeof (struct fiemap_extent )); + + fiemap->fm_start =0 ; + fiemap->fm_length = ~0 ; + fiemap->fm_flags =0 ; + fiemap->fm_extent_count =1 ; + +SAFE_IOCTL (fd,FS_IOC_FIEMAP , fiemap); + +/* +* fiemap->fm_mapped_extents != 1: +* This checks if the file does not have exactly one extent. If there are more +* or zero extents, the file is not stored in a single contiguous block. +* +* fiemap->fm_extents[0].fe_logical != 0: +* This checks if the first extent does not start at the logical offset 0 of +* the file. If it doesn't, it indicates that the file's first block of data +* is not at the beginning of the file, which implies non-contiguity. +* +* (fiemap->fm_extents[0].fe_flags & FIEMAP_EXTENT_LAST) != FIEMAP_EXTENT_LAST: +* This checks if the first extent does not have the FIEMAP_EXTENT_LAST flag set. +* If the flag isn't set, it means that this extent is not the last one, suggesting +* that there are more extents and the file is not contiguous. +*/ +if (fiemap->fm_mapped_extents !=1 || + fiemap->fm_extents[0 ].fe_logical !=0 || + (fiemap->fm_extents[0 ].fe_flags &FIEMAP_EXTENT_LAST ) !=FIEMAP_EXTENT_LAST ) { + +tst_res (TINFO ,"File '%s' is not contiguous" , filename); + contiguous =0 ; + } + +SAFE_CLOSE (fd); +free (fiemap); + +out: +return contiguous; +} +/* * Make a swap file */
@@ -105,10 +162,15 @@ int make_swapfile(const char *swapfile, int safe)void is_swap_supported (const char *filename) {int i, sw_support =0 ; -int fibmap =tst_fibmap (filename); +int ret =make_swapfile (filename,1 ); +int fi_contiguous =file_is_contiguous (filename);long fs_type =tst_fs_type (filename);const char *fstype =tst_fs_type_name (fs_type); +if (fs_type ==TST_BTRFS_MAGIC && +tst_kvercmp (5 ,0 ,0 ) <0 ) +tst_brk (TCONF ,"Swapfile on Btrfs (kernel < 5.0) not implemented" ); +for (i =0 ; swap_supported_fs[i]; i++) {if (strstr (fstype, swap_supported_fs[i])) { sw_support =1 ;
@@ -116,10 +178,8 @@ void is_swap_supported(const char *filename) } } -int ret =make_swapfile (filename,1 ); -if (ret !=0 ) { -if (fibmap ==1 && sw_support ==0 ) +if (fi_contiguous ==0 && sw_support ==0 )tst_brk (TCONF ,"mkswap on %s not supported" , fstype);else tst_brk (TFAIL ,"mkswap on %s failed" , fstype);
@@ -129,7 +189,7 @@ void is_swap_supported(const char *filename)if (TST_RET ==-1 ) {if (errno ==EPERM )tst_brk (TCONF ,"Permission denied for swapon()" ); -else if (fibmap ==1 && errno ==EINVAL && sw_support ==0 ) +else if (errno ==EINVAL && fi_contiguous ==0 && sw_support ==0 )tst_brk (TCONF ,"Swapfile on %s not implemented" , fstype);else tst_brk (TFAIL |TTERRNO ,"swapon() on %s failed" , fstype);
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 6/8 libswap: customize swapfile size
In reply to Li WangThe key change is the modification of the make_swapfile function to accept an additional parameter blocks, specifying the number of blocks to allocate for the swap file. This change allows for more granular control over the size of swap files created during tests.
--- include/libswap.h | 2 +- libs/libltpswap/libswap.c | 23 +++++++++++++------ testcases/kernel/syscalls/swapoff/swapoff01.c | 5 +--- testcases/kernel/syscalls/swapon/swapon01.c | 2 +- testcases/kernel/syscalls/swapon/swapon02.c | 4 ++-- testcases/kernel/syscalls/swapon/swapon03.c | 4 ++-- 6 files changed, 23 insertions(+), 17 deletions(-)
include/libswap.h +1 -1
@@ -14,7 +14,7 @@/* * Make a swap file */ -int make_swapfile (const char *swapfile,int safe); +int make_swapfile (const char *swapfile,int blocks,int safe);/* * Check swapon/swapoff support status of filesystems or files
libs/libltpswap/libswap.c +16 -7
@@ -4,6 +4,7 @@* Author: Stanislav Kholmanskikh <[email protected]> */ +#include <sys/statvfs.h> #include <linux/fs.h> #include <errno.h> #include <linux/fiemap.h>
@@ -129,19 +130,27 @@ out:/* * Make a swap file */ -int make_swapfile (const char *swapfile,int safe) +int make_swapfile (const char *swapfile,int blocks,int safe) { -if (!tst_fs_has_free ("." ,sysconf (_SC_PAGESIZE) *10 ,TST_BYTES )) +struct statvfs fs_info; +unsigned long blk_size; + +if (statvfs ("." , &fs_info) ==-1 ) +return -1 ; + + blk_size = fs_info.f_bsize; + +if (!tst_fs_has_free ("." , blk_size * blocks,TST_BYTES ))tst_brk (TBROK ,"Insufficient disk space to create swap file" );/* create file */ -if (prealloc_contiguous_file (swapfile,sysconf (_SC_PAGESIZE),10 ) !=0 ) +if (prealloc_contiguous_file (swapfile, blk_size, blocks) !=0 )tst_brk (TBROK ,"Failed to create swapfile" ); -/* Full the file to make old xfs happy*/ +/* Fill the file if needed (specific to old xfs filesystems) */ if (tst_fs_type (swapfile) ==TST_XFS_MAGIC ) { -if (tst_fill_file (swapfile,0 ,sysconf (_SC_PAGESIZE),10 ) !=0 ) -tst_brk (TBROK ,"Failed to create swapfile" ); +if (tst_fill_file (swapfile,0 , blk_size, blocks) !=0 ) +tst_brk (TBROK ,"Failed to fill swapfile" ); }/* make the file swapfile */
@@ -162,7 +171,7 @@ int make_swapfile(const char *swapfile, int safe)void is_swap_supported (const char *filename) {int i, sw_support =0 ; -int ret =make_swapfile (filename,1 ); +int ret =make_swapfile (filename,10 ,1 );int fi_contiguous =file_is_contiguous (filename);long fs_type =tst_fs_type (filename);const char *fstype =tst_fs_type_name (fs_type);
testcases/kernel/syscalls/swapoff/swapoff01.c +1 -4
@@ -44,11 +44,8 @@ static void setup(void)tst_brk (TBROK ,"Insufficient disk space to create swap file" ); -if (tst_fill_file ("swapfile01" ,0x00 ,1024 ,65536 )) +if (make_swapfile ("swapfile01" ,65536 ,1 ))tst_brk (TBROK ,"Failed to create file for swap" ); - -if (system ("mkswap swapfile01 > tmpfile 2>&1" ) !=0 ) -tst_brk (TBROK ,"Failed to make swapfile" ); }static struct tst_test test = {
testcases/kernel/syscalls/swapon/swapon01.c +1 -1
@@ -38,7 +38,7 @@ static void verify_swapon(void)static void setup (void ) {is_swap_supported (SWAP_FILE ); -make_swapfile (SWAP_FILE ,0 ); +make_swapfile (SWAP_FILE ,10 ,0 );SAFE_CG_PRINTF (tst_cg,"cgroup.procs" ,"%d" ,getpid ());SAFE_CG_PRINTF (tst_cg,"memory.max" ,"%lu" ,TESTMEM );
testcases/kernel/syscalls/swapon/swapon02.c +2 -2
@@ -44,8 +44,8 @@ static void setup(void)is_swap_supported ("./tstswap" );SAFE_TOUCH ("notswap" ,0777 ,NULL ); -make_swapfile ("swapfile01" ,0 ); -make_swapfile ("alreadyused" ,0 ); +make_swapfile ("swapfile01" ,10 ,0 ); +make_swapfile ("alreadyused" ,10 ,0 );if (tst_syscall (__NR_swapon,"alreadyused" ,0 ))tst_res (TWARN |TERRNO ,"swapon(alreadyused) failed" );
testcases/kernel/syscalls/swapon/swapon03.c +2 -2
@@ -155,7 +155,7 @@ static int setup_swap(void) }/* Create the swapfile */ -make_swapfile (filename,0 ); +make_swapfile (filename,10 ,0 );/* turn on the swap file */ res =tst_syscall (__NR_swapon, filename,0 );
@@ -178,7 +178,7 @@ static int setup_swap(void)/* Create all needed extra swapfiles for testing */ for (j =0 ; j < testfiles; j++) -make_swapfile (swap_testfiles[j].filename,0 ); +make_swapfile (swap_testfiles[j].filename,10 ,0 );return 0 ; }
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 6/8] libswap: customize swapfile size
Hi Li,
Quoted 4 lines
The key change is the modification of the
make_swapfilefunction to accept an additional parameter blocks, specifying the number of blocks to allocate for the swap file. This change allows for more granular control over the size of swap files created during tests.
...
include/libswap.h line 16
Quoted 8 lines
include/libswap.h +0
-0@@ -14,7 +14,7 @@/* * Make a swap file */
nit: it'd be nice to have a parameter description (feel free to add before merge).
include/libswap.h line 17
Quoted 2 lines
include/libswap.h +1
-1-int make_swapfile (const char *swapfile,int safe); +int make_swapfile (const char *swapfile,int blocks,int safe);
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 7/8 swapon/off: enable all_filesystem in swap test
In reply to Li Wang--- testcases/kernel/syscalls/swapoff/swapoff01.c | 16 ++++++++--- testcases/kernel/syscalls/swapoff/swapoff02.c | 20 ++++++++------ testcases/kernel/syscalls/swapon/swapon02.c | 27 ++++++++++++------- testcases/kernel/syscalls/swapon/swapon03.c | 8 +++++- 4 files changed, 49 insertions(+), 22 deletions(-)
testcases/kernel/syscalls/swapoff/swapoff01.c +12 -4
@@ -17,15 +17,19 @@#include "lapi/syscalls.h" #include "libswap.h" +#define MNTPOINT "mntpoint" +#define TEST_FILE MNTPOINT"/testswap" +#define SWAP_FILE MNTPOINT"/swapfile" +static void verify_swapoff (void ) { -if (tst_syscall (__NR_swapon,"./swapfile01" ,0 ) !=0 ) { +if (tst_syscall (__NR_swapon,SWAP_FILE ,0 ) !=0 ) {tst_res (TFAIL |TERRNO ,"Failed to turn on the swap file" ", skipping test iteration" );return ; } -TEST (tst_syscall (__NR_swapoff,"./swapfile01" )); +TEST (tst_syscall (__NR_swapoff,SWAP_FILE ));if (TST_RET ==-1 ) { tst_res(TFAIL | TTERRNO, "Failed to turn off swapfile,"
@@ -38,17 +42,21 @@ static void verify_swapoff(void)static void setup (void ) { -is_swap_supported ("./tstswap" ); +is_swap_supported (TEST_FILE );if (!tst_fs_has_free ("." ,64 ,TST_MB ))tst_brk (TBROK ,"Insufficient disk space to create swap file" ); -if (make_swapfile ("swapfile01" ,65536 ,1 )) +if (make_swapfile (SWAP_FILE ,65536 ,1 ))tst_brk (TBROK ,"Failed to create file for swap" ); }static struct tst_test test = { + .mntpoint =MNTPOINT , + .mount_device =1 , + .dev_min_size =512 , + .all_filesystems =1 , .needs_root =1 , .needs_tmpdir =1 , .test_all = verify_swapoff,
testcases/kernel/syscalls/swapoff/swapoff02.c +12 -8
@@ -18,6 +18,10 @@#include "lapi/syscalls.h" #include "libswap.h" +#define MNTPOINT "mntpoint" +#define TEST_FILE MNTPOINT"/testswap" +#define SWAP_FILE MNTPOINT"/swapfile" +static int setup01 (void );static void cleanup01 (void );
@@ -32,8 +36,8 @@ static struct tcase {void (*cleanup)(void ); } tcases[] = { {"path does not exist", ENOENT, "ENOENT", "./doesnotexist", NULL, NULL}, - {"Invalid file", EINVAL, "EINVAL", "./swapfile01", NULL, NULL}, - {"Permission denied", EPERM, "EPERM", "./swapfile01", setup01, cleanup01} + {"Invalid file", EINVAL, "EINVAL", SWAP_FILE, NULL, NULL}, + {"Permission denied", EPERM, "EPERM", SWAP_FILE, setup01, cleanup01} }; static void verify_swapoff(unsigned int i)
@@ -82,16 +86,16 @@ static void setup(void) nobody =SAFE_GETPWNAM ("nobody" ); nobody_uid = nobody->pw_uid; -is_swap_supported ("./tstswap" ); - -if (!tst_fs_has_free ("." ,1 ,TST_KB )) -tst_brk (TBROK ,"Insufficient disk space to create swap file" ); +is_swap_supported (TEST_FILE ); -if (tst_fill_file ("./swapfile01" ,0x00 ,1024 ,1 )) -tst_brk (TBROK ,"Failed to create swapfile" ); +if (make_swapfile (SWAP_FILE ,10 ,1 )) +tst_brk (TBROK ,"Failed to create file for swap" ); }static struct tst_test test = { + .mntpoint =MNTPOINT , + .mount_device =1 , + .all_filesystems =1 , .needs_root =1 , .needs_tmpdir =1 , .test = verify_swapoff,
testcases/kernel/syscalls/swapon/swapon02.c +18 -9
@@ -20,6 +20,12 @@#include "lapi/syscalls.h" #include "libswap.h" +#define MNTPOINT "mntpoint" +#define TEST_FILE MNTPOINT"/testswap" +#define NOTSWAP_FILE MNTPOINT"/notswap" +#define SWAP_FILE MNTPOINT"/swapfile" +#define USED_FILE MNTPOINT"/alreadyused" +static uid_t nobody_uid;static int do_swapoff;
@@ -29,9 +35,9 @@ static struct tcase {char *path; } tcases[] = { {"Path does not exist", ENOENT, "./doesnotexist"}, - {"Invalid path", EINVAL, "./notswap"}, - {"Permission denied", EPERM, "./swapfile01"}, - {"File already used", EBUSY, "./alreadyused"}, + {"Invalid path", EINVAL, NOTSWAP_FILE}, + {"Permission denied", EPERM, SWAP_FILE}, + {"File already used", EBUSY, USED_FILE}, }; static void setup(void)
@@ -41,13 +47,13 @@ static void setup(void) nobody =SAFE_GETPWNAM ("nobody" ); nobody_uid = nobody->pw_uid; -is_swap_supported ("./tstswap" ); +is_swap_supported (TEST_FILE ); -SAFE_TOUCH ("notswap" ,0777 ,NULL ); -make_swapfile ("swapfile01" ,10 ,0 ); -make_swapfile ("alreadyused" ,10 ,0 ); +SAFE_TOUCH (NOTSWAP_FILE ,0777 ,NULL ); +make_swapfile (SWAP_FILE ,10 ,0 ); +make_swapfile (USED_FILE ,10 ,0 ); -if (tst_syscall (__NR_swapon,"alreadyused" ,0 )) +if (tst_syscall (__NR_swapon,USED_FILE ,0 ))tst_res (TWARN |TERRNO ,"swapon(alreadyused) failed" );else do_swapoff =1 ;
@@ -55,7 +61,7 @@ static void setup(void)static void cleanup (void ) { -if (do_swapoff &&tst_syscall (__NR_swapoff,"alreadyused" )) +if (do_swapoff &&tst_syscall (__NR_swapoff,USED_FILE ))tst_res (TWARN |TERRNO ,"swapoff(alreadyused) failed" ); }
@@ -78,6 +84,9 @@ static void verify_swapon(unsigned int i) }static struct tst_test test = { + .mntpoint =MNTPOINT , + .mount_device =1 , + .all_filesystems =1 , .needs_root =1 , .needs_tmpdir =1 , .test = verify_swapon,
testcases/kernel/syscalls/swapon/swapon03.c +7 -1
@@ -22,6 +22,9 @@#include "swaponoff.h" #include "libswap.h" +#define MNTPOINT "mntpoint" +#define TEST_FILE MNTPOINT"/testswap" +static int setup_swap (void );static int clean_swap (void );static int check_and_swapoff (const char *filename);
@@ -256,7 +259,7 @@ static void setup(void)if (access ("/proc/swaps" ,F_OK ))tst_brk (TCONF ,"swap not supported by kernel" ); -is_swap_supported ("./tstswap" ); +is_swap_supported (TEST_FILE ); }static void cleanup (void )
@@ -265,6 +268,9 @@ static void cleanup(void) }static struct tst_test test = { + .mntpoint =MNTPOINT , + .mount_device =1 , + .all_filesystems =1 , .needs_root =1 , .needs_tmpdir =1 , .forks_child =1 ,
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
Hi Li,
LGTM
Although get on all VMs due low memory:
tst_test.c:1091: TCONF: No enough memory for tmpfs use
instead of
libswap.c:202: TCONF: Swapfile on tmpfs not implemented
I would also suggest to print who much memory is needed, e.g.:
tst_test.c +2 -1
@@ -1088,7 +1088,8 @@ static const char *limit_tmpfs_mount_size(const char *mnt_data, tmpfs_size = tdev.size;if ((tst_available_mem () /1024 ) < (tmpfs_size *2 )) -tst_brk (TCONF ,"No enough memory for tmpfs use" ); +tst_brk (TCONF ,"No enough memory for tmpfs use (%d MB < %d MB)" , +tst_available_mem () /1024 , tmpfs_size *2 );if (mnt_data)snprintf (buf, buf_size,"%s,size=%uM" , mnt_data, tmpfs_size);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
Hi Li,
First, I suppose you wait for Cyril, otherwise I would be for merging up to previous commit ("libswap: customize swapfile size").
I found a problem in this commit. It looks like this patch breaks testing on TMPDIR on tmpfs on Tumbleweed kernel 6.8.0-rc1-2.gf4ba5db-default:
TMPDIR=/tmp LTP_SINGLE_FS_TYPE=ntfs ./swapoff01
tst_test.c:1701: TINFO: === Testing on ntfs ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ntfs opts='' extra opts=''
The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. The number of heads was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set. Windows will not be able to boot from this device.
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swawDOaMz/mntpoint fstyp=ntfs flags=0
tst_test.c:1131: TINFO: Trying FUSE...
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:144: TBROK: Insufficient disk space to create swap file
df -hT /tmp/
Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 717M 0 717M 0% /tmp
Test works on 6.6.x stable kernel, but that's due bigger tmpfs. Could we at least TCONF (see below)?
I also wonder if we could make whole disk size a bit smaller. The default 300 MB is not enough for XFS, right? But why 512 MB? On6.8.0-rc1-2.gf4ba5db-default 350 MB is enough to test everything:
...
tst_test.c:1701: TINFO: === Testing on ntfs ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ntfs opts='' extra opts=''
The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. The number of heads was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set. Windows will not be able to boot from this device.
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaWEYzzv/mntpoint fstyp=ntfs flags=0
tst_test.c:1131: TINFO: Trying FUSE...
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
swapoff01.c:39: TPASS: Succeeded to turn off swapfile
tst_test.c:1701: TINFO: === Testing on tmpfs ===
tst_test.c:1117: TINFO: Skipping mkfs for TMPFS filesystem
tst_test.c:1098: TINFO: Limiting tmpfs size to 512MB
tst_test.c:1131: TINFO: Mounting ltp-tmpfs to /tmp/LTP_swaWEYzzv/mntpoint fstyp=tmpfs flags=0
tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22)
libswap.c:198: TCONF: Swapfile on tmpfs not implemented
Summary:
passed 8 failed 0 broken 0 skipped 1
warnings 0
Kind regards,
Petr
testcases/kernel/syscalls/swapoff/swapoff01.c +1 -2
@@ -45,8 +45,7 @@ static void setup(void)is_swap_supported (TEST_FILE );if (!tst_fs_has_free ("." ,64 ,TST_MB )) -tst_brk (TBROK , -"Insufficient disk space to create swap file" ); +tst_brk (TCONF ,"Insufficient disk space to create swap file" );if (make_swapfile (SWAP_FILE ,65536 ,1 ))tst_brk (TBROK ,"Failed to create file for swap" );
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
Hi Li,
also I got failures on ppc64le in our CI
* swapoff01 6.7.2 and other versions up to 4.12 based kernels on ppc64le
...
tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swazu2fTl/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:146: TBROK: Failed to create swapfile
Summary:
passed 0 failed 0 broken 1 skipped 0
warnings 0
### TEST swapoff01 COMPLETE >>> 2.
* swapon03 on 6.7.2 on ppc64le
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1117: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting /dev/loop0 to /tmp/LTP_swaT8ZD57/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
Failed to create swapfile: swapfile02
swapon03.c:180: TFAIL: Failed to setup swaps
Summary:
passed 0 failed 1 broken 0 skipped 0
warnings 0
* swapon03 on very old kernels (>= 4.4)
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 ===
tst_test.c:1118: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts='' mke2fs 1.42.11 (09-Jul-2014)
tst_test.c:1132: TINFO: Mounting /dev/loop0 to /tmp/LTP_swahOeodw/mntpoint fstyp=ext2 flags=0 tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:37: TINFO: FS_NOCOW_FL attribute set on swapfile02
Failed to create swapfile: swapfile02
swapon03.c:180: TFAIL: Failed to setup swaps
Summary:
passed 0 failed 1 broken 0 skipped 0
warnings 0
All other tests are working.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
Quoted 4 lines · Petr Vorel
Hi Li,
also I got failures on ppc64le in our CI
Quoted 13 lines
* swapoff01 6.7.2 and other versions up to 4.12 based kernels on ppc64le
...
tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1117: TINFO: Formatting/dev/loop0with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting/dev/loop0to/tmp/LTP_swazu2fTl/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported libswap.c:146: TBROK: Failed to create swapfile
Err, I reproduce it with an RHEL9 ppc64le too.
I guess it does not allow to create a file that size less than page_size.
Once I replace the blk_size with page_size, all tests get passed.
Quoted 56 lines
Summary:
passed 0 failed 0 broken 1 skipped 0warnings 0
### TEST swapoff01 COMPLETE >>> 2.* swapon03 on 6.7.2 on ppc64le
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1117: TINFO: Formatting/dev/loop0with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting/dev/loop0to/tmp/LTP_swaT8ZD57/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
Failed to create swapfile: swapfile02
swapon03.c:180: TFAIL: Failed to setup swapsSummary:
passed 0 failed 1 broken 0 skipped 0warnings 0
* swapon03 on very old kernels (>= 4.4)
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1118: TINFO: Formatting/dev/loop0with ext2 opts='' extra opts=''
mke2fs 1.42.11 (09-Jul-2014)
tst_test.c:1132: TINFO: Mounting/dev/loop0to/tmp/LTP_swahOeodw/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported
libswap.c:37: TINFO:FS_NOCOW_FLattribute set on swapfile02 Failed to create swapfile: swapfile02
swapon03.c:180: TFAIL: Failed to setup swapsSummary:
passed 0 failed 1 broken 0 skipped 0warnings 0
All other tests are working.
Kind regards,
Petr
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
Quoted 21 lines · Petr Vorel
Quoted 5 lines
Hi Li,
also I got failures on ppc64le in our CI
Quoted 12 lines
* swapoff01 6.7.2 and other versions up to 4.12 based kernels on ppc64le
...
tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs tst_test.c:1701: TINFO: === Testing on ext2 === tst_test.c:1117: TINFO: Formatting/dev/loop0with ext2 opts='' extra opts=''
mke2fs 1.47.0 (5-Feb-2023)
tst_test.c:1131: TINFO: Mounting/dev/loop0to/tmp/LTP_swazu2fTl/mntpointfstyp=ext2 flags=0
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported libswap.c:146: TBROK: Failed to create swapfile
Quoted 4 lines
Err, I reproduce it with an RHEL9 ppc64le too.
I guess it does not allow to create a file that size less thanpage_size.Once I replace the
blk_sizewithpage_size, all tests get passed.
+1, great. Feel free to merge the rest with my ack.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
Quoted 7 lines · Petr Vorel
Quoted 4 lines
Err, I reproduce it with an RHEL9 ppc64le too.
I guess it does not allow to create a file that size less thanpage_size.Once I replace the
blk_sizewithpage_size, all tests get passed.+1, great. Feel free to merge the rest with my ack.
Thanks, pushed with your suggestion (and tiny fixes).
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v6 7/8] swapon/off: enable all_filesystem in swap test
In reply to Petr VorelHi Petr,
Quoted 4 lines · Petr Vorel
Hi Li,
First, I suppose you wait for Cyril, otherwise I would be for merging up to previous commit ("libswap: customize swapfile size").
Sure, I merged the patch to 5/8. To better focus on the new changes.
I found a problem in this commit. It looks like this patch breaks testing on
Quoted 21 lines
TMPDIR on tmpfs on Tumbleweed kernel 6.8.0-rc1-2.gf4ba5db-default:
TMPDIR=/tmp LTP_SINGLE_FS_TYPE=ntfs ./swapoff01 tst_test.c:1701: TINFO: === Testing on ntfs === tst_test.c:1117: TINFO: Formatting
/dev/loop0with ntfs opts='' extra opts=''
The partition start sector was not specified for/dev/loop0and it could not be obtained automatically. It has been set to 0.
The number of sectors per track was not specified for/dev/loop0and it could not be obtained automatically. It has been set to 0. The number of heads was not specified for/dev/loop0and it could not be obtained automatically. It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set. Windows will not be able to boot from this device. tst_test.c:1131: TINFO: Mounting/dev/loop0to/tmp/LTP_swawDOaMz/mntpointfstyp=ntfs flags=0
tst_test.c:1131: TINFO: Trying FUSE...
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported libswap.c:144: TBROK: Insufficient disk space to create swap file
Quoted 7 lines
df -hT
/tmp/Filesystem Type Size Used Avail Use% Mounted on tmpfs tmpfs 717M 0 717M 0% /tmpTest works on 6.6.x stable kernel, but that's due bigger tmpfs. Could we at least TCONF (see below)?
+1
Quoted 5 lines
I also wonder if we could make whole disk size a bit smaller. The default 300 MB is not enough for XFS, right? But why 512 MB? On6.8.0-rc1-2.gf4ba5db-default 350 MB is enough to test everything:
Yes, 350MB is enough, I counted that by page_size (should use blk_size) wrongly on aarch64.
Quoted 43 lines
...
tst_test.c:1701: TINFO: === Testing on ntfs === tst_test.c:1117: TINFO: Formatting/dev/loop0with ntfs opts='' extra opts=''
The partition start sector was not specified for/dev/loop0and it could not be obtained automatically. It has been set to 0.
The number of sectors per track was not specified for/dev/loop0and it could not be obtained automatically. It has been set to 0. The number of heads was not specified for/dev/loop0and it could not be obtained automatically. It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set. Windows will not be able to boot from this device. tst_test.c:1131: TINFO: Mounting/dev/loop0to/tmp/LTP_swaWEYzzv/mntpointfstyp=ntfs flags=0
tst_test.c:1131: TINFO: Trying FUSE...
tst_ioctl.c:26: TINFO: FIBMAP ioctl is supported swapoff01.c:39: TPASS: Succeeded to turn off swapfile tst_test.c:1701: TINFO: === Testing on tmpfs === tst_test.c:1117: TINFO: Skipping mkfs for TMPFS filesystem tst_test.c:1098: TINFO: Limiting tmpfs size to 512MB tst_test.c:1131: TINFO: Mounting ltp-tmpfs to/tmp/LTP_swaWEYzzv/mntpointfstyp=tmpfs flags=0
tst_ioctl.c:21: TINFO: FIBMAP ioctl is NOT supported: EINVAL (22) libswap.c:198: TCONF: Swapfile on tmpfs not implementedSummary:
passed 8 failed 0 broken 0 skipped 1warnings 0
Kind regards,
Petrtestcases/kernel/syscalls/swapoff/swapoff01.c +0
-0
testcases/kernel/syscalls/swapoff/swapoff01.c static void setup(void) · line 50
Quoted 8 lines
testcases/kernel/syscalls/swapoff/swapoff01.c +1
-2@@ -45,8 +45,7 @@ static void setup(void)is_swap_supported (TEST_FILE );if (!tst_fs_has_free ("." ,64 ,TST_MB )) -tst_brk (TBROK , -"Insufficient disk space to create swap file" ); +tst_brk (TCONF ,"Insufficient disk space to create swap file");
This is not needed, libswap.c has a free space check already.
Quoted 5 lines
testcases/kernel/syscalls/swapoff/swapoff01.c +0
-0if (make_swapfile (SWAP_FILE ,65536 ,1 ))tst_brk(TBROK, "Failed to create file for swap");
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 8/8 libswap: Refactor is_swap_supported function to return status
In reply to Li WangThis updates the is_swap_supported function in the libltpswap to return an bool status instead of void, allowing the function to communicate success or failure to the caller. It introduces checks and returns false on various failure conditions while logging the failure without aborting the test case.
--- include/libswap.h | 2 +- libs/libltpswap/libswap.c | 36 +++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-)
include/libswap.h +1 -1
@@ -20,5 +20,5 @@ int make_swapfile(const char *swapfile, int blocks, int safe);* Check swapon/swapoff support status of filesystems or files * we are testing on. */ -void is_swap_supported (const char *filename); +bool is_swap_supported (const char *filename);#endif /* __LIBSWAP_H__ */
libs/libltpswap/libswap.c +19 -17
@@ -9,6 +9,7 @@#include <errno.h> #include <linux/fiemap.h> #include <stdlib.h> +#include <stdbool.h> #define TST_NO_DEFAULT_MAIN
@@ -127,9 +128,6 @@ out:return contiguous; } -/* -* Make a swap file -*/ int make_swapfile (const char *swapfile,int blocks,int safe) {struct statvfs fs_info;
@@ -164,11 +162,7 @@ int make_swapfile(const char *swapfile, int blocks, int safe) TST_CMD_PASS_RETVAL | TST_CMD_TCONF_ON_MISSING : 0); } -/* -* Check swapon/swapoff support status of filesystems or files -* we are testing on. -*/ -void is_swap_supported (const char *filename) +bool is_swap_supported (const char *filename) {int i, sw_support =0 ;int ret =make_swapfile (filename,10 ,1 );
@@ -188,23 +182,31 @@ void is_swap_supported(const char *filename) }if (ret !=0 ) { -if (fi_contiguous ==0 && sw_support ==0 ) +if (fi_contiguous ==0 && sw_support ==0 ) {tst_brk (TCONF ,"mkswap on %s not supported" , fstype); -else -tst_brk (TFAIL ,"mkswap on %s failed" , fstype); + }else { +tst_res (TFAIL ,"mkswap on %s failed" , fstype); +return false; + } }TEST (tst_syscall (__NR_swapon, filename,0 ));if (TST_RET ==-1 ) { -if (errno ==EPERM ) +if (errno ==EPERM ) {tst_brk (TCONF ,"Permission denied for swapon()" ); -else if (errno ==EINVAL && fi_contiguous ==0 && sw_support ==0 ) + }else if (errno ==EINVAL && fi_contiguous ==0 && sw_support ==0 ) {tst_brk (TCONF ,"Swapfile on %s not implemented" , fstype); -else -tst_brk (TFAIL |TTERRNO ,"swapon() on %s failed" , fstype); + }else { +tst_res (TFAIL |TTERRNO ,"swapon() on %s failed" , fstype); +return false; + } }TEST (tst_syscall (__NR_swapoff, filename,0 )); -if (TST_RET ==-1 ) -tst_brk (TFAIL |TTERRNO ,"swapoff on %s failed" , fstype); +if (TST_RET ==-1 ) { +tst_res (TFAIL |TTERRNO ,"swapoff on %s failed" , fstype); +return false; + } + +return true; }
Signature · 5 lines
2.40.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp