(t *testing.T)
| 480 | } |
| 481 | |
| 482 | func TestScriptUsesNumericReasonCode(t *testing.T) { |
| 483 | config := TraceConfig{ |
| 484 | EnableDrops: true, |
| 485 | } |
| 486 | |
| 487 | gen := NewScriptGenerator(config) |
| 488 | script := gen.Generate() |
| 489 | |
| 490 | // Script should NOT contain hardcoded reason names |
| 491 | hardcodedReasons := []string{ |
| 492 | "NO_SOCKET", |
| 493 | "NETFILTER_DROP", |
| 494 | "OTHERHOST", |
| 495 | } |
| 496 | |
| 497 | for _, reason := range hardcodedReasons { |
| 498 | if strings.Contains(script, reason) { |
| 499 | t.Errorf("script should not hardcode reason name: %s", reason) |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // Script should use $reason (numeric) in output |
| 504 | if !strings.Contains(script, "$reason") { |
| 505 | t.Error("script should use $reason variable for numeric code") |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | func TestGenerateNfqueueDropProbe(t *testing.T) { |
| 510 | config := TraceConfig{ |
nothing calls this directly
no test coverage detected