(t *testing.T)
| 213 | } |
| 214 | |
| 215 | func 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 | |
| 240 | func TestGenerateDropScriptTableOutput(t *testing.T) { |
| 241 | config := TraceConfig{ |
nothing calls this directly
no test coverage detected