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

Function TestGenerateDropScriptWithCIDRFilter

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

Source from the content-addressed store, hash-verified

183}
184
185func TestGenerateDropScriptWithCIDRFilter(t *testing.T) {
186 _, cidr, err := net.ParseCIDR("10.0.0.0/24")
187 if err != nil {
188 t.Fatalf("failed to parse CIDR: %v", err)
189 }
190
191 config := TraceConfig{
192 FilterCIDRs: []*net.IPNet{cidr},
193 OutputJSON: false,
194 }
195
196 gen := NewScriptGenerator(config)
197 filter := gen.buildSkbIPFilterCondition()
198
199 // Should contain hex network
200 if !strings.Contains(filter, "0x0a000000") {
201 t.Errorf("expected filter to contain hex network 0x0a000000, got: %s", filter)
202 }
203
204 // Should contain hex mask for /24
205 if !strings.Contains(filter, "0xffffff00") {
206 t.Errorf("expected filter to contain hex mask 0xffffff00, got: %s", filter)
207 }
208
209 // Should use bswap() for endianness
210 if !strings.Contains(filter, "bswap($saddr_raw)") {
211 t.Errorf("expected filter to use bswap() for endianness conversion, got: %s", filter)
212 }
213}
214
215func TestGenerateDropScriptJSONOutput(t *testing.T) {
216 config := TraceConfig{

Callers

nothing calls this directly

Calls 3

NewScriptGeneratorFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected