Delete temporary files after test finish.
This commit is contained in:
parent
bed72ccf14
commit
7e60c440ff
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user