* [LTP] [PATCH 1/2] FILE_PRINTF|SCANF: changing TWARN to TINFO
@ 2023-05-25 8:09 Li Wang
2023-05-25 8:09 ` [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF Li Wang
0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2023-05-25 8:09 UTC (permalink / raw)
To: ltp
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.
Signed-off-by: Li Wang <liwang@redhat.com>
---
lib/safe_file_ops.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/safe_file_ops.c b/lib/safe_file_ops.c
index f803691d8..63ae2dbbe 100644
--- a/lib/safe_file_ops.c
+++ b/lib/safe_file_ops.c
@@ -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);
}
--
2.40.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF
2023-05-25 8:09 [LTP] [PATCH 1/2] FILE_PRINTF|SCANF: changing TWARN to TINFO Li Wang
@ 2023-05-25 8:09 ` Li Wang
2023-05-26 14:25 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Li Wang @ 2023-05-25 8:09 UTC (permalink / raw)
To: ltp
SAFE_MACROS() used in cleanup do not exit the test anymore since:
commit 6440c5d0d15 (newlib: Allow SAFE_MACROS to be called from cleanup)
Signed-off-by: Li Wang <liwang@redhat.com>
---
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(-)
diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
index 67917b3fe..0a56519a1 100644
--- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
+++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
@@ -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)
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index 7e72a19ca..625761f6e 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -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 = {
diff --git a/testcases/kernel/syscalls/fcntl/fcntl33.c b/testcases/kernel/syscalls/fcntl/fcntl33.c
index 8d0d1a5a1..3c6a38b81 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl33.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl33.c
@@ -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 = {
diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index 7acf4bb18..b6c097b31 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -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) {
--
2.40.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF
2023-05-25 8:09 ` [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF Li Wang
@ 2023-05-26 14:25 ` Petr Vorel
2023-06-01 6:44 ` Li Wang
0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2023-05-26 14:25 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li,
> SAFE_MACROS() used in cleanup do not exit the test anymore since:
> commit 6440c5d0d15 (newlib: Allow SAFE_MACROS to be called from cleanup)
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
> 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(-)
> diff --git a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> index 67917b3fe..0a56519a1 100644
> --- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> +++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> @@ -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.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF
2023-05-26 14:25 ` Petr Vorel
@ 2023-06-01 6:44 ` Li Wang
0 siblings, 0 replies; 4+ messages in thread
From: Li Wang @ 2023-06-01 6:44 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi Petr,
On Fri, May 26, 2023 at 10:25 PM Petr Vorel <pvorel@suse.cz> wrote:
> > --- a/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> > +++ b/testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c
> > @@ -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.
>
That's right. I revert the change and pushed it, thanks!!
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-01 6:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 8:09 [LTP] [PATCH 1/2] FILE_PRINTF|SCANF: changing TWARN to TINFO Li Wang
2023-05-25 8:09 ` [LTP] [PATCH 2/2] cleanup: changing FILE_PRINTF to SAFE_FILE_PRINTF Li Wang
2023-05-26 14:25 ` Petr Vorel
2023-06-01 6:44 ` Li Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).