[LTP] [PATCH 1/5] alarm02: simplify using TST_EXP_* macros
Avinesh Kumar
akumar@suse.de
Thu Aug 11 15:13:54 CEST 2022
- copyright update
- description comment reword and turn into docparse format
- remove duplicated includes
- use TST_EXP_PASS and TST_EXP_VAL macros
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
testcases/kernel/syscalls/alarm/alarm02.c | 51 +++++++----------------
1 file changed, 15 insertions(+), 36 deletions(-)
diff --git a/testcases/kernel/syscalls/alarm/alarm02.c b/testcases/kernel/syscalls/alarm/alarm02.c
index 94239060c..7d60b532e 100644
--- a/testcases/kernel/syscalls/alarm/alarm02.c
+++ b/testcases/kernel/syscalls/alarm/alarm02.c
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: GPL-2.0-or-later
-/* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
* Author: Billy Jean Horne
- *
- * Test Description:
- * 1) alarm() return UINT_MAX if seconds is UINT_MAX.
- * 2) alarm() return UINT_MAX/2 if seconds is UINT_MAX/2.
- * 3) alarm() return UINT_MAX/4 if seconds is UINT_MAX/4.
+ * Copyright (c) Linux Test Project, 2009-2022
*/
-#include <unistd.h>
-#include <errno.h>
-#include <sys/signal.h>
-#include <limits.h>
+/*\
+ * [Description]
+ *
+ * Verify that alarm() returns:
+ * - zero when there was no previously scheduled alarm.
+ * - number of seconds remaining until any previously scheduled alarm.
+ */
#include "tst_test.h"
@@ -29,37 +29,16 @@ static struct tcase {
static void verify_alarm(unsigned int n)
{
struct tcase *tc = &tcases[n];
- unsigned int ret;
-
alarms_received = 0;
- ret = alarm(tc->sec);
- if (ret != 0) {
- tst_res(TFAIL,
- "alarm(%u) returned %ld, when 0 was ",
- tc->sec, TST_RET);
- return;
- }
+ TST_EXP_PASS(alarm(tc->sec), "alarm(%u)", tc->sec);
- TEST(alarm(0));
- if (alarms_received == 1) {
- tst_res(TFAIL,
- "alarm(%u) signal was received for value %s",
- tc->sec, tc->str);
- return;
- }
+ TST_EXP_VAL(alarm(0), tc->sec);
- if (tc->sec != TST_RET) {
+ if (alarms_received == 1)
tst_res(TFAIL,
- "alarm(%u) returned %ld as unexpected",
- tc->sec, TST_RET);
- return;
- }
-
- tst_res(TPASS,
- "alarm(%u) returned %ld as expected "
- "for value %s",
- tc->sec, TST_RET, tc->str);
+ "alarm(%u) delivered SIGALRM for seconds value %s",
+ tc->sec, tc->str);
}
static void sighandler(int sig)
--
2.36.1
More information about the ltp
mailing list