[LTP] [PATCH 3/5] alarm05: use TST_EXP_* macros
Avinesh Kumar
akumar@suse.de
Thu Aug 11 15:13:56 CEST 2022
- turn comment into docparse format
- make check fix: un-initialize static var
- simplify test using TST_EXP_* macros
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
testcases/kernel/syscalls/alarm/alarm05.c | 30 ++++++-----------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/testcases/kernel/syscalls/alarm/alarm05.c b/testcases/kernel/syscalls/alarm/alarm05.c
index c60f98994..2a1258f6a 100644
--- a/testcases/kernel/syscalls/alarm/alarm05.c
+++ b/testcases/kernel/syscalls/alarm/alarm05.c
@@ -7,8 +7,9 @@
* Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz>
*/
-/*
- * Test Description:
+/*\
+ * [Description]
+ *
* The return value of the alarm system call should be equal to the
* amount previously remaining in the alarm clock.
* A SIGALRM signal should be received after the specified amount of
@@ -17,34 +18,17 @@
#include "tst_test.h"
-static volatile int alarms_fired = 0;
+static volatile int alarms_fired;
static void run(void)
{
- unsigned int ret;
-
alarms_fired = 0;
- ret = alarm(10);
- if (ret)
- tst_res(TFAIL, "alarm() returned non-zero");
- else
- tst_res(TPASS, "alarm() returned zero");
-
+ TST_EXP_PASS(alarm(10));
sleep(1);
-
- ret = alarm(1);
- if (ret == 9)
- tst_res(TPASS, "alarm() returned remainder correctly");
- else
- tst_res(TFAIL, "alarm() returned wrong remained %u", ret);
-
+ TST_EXP_VAL(alarm(1), 9);
sleep(2);
-
- if (alarms_fired == 1)
- tst_res(TPASS, "alarm handler fired once");
- else
- tst_res(TFAIL, "alarm handler filred %u times", alarms_fired);
+ TST_EXP_EQ_LU(alarms_fired, 1);
}
static void sighandler(int sig)
--
2.36.1
More information about the ltp
mailing list