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

Function TestGenerateNfqueueDropProbeWithIPFilter

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

Source from the content-addressed store, hash-verified

578}
579
580func TestGenerateNfqueueDropProbeWithIPFilter(t *testing.T) {
581 ip := net.ParseIP("10.0.0.1")
582 config := TraceConfig{
583 EnableNfqueueDrops: true,
584 FilterIPs: []net.IP{ip},
585 }
586
587 gen := NewScriptGenerator(config)
588 script := gen.Generate()
589
590 // Should contain fexit probe
591 if !strings.Contains(script, "fexit:vmlinux:__nf_queue") {
592 t.Error("script missing fexit probe")
593 }
594
595 // Should contain IP filter hex
596 if !strings.Contains(script, "0x0a000001") {
597 t.Error("script missing hex IP in NFQUEUE probe filter")
598 }
599
600 // Should use bswap for filter
601 if !strings.Contains(script, "bswap($saddr_raw)") {
602 t.Error("script missing bswap in NFQUEUE probe filter")
603 }
604}
605
606func TestGenerateAllProbesIncludingNfqueue(t *testing.T) {
607 // Verify all probes can be generated together

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