[LTP] [PATCH 4/5] alarm06: cleanup and simplify

Avinesh Kumar akumar@suse.de
Thu Aug 11 15:13:57 CEST 2022


- turn description comment into docparse and reword
- remove duplicated headers
- make check fix: un-initialize static var
- test using TST_EXP_* macros

Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/alarm/alarm06.c | 34 +++++------------------
 1 file changed, 7 insertions(+), 27 deletions(-)

diff --git a/testcases/kernel/syscalls/alarm/alarm06.c b/testcases/kernel/syscalls/alarm/alarm06.c
index eee9429a1..e5c0d3768 100644
--- a/testcases/kernel/syscalls/alarm/alarm06.c
+++ b/testcases/kernel/syscalls/alarm/alarm06.c
@@ -5,25 +5,15 @@
  * Ported to LTP: Wayne Boyer
  */
 
-/*
- * Check the functionality of the Alarm system call when the time input
- * parameter is zero.
+/*\
+ * [Description]
  *
- * Expected Result:
- * The previously specified alarm request should be cancelled and the
- * SIGALRM should not be received.
+ * Verify that any pending alarm() is canceled when seconds is zero.
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-
 #include "tst_test.h"
 
-static volatile int alarms_received = 0;
+static volatile int alarms_received;
 
 static void sigproc(int sig)
 {
@@ -38,25 +28,15 @@ static void setup(void)
 
 static void verify_alarm(void)
 {
-	int ret;
-
-	alarm(2);
+	TST_EXP_PASS_SILENT(alarm(2));
 	sleep(1);
 
-	ret = alarm(0);
+	TST_EXP_VAL(alarm(0), 1);
 
 	/* Wait for signal SIGALRM */
 	sleep(2);
 
-	if (alarms_received)
-		tst_res(TFAIL, "Received %i alarms", alarms_received);
-	else
-		tst_res(TPASS, "Received 0 alarms");
-
-	if (ret == 1)
-		tst_res(TPASS, "alarm(0) returned 1");
-	else
-		tst_res(TFAIL, "alarm(0) returned %i, expected 1", ret);
+	TST_EXP_EQ_LU(alarms_received, 0);
 }
 
 static struct tst_test test = {
-- 
2.36.1



More information about the ltp mailing list