(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func TestGenerateDropScript(t *testing.T) { |
| 114 | config := TraceConfig{ |
| 115 | EnableDrops: true, |
| 116 | EnableRST: true, |
| 117 | EnableErrors: true, |
| 118 | EnableRetransmits: true, |
| 119 | } |
| 120 | |
| 121 | gen := NewScriptGenerator(config) |
| 122 | script := gen.Generate() |
| 123 | |
| 124 | // Verify script structure |
| 125 | if !strings.Contains(script, "#!/usr/bin/env bpftrace") { |
| 126 | t.Error("script missing shebang") |
| 127 | } |
| 128 | if !strings.Contains(script, "tracepoint:skb:kfree_skb") { |
| 129 | t.Error("script missing kfree_skb tracepoint") |
| 130 | } |
| 131 | if !strings.Contains(script, "BEGIN {") { |
| 132 | t.Error("script missing BEGIN block") |
| 133 | } |
| 134 | if !strings.Contains(script, "END {") { |
| 135 | t.Error("script missing END block") |
| 136 | } |
| 137 | if !strings.Contains(script, "$reason") { |
| 138 | t.Error("script missing reason variable") |
| 139 | } |
| 140 | if !strings.Contains(script, "DROP") { |
| 141 | t.Error("script missing DROP output") |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func TestGenerateDropScriptNoFilter(t *testing.T) { |
| 146 | config := TraceConfig{ |
nothing calls this directly
no test coverage detected