* [LTP] [PATCH 1/5] alarm02: simplify using TST_EXP_* macros
@ 2022-08-11 13:13 Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 2/5] alarm03: cleanup and simplify Avinesh Kumar
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Avinesh Kumar @ 2022-08-11 13:13 UTC (permalink / raw)
To: ltp
- 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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 2/5] alarm03: cleanup and simplify
2022-08-11 13:13 [LTP] [PATCH 1/5] alarm02: simplify using TST_EXP_* macros Avinesh Kumar
@ 2022-08-11 13:13 ` Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 3/5] alarm05: use TST_EXP_* macros Avinesh Kumar
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Avinesh Kumar @ 2022-08-11 13:13 UTC (permalink / raw)
To: ltp
- copyright udpate
- description comment reword and turn into docparse format
- remove duplicated headers
- use TST_EXP_* macros
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
testcases/kernel/syscalls/alarm/alarm03.c | 41 ++++++-----------------
1 file changed, 10 insertions(+), 31 deletions(-)
diff --git a/testcases/kernel/syscalls/alarm/alarm03.c b/testcases/kernel/syscalls/alarm/alarm03.c
index c0341827e..83c9932ae 100644
--- a/testcases/kernel/syscalls/alarm/alarm03.c
+++ b/testcases/kernel/syscalls/alarm/alarm03.c
@@ -2,53 +2,32 @@
/*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
* Author: Richard Logan
+ * Copyright (c) Linux Test Project, 2009-2022
+ */
+
+/*\
+ * [Description]
*
- * Test Description:
- * The process does a fork:
- * 1) By the value returned by child's alarm(0), check whether child
- * process cleared the previously specified alarm request or not.
- * 2) By the value returned by parent's alarm(0), check whether parent
- * process cleared the previously specified alarm request or not.
+ * Verify that alarms created by alarm() are not inherited by children
+ * created via fork.
*/
-#include <errno.h>
-#include <signal.h>
#include <stdlib.h>
-#include <unistd.h>
-
#include "tst_test.h"
static void verify_alarm(void)
{
pid_t pid;
- TEST(alarm(100));
+ TST_EXP_PASS_SILENT(alarm(100));
pid = SAFE_FORK();
if (pid == 0) {
- TEST(alarm(0));
- if (TST_RET != 0) {
- tst_res(TFAIL,
- "alarm(100), fork, alarm(0) child's "
- "alarm returned %ld", TST_RET);
- } else {
- tst_res(TPASS,
- "alarm(100), fork, alarm(0) child's "
- "alarm returned %ld", TST_RET);
- }
+ TST_EXP_PASS(alarm(0), "alarm(0) in child process");
exit(0);
}
- TEST(alarm(0));
- if (TST_RET != 100) {
- tst_res(TFAIL,
- "alarm(100), fork, alarm(0) parent's "
- "alarm returned %ld", TST_RET);
- } else {
- tst_res(TPASS,
- "alarm(100), fork, alarm(0) parent's "
- "alarm returned %ld", TST_RET);
- }
+ TST_EXP_VAL(alarm(0), 100, "alarm(0) in parent process");
}
static struct tst_test test = {
--
2.36.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 3/5] alarm05: use TST_EXP_* macros
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
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
3 siblings, 0 replies; 6+ messages in thread
From: Avinesh Kumar @ 2022-08-11 13:13 UTC (permalink / raw)
To: ltp
- 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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 4/5] alarm06: cleanup and simplify
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 ` Avinesh Kumar
2022-08-11 13:13 ` [LTP] [PATCH 5/5] alarm07: " Avinesh Kumar
3 siblings, 0 replies; 6+ messages in thread
From: Avinesh Kumar @ 2022-08-11 13:13 UTC (permalink / raw)
To: ltp
- 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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 5/5] alarm07: cleanup and simplify
2022-08-11 13:13 [LTP] [PATCH 1/5] alarm02: simplify using TST_EXP_* macros Avinesh Kumar
` (2 preceding siblings ...)
2022-08-11 13:13 ` [LTP] [PATCH 4/5] alarm06: cleanup and simplify Avinesh Kumar
@ 2022-08-11 13:13 ` Avinesh Kumar
2022-08-11 14:24 ` Petr Vorel
3 siblings, 1 reply; 6+ messages in thread
From: Avinesh Kumar @ 2022-08-11 13:13 UTC (permalink / raw)
To: ltp
- 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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 5/5] alarm07: cleanup and simplify
2022-08-11 13:13 ` [LTP] [PATCH 5/5] alarm07: " Avinesh Kumar
@ 2022-08-11 14:24 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2022-08-11 14:24 UTC (permalink / raw)
To: Avinesh Kumar; +Cc: ltp
Hi Avinesh,
thanks, patchset merged!
> +++ 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
FYI this was 2002 (fixed).
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-11 14:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [LTP] [PATCH 5/5] alarm07: " Avinesh Kumar
2022-08-11 14:24 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox