| 103 | } |
| 104 | |
| 105 | void FuzzGenReporter::saveReport(std::string OutDir) const { |
| 106 | // Report Stats |
| 107 | Json::Value StatsJson = exportStatsJson(); |
| 108 | |
| 109 | // Report UT and API Information |
| 110 | Json::Value UTsJson = exportUTsReportJson(); |
| 111 | Json::Value APIsJson = exportAPIsReportJson(); |
| 112 | |
| 113 | // Make FuzzGenReport Json |
| 114 | Json::Value FuzzGenReportJson; |
| 115 | FuzzGenReportJson["FuzzInputMutator"] = "ProtoBuf"; |
| 116 | FuzzGenReportJson["UT"] = UTsJson; |
| 117 | FuzzGenReportJson["API"] = APIsJson; |
| 118 | for (std::string StatsField : StatsJson.getMemberNames()) { |
| 119 | FuzzGenReportJson[StatsField] = StatsJson[StatsField]; |
| 120 | } |
| 121 | |
| 122 | // Write FuzzGenReport Json File |
| 123 | Json::StreamWriterBuilder WBuilder; |
| 124 | std::string FuzzGenReportJsonStr = writeString(WBuilder, FuzzGenReportJson); |
| 125 | std::string ReportFilePath = OutDir + PATH_SEPARATOR + REPORT_FILENAME; |
| 126 | if (util::saveFile(ReportFilePath.c_str(), FuzzGenReportJsonStr.c_str())) { |
| 127 | llvm::outs() << "Write Report : " << ReportFilePath << "\n"; |
| 128 | } else { |
| 129 | llvm::outs() << "[ERROR] Writing Report Failed: " << ReportFilePath << "\n"; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | Json::Value FuzzGenReporter::exportUTsReportJson() const { |
| 134 | Json::Value UTsJson = Json::Value(Json::arrayValue); |
no test coverage detected