Skip to contentSkip to conversation

syscalls/nanosleep03: remove duplicated nanosleep03

PATCH Superseded Yang Xu 3 participants 8 messages Jul 29, 2019 – Aug 13, 2019

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/2 syscalls/nanosleep03: remove duplicated nanosleep03

1) remove duplicated nanosleep03, because nanosleep02 also test EINTR when it is interrupted by a signal handler 2)nanosleep01:Replace GPL verbose text by SPDX license identifier

---
 runtest/syscalls                              |   1 -
 .../kernel/syscalls/nanosleep/.gitignore      |   1 -
 .../kernel/syscalls/nanosleep/nanosleep01.c   |  16 +-
 .../kernel/syscalls/nanosleep/nanosleep02.c   |   7 +-
 .../kernel/syscalls/nanosleep/nanosleep03.c   | 148 ------------------
 5 files changed, 7 insertions(+), 166 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/nanosleep/nanosleep03.c
runtest/syscalls +0 -1
index 48836f422..881ed2403 100644
@@ -784,7 +784,6 @@ munmap03 munmap03
 
 nanosleep01 nanosleep01
 nanosleep02 nanosleep02
-nanosleep03 nanosleep03
 nanosleep04 nanosleep04
 
 nftw01 nftw01
testcases/kernel/syscalls/nanosleep/.gitignore +0 -1
index 11ed6bbcb..9bf03ea97 100644
@@ -1,4 +1,3 @@
 /nanosleep01
 /nanosleep02
-/nanosleep03
 /nanosleep04
testcases/kernel/syscalls/nanosleep/nanosleep01.c +1 -15
index 96e1cf1b4..418f86565 100644
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-lat
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
  * Copyright (C) 2015-2017 Cyril Hrubis <[email protected]>
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -25,7 +12,6 @@
  */
 
 #include <errno.h>
-
 #include "tst_timer_test.h"
 
 int sample_fn(int clk_id, long long usec)
testcases/kernel/syscalls/nanosleep/nanosleep02.c +6 -1
index 8bd2c44c4..20a93d3b6 100644
@@ -10,6 +10,9 @@
  *  Verify that nanosleep() will be successful to suspend the execution
  *  of a process, returns after the receipt of a signal and writes the
  *  remaining sleep time into the structure.
+ *
+ *  This test also verifies that if the call is interrupted by a signal
+ *  handler, nanosleep() returns -1, sets errno to EINTR.
  */
 
 #include <errno.h>
@@ -39,11 +42,13 @@ static void do_child(void)
 	TEST(nanosleep(&timereq, &timerem));
 	tst_timer_stop();
 
-	if (!TST_RET)
+	if (TST_RET != -1)
 		tst_brk(TBROK, "nanosleep was not interrupted");
 	if (TST_ERR != EINTR)
 		tst_brk(TBROK | TTERRNO, "nanosleep() failed");
 
+	tst_res(TPASS, "nanosleep() returned -1, set errno to EINTER");
+
 	if (tst_timespec_lt(timereq, tst_timer_elapsed()))
 		tst_brk(TFAIL, "nanosleep() slept more than timereq");
 
testcases/kernel/syscalls/nanosleep/nanosleep03.c deleted +0 -148

148 lines not on this page · raw message

Signature · 1 line
2.18.1
author
#1 lore raw

PATCH 2/2 syscalls/nanosleep04: Ported into new library

Also add EINVAL test when tv_nsec is negative.

---
 .../kernel/syscalls/nanosleep/nanosleep04.c   | 69 +++++--------------
 1 file changed, 17 insertions(+), 52 deletions(-)
testcases/kernel/syscalls/nanosleep/nanosleep04.c +17 -52
index f5108d026..572738c96 100644
@@ -1,20 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
  *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Ported to new library:
+ * 07/2019    Yang Xu <[email protected]>
  */
 
 /*
@@ -27,60 +17,35 @@
  */
 
 #include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/wait.h>
 #include <time.h>
-
-#include "test.h"
+#include "tst_test.h"
 
 static struct timespec tcases[] = {
 	{.tv_sec = -5, .tv_nsec = 9999},
 	{.tv_sec = 0, .tv_nsec = 1000000000},
+	{.tv_sec = 1, .tv_nsec = -100},
 };
 
-char *TCID = "nanosleep04";
-int TST_TOTAL = ARRAY_SIZE(tcases);
-
-static void setup(void);
-
-static void verify_nanosleep(struct timespec *tcase)
+static void verify_nanosleep(unsigned int n)
 {
-	TEST(nanosleep(tcase, NULL));
+	TEST(nanosleep(&tcases[n], NULL));
 
-	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "nanosleep() succeded unexpectedly");
+	if (TST_RET != -1) {
+		tst_res(TFAIL, "nanosleep() succeded unexpectedly");
 		return;
 	}
 
-	if (TEST_ERRNO != EINVAL) {
-		tst_resm(TFAIL | TTERRNO,
-		         "nanosleep() expected failure with EINVAL");
+	if (TST_ERR != EINVAL) {
+		tst_res(TFAIL | TTERRNO,
+			"nanosleep() failed,expected EINVAL, got");
 		return;
 	}
 
-	tst_resm(TPASS, "nanoslep() failed with EINVAL");
-}
-
-int main(int ac, char **av)
-{
-	int lc, i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		for (i = 0; i < TST_TOTAL; i++)
-			verify_nanosleep(&tcases[i]);
-	}
-
-	tst_exit();
+	tst_res(TPASS, "nanosleep() failed with EINVAL");
 }
 
-static void setup(void)
-{
-	tst_sig(FORK, DEF_HANDLER, NULL);
+static struct tst_test test = {
+	.test = verify_nanosleep,
+	.tcnt = ARRAY_SIZE(tcases),
+};
 
-	TEST_PAUSE;
-}
Signature · 1 line
2.18.1
#2 lore raw

PATCH 2/2 syscalls/nanosleep04: Ported into new library

Hi!
Pushed with minor change, thanks.

testcases/kernel/syscalls/nanosleep/nanosleep04.c line 34

Quoted 4 lines
testcases/kernel/syscalls/nanosleep/nanosleep04.c +2 -2
-	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "nanosleep() succeded unexpectedly");
+	if (TST_RET != -1) {
+		tst_res(TFAIL, "nanosleep() succeded unexpectedly");

I've changed this message to print the value of TST_RET.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/2 syscalls/nanosleep03: remove duplicated nanosleep03

In reply to Yang Xu

Hi!

testcases/kernel/syscalls/nanosleep/nanosleep01.c line 1

Quoted 6 lines
testcases/kernel/syscalls/nanosleep/nanosleep01.c +1 -0
index 96e1cf1b4..418f86565 100644
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-lat
                                             ^
					   later
Quoted 44 lines
testcases/kernel/syscalls/nanosleep/nanosleep01.c +0 -15
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
  * Copyright (C) 2015-2017 Cyril Hrubis <[email protected]>
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -25,7 +12,6 @@
  */
 
 #include <errno.h>
-
 #include "tst_timer_test.h"
 
 int sample_fn(int clk_id, long long usec)
testcases/kernel/syscalls/nanosleep/nanosleep02.c +3 -0
index 8bd2c44c4..20a93d3b6 100644
@@ -10,6 +10,9 @@
  *  Verify that nanosleep() will be successful to suspend the execution
  *  of a process, returns after the receipt of a signal and writes the
  *  remaining sleep time into the structure.
+ *
+ *  This test also verifies that if the call is interrupted by a signal
+ *  handler, nanosleep() returns -1, sets errno to EINTR.
  */
 
 #include <errno.h>

testcases/kernel/syscalls/nanosleep/nanosleep02.c static void do_child(void) · line 46

Quoted 6 lines
testcases/kernel/syscalls/nanosleep/nanosleep02.c +1 -1
@@ -39,11 +42,13 @@ static void do_child(void)
 	TEST(nanosleep(&timereq, &timerem));
 	tst_timer_stop();
 
-	if (!TST_RET)
+	if (TST_RET != -1)
 		tst_brk(TBROK, "nanosleep was not interrupted");

We should probably print the TST_RET after this change.

testcases/kernel/syscalls/nanosleep/nanosleep02.c static void do_child(void) · line 48

Quoted 2 lines
testcases/kernel/syscalls/nanosleep/nanosleep02.c +0 -0
 	if (TST_ERR != EINTR)
 		tst_brk(TBROK | TTERRNO, "nanosleep() failed");

And I guess that we should change these two messages to tst_res(TFAIL, followed by return;

testcases/kernel/syscalls/nanosleep/nanosleep02.c static void do_child(void) · line 54

Quoted 5 lines
testcases/kernel/syscalls/nanosleep/nanosleep02.c +2 -0
+	tst_res(TPASS, "nanosleep() returned -1, set errno to EINTER");
+
 	if (tst_timespec_lt(timereq, tst_timer_elapsed()))
 		tst_brk(TFAIL, "nanosleep() slept more than timereq");
 

Other than these minor issues the patch is OK.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#4 lore raw

PATCH v2 1/1 syscalls/nanosleep03: remove duplicated nanosleep03

1) remove duplicated nanosleep03, because nanosleep02 also test EINTR when it is interrupted by a signal handler 2)nanosleep01:Replace GPL verbose text by SPDX license identifier

---
 runtest/syscalls                              |   1 -
 .../kernel/syscalls/nanosleep/.gitignore      |   1 -
 .../kernel/syscalls/nanosleep/nanosleep01.c   |  16 +-
 .../kernel/syscalls/nanosleep/nanosleep02.c   |  20 ++-
 .../kernel/syscalls/nanosleep/nanosleep03.c   | 148 ------------------
 5 files changed, 17 insertions(+), 169 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/nanosleep/nanosleep03.c
runtest/syscalls +0 -1
index da5924716..1c858d53e 100644
@@ -785,7 +785,6 @@ munmap03 munmap03
 
 nanosleep01 nanosleep01
 nanosleep02 nanosleep02
-nanosleep03 nanosleep03
 nanosleep04 nanosleep04
 
 nftw01 nftw01
testcases/kernel/syscalls/nanosleep/.gitignore +0 -1
index 11ed6bbcb..9bf03ea97 100644
@@ -1,4 +1,3 @@
 /nanosleep01
 /nanosleep02
-/nanosleep03
 /nanosleep04
testcases/kernel/syscalls/nanosleep/nanosleep01.c +1 -15
index 96e1cf1b4..567be8c10 100644
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
  * Copyright (C) 2015-2017 Cyril Hrubis <[email protected]>
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -25,7 +12,6 @@
  */
 
 #include <errno.h>
-
 #include "tst_timer_test.h"
 
 int sample_fn(int clk_id, long long usec)
testcases/kernel/syscalls/nanosleep/nanosleep02.c +16 -4
index 8bd2c44c4..cf7849ca5 100644
@@ -10,6 +10,9 @@
  *  Verify that nanosleep() will be successful to suspend the execution
  *  of a process, returns after the receipt of a signal and writes the
  *  remaining sleep time into the structure.
+ *
+ *  This test also verifies that if the call is interrupted by a signal
+ *  handler, nanosleep() returns -1, sets errno to EINTR.
  */
 
 #include <errno.h>
@@ -39,10 +42,19 @@ static void do_child(void)
 	TEST(nanosleep(&timereq, &timerem));
 	tst_timer_stop();
 
-	if (!TST_RET)
-		tst_brk(TBROK, "nanosleep was not interrupted");
-	if (TST_ERR != EINTR)
-		tst_brk(TBROK | TTERRNO, "nanosleep() failed");
+	if (TST_RET != -1) {
+		tst_res(TFAIL,
+			"nanosleep was not interrupted, returned %ld ,expected -1",
+			TST_RET);
+		return;
+	}
+	if (TST_ERR != EINTR) {
+		tst_res(TFAIL | TTERRNO,
+			"nanosleep() failed, expected EINTT, got");
+		return;
+	}
+
+	tst_res(TPASS, "nanosleep() returned -1, set errno to EINTER");
 
 	if (tst_timespec_lt(timereq, tst_timer_elapsed()))
 		tst_brk(TFAIL, "nanosleep() slept more than timereq");
testcases/kernel/syscalls/nanosleep/nanosleep03.c deleted +0 -148

148 lines not on this page · raw message

Signature · 1 line
2.18.1
author
#5 lore raw

PATCH v3 1/1 syscalls/nanosleep03: remove duplicated nanosleep03

In reply to Cyril Hrubis

1) remove duplicated nanosleep03, because nanosleep02 also test EINTR when it is interrupted by a signal handler 2)nanosleep01:Replace GPL verbose text by SPDX license identifier

------
v2->v3:
fix some typos
------

---
 runtest/syscalls                              |   1 -
 .../kernel/syscalls/nanosleep/.gitignore      |   1 -
 .../kernel/syscalls/nanosleep/nanosleep01.c   |  16 +-
 .../kernel/syscalls/nanosleep/nanosleep02.c   |  20 ++-
 .../kernel/syscalls/nanosleep/nanosleep03.c   | 148 ------------------
 5 files changed, 17 insertions(+), 169 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/nanosleep/nanosleep03.c
runtest/syscalls +0 -1
index da5924716..1c858d53e 100644
@@ -785,7 +785,6 @@ munmap03 munmap03
 
 nanosleep01 nanosleep01
 nanosleep02 nanosleep02
-nanosleep03 nanosleep03
 nanosleep04 nanosleep04
 
 nftw01 nftw01
testcases/kernel/syscalls/nanosleep/.gitignore +0 -1
index 11ed6bbcb..9bf03ea97 100644
@@ -1,4 +1,3 @@
 /nanosleep01
 /nanosleep02
-/nanosleep03
 /nanosleep04
testcases/kernel/syscalls/nanosleep/nanosleep01.c +1 -15
index 96e1cf1b4..567be8c10 100644
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
  * Copyright (C) 2015-2017 Cyril Hrubis <[email protected]>
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -25,7 +12,6 @@
  */
 
 #include <errno.h>
-
 #include "tst_timer_test.h"
 
 int sample_fn(int clk_id, long long usec)
testcases/kernel/syscalls/nanosleep/nanosleep02.c +16 -4
index 8bd2c44c4..7176f9373 100644
@@ -10,6 +10,9 @@
  *  Verify that nanosleep() will be successful to suspend the execution
  *  of a process, returns after the receipt of a signal and writes the
  *  remaining sleep time into the structure.
+ *
+ *  This test also verifies that if the call is interrupted by a signal
+ *  handler, nanosleep() returns -1, sets errno to EINTR.
  */
 
 #include <errno.h>
@@ -39,10 +42,19 @@ static void do_child(void)
 	TEST(nanosleep(&timereq, &timerem));
 	tst_timer_stop();
 
-	if (!TST_RET)
-		tst_brk(TBROK, "nanosleep was not interrupted");
-	if (TST_ERR != EINTR)
-		tst_brk(TBROK | TTERRNO, "nanosleep() failed");
+	if (TST_RET != -1) {
+		tst_res(TFAIL,
+			"nanosleep was not interrupted, returned %ld ,expected -1",
+			TST_RET);
+		return;
+	}
+	if (TST_ERR != EINTR) {
+		tst_res(TFAIL | TTERRNO,
+			"nanosleep() failed, expected EINTR, got");
+		return;
+	}
+
+	tst_res(TPASS, "nanosleep() returned -1, set errno to EINTR");
 
 	if (tst_timespec_lt(timereq, tst_timer_elapsed()))
 		tst_brk(TFAIL, "nanosleep() slept more than timereq");
testcases/kernel/syscalls/nanosleep/nanosleep03.c deleted +0 -148

148 lines not on this page · raw message

Signature · 1 line
2.18.1
author
#6 lore raw

PATCH v3 1/1 syscalls/nanosleep03: remove duplicated nanosleep03

Hi Cyril
This is a simple merge. I guess you forgot it.:-)

Quoted 266 lines

1) remove duplicated nanosleep03, because nanosleep02 also test EINTR when it is interrupted by a signal handler 2)nanosleep01:Replace GPL verbose text by SPDX license identifier

------
v2->v3:
fix some typos
------

---
 runtest/syscalls                              |   1 -
 .../kernel/syscalls/nanosleep/.gitignore      |   1 -
 .../kernel/syscalls/nanosleep/nanosleep01.c   |  16 +-
 .../kernel/syscalls/nanosleep/nanosleep02.c   |  20 ++-
 .../kernel/syscalls/nanosleep/nanosleep03.c   | 148 ------------------
 5 files changed, 17 insertions(+), 169 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/nanosleep/nanosleep03.c
runtest/syscalls +0 -1
index da5924716..1c858d53e 100644
@@ -785,7 +785,6 @@ munmap03 munmap03
 
 nanosleep01 nanosleep01
 nanosleep02 nanosleep02
-nanosleep03 nanosleep03
 nanosleep04 nanosleep04
 
 nftw01 nftw01
testcases/kernel/syscalls/nanosleep/.gitignore +0 -1
index 11ed6bbcb..9bf03ea97 100644
@@ -1,4 +1,3 @@
 /nanosleep01
 /nanosleep02
-/nanosleep03
 /nanosleep04
testcases/kernel/syscalls/nanosleep/nanosleep01.c +1 -15
index 96e1cf1b4..567be8c10 100644
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) International Business Machines  Corp., 2001
  *  07/2001 Ported by Wayne Boyer
  * Copyright (C) 2015-2017 Cyril Hrubis <[email protected]>
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /*
@@ -25,7 +12,6 @@
  */
 
 #include <errno.h>
-
 #include "tst_timer_test.h"
 
 int sample_fn(int clk_id, long long usec)
testcases/kernel/syscalls/nanosleep/nanosleep02.c +16 -4
index 8bd2c44c4..7176f9373 100644
@@ -10,6 +10,9 @@
  *  Verify that nanosleep() will be successful to suspend the execution
  *  of a process, returns after the receipt of a signal and writes the
  *  remaining sleep time into the structure.
+ *
+ *  This test also verifies that if the call is interrupted by a signal
+ *  handler, nanosleep() returns -1, sets errno to EINTR.
  */
 
 #include <errno.h>
@@ -39,10 +42,19 @@ static void do_child(void)
 	TEST(nanosleep(&timereq, &timerem));
 	tst_timer_stop();
 
-	if (!TST_RET)
-		tst_brk(TBROK, "nanosleep was not interrupted");
-	if (TST_ERR != EINTR)
-		tst_brk(TBROK | TTERRNO, "nanosleep() failed");
+	if (TST_RET != -1) {
+		tst_res(TFAIL,
+			"nanosleep was not interrupted, returned %ld ,expected -1",
+			TST_RET);
+		return;
+	}
+	if (TST_ERR != EINTR) {
+		tst_res(TFAIL | TTERRNO,
+			"nanosleep() failed, expected EINTR, got");
+		return;
+	}
+
+	tst_res(TPASS, "nanosleep() returned -1, set errno to EINTR");
 
 	if (tst_timespec_lt(timereq, tst_timer_elapsed()))
 		tst_brk(TFAIL, "nanosleep() slept more than timereq");
testcases/kernel/syscalls/nanosleep/nanosleep03.c deleted +0 -148
deleted file mode 100644
index 456e140e9..000000000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) International Business Machines  Corp., 2001
- *  07/2001 Ported by Wayne Boyer
- *
- * This program is free software;  you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY;  without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program;  if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Test Description:
- *  Verify that nanosleep() will fail to suspend the execution
- *  of a process for a specified time if interrupted by a non-blocked signal.
- *
- * Expected Result:
- *  nanosleep() should return with -1 value and sets errno to EINTR.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <time.h>
-#include <sys/wait.h>
-
-#include "test.h"
-#include "safe_macros.h"
-
-char *TCID = "nanosleep03";
-int TST_TOTAL = 1;
-
-static void do_child(void);
-static void setup(void);
-static void sig_handler();
-
-int main(int ac, char **av)
-{
-	int lc;
-	pid_t cpid;
-	int status;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-#ifdef UCLINUX
-	maybe_run_child(&do_child, "dddd", &timereq.tv_sec, &timereq.tv_nsec,
-			&timerem.tv_sec, &timerem.tv_nsec);
-#endif
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		/*
-		 * Creat a child process and suspend its
-		 * execution using nanosleep()
-		 */
-		if ((cpid = FORK_OR_VFORK()) == -1)
-			tst_brkm(TBROK, NULL, "fork() failed");
-
-		if (cpid == 0) {
-#ifdef UCLINUX
-			if (self_exec(av[0], "dddd",
-				      timereq.tv_sec, timereq.tv_nsec,
-				      timerem.tv_sec, timerem.tv_nsec) < 0) {
-				tst_brkm(TBROK, NULL, "self_exec failed");
-			}
-#else
-			do_child();
-#endif
-		}
-
-		sleep(1);
-
-		/* Now send signal to child */
-		SAFE_KILL(NULL, cpid, SIGINT);
-
-		/* Wait for child to execute */
-		wait(&status);
-		if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
-			tst_resm(TPASS, "nanosleep() failed, interrupted"
-				 " by signal (%d) as expected", EINTR);
-		} else {
-			tst_resm(TFAIL, "child process exited abnormally; "
-				 "status = %d", status);
-		}
-	}
-
-	tst_exit();
-}
-
-static void do_child(void)
-{
-	struct timespec timereq = {.tv_sec = 5, .tv_nsec = 9999};
-	struct timespec timerem;
-
-	/*
-	 * Call nanosleep() to suspend child process
-	 * for specified time 'tv_sec'.
-	 * Call should return before suspending execution
-	 * for the specified time due to receipt of signal
-	 * from Parent.
-	 */
-	TEST(nanosleep(&timereq, &timerem));
-
-	if (TEST_RETURN == -1) {
-
-		/* Check for expected errno is set */
-		if (TEST_ERRNO != EINTR) {
-			tst_resm(TFAIL | TTERRNO,
-				 "nanosleep() failed; expected errno: %d",
-				 EINTR);
-			exit(1);
-		}
-	} else {
-		tst_resm(TFAIL, "nanosleep() returns %ld, "
-			 "expected -1, errno:%d", TEST_RETURN, EINTR);
-		exit(1);
-	}
-
-	exit(0);
-}
-
-static void setup(void)
-{
-	tst_sig(FORK, DEF_HANDLER, NULL);
-
-	TEST_PAUSE;
-
-	if (signal(SIGINT, sig_handler) == SIG_ERR) {
-		tst_brkm(TBROK, NULL,
-			 "signal() fails to setup signal handler");
-	}
-
-}
-
-static void sig_handler(void)
-{
-}
#7 lore raw

PATCH v3 1/1 syscalls/nanosleep03: remove duplicated nanosleep03

Hi Yang,

Quoted 2 lines

Hi Cyril
This is a simple merge. I guess you forgot it.:-)

I split it into 2 commits and merged.
Thanks for your patch.

Kind regards,
Petr