MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / TestEventSourceRundownEvents

Function TestEventSourceRundownEvents

internal/etw/source_test.go:309–383  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

307}
308
309func TestEventSourceRundownEvents(t *testing.T) {
310 psnap := new(ps.SnapshotterMock)
311 psnap.On("Write", mock.Anything).Return(nil)
312 psnap.On("AddThread", mock.Anything).Return(nil)
313 psnap.On("AddModule", mock.Anything).Return(nil)
314 psnap.On("AddMmap", mock.Anything).Return(nil)
315 psnap.On("RemoveMmap", mock.Anything, mock.Anything).Return(nil)
316 psnap.On("RemoveThread", mock.Anything, mock.Anything).Return(nil)
317 psnap.On("RemoveModule", mock.Anything, mock.Anything).Return(nil)
318 psnap.On("FindModule", mock.Anything).Return(false, nil)
319 psnap.On("FindAndPut", mock.Anything).Return(&pstypes.PS{})
320 psnap.On("Find", mock.Anything).Return(true, &pstypes.PS{})
321 psnap.On("Remove", mock.Anything).Return(nil)
322
323 hsnap := new(handle.SnapshotterMock)
324 hsnap.On("FindByObject", mock.Anything).Return(htypes.Handle{}, false)
325 hsnap.On("FindHandles", mock.Anything).Return([]htypes.Handle{}, nil)
326
327 evsConfig := config.EventSourceConfig{
328 EnableThreadEvents: true,
329 EnableModuleEvents: true,
330 EnableFileIOEvents: true,
331 EnableNetEvents: true,
332 EnableRegistryEvents: true,
333 }
334 cfg := &config.Config{
335 EventSource: evsConfig,
336 CapFile: "fake.cap", // simulate capture to receive state/rundown events
337 Filters: &config.Filters{},
338 }
339
340 cfg.EventSource.Init()
341 evs := NewEventSource(psnap, hsnap, cfg, nil)
342
343 l := &MockListener{}
344 evs.RegisterEventListener(l)
345 require.NoError(t, evs.Open(cfg))
346 defer evs.Close()
347
348 rundownsByType := map[event.Type]bool{
349 event.ProcessRundown: false,
350 event.ThreadRundown: false,
351 event.ModuleRundown: false,
352 event.FileRundown: false,
353 event.RegKCBRundown: false,
354 }
355 rundownsByHash := make(map[uint64]uint8)
356 timeout := time.After(time.Minute)
357
358 for {
359 select {
360 case e := <-evs.Events():
361 if !e.IsRundown() {
362 continue
363 }
364 rundownsByType[e.Type] = true
365 rundownsByHash[e.RundownKey()]++
366 case err := <-evs.Errors():

Callers

nothing calls this directly

Calls 10

RegisterEventListenerMethod · 0.95
OpenMethod · 0.95
CloseMethod · 0.95
EventsMethod · 0.95
ErrorsMethod · 0.95
NewEventSourceFunction · 0.85
IsRundownMethod · 0.80
RundownKeyMethod · 0.80
StringMethod · 0.65
InitMethod · 0.45

Tested by

no test coverage detected