From a37f70eacae01881d3ed517cdf93f59b5a0156e1 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Fri, 14 Feb 2025 17:15:00 +0100 Subject: pkg/manager: export programs + coverage jsonl The export is quite big but is generated fast. Every line is a valid json object representing the single program coverage. --- pkg/manager/http.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pkg/manager') diff --git a/pkg/manager/http.go b/pkg/manager/http.go index 99af2c0ed..50f672207 100644 --- a/pkg/manager/http.go +++ b/pkg/manager/http.go @@ -86,6 +86,7 @@ func (serv *HTTPServer) Serve(ctx context.Context) error { handle("/corpus", serv.httpCorpus) handle("/corpus.db", serv.httpDownloadCorpus) handle("/cover", serv.httpCover) + handle("/coverprogs", serv.httpPrograms) handle("/debuginput", serv.httpDebugInput) handle("/file", serv.httpFile) handle("/filecover", serv.httpFileCover) @@ -444,6 +445,7 @@ const ( DoRawCover DoFilterPCs DoCoverJSONL + DoCoverPrograms ) func (serv *HTTPServer) httpCover(w http.ResponseWriter, r *http.Request) { @@ -458,6 +460,18 @@ func (serv *HTTPServer) httpCover(w http.ResponseWriter, r *http.Request) { serv.httpCoverCover(w, r, DoHTML) } +func (serv *HTTPServer) httpPrograms(w http.ResponseWriter, r *http.Request) { + if !serv.Cfg.Cover { + http.Error(w, "coverage is not enabled", http.StatusInternalServerError) + return + } + if r.FormValue("jsonl") != "1" { + http.Error(w, "only ?jsonl=1 param is supported", http.StatusBadRequest) + return + } + serv.httpCoverCover(w, r, DoCoverPrograms) +} + func (serv *HTTPServer) httpSubsystemCover(w http.ResponseWriter, r *http.Request) { if !serv.Cfg.Cover { serv.httpCoverFallback(w, r) @@ -577,6 +591,7 @@ func (serv *HTTPServer) httpCoverCover(w http.ResponseWriter, r *http.Request, f DoRawCover: {rg.DoRawCover, ctTextPlain}, DoFilterPCs: {rg.DoFilterPCs, ctTextPlain}, DoCoverJSONL: {rg.DoCoverJSONL, ctApplicationJSON}, + DoCoverPrograms: {rg.DoCoverPrograms, ctApplicationJSON}, } if ct := flagToFunc[funcFlag].contentType; ct != "" { -- cgit mrf-deployment