@@ -28,26 +28,26 @@ using facebook::cachelib::detail::getPageSize;
2828using facebook::cachelib::detail::getPageSizeInSMap;
2929using facebook::cachelib::detail::isPageAlignedSize;
3030
31- void ShmTest::testCreateAttach (bool posix ) {
31+ void ShmTest::testCreateAttach () {
3232 const unsigned char magicVal = ' d' ;
3333 {
3434 // create with 0 size should round up to page size
35- ShmSegment s (ShmNew, segmentName, 0 , posix );
35+ ShmSegment s (ShmNew, segmentName, 0 , opts );
3636 ASSERT_EQ (getPageSize (), s.getSize ());
3737 s.markForRemoval ();
3838 }
3939
4040 {
4141 // create with unaligned size
4242 ASSERT_TRUE (isPageAlignedSize (shmSize));
43- ShmSegment s (ShmNew, segmentName, shmSize + 500 , posix );
43+ ShmSegment s (ShmNew, segmentName, shmSize + 500 , opts );
4444 ASSERT_EQ (shmSize + getPageSize (), s.getSize ());
4545 s.markForRemoval ();
4646 }
4747 auto addr = getNewUnmappedAddr ();
4848
4949 {
50- ShmSegment s (ShmNew, segmentName, shmSize, posix );
50+ ShmSegment s (ShmNew, segmentName, shmSize, opts );
5151 ASSERT_EQ (s.getSize (), shmSize);
5252 ASSERT_FALSE (s.isMapped ());
5353 ASSERT_TRUE (s.mapAddress (addr));
@@ -57,14 +57,14 @@ void ShmTest::testCreateAttach(bool posix) {
5757 ASSERT_TRUE (s.isMapped ());
5858 checkMemory (addr, s.getSize (), 0 );
5959 writeToMemory (addr, s.getSize (), magicVal);
60- ASSERT_THROW (ShmSegment (ShmNew, segmentName, shmSize, posix ),
60+ ASSERT_THROW (ShmSegment (ShmNew, segmentName, shmSize, opts ),
6161 std::system_error);
6262 const auto m = s.getCurrentMapping ();
6363 ASSERT_EQ (m.size , shmSize);
6464 }
6565
6666 ASSERT_NO_THROW ({
67- ShmSegment s2 (ShmAttach, segmentName, posix );
67+ ShmSegment s2 (ShmAttach, segmentName, opts );
6868 ASSERT_EQ (s2.getSize (), shmSize);
6969 ASSERT_TRUE (s2.mapAddress (addr));
7070 checkMemory (addr, s2.getSize (), magicVal);
@@ -73,15 +73,17 @@ void ShmTest::testCreateAttach(bool posix) {
7373 });
7474}
7575
76- TEST_F (ShmTestPosix, CreateAttach) { testCreateAttach (true ); }
76+ TEST_F (ShmTestPosix, CreateAttach) { testCreateAttach (); }
7777
78- TEST_F (ShmTestSysV, CreateAttach) { testCreateAttach (false ); }
78+ TEST_F (ShmTestSysV, CreateAttach) { testCreateAttach (); }
7979
80- void ShmTest::testMapping (bool posix) {
80+ TEST_F (ShmTestFile, CreateAttach) { testCreateAttach (); }
81+
82+ void ShmTest::testMapping () {
8183 const unsigned char magicVal = ' z' ;
8284 auto addr = getNewUnmappedAddr ();
8385 { // create a segment
84- ShmSegment s (ShmNew, segmentName, shmSize, posix );
86+ ShmSegment s (ShmNew, segmentName, shmSize, opts );
8587 ASSERT_TRUE (s.mapAddress (addr));
8688 ASSERT_TRUE (s.isMapped ());
8789 // creating another mapping should fail
@@ -95,7 +97,7 @@ void ShmTest::testMapping(bool posix) {
9597
9698 // map with nullptr
9799 {
98- ShmSegment s (ShmAttach, segmentName, posix );
100+ ShmSegment s (ShmAttach, segmentName, opts );
99101 ASSERT_TRUE (s.mapAddress (nullptr ));
100102 ASSERT_TRUE (s.isMapped ());
101103 const auto m = s.getCurrentMapping ();
@@ -107,7 +109,7 @@ void ShmTest::testMapping(bool posix) {
107109 }
108110
109111 {
110- ShmSegment s (ShmAttach, segmentName, posix );
112+ ShmSegment s (ShmAttach, segmentName, opts );
111113 // can map again.
112114 ASSERT_TRUE (s.mapAddress (addr));
113115 ASSERT_TRUE (s.isMapped ());
@@ -148,13 +150,15 @@ void ShmTest::testMapping(bool posix) {
148150 }
149151}
150152
151- TEST_F (ShmTestPosix, Mapping) { testMapping (true ); }
153+ TEST_F (ShmTestPosix, Mapping) { testMapping (); }
154+
155+ TEST_F (ShmTestSysV, Mapping) { testMapping (); }
152156
153- TEST_F (ShmTestSysV , Mapping) { testMapping (false ); }
157+ TEST_F (ShmTestFile , Mapping) { testMapping (); }
154158
155- void ShmTest::testMappingAlignment (bool posix ) {
159+ void ShmTest::testMappingAlignment () {
156160 { // create a segment
157- ShmSegment s (ShmNew, segmentName, shmSize, posix );
161+ ShmSegment s (ShmNew, segmentName, shmSize, opts );
158162
159163 // 0 alignment is wrong.
160164 ASSERT_FALSE (s.mapAddress (nullptr , 0 ));
@@ -171,11 +175,13 @@ void ShmTest::testMappingAlignment(bool posix) {
171175 }
172176}
173177
174- TEST_F (ShmTestPosix, MappingAlignment) { testMappingAlignment (true ); }
178+ TEST_F (ShmTestPosix, MappingAlignment) { testMappingAlignment (); }
179+
180+ TEST_F (ShmTestSysV, MappingAlignment) { testMappingAlignment (); }
175181
176- TEST_F (ShmTestSysV , MappingAlignment) { testMappingAlignment (false ); }
182+ TEST_F (ShmTestFile , MappingAlignment) { testMappingAlignment (); }
177183
178- void ShmTest::testLifetime (bool posix ) {
184+ void ShmTest::testLifetime () {
179185 const size_t safeSize = getRandomSize ();
180186 const char magicVal = ' x' ;
181187 ASSERT_NO_THROW ({
@@ -184,7 +190,7 @@ void ShmTest::testLifetime(bool posix) {
184190 // from address space. this should not actually delete the segment and
185191 // we should be able to map it back as long as the object is within the
186192 // scope.
187- ShmSegment s (ShmNew, segmentName, safeSize, posix );
193+ ShmSegment s (ShmNew, segmentName, safeSize, opts );
188194 s.mapAddress (nullptr );
189195 auto m = s.getCurrentMapping ();
190196 writeToMemory (m.addr , m.size , magicVal);
@@ -200,14 +206,14 @@ void ShmTest::testLifetime(bool posix) {
200206 // should be able to create a new segment with same segmentName after the
201207 // previous scope exit destroys the segment.
202208 const size_t newSize = getRandomSize ();
203- ShmSegment s (ShmNew, segmentName, newSize, posix );
209+ ShmSegment s (ShmNew, segmentName, newSize, opts );
204210 s.mapAddress (nullptr );
205211 auto m = s.getCurrentMapping ();
206212 checkMemory (m.addr , m.size , 0 );
207213 writeToMemory (m.addr , m.size , magicVal);
208214 }
209215 // attaching should have the same behavior.
210- ShmSegment s (ShmAttach, segmentName, posix );
216+ ShmSegment s (ShmAttach, segmentName, opts );
211217 s.mapAddress (nullptr );
212218 s.markForRemoval ();
213219 ASSERT_TRUE (s.isMarkedForRemoval ());
@@ -218,5 +224,6 @@ void ShmTest::testLifetime(bool posix) {
218224 });
219225}
220226
221- TEST_F (ShmTestPosix, Lifetime) { testLifetime (true ); }
222- TEST_F (ShmTestSysV, Lifetime) { testLifetime (false ); }
227+ TEST_F (ShmTestPosix, Lifetime) { testLifetime (); }
228+ TEST_F (ShmTestSysV, Lifetime) { testLifetime (); }
229+ TEST_F (ShmTestFile, Lifetime) { testLifetime (); }
0 commit comments