Skip to contentSkip to conversation

Testing statx syscall Timestamp fields

PATCH Superseded subash 2 participants 2 messages Sep 4, 2018 – Oct 4, 2018

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

subash

author
#0 lore raw

PATCH v2 1/4 Testing statx syscall Timestamp fields

* statx_btime.c:The time before and after the execution of the create system call is noted.
It is checked whether the birth time returned by statx lies in this range.

---
 runtest/syscalls                                   |  2 +
 testcases/kernel/syscalls/statx/.gitignore         |  2 +
 testcases/kernel/syscalls/statx/Makefile           | 29 +++++++
 testcases/kernel/syscalls/statx/statx_btime.c      | 91 ++++++++++++++++++++++
 testcases/kernel/syscalls/statx/timestamp_helper.c | 40 ++++++++++
 testcases/kernel/syscalls/statx/timestamp_helper.h | 31 ++++++++
 6 files changed, 195 insertions(+)
 create mode 100644 testcases/kernel/syscalls/statx/.gitignore
 create mode 100644 testcases/kernel/syscalls/statx/Makefile
 create mode 100644 testcases/kernel/syscalls/statx/statx_btime.c
 create mode 100644 testcases/kernel/syscalls/statx/timestamp_helper.c
 create mode 100644 testcases/kernel/syscalls/statx/timestamp_helper.h
runtest/syscalls +2 -0
index 3161d918d..048fb9cc4 100644
@@ -1493,3 +1493,5 @@ memfd_create01 memfd_create01
 memfd_create02 memfd_create02
 
 copy_file_range01 copy_file_range01
+
+statx_btime statx_btime
testcases/kernel/syscalls/statx/.gitignore new file +2 -0
new file mode 100644
index 000000000..4fb6f516f
@@ -0,0 +1,2 @@
+/timestamp_helper
+/statx_btime
\ No newline at end of file
testcases/kernel/syscalls/statx/Makefile new file +29 -0
new file mode 100644
index 000000000..3a326423c
@@ -0,0 +1,29 @@
+# Copyright (c) Zilogic Systems Pvt. Ltd., 2018
+#  Email : [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 St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+FILTER_OUT_MAKE_TARGETS         := timestamp_helper
+
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+$(MAKE_TARGETS): %: %.o timestamp_helper.o
testcases/kernel/syscalls/statx/statx_btime.c new file +91 -0

91 lines not on this page · raw message

testcases/kernel/syscalls/statx/timestamp_helper.c new file +40 -0
new file mode 100644
index 000000000..6b12dfd26
@@ -0,0 +1,40 @@
+//SPDX-License-Identifier:GPL-2.0-or-later
+/*
+ * Copyright (c) Zilogic Systems Pvt. Ltd., 2018
+ * Email: [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, see <http://www.gnu.org/licenses/>.
+ */
+
+#define TST_NO_DEFAULT_MAIN
+
+#include "timestamp_helper.h"
+
+void statx_timestamp_to_timespec(const struct statx_timestamp *timestamp,
+				 struct timespec *timespec)
+{
+	timespec->tv_sec = timestamp->tv_sec;
+	timespec->tv_nsec = timestamp->tv_nsec;
+}
+
+void clock_wait_tick(void)
+{
+	struct timespec res;
+	unsigned int usecs;
+
+	SAFE_CLOCK_GETRES(CLOCK_REALTIME_COARSE, &res);
+	usecs = ((res.tv_sec * 1000000) + (res.tv_nsec / 1000)) * 1.5;
+
+	usleep(usecs);
+}
testcases/kernel/syscalls/statx/timestamp_helper.h new file +31 -0
new file mode 100644
index 000000000..bb6794920
@@ -0,0 +1,31 @@
+//SPDX-License-Identifier:GPL-2.0-or-later
+/*
+ * Copyright (c) Zilogic Systems Pvt. Ltd., 2018
+ * Email: [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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TIMESTAMP_HELPER
+#define TIMESTAMP_HELPER
+
+#include <time.h>
+#include "lapi/stat.h"
+#include "tst_test.h"
+#include "tst_safe_macros.h"
+
+void statx_timestamp_to_timespec(const struct statx_timestamp *timestamp,
+				struct timespec *timespec);
+void clock_wait_tick(void);
+#endif
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/4 Testing statx syscall Timestamp fields

Hi!
Looking at these tests they are almost identical, it would make much sense to keep them in a single test, so that we will format and mount the device only once at the start of the test, then we can execute the four different test scenarios. That should save at least half of a minute of a runtime. What do you think?

Signature · 2 lines
Cyril Hrubis
[email protected]