Testing LogReader Corrupt Data Handling in openpilot
This test suite validates the LogReader functionality in openpilot’s replay tools, focusing on handling corrupt log files and data integrity. It ensures the system can properly process and validate log data even under compromised conditions.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
commaai/openpilot
tools/replay/tests/test_replay.cc
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
#include "tools/replay/replay.h"
const std::string TEST_RLOG_URL = "https://commadataci.blob.core.windows.net/openpilotci/0c94aa1e1296d7c6/2021-05-05--19-48-37/0/rlog.bz2";
TEST_CASE("LogReader") {
SECTION("corrupt log") {
FileReader reader(true);
std::string corrupt_content = reader.read(TEST_RLOG_URL);
corrupt_content.resize(corrupt_content.length() / 2);
corrupt_content = decompressBZ2(corrupt_content);
LogReader log;
REQUIRE(log.load(corrupt_content.data(), corrupt_content.size()));
REQUIRE(log.events.size() > 0);
}
}