diff options
| author | levlam <levlam@telegram.org> | 2023-04-23 02:01:51 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2023-04-23 02:01:51 +0300 |
| commit | 7e60c440ffa67b8c7121fe1b2b8fadc6498d1bb7 (patch) | |
| tree | d4819f89e1650238d448d39524c282a21893a3f2 | |
| parent | bed72ccf143430a815e73fdb214d5219732bfa55 (diff) | |
Delete temporary files after test finish.
| -rw-r--r-- | tdactor/test/actors_simple.cpp | 5 | ||||
| -rw-r--r-- | tdutils/test/port.cpp | 1 | ||||
| -rw-r--r-- | test/db.cpp | 4 | ||||
| -rw-r--r-- | test/http.cpp | 1 | ||||
| -rw-r--r-- | test/secure_storage.cpp | 3 | ||||
| -rw-r--r-- | test/tqueue.cpp | 9 |
6 files changed, 22 insertions, 1 deletions
diff --git a/tdactor/test/actors_simple.cpp b/tdactor/test/actors_simple.cpp index be1a78b25..4782ed208 100644 --- a/tdactor/test/actors_simple.cpp +++ b/tdactor/test/actors_simple.cpp @@ -15,6 +15,7 @@ #include "td/utils/MpscPollableQueue.h" #include "td/utils/Observer.h" #include "td/utils/port/FileFd.h" +#include "td/utils/port/path.h" #include "td/utils/port/thread.h" #include "td/utils/Promise.h" #include "td/utils/Slice.h" @@ -281,8 +282,9 @@ class OpenClose final : public td::Actor { } void wakeup() final { auto observer = reinterpret_cast<td::ObserverBase *>(123); + td::CSlice file_name = "server"; if (cnt_ > 0) { - auto r_file_fd = td::FileFd::open("server", td::FileFd::Read | td::FileFd::Create); + auto r_file_fd = td::FileFd::open(file_name, td::FileFd::Read | td::FileFd::Create); LOG_CHECK(r_file_fd.is_ok()) << r_file_fd.error(); auto file_fd = r_file_fd.move_as_ok(); { auto pollable_fd = file_fd.get_poll_info().extract_pollable_fd(observer); } @@ -290,6 +292,7 @@ class OpenClose final : public td::Actor { cnt_--; yield(); } else { + td::unlink(file_name); td::Scheduler::instance()->finish(); } } diff --git a/tdutils/test/port.cpp b/tdutils/test/port.cpp index 1c870f212..4b01169fa 100644 --- a/tdutils/test/port.cpp +++ b/tdutils/test/port.cpp @@ -106,6 +106,7 @@ TEST(Port, files) { fd.seek(0).ensure(); ASSERT_EQ(13u, fd.read(buf_slice.substr(0, 13)).move_as_ok()); ASSERT_STREQ("Habcd world?!", buf_slice.substr(0, 13)); + td::rmrf(main_dir).ensure(); } TEST(Port, SparseFiles) { diff --git a/test/db.cpp b/test/db.cpp index ffbd78ba1..9e56e331f 100644 --- a/test/db.cpp +++ b/test/db.cpp @@ -63,6 +63,7 @@ TEST(DB, binlog_encryption_bug) { binlog_name.str(), [&](const td::BinlogEvent &x) {}, cucumber) .ensure(); } + td::Binlog::destroy(binlog_name).ignore(); } TEST(DB, binlog_encryption) { @@ -91,6 +92,7 @@ TEST(DB, binlog_encryption) { binlog.close().ensure(); } + td::Binlog::destroy(binlog_name).ignore(); return; auto add_suffix = [&] { @@ -132,6 +134,8 @@ TEST(DB, binlog_encryption) { binlog_name.str(), [&](const td::BinlogEvent &x) { v.push_back(x.get_data().str()); }, cucumber, hello); CHECK(v == td::vector<td::string>({"AAAA", "BBBB", long_data, "CCCC"})); } + + td::Binlog::destroy(binlog_name).ignore(); } TEST(DB, sqlite_lfs) { diff --git a/test/http.cpp b/test/http.cpp index 74cf90e3e..e3d2301f6 100644 --- a/test/http.cpp +++ b/test/http.cpp @@ -347,6 +347,7 @@ TEST(Http, aes_file_encryption) { auto result = sink.result()->move_as_buffer_slice().as_slice().str(); ASSERT_EQ(str, result); } + td::unlink(name).ignore(); } TEST(Http, chunked_flow) { diff --git a/test/secure_storage.cpp b/test/secure_storage.cpp index 2126054f8..714e92f77 100644 --- a/test/secure_storage.cpp +++ b/test/secure_storage.cpp @@ -67,5 +67,8 @@ TEST(SecureStorage, simple) { auto hash = td::secure_storage::encrypt_file(value_secret, value_path, encrypted_path).move_as_ok(); td::secure_storage::decrypt_file(value_secret, hash, encrypted_path, decrypted_path).ensure(); ASSERT_TRUE(td::read_file(decrypted_path).move_as_ok().as_slice() == file_value); + td::unlink(value_path).ignore(); + td::unlink(encrypted_path).ignore(); + td::unlink(decrypted_path).ignore(); } } diff --git a/test/tqueue.cpp b/test/tqueue.cpp index bbfc5000a..9c3da0034 100644 --- a/test/tqueue.cpp +++ b/test/tqueue.cpp @@ -68,6 +68,15 @@ class TestTQueue { binlog_->set_callback(std::move(tqueue_binlog)); } + TestTQueue(const TestTQueue &) = delete; + TestTQueue &operator=(const TestTQueue &) = delete; + TestTQueue(TestTQueue &&) = delete; + TestTQueue &operator=(TestTQueue &&) = delete; + + ~TestTQueue() { + td::Binlog::destroy(binlog_path()).ensure(); + } + void restart(td::Random::Xorshift128plus &rnd, td::int32 now) { if (rnd.fast(0, 10) == 0) { baseline_->run_gc(now); |
