Linux Test Project
 help / color / mirror / Atom feed
From: Avinesh Kumar <akumar@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/5] alarm02: simplify using TST_EXP_* macros
Date: Thu, 11 Aug 2022 18:43:54 +0530	[thread overview]
Message-ID: <20220811131358.18906-1-akumar@suse.de> (raw)

- 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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2022-08-11 13:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 13:13 Avinesh Kumar [this message]
2022-08-11 13:13 ` [LTP] [PATCH 2/5] alarm03: cleanup and simplify Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 3/5] alarm05: use TST_EXP_* macros Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 4/5] alarm06: cleanup and simplify Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 5/5] alarm07: " Avinesh Kumar
2022-08-11 14:24   ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220811131358.18906-1-akumar@suse.de \
    --to=akumar@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox