sql: Switch from environment variables to command switches
Switches the recovery fuzzer from using environment variables to dump the input to using command line flags. The plan is to add more debug flags to make debugging quicker. Change-Id: I8fd53178bd614de19f07f0af6adda804e6d47dc4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5646527 Reviewed-by: Evan Stade <estade@chromium.org> Commit-Queue: Nathan Memmott <memmott@chromium.org> Cr-Commit-Position: refs/heads/main@{#1318834}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
c9293d2432
commit
85c29e170b
@ -40,6 +40,7 @@
|
||||
#include "sql/fuzzers/sql_disk_corruption.pb.h"
|
||||
#include "sql/recovery.h"
|
||||
#include "sql/statement.h"
|
||||
#include "testing/libfuzzer/libfuzzer_exports.h"
|
||||
#include "testing/libfuzzer/proto/lpm_interface.h"
|
||||
#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
|
||||
#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
|
||||
@ -51,9 +52,9 @@ namespace {
|
||||
class Environment {
|
||||
public:
|
||||
Environment()
|
||||
: temp_dir_(MakeTempDir()),
|
||||
db_path_(GetTempFilePath("db.sqlite")),
|
||||
should_dump_input_(std::getenv("LPM_DUMP_NATIVE_INPUT") != nullptr) {
|
||||
: temp_dir_(MakeTempDir()), db_path_(GetTempFilePath("db.sqlite")) {
|
||||
base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
|
||||
should_dump_input_ = command_line.HasSwitch("dump_input");
|
||||
// Logging must be initialized before `ScopedLoggingSettings`. See
|
||||
// <https://crbug.com/331909454>.
|
||||
logging::InitLogging(logging::LoggingSettings{
|
||||
@ -303,6 +304,13 @@ DEFINE_PROTO_FUZZER(const sql_fuzzers::RecoveryFuzzerTestCase& fuzzer_input) {
|
||||
env.AssertTempDirIsEmpty();
|
||||
}
|
||||
|
||||
// One-time early initialization at process startup.
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
// Parse command line arguments
|
||||
base::CommandLine::Init(*argc, *argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
sql::Recovery::Strategy TestCase::RecoveryStrategyFromInt(int input) {
|
||||
|
Reference in New Issue
Block a user