@@ -39,9 +39,10 @@ class TestFileNumberGenerator {
39
39
40
40
class BlobFileBuilderTest : public testing ::Test {
41
41
protected:
42
- BlobFileBuilderTest () : mock_env_(Env::Default()) {
43
- fs_ = mock_env_.GetFileSystem ().get ();
44
- clock_ = mock_env_.GetSystemClock ().get ();
42
+ BlobFileBuilderTest () {
43
+ mock_env_.reset (MockEnv::Create (Env::Default ()));
44
+ fs_ = mock_env_->GetFileSystem ().get ();
45
+ clock_ = mock_env_->GetSystemClock ().get ();
45
46
}
46
47
47
48
void VerifyBlobFile (uint64_t blob_file_number,
@@ -108,7 +109,7 @@ class BlobFileBuilderTest : public testing::Test {
108
109
ASSERT_EQ (footer.expiration_range , ExpirationRange ());
109
110
}
110
111
111
- MockEnv mock_env_;
112
+ std::unique_ptr<Env> mock_env_;
112
113
FileSystem* fs_;
113
114
SystemClock* clock_;
114
115
FileOptions file_options_;
@@ -123,11 +124,11 @@ TEST_F(BlobFileBuilderTest, BuildAndCheckOneFile) {
123
124
124
125
Options options;
125
126
options.cf_paths .emplace_back (
126
- test::PerThreadDBPath (& mock_env_,
127
+ test::PerThreadDBPath (mock_env_. get () ,
127
128
" BlobFileBuilderTest_BuildAndCheckOneFile" ),
128
129
0 );
129
130
options.enable_blob_files = true ;
130
- options.env = & mock_env_;
131
+ options.env = mock_env_. get () ;
131
132
132
133
ImmutableOptions immutable_options (options);
133
134
MutableCFOptions mutable_cf_options (options);
@@ -206,12 +207,12 @@ TEST_F(BlobFileBuilderTest, BuildAndCheckMultipleFiles) {
206
207
207
208
Options options;
208
209
options.cf_paths .emplace_back (
209
- test::PerThreadDBPath (& mock_env_,
210
+ test::PerThreadDBPath (mock_env_. get () ,
210
211
" BlobFileBuilderTest_BuildAndCheckMultipleFiles" ),
211
212
0 );
212
213
options.enable_blob_files = true ;
213
214
options.blob_file_size = value_size;
214
- options.env = & mock_env_;
215
+ options.env = mock_env_. get () ;
215
216
216
217
ImmutableOptions immutable_options (options);
217
218
MutableCFOptions mutable_cf_options (options);
@@ -293,11 +294,12 @@ TEST_F(BlobFileBuilderTest, InlinedValues) {
293
294
294
295
Options options;
295
296
options.cf_paths .emplace_back (
296
- test::PerThreadDBPath (&mock_env_, " BlobFileBuilderTest_InlinedValues" ),
297
+ test::PerThreadDBPath (mock_env_.get (),
298
+ " BlobFileBuilderTest_InlinedValues" ),
297
299
0 );
298
300
options.enable_blob_files = true ;
299
301
options.min_blob_size = 1024 ;
300
- options.env = & mock_env_;
302
+ options.env = mock_env_. get () ;
301
303
302
304
ImmutableOptions immutable_options (options);
303
305
MutableCFOptions mutable_cf_options (options);
@@ -347,10 +349,11 @@ TEST_F(BlobFileBuilderTest, Compression) {
347
349
348
350
Options options;
349
351
options.cf_paths .emplace_back (
350
- test::PerThreadDBPath (&mock_env_, " BlobFileBuilderTest_Compression" ), 0 );
352
+ test::PerThreadDBPath (mock_env_.get (), " BlobFileBuilderTest_Compression" ),
353
+ 0 );
351
354
options.enable_blob_files = true ;
352
355
options.blob_compression_type = kSnappyCompression ;
353
- options.env = & mock_env_;
356
+ options.env = mock_env_. get () ;
354
357
355
358
ImmutableOptions immutable_options (options);
356
359
MutableCFOptions mutable_cf_options (options);
@@ -429,11 +432,12 @@ TEST_F(BlobFileBuilderTest, CompressionError) {
429
432
430
433
Options options;
431
434
options.cf_paths .emplace_back (
432
- test::PerThreadDBPath (&mock_env_, " BlobFileBuilderTest_CompressionError" ),
435
+ test::PerThreadDBPath (mock_env_.get (),
436
+ " BlobFileBuilderTest_CompressionError" ),
433
437
0 );
434
438
options.enable_blob_files = true ;
435
439
options.blob_compression_type = kSnappyCompression ;
436
- options.env = & mock_env_;
440
+ options.env = mock_env_. get () ;
437
441
ImmutableOptions immutable_options (options);
438
442
MutableCFOptions mutable_cf_options (options);
439
443
@@ -506,11 +510,12 @@ TEST_F(BlobFileBuilderTest, Checksum) {
506
510
507
511
Options options;
508
512
options.cf_paths .emplace_back (
509
- test::PerThreadDBPath (&mock_env_, " BlobFileBuilderTest_Checksum" ), 0 );
513
+ test::PerThreadDBPath (mock_env_.get (), " BlobFileBuilderTest_Checksum" ),
514
+ 0 );
510
515
options.enable_blob_files = true ;
511
516
options.file_checksum_gen_factory =
512
517
std::make_shared<DummyFileChecksumGenFactory>();
513
- options.env = & mock_env_;
518
+ options.env = mock_env_. get () ;
514
519
515
520
ImmutableOptions immutable_options (options);
516
521
MutableCFOptions mutable_cf_options (options);
@@ -575,12 +580,12 @@ class BlobFileBuilderIOErrorTest
575
580
: public testing::Test,
576
581
public testing::WithParamInterface<std::string> {
577
582
protected:
578
- BlobFileBuilderIOErrorTest ()
579
- : mock_env_( Env::Default()),
580
- fs_ ( mock_env_. GetFileSystem().get()),
581
- sync_point_(GetParam()) { }
583
+ BlobFileBuilderIOErrorTest () : sync_point_(GetParam()) {
584
+ mock_env_. reset ( MockEnv::Create ( Env::Default ()));
585
+ fs_ = mock_env_-> GetFileSystem ().get ();
586
+ }
582
587
583
- MockEnv mock_env_;
588
+ std::unique_ptr<Env> mock_env_;
584
589
FileSystem* fs_;
585
590
FileOptions file_options_;
586
591
std::string sync_point_;
@@ -602,11 +607,12 @@ TEST_P(BlobFileBuilderIOErrorTest, IOError) {
602
607
603
608
Options options;
604
609
options.cf_paths .emplace_back (
605
- test::PerThreadDBPath (&mock_env_, " BlobFileBuilderIOErrorTest_IOError" ),
610
+ test::PerThreadDBPath (mock_env_.get (),
611
+ " BlobFileBuilderIOErrorTest_IOError" ),
606
612
0 );
607
613
options.enable_blob_files = true ;
608
614
options.blob_file_size = value_size;
609
- options.env = & mock_env_;
615
+ options.env = mock_env_. get () ;
610
616
611
617
ImmutableOptions immutable_options (options);
612
618
MutableCFOptions mutable_cf_options (options);
0 commit comments