_Z23validateErrorsToMonitorRNSt3__16vectorINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS4_IS6_EEEE:
   11|    831|{
   12|    831|    assert(errorsToMonitor.size());
  ------------------
  |  Branch (12:5): [True: 831, False: 0]
  ------------------
   13|       |
   14|    831|    const std::vector<std::string> validErrorsToMonitor = {
   15|    831|        "default", "timeout", "failed", "dependency"};
   16|    831|    for (const auto& errorToMonitor : errorsToMonitor)
  ------------------
  |  Branch (16:37): [True: 831, False: 780]
  ------------------
   17|    831|    {
   18|    831|        if (std::find(validErrorsToMonitor.begin(), validErrorsToMonitor.end(),
  ------------------
  |  Branch (18:13): [True: 51, False: 780]
  ------------------
   19|    831|                      errorToMonitor) == validErrorsToMonitor.end())
   20|     51|        {
   21|     51|            throw std::out_of_range("Found invalid error to monitor");
   22|     51|        }
   23|    831|    }
   24|       |    // See if default was in the errors to monitor, if so replace with defaults
   25|    780|    auto errorItr =
   26|    780|        std::find(errorsToMonitor.begin(), errorsToMonitor.end(), "default");
   27|    780|    if (errorItr != errorsToMonitor.end())
  ------------------
  |  Branch (27:9): [True: 780, False: 0]
  ------------------
   28|    780|    {
   29|       |        // Verify default is the only entry
   30|    780|        if (errorsToMonitor.size() != 1)
  ------------------
  |  Branch (30:13): [True: 0, False: 780]
  ------------------
   31|      0|        {
   32|      0|            throw std::invalid_argument(
   33|      0|                "default must be only error to monitor");
   34|      0|        }
   35|       |        // delete "default" and insert defaults
   36|    780|        errorsToMonitor.erase(errorItr);
   37|    780|        errorsToMonitor.emplace_back("timeout");
   38|    780|        errorsToMonitor.emplace_back("failed");
   39|    780|        errorsToMonitor.emplace_back("dependency");
   40|    780|    }
   41|    780|}
_Z10parseFilesRKNSt3__16vectorINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS4_IS6_EEEE:
   44|  4.44k|{
   45|  4.44k|    TargetErrorData systemdTargetMap;
   46|  4.44k|    for (const auto& jsonFile : filePaths)
  ------------------
  |  Branch (46:31): [True: 4.44k, False: 4.44k]
  ------------------
   47|  4.44k|    {
   48|  4.44k|        if (gVerbose)
  ------------------
  |  Branch (48:13): [True: 0, False: 4.44k]
  ------------------
   49|      0|        {
   50|      0|            debug("Parsing input file {FILE}", "FILE", jsonFile);
   51|      0|        }
   52|  4.44k|        std::ifstream fileStream(jsonFile);
   53|  4.44k|        if (!fileStream.is_open())
  ------------------
  |  Branch (53:13): [True: 0, False: 4.44k]
  ------------------
   54|      0|        {
   55|      0|            error("Failed to open target monitor file: {FILE}", "FILE",
   56|      0|                  jsonFile);
   57|      0|            continue;
   58|      0|        }
   59|  4.44k|        auto j = json::parse(fileStream);
   60|       |
   61|  5.30k|        for (auto it = j["targets"].begin(); it != j["targets"].end(); ++it)
  ------------------
  |  Branch (61:46): [True: 852, False: 4.44k]
  ------------------
   62|    852|        {
   63|    852|            targetEntry entry;
   64|    852|            if (gVerbose)
  ------------------
  |  Branch (64:17): [True: 0, False: 852]
  ------------------
   65|      0|            {
   66|      0|                debug("target: {KEY} | {VALUE}", "KEY", it.key(), "VALUE",
   67|      0|                      it.value());
   68|      0|            }
   69|       |
   70|       |            // Be unforgiving on invalid json files. Just throw or allow
   71|       |            // nlohmann to throw an exception if something is off
   72|    852|            auto errorsToMonitor = it.value().find("errorsToMonitor");
   73|    852|            entry.errorsToMonitor =
   74|    852|                errorsToMonitor->get<std::vector<std::string>>();
   75|       |
   76|    852|            validateErrorsToMonitor(entry.errorsToMonitor);
   77|       |
   78|    852|            auto errorToLog = it.value().find("errorToLog");
   79|    852|            entry.errorToLog = errorToLog->get<std::string>();
   80|       |
   81|    852|            systemdTargetMap[it.key()] = entry;
   82|    852|        }
   83|  4.44k|    }
   84|  4.44k|    return systemdTargetMap;
   85|  4.44k|}

LLVMFuzzerTestOneInput:
   27|  4.44k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   28|       |    // Write data to a temporary file
   29|  4.44k|    char temp_filename[] = "/tmp/target_parser_fuzzer_XXXXXX";
   30|  4.44k|    int fd = mkstemp(temp_filename);
   31|  4.44k|    if (fd < 0) {
  ------------------
  |  Branch (31:9): [True: 0, False: 4.44k]
  ------------------
   32|      0|        return 0;
   33|      0|    }
   34|       |    
   35|  4.44k|    if (write(fd, data, size) != static_cast<ssize_t>(size)) {
  ------------------
  |  Branch (35:9): [True: 0, False: 4.44k]
  ------------------
   36|      0|        close(fd);
   37|      0|        unlink(temp_filename);
   38|      0|        return 0;
   39|      0|    }
   40|  4.44k|    close(fd);
   41|       |
   42|       |    // Call the function under test
   43|  4.44k|    try {
   44|  4.44k|        std::vector<std::string> filePaths = {temp_filename};
   45|  4.44k|        parseFiles(filePaths);
   46|  4.44k|    } catch (const std::exception& e) {
   47|       |        // We expect exceptions for invalid JSON or validation errors,
   48|       |        // which is fine. We want to catch them so the fuzzer doesn't
   49|       |        // treat them as crashes.
   50|  4.16k|    }
   51|       |
   52|       |    // Clean up
   53|  4.44k|    unlink(temp_filename);
   54|  4.44k|    return 0;
   55|  4.44k|}

