All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library
@ 2020-03-04  8:44 Yang Xu
  2020-03-04  8:44 ` [LTP] [PATCH v1 2/2] syscalls/settimeofday02: " Yang Xu
  2020-03-09  8:01 ` [LTP] [PATCH v1 1/2] syscalls/settimeofday01: " Petr Vorel
  0 siblings, 2 replies; 11+ messages in thread
From: Yang Xu @ 2020-03-04  8:44 UTC (permalink / raw)
  To: ltp

Also, since glibc 2.31[1], when tz and tv are both null, it will get
SIGSEGV sig. So, remove this EFAULT error test to adopt glibc2.31.

Moreover, musl 1.2.0 is now available and changes time_t for 32-bit
archs to a 64-bit type. It is updated to slove y2038 problem and get
time function no longer used for 32bit arch but not affecting set time
function and 64 bit arch, more info see[2]. So for gettimeofday(), we
use tst_syscall instead of calling libc to avoid this problem.

[1]https://sourceware.org/ml/libc-announce/2020/msg00001.html
[2]https://musl.libc.org/time64.html
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 .../syscalls/settimeofday/settimeofday01.c    | 200 ++++--------------
 1 file changed, 46 insertions(+), 154 deletions(-)

diff --git a/testcases/kernel/syscalls/settimeofday/settimeofday01.c b/testcases/kernel/syscalls/settimeofday/settimeofday01.c
index 7388c3231..fdb03ba7f 100644
--- a/testcases/kernel/syscalls/settimeofday/settimeofday01.c
+++ b/testcases/kernel/syscalls/settimeofday/settimeofday01.c
@@ -1,52 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */
-
-/*
- * NAME
- * 	settimeofday01.c
+ * Copyright (c) International Business Machines  Corp., 2001
  *
  * DESCRIPTION
  *	Testcase to check the basic functionality of settimeofday().
  *
- * ALGORITHM
- *	Setup:
- *	  Setup signal handling.
- *	  Check that we are the proper user.
- *	  Setup expected errnos.
- *	  Pause for SIGUSER1 if option specified.
- *	  Save the current time values.
- *	Loop if the proper options are given.
- *	  Call settimeofday and verify the time was changed.
- *	  Call settimeofday with invalid Args and verify that the call fails.
- *	Cleanup:
- *	  Restore the original time values.
- *	  Print errno log and/or timing stats if options given.
- *
- * USAGE:  <for command-line>
- *	settimeofday01 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *	where,  -c n : Run n copies concurrently.
- *		-e   : Turn on errno logging.
- *		-i n : Execute test n times.
- *		-I x : Execute test for x seconds.
- *		-P x : Pause for x seconds between iterations.
- *		-t   : Turn on syscall timing.
- *
  * History
  *	07/2001 John George
  *		-Ported
@@ -58,135 +16,69 @@
 #include <sys/time.h>
 #include <errno.h>
 #include <unistd.h>
-#include "test.h"
+#include "tst_test.h"
+#include "lapi/syscalls.h"
 
-#define	FAILED		1
 #define	VAL_SEC		100
 #define	VAL_MSEC	100
-#define ACCEPTABLE_DELTA	500	/* in milli-seconds */
+#define ACCEPTABLE_DELTA 500
 #define USEC_PER_SEC    1000000L
 
-char *TCID = "settimeofday01";
-int TST_TOTAL = 1;
-time_t save_tv_sec, save_tv_usec;
-struct timeval tp, tp1, tp2;
-
-void setup(void);
-void cleanup(void);
+struct timeval tv_saved;
 
-#if !defined(UCLINUX)
-
-int main(int argc, char **argv)
+static void verify_settimeofday(void)
 {
-	int lc;
 	suseconds_t delta;
+	struct timeval tv1, tv2;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		int condition_number = 1;
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		gettimeofday(&tp, NULL);
-		tp.tv_sec += VAL_SEC;
-		tp.tv_usec += VAL_MSEC;
-		if (tp.tv_usec >= USEC_PER_SEC)
-			tp.tv_usec = VAL_MSEC;
-
-		TEST(settimeofday(&tp, NULL));
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "Error Setting Time, errno=%d",
-				 TEST_ERRNO);
-		}
-
-		if ((gettimeofday(&tp2, (struct timezone *)&tp1)) == -1) {
-			tst_resm(TBROK, "Error Getting Time, errno=%d", errno);
-		}
+	if (tst_syscall(__NR_gettimeofday, &tv1, NULL) == -1)
+		tst_brk(TBROK | TERRNO, "gettimeofday(&tv1, NULL) failed");
 
-		if (tp2.tv_sec > tp.tv_sec) {
-			delta =
-			    (suseconds_t) (tp2.tv_sec - tp.tv_sec) * 1000 +
-			    (tp2.tv_usec - tp.tv_usec) / 1000;
-		} else {
-			delta =
-			    (suseconds_t) (tp.tv_sec - tp2.tv_sec) * 1000 +
-			    (tp.tv_usec - tp2.tv_usec) / 1000;
-		}
+	tv1.tv_sec += VAL_SEC;
+	tv1.tv_usec += VAL_MSEC;
+	if (tv1.tv_usec >= USEC_PER_SEC)
+		tv1.tv_usec = VAL_MSEC;
 
-		if (delta > -ACCEPTABLE_DELTA && delta < ACCEPTABLE_DELTA) {
-			tst_resm(TPASS, "Test condition %d successful",
-				 condition_number++);
-		} else {
-			tst_resm(TFAIL, "Test condition %d failed",
-				 condition_number++);
-		}
-
-		/* Invalid Args : Error Condition where tp = NULL */
-		TEST(settimeofday((struct timeval *)-1, NULL));
-		if (TEST_RETURN == -1) {
-			tst_resm(TPASS, "Test condition %d successful",
-				 condition_number++);
-		} else {
-			tst_resm(TFAIL, "Test condition %d failed",
-				 condition_number);
-		}
+	TEST(settimeofday(&tv1, NULL));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "settimeofday(&tv1, NULL) failed");
+		return;
+	}
 
+	if (tst_syscall(__NR_gettimeofday, &tv2, NULL) == -1)
+		tst_brk(TBROK | TERRNO, "gettimeofday(&tv2, NULL) failed");
+
+	if (tv2.tv_sec > tv1.tv_sec) {
+		delta =
+			(suseconds_t) (tv2.tv_sec - tv1.tv_sec) * 1000 +
+			(tv2.tv_usec - tv1.tv_usec) / 1000;
+	} else {
+		delta =
+			(suseconds_t) (tv1.tv_sec - tv2.tv_sec) * 1000 +
+			(tv1.tv_usec - tv2.tv_usec) / 1000;
 	}
-	cleanup();
-	tst_exit();
 
+	if (delta > -ACCEPTABLE_DELTA && delta < ACCEPTABLE_DELTA)
+		tst_res(TPASS, "settimeofday() pass");
+	else
+		tst_res(TFAIL, "settimeofday() fail");
 }
 
-#else
-
-int main(void)
+static void setup(void)
 {
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
+	if (tst_syscall(__NR_gettimeofday, &tv_saved, NULL) == -1)
+		tst_brk(TBROK | TERRNO, "gettimeofday(&tv_saved, NULL) failed");
 }
 
-#endif /* if !defined(UCLINUX) */
-
-/*
- * setup()
- *	performs all ONE TIME setup for this test
- */
-void setup(void)
+static void cleanup(void)
 {
-	tst_require_root();
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	/* Pause if that option was specified
-	 * TEST_PAUSE contains the code to fork the test with the -c option.
-	 */
-	TEST_PAUSE;
-
-	/* Save the current time values */
-	if ((gettimeofday(&tp, (struct timezone *)&tp1)) == -1) {
-		tst_brkm(TBROK, cleanup, "gettimeofday failed. "
-			 "errno=%d", errno);
-	}
-	save_tv_sec = tp.tv_sec;
-	save_tv_usec = tp.tv_usec;
+	if ((settimeofday(&tv_saved, NULL)) == -1)
+		tst_brk(TBROK | TERRNO, "settimeofday(&tv_saved, NULL) failed");
 }
 
-/*
- * cleanup()
- *	performs all ONE TIME cleanup for this test at
- *	completion or premature exit
- */
-void cleanup(void)
-{
-	/* restore the original time values. */
-	tp.tv_sec = save_tv_sec;
-	tp.tv_usec = save_tv_usec;
-	if ((settimeofday(&tp, NULL)) == -1) {
-		tst_resm(TWARN, "FATAL COULD NOT RESET THE CLOCK");
-		tst_resm(TFAIL, "Error Setting Time, errno=%d", errno);
-	}
-
-}
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_settimeofday,
+	.needs_root = 1,
+};
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-04  8:44 [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library Yang Xu
@ 2020-03-04  8:44 ` Yang Xu
  2020-03-09  7:47   ` Petr Vorel
  2020-03-09  8:09   ` Petr Vorel
  2020-03-09  8:01 ` [LTP] [PATCH v1 1/2] syscalls/settimeofday01: " Petr Vorel
  1 sibling, 2 replies; 11+ messages in thread
From: Yang Xu @ 2020-03-04  8:44 UTC (permalink / raw)
  To: ltp

As well as settimeofday01, using tst_sycall for gettimeofday
and remove EFAULT error test. Also, add EINVAL error test.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 .../syscalls/settimeofday/settimeofday02.c    | 207 +++++-------------
 1 file changed, 49 insertions(+), 158 deletions(-)

diff --git a/testcases/kernel/syscalls/settimeofday/settimeofday02.c b/testcases/kernel/syscalls/settimeofday/settimeofday02.c
index 5516e619e..290c692b8 100644
--- a/testcases/kernel/syscalls/settimeofday/settimeofday02.c
+++ b/testcases/kernel/syscalls/settimeofday/settimeofday02.c
@@ -1,189 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *
- *   Copyright (c) International Business Machines  Corp., 2001
- *
- *   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
- */
-
-/*
- * NAME
- * 	settimeofday02.c
+ * Copyright (c) International Business Machines  Corp., 2001
  *
  * DESCRIPTION
  *	Testcase to check that settimeofday() sets errnos correctly.
  *
- * ALGORITHM
- *	Setup:
- *	  Setup signal handling.
- *	  Check that we are not root.
- *	  Setup expected errnos.
- *	  Pause for SIGUSER1 if option specified.
- *	  Save the current time values.
- *	Loop if the proper options are given.
- *	  Call settimeofday with an invalid "buf" address and verify that
- *		errno is set to EFAULT.
- *	  Call settimeofday as a non-root user.  Verify that the call fails
- *		and errno is set to EPERM.
- *	Cleanup:
- *	  Print errno log and/or timing stats if options given.
- *
- * USAGE:  <for command-line>
- *	settimeofday02 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- *	where,  -c n : Run n copies concurrently.
- *		-e   : Turn on errno logging.
- *		-i n : Execute test n times.
- *		-I x : Execute test for x seconds.
- *		-P x : Pause for x seconds between iterations.
- *		-t   : Turn on syscall timing.
- *
  * History
  *	07/2001 John George
  *		-Ported
- *
- * Restrictions
- *	Must not be run as root
  */
 
 #include <stdio.h>
 #include <sys/time.h>
 #include <errno.h>
-#include "test.h"
-#include <pwd.h>
+#include <linux/capability.h>
+#include "tst_capability.h"
+#include "tst_test.h"
+#include "lapi/syscalls.h"
 
 #define	VAL_SEC		100
 #define	VAL_MSEC	100
 
-char *TCID = "settimeofday02";
-int TST_TOTAL = 1;
-
-struct timeval tp;
-time_t save_tv_sec, save_tv_usec;
-
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
+struct timeval tv_saved;
+static int flag;
 
-void setup(void);
-void cleanup(void);
-void restore_time(void);
+static struct tcase {
+	struct timeval tv;
+	int exp_errno;
+	char *message;
+} tcases[] = {
+	{{-1, 0}, EINVAL, "tv.tv_sec is negative"},
+	{{0, -1}, EINVAL, "tv.tv_usec is outside the range [0..999,999]"},
+	{{100, 100}, EPERM, "calling process without CAP_SYS_TIME capability"},
+};
 
-#if !defined(UCLINUX)
-
-int main(int argc, char **argv)
+static void verify_settimeofday(unsigned int n)
 {
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		TEST(settimeofday((void *)-1, NULL));
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "settimeofday(2) failed to FAIL");
-			restore_time();
-		} else {
-			if (TEST_ERRNO != EFAULT) {
-				tst_resm(TFAIL, "Expected EFAULT got %d",
-					 TEST_ERRNO);
-			} else {
-				tst_resm(TPASS, "Received expected errno");
-			}
-		}
-
-		tp.tv_sec = VAL_SEC;
-		tp.tv_usec = VAL_MSEC;
-		TEST(settimeofday(&tp, NULL));
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "settimeofday(2) failed to FAIL");
-			restore_time();
-		} else {
-			if (TEST_ERRNO != EPERM) {
-				tst_resm(TFAIL, "Expected EPERM got %d",
-					 TEST_ERRNO);
-			} else {
-				tst_resm(TPASS, "Received expected errno");
-			}
-		}
+	struct tcase *tc = &tcases[n];
+
+	flag = 0;
+	tst_res(TINFO, "%s", tc->message);
+	TEST(settimeofday(&tc->tv, NULL));
+	if (TST_RET != -1) {
+		tst_res(TFAIL, "settimeofday() succeeded unexpectedly");
+		flag = 1;
+		return;
 	}
-	cleanup();
-	tst_exit();
 
+	if (TST_ERR != tc->exp_errno)
+		tst_res(TFAIL | TTERRNO, "Expected %s got ", tst_strerrno(tc->exp_errno));
+	else
+		tst_res(TPASS | TTERRNO, "Received expected errno");
 }
 
-#else
-
-int main(void)
+static void setup(void)
 {
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
+	if (tst_syscall(__NR_gettimeofday, &tv_saved, NULL) == -1)
+		tst_brk(TBROK | TERRNO, "gettimeofday(&tv_saved, NULL) failed");
 }
 
-#endif /* if !defined(UCLINUX) */
-
-/*
- * setup()
- *	performs all ONE TIME setup for this test
- */
-void setup(void)
+static void cleanup(void)
 {
-	tst_require_root();
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	/* Switch to nobody user for correct error code collection */
-	ltpuser = getpwnam(nobody_uid);
-	if (setuid(ltpuser->pw_uid) == -1) {
-		tst_resm(TINFO, "setuid failed to "
-			 "to set the effective uid to %d", ltpuser->pw_uid);
-		perror("setuid");
-	}
-
-	/* Pause if that option was specified
-	 * TEST_PAUSE contains the code to fork the test with the -c option.
-	 */
-	TEST_PAUSE;
-
-	/* Save the current time values */
-	if ((gettimeofday(&tp, (struct timezone *)&tp)) == -1) {
-		tst_brkm(TBROK, cleanup, "gettimeofday failed. "
-			 "errno=%d", errno);
-	}
-	save_tv_sec = tp.tv_sec;
-	save_tv_usec = tp.tv_usec;
+	if (!flag)
+		return;
+	if ((settimeofday(&tv_saved, NULL)) == -1)
+		tst_brk(TBROK | TERRNO, "settimeofday(&tv_saved, NULL) failed");
 }
 
-/*
- * cleanup()
- *	performs all ONE TIME cleanup for this test at
- *	completion or premature exit
- */
-void cleanup(void)
-{
+static struct tst_test test = {
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_settimeofday,
+	.tcnt = ARRAY_SIZE(tcases),
+	.caps = (struct tst_cap []) {
+		TST_CAP(TST_CAP_DROP, CAP_SYS_TIME),
+		{}
+	},
+};
 
-}
-
-void restore_time(void)
-{
-	/* restore the original time values. */
-	tp.tv_sec = save_tv_sec;
-	tp.tv_usec = save_tv_usec;
-	if ((settimeofday(&tp, NULL)) == -1) {
-		tst_resm(TWARN, "FATAL COULD NOT RESET THE CLOCK");
-		tst_resm(TFAIL, "Error Setting Time, errno=%d", errno);
-	}
-}
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-04  8:44 ` [LTP] [PATCH v1 2/2] syscalls/settimeofday02: " Yang Xu
@ 2020-03-09  7:47   ` Petr Vorel
  2020-03-09  7:52     ` Yang Xu
  2020-03-09  8:09   ` Petr Vorel
  1 sibling, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2020-03-09  7:47 UTC (permalink / raw)
  To: ltp

