From 8457b74c2605d524a2bc7e9db264b50820b54685 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Tue, 15 Oct 2013 11:58:19 -0700 Subject: [PATCH] Fix Unit test when run on tmpfs Summary: tmpfs might not support fallocate(). Fix unit test so that this does not cause a unit test to fail. Test Plan: ./env_test Reviewers: emayanke, igor, kailiu Reviewed By: kailiu CC: leveldb Differential Revision: https://reviews.facebook.net/D13455 --- util/env_test.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/env_test.cc b/util/env_test.cc index 2163ad14b..2584b4a3c 100644 --- a/util/env_test.cc +++ b/util/env_test.cc @@ -364,7 +364,10 @@ TEST(EnvPosixTest, PosixRandomRWFileTest) { unique_ptr file; ASSERT_OK(env_->NewRandomRWFile(fname, &file, soptions)); - ASSERT_OK(file.get()->Allocate(0, 10*1024*1024)); + // If you run the unit test on tmpfs, then tmpfs might not + // support ftruncate. It is still better to trigger that + // code-path instead of eliminating it completely. + file.get()->Allocate(0, 10*1024*1024); ASSERT_OK(file.get()->Write(100, Slice("Hello world"))); ASSERT_OK(file.get()->Write(105, Slice("Hello world"))); ASSERT_OK(file.get()->Sync()); -- GitLab