Skip to content

Commit

Permalink
Fix stricter fbcode compiler settings
Browse files Browse the repository at this point in the history
Summary: Apparently, the compiler settings are now stricter.

Reviewed By: hanghu

Differential Revision: D69677824

fbshipit-source-id: 1533f17e6b15c8d0c1a0955005c2f449f6ab33c6
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Feb 15, 2025
1 parent caec653 commit c91d458
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sample_apps/SampleRecordingApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace vrs_sample_apps;
namespace vrs_sample_apps {

// Use your own clock source.
double getTimestampSec() {
static double getTimestampSec() {
using namespace std::chrono;
return duration_cast<duration<double>>(steady_clock::now().time_since_epoch()).count();
}
Expand Down
2 changes: 1 addition & 1 deletion tools/vrs/test/VrsCommandTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using coretech::getTestDataDir;

struct VrsCommandTest : testing::Test {};

bool parse(VrsCommand& command, vector<string>& args, int& argn, int& outStatusCode) {
static bool parse(VrsCommand& command, vector<string>& args, int& argn, int& outStatusCode) {
argn = 0;
outStatusCode = EXIT_SUCCESS;
vector<char*> argvs(args.size());
Expand Down
10 changes: 5 additions & 5 deletions vrs/test/GetRecordTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ struct GetRecordTester : testing::Test {
string kTestFile3 = os::pathJoin(coretech::getTestDataDir(), "VRS_Files/chunks.vrs");
string kTestFile4 = os::pathJoin(coretech::getTestDataDir(), "VRS_Files/chunks-shuffled.vrs");
};
} // namespace

// legacy implementation, without caching
static const IndexRecord::RecordInfo* getRecord(
const IndexRecord::RecordInfo* getRecord(
vrs::RecordFileReader& file,
StreamId streamId,
Record::Type recordType,
Expand All @@ -58,8 +57,7 @@ static const IndexRecord::RecordInfo* getRecord(
return nullptr;
}

inline void
check(vrs::RecordFileReader& file, StreamId id, Record::Type type, uint32_t indexNumber) {
void check(vrs::RecordFileReader& file, StreamId id, Record::Type type, uint32_t indexNumber) {
// Compare the old method and the new method
const IndexRecord::RecordInfo* ref = getRecord(file, id, type, indexNumber);
EXPECT_EQ(ref, file.getRecord(id, type, indexNumber));
Expand All @@ -68,7 +66,7 @@ check(vrs::RecordFileReader& file, StreamId id, Record::Type type, uint32_t inde
EXPECT_EQ(ref, file.getRecord(id, type, indexNumber));
}

static bool isCloserThan(
bool isCloserThan(
const IndexRecord::RecordInfo& closer,
double timestamp,
const IndexRecord::RecordInfo& farther) {
Expand Down Expand Up @@ -226,6 +224,8 @@ void checkIndex(vrs::RecordFileReader& file, uint32_t recordIndex) {
EXPECT_NE(r, nullptr);
}

} // namespace

TEST_F(GetRecordTester, GetRecordTest) {
vrs::RecordFileReader file;
EXPECT_EQ(file.openFile(kTestFile), 0);
Expand Down
8 changes: 8 additions & 0 deletions vrs/test/MultiRecordFileReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class TestRecordable : public Recordable {
MyMetadata metadata_;
};

namespace {

struct VrsFileBuilder {
explicit VrsFileBuilder(string path) : path_{std::move(path)} {
XR_CHECK_FALSE(os::isFile(path_));
Expand Down Expand Up @@ -237,6 +239,8 @@ class RecordFormatTestStreamPlayer : public RecordFormatStreamPlayer {
int counter{};
};

} // namespace

class MultiRecordFileReaderTest : public testing::Test {};

TEST_F(MultiRecordFileReaderTest, invalidFilePaths) {
Expand Down Expand Up @@ -285,6 +289,8 @@ TEST_F(MultiRecordFileReaderTest, relatedFiles) {
removeFiles(unrelatedFilePaths);
}

namespace {

vector<double> getNonDecreasingTimestamps(
const size_t count,
const double startTimestamp = 0,
Expand All @@ -299,6 +305,8 @@ vector<double> getNonDecreasingTimestamps(
return timestamps;
}

} // namespace

TEST_F(MultiRecordFileReaderTest, multiFile) {
const auto expectedTimestamps = getNonDecreasingTimestamps(50);
const auto filePaths = getOsTempPaths(4);
Expand Down
4 changes: 2 additions & 2 deletions vrs/test/RecordFormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ class TestRecordable : public Recordable {
}
};

} // namespace

#define FORMAT_EQUAL(_block_format, _cstring) \
EXPECT_STREQ((_block_format).asString().c_str(), _cstring)

Expand Down Expand Up @@ -112,6 +110,8 @@ bool checkImageHeights(
XR_VERIFY(spec.getPlaneHeight(3) == height3) && XR_VERIFY(spec.getPlaneHeight(4) == 0);
}

} // namespace

TEST_F(RecordFormatTest, testBlockFormat) {
ContentBlock emptyString("");
EXPECT_EQ(emptyString.getContentType(), ContentType::CUSTOM);
Expand Down
2 changes: 1 addition & 1 deletion vrs/test/RecordTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ TEST_F(RecordTester, indexSortTest) {
checkIndexOrder(records);
}

void checkSortOrder(const vector<RecordFileWriter::SortRecord>& records) {
static void checkSortOrder(const vector<RecordFileWriter::SortRecord>& records) {
for (size_t first = 0; first < records.size(); first++) {
for (size_t second = first + 1; second < records.size(); second++) {
EXPECT_TRUE(records[first] < records[second]);
Expand Down
2 changes: 1 addition & 1 deletion vrs/test/file_tests/DeviceSimulatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ struct ChunkCollector : public NewChunkHandler {
map<size_t, string>& chunks;
};

void checkChunks(const map<size_t, string>& chunks, const string& path, size_t count) {
static void checkChunks(const map<size_t, string>& chunks, const string& path, size_t count) {
EXPECT_EQ(chunks.size(), count);
if (!chunks.empty()) {
auto iter = chunks.begin();
Expand Down
4 changes: 4 additions & 0 deletions vrs/test/file_tests/FileCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ TEST_F(FileCacheTest, cacheDomainTest) {
EXPECT_EQ(fcache->getFile(domain, "123.txt", location2), INVALID_DISK_DATA);
}

namespace {

void verifyDetails(
const string& cacheFile,
const RecordFileReader& reader,
Expand Down Expand Up @@ -140,6 +142,8 @@ void createRecordsThreadTask(ThreadParam* param) {
testDetails(param->cacheFile, param->reader, param->hasIndex, true);
}

} // namespace

TEST_F(FileCacheTest, detailsTest) {
string kTestFile = os::pathJoin(coretech::getTestDataDir(), "VRS_Files/sample_file.vrs");
const string cacheFile = os::getTempFolder() + "detailsTest.vrsi";
Expand Down
17 changes: 17 additions & 0 deletions vrs/test/helpers/VRSTestsHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ using namespace std;
using namespace vrs;
using namespace vrs::test;

namespace vrs::test {

const FileConfig& getClassicFileConfig() {
static const FileConfig sClassicFileConfig(30, 100);
return sClassicFileConfig;
}
const FileConfig& getLongFileConfig() {
static const FileConfig sLongFileConfig(30, 20000);
return sLongFileConfig;
}
const FileConfig& getVeryLongFileConfig() {
static const FileConfig sVeryLongFileConfig(90, 60000);
return sVeryLongFileConfig;
}

} // namespace vrs::test

namespace {

// Detect if there was any attempt to got back in the file
Expand Down
12 changes: 8 additions & 4 deletions vrs/test/helpers/VRSTestsHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ struct FileConfig {
totalRecordCount = kCameraCount * (2 + frameCount);
}
uint32_t frameRate;
uint32_t simulationDurationMs = 100;
uint32_t simulationDurationMs;
size_t frameCount;
size_t totalRecordCount;
};

const FileConfig kClassicFileConfig(30, 100);
const FileConfig kLongFileConfig(30, 20000);
const FileConfig kVeryLongFileConfig(90, 60000);
const FileConfig& getClassicFileConfig();
const FileConfig& getLongFileConfig();
const FileConfig& getVeryLongFileConfig();

#define kClassicFileConfig test::getClassicFileConfig()
#define kLongFileConfig test::getLongFileConfig()
#define kVeryLongFileConfig test::getVeryLongFileConfig()

/// Parameterization of the VRS file creation, so we can simulate a wide variety of cases.
struct CreateParams {
Expand Down

0 comments on commit c91d458

Please sign in to comment.