Hi Xu,

> +static void verify_settimeofday(unsigned int n)
...
> +	struct tcase *tc = &tcases[n];
> +
> +	flag = 0;
> +	tst_res(TINFO, "%s", tc->message);
> +	TEST(settimeofday(&tc->tv, NULL));
> +	if (TST_RET != -1) {
> +		tst_res(TFAIL, "settimeofday() succeeded unexpectedly");
Maybe add TTERRNO here as well?
> +		flag = 1;
> +		return;

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-09  7:47   ` Petr Vorel
@ 2020-03-09  7:52     ` Yang Xu
  2020-03-09  8:28       ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Yang Xu @ 2020-03-09  7:52 UTC (permalink / raw)
  To: ltp

Hi


> Hi Xu,
> 
>> +static void verify_settimeofday(unsigned int n)
> ...
>> +	struct tcase *tc = &tcases[n];
>> +
>> +	flag = 0;
>> +	tst_res(TINFO, "%s", tc->message);
>> +	TEST(settimeofday(&tc->tv, NULL));
>> +	if (TST_RET != -1) {
>> +		tst_res(TFAIL, "settimeofday() succeeded unexpectedly");
> Maybe add TTERRNO here as well?
Why? When run into here, settimeofyday succeeded unexpectedly, errno 
should be 0.

Best Regards
Yang Xu
>> +		flag = 1;
>> +		return;
> 
> Kind regards,
> Petr
> 
> 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library
  2020-03-04  8:44 [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library Yang Xu
  2020-03-04  8:44 ` [LTP] [PATCH v1 2/2] syscalls/settimeofday02: " Yang Xu
@ 2020-03-09  8:01 ` Petr Vorel
  2020-03-09  9:27   ` Yang Xu
  1 sibling, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2020-03-09  8:01 UTC (permalink / raw)
  To: ltp

Hi Xu,
> Also, since glibc 2.31[1], when tz and tv are both null, it will get
> SIGSEGV sig. So, remove this EFAULT error test to adopt glibc 2.31.
+1, thanks for testing on new glibc.

> Moreover, musl 1.2.0 is now available and changes time_t for 32-bit
> archs to a 64-bit type. It is updated to slove y2038 problem and get
=> typo solve.
> time function no longer used for 32bit arch but not affecting set time
> function and 64 bit arch, more info see[2]. So for gettimeofday(), we
> use tst_syscall instead of calling libc to avoid this problem.
Hm, it'd be nice to test both raw syscall and libc implementations (via
tst_variant), but IMHO there is no way to detect musl change. Or am I missing
something?

+ one would prefer this change to be in a separate commit, but we can live with that :).

I guess there is no need to setup SAFE_{G,S}ETTIMEOFDAY(), because only these 2
tests and stime_var.h are using it (or at least no now).

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-04  8:44 ` [LTP] [PATCH v1 2/2] syscalls/settimeofday02: " Yang Xu
  2020-03-09  7:47   ` Petr Vorel
@ 2020-03-09  8:09   ` Petr Vorel
  2020-03-09  8:10     ` Yang Xu
  1 sibling, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2020-03-09  8:09 UTC (permalink / raw)
  To: ltp

Hi Xu,

>  #define	VAL_SEC		100
>  #define	VAL_MSEC	100
These 2 definitions aren't needed any more.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-09  8:09   ` Petr Vorel
@ 2020-03-09  8:10     ` Yang Xu
  2020-03-09  8:30       ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Yang Xu @ 2020-03-09  8:10 UTC (permalink / raw)
  To: ltp

Hi Petr


> Hi Xu,
> 
>>   #define	VAL_SEC		100
>>   #define	VAL_MSEC	100
> These 2 definitions aren't needed any more.
Yes. I forgot to delete...

Best Regards
Yang Xu
> 
> Kind regards,
> Petr
> 
> 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-09  7:52     ` Yang Xu
@ 2020-03-09  8:28       ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2020-03-09  8:28 UTC (permalink / raw)
  To: ltp

Hi Xu,

> > > +static void verify_settimeofday(unsigned int n)
> > ...
> > > +	struct tcase *tc = &tcases[n];
> > > +
> > > +	flag = 0;
> > > +	tst_res(TINFO, "%s", tc->message);
> > > +	TEST(settimeofday(&tc->tv, NULL));
> > > +	if (TST_RET != -1) {
> > > +		tst_res(TFAIL, "settimeofday() succeeded unexpectedly");
> > Maybe add TTERRNO here as well?
> Why? When run into here, settimeofyday succeeded unexpectedly, errno should
> be 0.
Correct. I'm sorry, I read != as ==.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 2/2] syscalls/settimeofday02: convert to new library
  2020-03-09  8:10     ` Yang Xu
@ 2020-03-09  8:30       ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2020-03-09  8:30 UTC (permalink / raw)
  To: ltp

Hi Xu,

> > >   #define	VAL_SEC		100
> > >   #define	VAL_MSEC	100
> > These 2 definitions aren't needed any more.
> Yes. I forgot to delete...
This can be done during merge.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library
  2020-03-09  8:01 ` [LTP] [PATCH v1 1/2] syscalls/settimeofday01: " Petr Vorel
@ 2020-03-09  9:27   ` Yang Xu
  2020-03-09 17:47     ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Yang Xu @ 2020-03-09  9:27 UTC (permalink / raw)
  To: ltp

Hi  Petr

> Hi Xu,
>> Also, since glibc 2.31[1], when tz and tv are both null, it will get
>> SIGSEGV sig. So, remove this EFAULT error test to adopt glibc 2.31.
> +1, thanks for testing on new glibc.
> 
>> Moreover, musl 1.2.0 is now available and changes time_t for 32-bit
>> archs to a 64-bit type. It is updated to slove y2038 problem and get
> => typo solve.
>> time function no longer used for 32bit arch but not affecting set time
>> function and 64 bit arch, more info see[2]. So for gettimeofday(), we
>> use tst_syscall instead of calling libc to avoid this problem.
> Hm, it'd be nice to test both raw syscall and libc implementations (via
> tst_variant),
 From glibc 2.31 announce,
"settimeofday itself is obsolescent according to POSIX.  Programs
   that set the system time should use clock_settime and/or the adjtime
   family of functions instead".

This is why I am not using tst_variant for this case.
Also, glibc actually call clock_settime/gettime for this pair.

>but IMHO there is no way to detect musl change. Or am I missing
> something?
> 
I remembered we have a commit for this "
syscalls: Check for time64 unsafe syscalls before using them"
Looking musl glibc code[1], can we use 
__NR_gettimeofday_time32/__NR_settimeofday_time32 in syscalls.h to 
detect this change?

[1]http://git.musl-libc.org/cgit/musl/commit/?id=5a105f19b5aae79dd302899e634b6b18b3dcd0d6
> + one would prefer this change to be in a separate commit, but we can live with that :).
> 
> I guess there is no need to setup SAFE_{G,S}ETTIMEOFDAY(), because only these 2
> tests and stime_var.h are using it (or at least no now).
Agree. The more important reason is that get/settimeofday is obsolete, 
we should use other syscall to set/get time.

Best Regards
Yang Xu
> 
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> Kind regards,
> Petr
> 
> 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library
  2020-03-09  9:27   ` Yang Xu
@ 2020-03-09 17:47     ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2020-03-09 17:47 UTC (permalink / raw)
  To: ltp

Hi Xu,

both patches accepted.
Thank you.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-03-09 17:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04  8:44 [LTP] [PATCH v1 1/2] syscalls/settimeofday01: convert to new library Yang Xu
2020-03-04  8:44 ` [LTP] [PATCH v1 2/2] syscalls/settimeofday02: " Yang Xu
2020-03-09  7:47   ` Petr Vorel
2020-03-09  7:52     ` Yang Xu
2020-03-09  8:28       ` Petr Vorel
2020-03-09  8:09   ` Petr Vorel
2020-03-09  8:10     ` Yang Xu
2020-03-09  8:30       ` Petr Vorel
2020-03-09  8:01 ` [LTP] [PATCH v1 1/2] syscalls/settimeofday01: " Petr Vorel
2020-03-09  9:27   ` Yang Xu
2020-03-09 17:47     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.