Fix close_range syscall tests for Linux kernels <5.11

The CLOEXEC flag for close_range was added in 5.11; if CLOEXEC tests are run on
earlier versions they will return EINVAL.

PiperOrigin-RevId: 537160906
This commit is contained in:
Konstantin Bogomolov
2023-06-01 16:37:00 -07:00
committed by gVisor bot
parent 3260f6bed6
commit 64d1e9c09b
+6
View File
@@ -216,6 +216,9 @@ TEST_F(CloseRangeTest, CloexecFlagTest) {
int num_files_in_range = 10;
unsigned int flags = CLOSE_RANGE_CLOEXEC;
// CLOEXEC is only available on >=5.11 kernels.
SKIP_IF(close_range(1, 0, flags) < 0 && errno == EINVAL);
CreateFiles(num_files_in_range);
OpenFilesRdwr();
@@ -318,6 +321,9 @@ TEST_F(CloseRangeTest, CloexecAndUnshareFlagTest) {
int num_files_in_range = 10;
unsigned int flags = CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_UNSHARE;
// CLOEXEC is only available on >=5.11 kernels.
SKIP_IF(close_range(1, 0, flags) < 0 && errno == EINVAL);
CreateFiles(num_files_in_range);
OpenFilesRdwr();