Skip to contentSkip to conversation

Test seeks from LLONG_MIN

PATCH In review Matthew Wilcox 2 participants 2 messages Jul 6, 2021 – Jul 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Test seeks from LLONG_MIN

We don't currently test seeking from LLONG_MIN, which apparently can produce an UBSAN warning, although I've been unable to reproduce that. In any case, it's a good corner case to test and straightforward to add.

src/seek_sanity_test.c +4 -0
index cb036f7b..76587b7f 100644
@@ -395,8 +395,12 @@ static int test18(int fd, int testnum)
 	int ret = 0;
 
 	/* file size doesn't matter in this test, set to 0 */
+	ftruncate(fd, 0);
+
 	ret += do_lseek(testnum, 1, fd, 0, SEEK_HOLE, -1, -1);
 	ret += do_lseek(testnum, 2, fd, 0, SEEK_DATA, -1, -1);
+	ret += do_lseek(testnum, 3, fd, 0, SEEK_HOLE, LLONG_MIN, -1);
+	ret += do_lseek(testnum, 4, fd, 0, SEEK_DATA, LLONG_MIN, -1);
 
 	return ret;
 }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Matthew Wilcox

We don't currently test seeking from LLONG_MIN, which apparently can produce an UBSAN warning, although I've been unable to reproduce that. In any case, it's a good corner case to test and straightforward to add.

Seems reasonable to me...

--D

Quoted 19 lines
src/seek_sanity_test.c +4 -0
index cb036f7b..76587b7f 100644
@@ -395,8 +395,12 @@ static int test18(int fd, int testnum)
 	int ret = 0;
 
 	/* file size doesn't matter in this test, set to 0 */
+	ftruncate(fd, 0);
+
 	ret += do_lseek(testnum, 1, fd, 0, SEEK_HOLE, -1, -1);
 	ret += do_lseek(testnum, 2, fd, 0, SEEK_DATA, -1, -1);
+	ret += do_lseek(testnum, 3, fd, 0, SEEK_HOLE, LLONG_MIN, -1);
+	ret += do_lseek(testnum, 4, fd, 0, SEEK_DATA, LLONG_MIN, -1);
 
 	return ret;
 }