MCPcopy Index your code
hub / github.com/microsoft/retina / TestScriptUsesNumericReasonCode

Function TestScriptUsesNumericReasonCode

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

Source from the content-addressed store, hash-verified

480}
481
482func 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
509func TestGenerateNfqueueDropProbe(t *testing.T) {
510 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