[compiler-rt] [compiler-rt][rtsan] fseek api interception. (PR #122163)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 11:57:19 PST 2025
================
@@ -478,6 +478,80 @@ class RtsanOpenedFileTest : public RtsanFileTest {
int fd = -1;
};
+#if SANITIZER_INTERCEPT_FSEEK
+TEST_F(RtsanOpenedFileTest, FgetposDieWhenRealtime) {
+ auto Func = [this]() {
+ fpos_t pos;
+ int ret = fgetpos(GetOpenFile(), &pos);
+ ASSERT_THAT(ret, Eq(0));
+ };
+
+ ExpectRealtimeDeath(Func, MAYBE_APPEND_64("fgetpos"));
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, FsetposDieWhenRealtime) {
+ fpos_t pos;
+ int ret = fgetpos(GetOpenFile(), &pos);
+ ASSERT_THAT(ret, Eq(0));
+ auto Func = [this, pos]() {
+ int ret = fsetpos(GetOpenFile(), &pos);
+ ASSERT_THAT(ret, Eq(0));
+ };
+
+ ExpectRealtimeDeath(Func, MAYBE_APPEND_64("fsetpos"));
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, FseekDieWhenRealtime) {
+ auto Func = [this]() {
+ int ret = fseek(GetOpenFile(), 0, SEEK_CUR);
+ ASSERT_THAT(ret, Eq(0));
+ };
+
+ ExpectRealtimeDeath(Func, "fseek");
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, FseekoDieWhenRealtime) {
+ auto Func = [this]() {
+ int ret = fseeko(GetOpenFile(), 0, SEEK_CUR);
+ ASSERT_THAT(ret, Eq(0));
+ };
+
+ ExpectRealtimeDeath(Func, MAYBE_APPEND_64("fseeko"));
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, FtellDieWhenRealtime) {
+ auto Func = [this]() {
+ long ret = ftell(GetOpenFile());
+ ASSERT_THAT(ret, Eq(0));
+ };
+
+ ExpectRealtimeDeath(Func, "ftell");
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, FtelloDieWhenRealtime) {
+ auto Func = [this]() {
+ off_t ret = ftello(GetOpenFile());
+ ASSERT_THAT(ret, Eq(0));
+ };
+
+ ExpectRealtimeDeath(Func, MAYBE_APPEND_64("ftello"));
+ ExpectNonRealtimeSurvival(Func);
+}
+
+TEST_F(RtsanOpenedFileTest, RewindDieWhenRealtime) {
+ int end = fseek(GetOpenFile(), 0, SEEK_END);
----------------
devnexen wrote:
sure, doing it now.
https://github.com/llvm/llvm-project/pull/122163
More information about the llvm-commits
mailing list