[PATCH v3 3/4] tests/sockopt-timestamp: Don't test old timestamps if unsupported

Alistair Francis alistair.francis at wdc.com
Sat Mar 7 02:22:22 UTC 2020


On new 32-bit architectures (like RV32) the kernel defines SO_TIMESTAMP
to SO_TIMESTAMP_NEW (see include/uapi/asm-generic/socket.h:133).
Although SO_TIMESTAMP_OLD still exists it returns data that doesn't fit
into the struct timeval as the old timestamp isn't 64-bit (y2038 safe).

To fix this let's skip the test cases if SO_TIMESTAMP is the same as
SO_TIMESTAMP_NEW. Unfortunately as SO_TIMESTAMP is defined with a one
line if statement (? :) we can't use preprocess defines and instead need
to just skipt the tests.

Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
---
 tests/sockopt-timestamp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/sockopt-timestamp.c b/tests/sockopt-timestamp.c
index fd332ec2..a092d305 100644
--- a/tests/sockopt-timestamp.c
+++ b/tests/sockopt-timestamp.c
@@ -195,10 +195,15 @@ main(void)
 #endif
 	};
 	unsigned int tested = 0;
-	for (unsigned int i = 0; i < ARRAY_SIZE(tests); ++i)
+	for (unsigned int i = 0; i < ARRAY_SIZE(tests); ++i) {
+		if (SO_TIMESTAMP == SO_TIMESTAMP_NEW && tests[i].val == SO_TIMESTAMP_OLD)
+				continue;
+		if (SO_TIMESTAMPNS == SO_TIMESTAMPNS_NEW && tests[i].val == SO_TIMESTAMPNS_OLD)
+				continue;
 		tested |= test_sockopt(tests[i].val,
 				       tests[i].str,
 				       tests[i].fun);
+	}
 	if (!tested)
 		return 77;
 
-- 
2.25.1



More information about the Strace-devel mailing list