OffloadUtilsTest - fix yoda conditions
Bernie says 3 <= fd is harder to read then fd >= 3, and I don't disagree.
Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If2c0c1fa4a533375ec990d969f3a932e381929aa
diff --git a/server/OffloadUtilsTest.cpp b/server/OffloadUtilsTest.cpp
index a7b132e..5ca841f 100644
--- a/server/OffloadUtilsTest.cpp
+++ b/server/OffloadUtilsTest.cpp
@@ -102,7 +102,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getClatEgressMapFd();
- ASSERT_LE(3, fd); // 0,1,2 - stdin/out/err, thus 3 <= fd
+ ASSERT_GE(fd, 3); // 0,1,2 - stdin/out/err, thus fd >= 3
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -111,7 +111,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getClatEgressProgFd(RAWIP);
- ASSERT_LE(3, fd);
+ ASSERT_GE(fd, 3);
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -120,7 +120,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getClatEgressProgFd(ETHER);
- ASSERT_LE(3, fd);
+ ASSERT_GE(fd, 3);
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -129,7 +129,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getClatIngressMapFd();
- ASSERT_LE(3, fd); // 0,1,2 - stdin/out/err, thus 3 <= fd
+ ASSERT_GE(fd, 3); // 0,1,2 - stdin/out/err, thus fd >= 3
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -138,7 +138,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getClatIngressProgFd(RAWIP);
- ASSERT_LE(3, fd);
+ ASSERT_GE(fd, 3);
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -147,7 +147,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getClatIngressProgFd(ETHER);
- ASSERT_LE(3, fd);
+ ASSERT_GE(fd, 3);
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -156,7 +156,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getTetherIngressMapFd();
- ASSERT_LE(3, fd); // 0,1,2 - stdin/out/err, thus 3 <= fd
+ ASSERT_GE(fd, 3); // 0,1,2 - stdin/out/err, thus fd >= 3
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -167,7 +167,7 @@
SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED;
int fd = getTetherIngressProgFd(RAWIP);
- ASSERT_LE(3, fd);
+ ASSERT_GE(fd, 3);
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -178,7 +178,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getTetherIngressProgFd(ETHER);
- ASSERT_LE(3, fd);
+ ASSERT_GE(fd, 3);
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -187,7 +187,7 @@
SKIP_IF_BPF_NOT_SUPPORTED;
int fd = getTetherStatsMapFd();
- ASSERT_LE(3, fd); // 0,1,2 - stdin/out/err, thus 3 <= fd
+ ASSERT_GE(fd, 3); // 0,1,2 - stdin/out/err, thus fd >= 3
EXPECT_EQ(FD_CLOEXEC, fcntl(fd, F_GETFD));
close(fd);
}
@@ -265,12 +265,12 @@
: EINVAL;
int clatBpfFd = ingress ? getClatIngressProgFd(ethernet) : getClatEgressProgFd(ethernet);
- ASSERT_LE(3, clatBpfFd);
+ ASSERT_GE(clatBpfFd, 3);
int tetherBpfFd = -1;
if (extended && ingress) {
tetherBpfFd = getTetherIngressProgFd(ethernet);
- ASSERT_LE(3, tetherBpfFd);
+ ASSERT_GE(tetherBpfFd, 3);
}
// This attaches and detaches a clsact plus ebpf program to loopback