FILE_PRINTF|SCANF: changing TWARN to TINFO
PATCH 1/2 FILE_PRINTF|SCANF: changing TWARN to TINFO
There is no necessity to generate TWARN in unsafe marcos. As we do have SAFE_FILE_PRINTF to break test on TBROK when needed, so we should unify the behavior for LTP macro.
--- lib/safe_file_ops.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
lib/safe_file_ops.c +9 -9
@@ -76,7 +76,7 @@ int file_scanf(const char *file, const int lineno, f =fopen (path,"r" );if (f ==NULL ) { -tst_resm_ (file, lineno,TWARN ,"Failed to open FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to open FILE '%s'" , path);return 1 ; }
@@ -88,20 +88,20 @@ int file_scanf(const char *file, const int lineno,va_end (va);if (ret ==EOF ) { -tst_resm_ (file, lineno,TWARN , +tst_resm_ (file, lineno,TINFO ,"The FILE '%s' ended prematurely" , path); goto err; }if (ret != exp_convs) { -tst_resm_ (file, lineno,TWARN , +tst_resm_ (file, lineno,TINFO ,"Expected %i conversions got %i FILE '%s'" , exp_convs, ret, path); goto err; }if (fclose (f)) { -tst_resm_ (file, lineno,TWARN ,"Failed to close FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to close FILE '%s'" , path);return 1 ; }
@@ -110,7 +110,7 @@ int file_scanf(const char *file, const int lineno, err:if (fclose (f)) { -tst_resm_ (file, lineno,TWARN ,"Failed to close FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to close FILE '%s'" , path); }
@@ -218,7 +218,7 @@ int file_printf(const char *file, const int lineno, f =fopen (path,"w" );if (f ==NULL ) { -tst_resm_ (file, lineno,TWARN ,"Failed to open FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to open FILE '%s'" , path);return 1 ; }
@@ -226,7 +226,7 @@ int file_printf(const char *file, const int lineno,va_start (va, fmt);if (vfprintf (f, fmt, va) <0 ) { -tst_resm_ (file, lineno,TWARN ,"Failed to print to FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to print to FILE '%s'" , path); goto err; }
@@ -234,7 +234,7 @@ int file_printf(const char *file, const int lineno,va_end (va);if (fclose (f)) { -tst_resm_ (file, lineno,TWARN ,"Failed to close FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to close FILE '%s'" , path);return 1 ; }
@@ -243,7 +243,7 @@ int file_printf(const char *file, const int lineno, err:if (fclose (f)) { -tst_resm_ (file, lineno,TWARN ,"Failed to close FILE '%s'" , +tst_resm_ (file, lineno,TINFO ,"Failed to close FILE '%s'" , path); }
Signature · 5 lines
2.40.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/2 cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF
SAFE_MACROS() used in cleanup do not exit the test anymore since:
commit 6440c5d0d15 (newlib: Allow SAFE_MACROS to be called from cleanup)
--- testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c | 4 ++-- testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c | 2 +- testcases/kernel/syscalls/fcntl/fcntl33.c | 2 +- testcases/kernel/syscalls/readahead/readahead02.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c +2 -2
@@ -78,10 +78,10 @@ static void check_set_turbo(char *file, char *off)static void cleanup (void ) { -FILE_PRINTF (cdrv[id].file,"%d" , boost_value); +SAFE_FILE_PRINTF (cleanup, cdrv[id].file,"%d" , boost_value);if (governor[0 ] !='\0' ) -FILE_PRINTF (governor,"%s" , governor_name); +SAFE_FILE_PRINTF (cleanup, governor,"%s" , governor_name); }static void setup (void )
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +1 -1
@@ -84,7 +84,7 @@ static void cleanup(void)rm_shm (shm_id_arr[i]);if (orig_shmmni !=-1 ) -FILE_PRINTF (PATH_SHMMNI ,"%ld" , orig_shmmni); +SAFE_FILE_PRINTF (PATH_SHMMNI ,"%ld" , orig_shmmni); }static struct tst_test test = {
testcases/kernel/syscalls/fcntl/fcntl33.c +1 -1
@@ -209,7 +209,7 @@ static void cleanup(void)SAFE_CLOSE (fd);/* Restore the lease-break-time. */ -FILE_PRINTF (PATH_LS_BRK_T ,"%d" , ls_brk_t); +SAFE_FILE_PRINTF (PATH_LS_BRK_T ,"%d" , ls_brk_t); }static struct tst_test test = {
testcases/kernel/syscalls/readahead/readahead02.c +1 -1
@@ -352,7 +352,7 @@ static void setup_readahead_length(void)/* raise bdi limit as much as kernel allows */ ra_new_limit = testfile_size /1024 ;while (ra_new_limit > pagesize /1024 ) { -FILE_PRINTF (sys_bdi_ra_path,"%d" , ra_new_limit); +SAFE_FILE_PRINTF (sys_bdi_ra_path,"%d" , ra_new_limit);SAFE_FILE_SCANF (sys_bdi_ra_path,"%d" , &ra_limit);if (ra_limit == ra_new_limit) {
Signature · 5 lines
2.40.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF
Hi Li,
Quoted 16 lines
SAFE_MACROS()used in cleanup do not exit the test anymore since:
commit6440c5d0d15(newlib: AllowSAFE_MACROSto be called from cleanup)Signed-off-by Li Wang <[email protected]>--- testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c | 4 ++-- testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c | 2 +- testcases/kernel/syscalls/fcntl/fcntl33.c | 2 +- testcases/kernel/syscalls/readahead/readahead02.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c +0
-0
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c static void check_set_turbo(char *file, char *off) · line 81
Quoted 5 lines
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c +1
-1@@ -78,10 +78,10 @@ static void check_set_turbo(char *file, char *off)static void cleanup (void ) { -FILE_PRINTF (cdrv[id].file,"%d" , boost_value); +SAFE_FILE_PRINTF (cleanup, cdrv[id].file,"%d" , boost_value);
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c uses old API, IMHO not affected by 6440c5d0d15. Therefore we should postpone this till it's converted to the new API.
The rest LGTM.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF
Hi Petr,
Quoted 9 lines · Petr Vorel
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c static void check_set_turbo(char *file, char *off) · line 81
Quoted 8 lines
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c +1
-1@@ -78,10 +78,10 @@ static void check_set_turbo(char *file, char *off)static void cleanup (void ) { -FILE_PRINTF (cdrv[id].file,"%d" , boost_value); +SAFE_FILE_PRINTF (cleanup, cdrv[id].file,"%d" , boost_value);
Quoted 5 lines
testcases/kernel/device-drivers/cpufreq/cpufreq_boost.cuses old API, IMHO not affected by6440c5d0d15. Therefore we should postpone this till it's
converted to the new API.
That's right. I revert the change and pushed it, thanks!!
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp