[LTP] [RFC PATCH 2/2] testcase: use new TST_RES macros
Li Wang
liwang@redhat.com
Wed Jun 26 12:54:31 CEST 2024
This is a damo for use TST_RES_ MACRO (randomly replace some), we might
not want to replace tst_res() all by macros, to keep both methods exist
probably more flexiable.
Signed-off-by: Li Wang <liwang@redhat.com>
---
lib/tst_kconfig.c | 2 +-
lib/tst_supported_fs_types.c | 2 +-
testcases/kernel/kvm/kvm_pagefault01.c | 2 +-
testcases/kernel/mem/hugetlb/lib/hugetlb.c | 2 +-
testcases/kernel/syscalls/ipc/semctl/semctl08.c | 2 +-
testcases/kernel/syscalls/madvise/madvise01.c | 6 +++---
testcases/kernel/syscalls/madvise/madvise02.c | 10 +++++-----
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index e16ca1400..3678669c7 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -606,7 +606,7 @@ void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t params_len)
break;
default:
if (b_pos + 1 >= sizeof(buf)) {
- tst_res(TWARN, "Buffer overflowed while parsing /proc/cmdline");
+ TST_RES_TWARN("Buffer overflowed while parsing /proc/cmdline");
while (line[l_pos] != '\0' && line[l_pos] != ' ' && line[l_pos] != '\n')
l_pos++;
diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
index bbbb8df19..fbee7f23b 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -158,7 +158,7 @@ const char **tst_get_supported_fs_types(const char *const *skiplist)
only_fs = getenv("LTP_SINGLE_FS_TYPE");
if (only_fs) {
- tst_res(TINFO, "WARNING: testing only %s", only_fs);
+ TST_RES_TWARN("testing only %s", only_fs);
if (tst_fs_is_supported(only_fs))
fs_types[0] = only_fs;
return fs_types;
diff --git a/testcases/kernel/kvm/kvm_pagefault01.c b/testcases/kernel/kvm/kvm_pagefault01.c
index 16b3137c0..e6ed1bacb 100644
--- a/testcases/kernel/kvm/kvm_pagefault01.c
+++ b/testcases/kernel/kvm/kvm_pagefault01.c
@@ -200,7 +200,7 @@ static void disable_tdp(void)
reload_module("kvm_intel", "ept=0");
if (read_bool_sys_param(TDP_MMU_SYSFILE) > 0)
- tst_res(TINFO, "WARNING: tdp_mmu is enabled, beware of false negatives");
+ TST_RES_TWARN("tdp_mmu is enabled, beware of false negatives");
}
static void setup(void)
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
index 43a677ce9..14fc5a905 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c
@@ -106,7 +106,7 @@ void rm_shm(int shm_id)
* check for # of attaches ?
*/
if (shmctl(shm_id, IPC_RMID, NULL) == -1) {
- tst_res(TINFO, "WARNING: shared memory deletion failed.");
+ TST_RES_TWARN("shared memory deletion failed.");
tst_res(TINFO, "This could lead to IPC resource problems.");
tst_res(TINFO, "id = %d", shm_id);
}
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl08.c b/testcases/kernel/syscalls/ipc/semctl/semctl08.c
index 1878bd49d..64160af05 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl08.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl08.c
@@ -40,7 +40,7 @@ static void run(void)
tst_res(TPASS, "time_high fields cleared by the kernel");
if (semctl(semid, 0, IPC_RMID, arg) == -1)
- tst_res(TINFO, "WARNING: semaphore deletion failed.");
+ TST_RES_TWARN("semaphore deletion failed.");
}
static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/madvise/madvise01.c b/testcases/kernel/syscalls/madvise/madvise01.c
index 884c59b0b..ba2c79536 100644
--- a/testcases/kernel/syscalls/madvise/madvise01.c
+++ b/testcases/kernel/syscalls/madvise/madvise01.c
@@ -102,15 +102,15 @@ static void verify_madvise(unsigned int i)
if (TST_RET == -1) {
if (TST_ERR == EINVAL) {
- tst_res(TCONF, "%s is not supported", tc->name);
+ TST_BRK_TCONF("%s is not supported", tc->name);
} else {
- tst_res(TFAIL, "madvise test for %s failed with "
+ TST_RES_TFAIL("madvise test for %s failed with "
"return = %ld, errno = %d : %s",
tc->name, TST_RET, TST_ERR,
tst_strerrno(TFAIL | TTERRNO));
}
} else {
- tst_res(TPASS, "madvise test for %s PASSED", tc->name);
+ TST_RES_TPASS("madvise test for %s PASSED", tc->name);
}
}
diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
index cc3faf5cf..bfe6e55c4 100644
--- a/testcases/kernel/syscalls/madvise/madvise02.c
+++ b/testcases/kernel/syscalls/madvise/madvise02.c
@@ -92,7 +92,7 @@ static void tcases_filter(void)
switch (tc->advice) {
case MADV_DONTNEED:
if (mlock(file1, st.st_size) < 0)
- tst_brk(TBROK | TERRNO, "mlock failed");
+ TST_BRK_TBROK_ER(TERRNO, "mlock failed");
break;
case MADV_MERGEABLE:
case MADV_UNMERGEABLE:
@@ -160,22 +160,22 @@ static void advice_test(unsigned int i)
struct tcase *tc = &tcases[i];
if (tc->skip == 1) {
- tst_res(TCONF, "%s is not supported", tc->name);
+ TST_RES_TCONF("%s is not supported", tc->name);
return;
}
TEST(madvise(*(tc->addr), st.st_size, tc->advice));
if (TST_RET == -1) {
if (TST_ERR == tc->exp_errno) {
- tst_res(TPASS | TTERRNO, "%s failed as expected", tc->name);
+ TST_RES_TPASS_ER(TTERRNO, "%s failed as expected", tc->name);
} else {
- tst_res(TFAIL | TTERRNO,
+ TST_RES_TFAIL_ER(TTERRNO,
"%s failed unexpectedly; expected - %d : %s",
tc->name, tc->exp_errno,
tst_strerrno(TFAIL | TTERRNO));
}
} else {
- tst_res(TFAIL, "madvise succeeded unexpectedly");
+ TST_RES_TFAIL("madvise succeeded unexpectedly");
}
}
--
2.45.2
More information about the ltp
mailing list