MCPcopy
hub / github.com/microsoft/retina / TestGenerateDropScriptJSONOutput

Function TestGenerateDropScriptJSONOutput

shell/tracescript_test.go:215–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestGenerateDropScriptJSONOutput(t *testing.T) {
216 config := TraceConfig{
217 OutputJSON: true,
218 EnableDrops: true,
219 EnableRST: true,
220 EnableErrors: true,
221 EnableRetransmits: true,
222 }
223
224 gen := NewScriptGenerator(config)
225 script := gen.Generate()
226
227 // JSON output should have JSON-formatted printf statements
228 // Note: In the bpftrace script, quotes are escaped with backslash
229 if !strings.Contains(script, `\"type\":\"DROP\"`) {
230 t.Error("JSON script missing DROP type field")
231 }
232 if !strings.Contains(script, `\"reason_code\"`) {
233 t.Error("JSON script missing reason_code field")
234 }
235 if !strings.Contains(script, `\"src_ip\"`) {
236 t.Error("JSON script missing src_ip field")
237 }
238}
239
240func TestGenerateDropScriptTableOutput(t *testing.T) {
241 config := TraceConfig{

Callers

nothing calls this directly

Calls 4

GenerateMethod · 0.95
NewScriptGeneratorFunction · 0.85
ContainsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected