|
|
@ -172,8 +172,8 @@ TEST(EnvPosixTest, TwoPools) { |
|
|
|
env_->SetBackgroundThreads(kLowPoolSize); |
|
|
|
env_->SetBackgroundThreads(kLowPoolSize); |
|
|
|
env_->SetBackgroundThreads(kHighPoolSize, Env::Priority::HIGH); |
|
|
|
env_->SetBackgroundThreads(kHighPoolSize, Env::Priority::HIGH); |
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(0, env_->GetThreadPoolQueueLen(Env::Priority::LOW)); |
|
|
|
ASSERT_EQ(0U, env_->GetThreadPoolQueueLen(Env::Priority::LOW)); |
|
|
|
ASSERT_EQ(0, env_->GetThreadPoolQueueLen(Env::Priority::HIGH)); |
|
|
|
ASSERT_EQ(0U, env_->GetThreadPoolQueueLen(Env::Priority::HIGH)); |
|
|
|
|
|
|
|
|
|
|
|
// schedule same number of jobs in each pool
|
|
|
|
// schedule same number of jobs in each pool
|
|
|
|
for (int i = 0; i < kJobs; i++) { |
|
|
|
for (int i = 0; i < kJobs; i++) { |
|
|
@ -182,10 +182,11 @@ TEST(EnvPosixTest, TwoPools) { |
|
|
|
} |
|
|
|
} |
|
|
|
// Wait a short while for the jobs to be dispatched.
|
|
|
|
// Wait a short while for the jobs to be dispatched.
|
|
|
|
Env::Default()->SleepForMicroseconds(kDelayMicros); |
|
|
|
Env::Default()->SleepForMicroseconds(kDelayMicros); |
|
|
|
ASSERT_EQ(kJobs - kLowPoolSize, env_->GetThreadPoolQueueLen()); |
|
|
|
ASSERT_EQ((unsigned int)(kJobs - kLowPoolSize), |
|
|
|
ASSERT_EQ(kJobs - kLowPoolSize, |
|
|
|
env_->GetThreadPoolQueueLen()); |
|
|
|
|
|
|
|
ASSERT_EQ((unsigned int)(kJobs - kLowPoolSize), |
|
|
|
env_->GetThreadPoolQueueLen(Env::Priority::LOW)); |
|
|
|
env_->GetThreadPoolQueueLen(Env::Priority::LOW)); |
|
|
|
ASSERT_EQ(kJobs - kHighPoolSize, |
|
|
|
ASSERT_EQ((unsigned int)(kJobs - kHighPoolSize), |
|
|
|
env_->GetThreadPoolQueueLen(Env::Priority::HIGH)); |
|
|
|
env_->GetThreadPoolQueueLen(Env::Priority::HIGH)); |
|
|
|
|
|
|
|
|
|
|
|
// wait for all jobs to finish
|
|
|
|
// wait for all jobs to finish
|
|
|
@ -194,8 +195,8 @@ TEST(EnvPosixTest, TwoPools) { |
|
|
|
env_->SleepForMicroseconds(kDelayMicros); |
|
|
|
env_->SleepForMicroseconds(kDelayMicros); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(0, env_->GetThreadPoolQueueLen(Env::Priority::LOW)); |
|
|
|
ASSERT_EQ(0U, env_->GetThreadPoolQueueLen(Env::Priority::LOW)); |
|
|
|
ASSERT_EQ(0, env_->GetThreadPoolQueueLen(Env::Priority::HIGH)); |
|
|
|
ASSERT_EQ(0U, env_->GetThreadPoolQueueLen(Env::Priority::HIGH)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool IsSingleVarint(const std::string& s) { |
|
|
|
bool IsSingleVarint(const std::string& s) { |
|
|
@ -296,18 +297,18 @@ TEST(EnvPosixTest, AllocateTest) { |
|
|
|
|
|
|
|
|
|
|
|
struct stat f_stat; |
|
|
|
struct stat f_stat; |
|
|
|
stat(fname.c_str(), &f_stat); |
|
|
|
stat(fname.c_str(), &f_stat); |
|
|
|
ASSERT_EQ(data.size(), f_stat.st_size); |
|
|
|
ASSERT_EQ((unsigned int)data.size(), f_stat.st_size); |
|
|
|
// verify that blocks are preallocated
|
|
|
|
// verify that blocks are preallocated
|
|
|
|
ASSERT_EQ(kPreallocateSize / kBlockSize, f_stat.st_blocks); |
|
|
|
ASSERT_EQ((unsigned int)(kPreallocateSize / kBlockSize), f_stat.st_blocks); |
|
|
|
|
|
|
|
|
|
|
|
// close the file, should deallocate the blocks
|
|
|
|
// close the file, should deallocate the blocks
|
|
|
|
wfile.reset(); |
|
|
|
wfile.reset(); |
|
|
|
|
|
|
|
|
|
|
|
stat(fname.c_str(), &f_stat); |
|
|
|
stat(fname.c_str(), &f_stat); |
|
|
|
ASSERT_EQ(data.size(), f_stat.st_size); |
|
|
|
ASSERT_EQ((unsigned int)data.size(), f_stat.st_size); |
|
|
|
// verify that preallocated blocks were deallocated on file close
|
|
|
|
// verify that preallocated blocks were deallocated on file close
|
|
|
|
size_t data_blocks_pages = ((data.size() + kPageSize - 1) / kPageSize); |
|
|
|
size_t data_blocks_pages = ((data.size() + kPageSize - 1) / kPageSize); |
|
|
|
ASSERT_EQ(data_blocks_pages * kPageSize / kBlockSize, f_stat.st_blocks); |
|
|
|
ASSERT_EQ((unsigned int)(data_blocks_pages * kPageSize / kBlockSize), f_stat.st_blocks); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|