Commit a91ed7e3 authored by Tom Jackson's avatar Tom Jackson Committed by Pavlo Kushnir

Remove volatile from MemoryMappingTest

Summary: Not needed, I don't know why I put them there before.

Test Plan: Run the unit test

Reviewed By: njormrod@fb.com

Subscribers: njormrod, folly-diffs@

FB internal diff: D1665689

Tasks: 5487902

Signature: t1:1665689:1415323144:0998e7f700a3b40652615a36c3b9c9f661fbdadf
parent 27d533e5
......@@ -23,18 +23,17 @@ namespace folly {
TEST(MemoryMapping, Basic) {
File f = File::temporary();
{
MemoryMapping m(File(f.fd()), 0, sizeof(double),
MemoryMapping::writable());
double volatile* d = m.asWritableRange<double>().data();
MemoryMapping m(File(f.fd()), 0, sizeof(double), MemoryMapping::writable());
double* d = m.asWritableRange<double>().data();
*d = 37 * M_PI;
}
{
MemoryMapping m(File(f.fd()), 0, 3);
EXPECT_EQ(0, m.asRange<int>().size()); //not big enough
EXPECT_EQ(0, m.asRange<int>().size()); // not big enough
}
{
MemoryMapping m(File(f.fd()), 0, sizeof(double));
const double volatile* d = m.asRange<double>().data();
const double* d = m.asRange<double>().data();
EXPECT_EQ(*d, 37 * M_PI);
}
}
......@@ -42,20 +41,20 @@ TEST(MemoryMapping, Basic) {
TEST(MemoryMapping, Move) {
File f = File::temporary();
{
MemoryMapping m(File(f.fd()), 0, sizeof(double) * 2,
MemoryMapping::writable());
double volatile* d = m.asWritableRange<double>().data();
MemoryMapping m(
File(f.fd()), 0, sizeof(double) * 2, MemoryMapping::writable());
double* d = m.asWritableRange<double>().data();
d[0] = 37 * M_PI;
MemoryMapping m2(std::move(m));
double volatile* d2 = m2.asWritableRange<double>().data();
double* d2 = m2.asWritableRange<double>().data();
d2[1] = 39 * M_PI;
}
{
MemoryMapping m(File(f.fd()), 0, sizeof(double));
const double volatile* d = m.asRange<double>().data();
const double* d = m.asRange<double>().data();
EXPECT_EQ(d[0], 37 * M_PI);
MemoryMapping m2(std::move(m));
const double volatile* d2 = m2.asRange<double>().data();
const double* d2 = m2.asRange<double>().data();
EXPECT_EQ(d2[1], 39 * M_PI);
}
}
......@@ -63,12 +62,11 @@ TEST(MemoryMapping, Move) {
TEST(MemoryMapping, DoublyMapped) {
File f = File::temporary();
// two mappings of the same memory, different addresses.
MemoryMapping mw(File(f.fd()), 0, sizeof(double),
MemoryMapping::writable());
MemoryMapping mw(File(f.fd()), 0, sizeof(double), MemoryMapping::writable());
MemoryMapping mr(File(f.fd()), 0, sizeof(double));
double volatile* dw = mw.asWritableRange<double>().data();
const double volatile* dr = mr.asRange<double>().data();
double* dw = mw.asWritableRange<double>().data();
const double* dr = mr.asRange<double>().data();
// Show that it's truly the same value, even though the pointers differ
EXPECT_NE(dw, dr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment