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

- copyright update
- description comment into docparse format and reword
- remove duplicated headers
- make check fix: un-initialize static var
- use TST_EXP_* macros

Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/alarm/alarm07.c | 31 +++++++++--------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/testcases/kernel/syscalls/alarm/alarm07.c b/testcases/kernel/syscalls/alarm/alarm07.c
index 47c30dc76..17d81f594 100644
--- a/testcases/kernel/syscalls/alarm/alarm07.c
+++ b/testcases/kernel/syscalls/alarm/alarm07.c
@@ -2,45 +2,38 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  * Author: Wayne Boyer
+ * Copyright (c) Linux Test Project, 2009-2022
+ */
+
+/*\
+ * [Description]
  *
- * Test Description:
- *  By the SIGALRM signal, check whether the previously specified alarm request
- *  was cleared in the child process or not.
+ * Verify that SIGALRM signal scheduled by alarm() in the parent process
+ * is not delivered to the child process.
  */
 
-#include <unistd.h>
 #include <stdlib.h>
-#include <errno.h>
-#include <signal.h>
-
 #include "tst_test.h"
 
-static volatile int alarm_cnt = 0;
+static volatile int alarm_cnt;
 
 static void verify_alarm(void)
 {
 	pid_t pid;
+
 	alarm_cnt = 0;
 
-	TEST(alarm(1));
+	TST_EXP_PASS_SILENT(alarm(1));
 	pid = SAFE_FORK();
 
 	sleep(3);
 
 	if (pid == 0) {
-		if (alarm_cnt == 0) {
-			tst_res(TPASS, "alarm() request cleared in child");
-		} else {
-			tst_res(TFAIL, "alarm() request not cleared in "
-				"child; alarms received:%d", alarm_cnt);
-		}
+		TST_EXP_EQ_LU(alarm_cnt, 0);
 		exit(0);
 	}
 
-	if (alarm_cnt != 1)
-		tst_res(TFAIL, "Sigalarms in parent %i, expected 1", alarm_cnt);
-	else
-		tst_res(TPASS, "Got 1 sigalarm in parent");
+	TST_EXP_EQ_LU(alarm_cnt, 1);
 }
 
 static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
-- 
2.36.1


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

  parent reply	other threads:[~2022-08-11 13:15 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 ` [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 ` Avinesh Kumar [this message]
2022-08-11 14:24   ` [LTP] [PATCH 5/5] alarm07: " 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-5-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