Skip to contentSkip to conversation

Testing statx syscall Timestamp fields

PATCH Superseded Subash Ganesan 2 participants 2 messages Nov 9, 2018 – Nov 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Testing statx syscall Timestamp fields

The time before and after the execution of the corresponding system call is noted.

It is checked whether the time returned by statx lies in this range.

open syscall with O_CREAT flag for birth time.
write syscall for modified time.
read syscall for access time.
chmod syscall for status change time.

---
 include/tst_safe_clocks.h                  |  38 +++++++
 runtest/syscalls                           |   1 +
 testcases/kernel/syscalls/statx/.gitignore |   2 +
 testcases/kernel/syscalls/statx/Makefile   |   4 +
 testcases/kernel/syscalls/statx/statx06.c  | 174 +++++++++++++++++++++++++++++
 5 files changed, 219 insertions(+)
 create mode 100644 include/tst_safe_clocks.h
 create mode 100644 testcases/kernel/syscalls/statx/statx06.c
include/tst_safe_clocks.h new file +38 -0
new file mode 100644
index 000000000..1b4d48543
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0 or later
+/*
+ *  Copyright (c) Zilogic Systems Pvt. Ltd., 2018
+ *  Email : [email protected]
+ */
+
+#include <time.h>
+#include "tst_test.h"
+
+static inline void safe_clock_getres(const char *file, const int lineno,
+	clockid_t clk_id, struct timespec *res)
+{
+	int rval;
+
+	rval = clock_getres(clk_id, res);
+	if (rval != 0)
+		tst_brk(TBROK | TERRNO,
+			"%s:%d clock_getres() failed", file, lineno);
+
+}
+
+static inline void safe_clock_gettime(const char *file, const int lineno,
+	clockid_t clk_id, struct timespec *tp)
+{
+	int rval;
+
+	rval = clock_gettime(clk_id, tp);
+	if (rval != 0)
+		tst_brk(TBROK | TERRNO,
+			"%s:%d clock_gettime() failed", file, lineno);
+}
+
+#define SAFE_CLOCK_GETRES(clk_id, res)\
+	safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))
+
+#define SAFE_CLOCK_GETTIME(clk_id, tp)\
+	safe_clock_gettime(__FILE__, __LINE__, (clk_id), (tp))
+
runtest/syscalls +1 -0
index 53a4a427e..1f76cd9de 100644
@@ -1514,3 +1514,4 @@ statx02 statx02
 statx03 statx03
 statx04 statx04
 statx05 statx05
+statx06 statx06
testcases/kernel/syscalls/statx/.gitignore +2 -0
index 209fc3a33..40b5ee392 100644
@@ -3,3 +3,5 @@
 /statx03
 /statx04
 /statx05
+/statx06
+
testcases/kernel/syscalls/statx/Makefile +4 -0
index 3a9c66d6d..563c868e5 100644
@@ -24,3 +24,7 @@ include $(top_srcdir)/include/mk/testcases.mk
 %_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+statx06: LDLIBS += -lrt
+
+
testcases/kernel/syscalls/statx/statx06.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

PATCH v4 1/1 Testing statx syscall Timestamp fields

Hi!
Pushed with minor changes, thanks.

* Changed the tst_test structure to pass -I 256 instead of specifying minimal size for the image

* Removed additional \n from the TPASS message

Signature · 2 lines
Cyril Hrubis
[email protected]