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

- 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


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

  parent 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 [LTP] [PATCH 1/5] alarm02: simplify using TST_EXP_* macros Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 2/5] alarm03: cleanup and simplify Avinesh Kumar
2022-08-11 13:13 ` Avinesh Kumar [this message]
2022-08-11 13:13 ` [LTP] [PATCH 4/5] alarm06: " 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-3-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