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

Function TestQueryWorkingSetBatchAddresses

pkg/util/va/ws_test.go:362–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

360}
361
362func TestQueryWorkingSetBatchAddresses(t *testing.T) {
363 const pageSize = 4096
364 const pages = 8
365
366 addr, err := windows.VirtualAlloc(0, pageSize*pages, windows.MEM_COMMIT|windows.MEM_RESERVE, windows.PAGE_READWRITE)
367 if err != nil {
368 t.Fatalf("VirtualAlloc failed: %v", err)
369 }
370 defer windows.VirtualFree(addr, 0, windows.MEM_RELEASE)
371
372 ws := make([]sys.MemoryWorkingSetExInformation, pages)
373 for i := range ws {
374 ws[i].VirtualAddress = addr + uintptr(i*pageSize)
375 }
376
377 result := QueryWorkingSet(windows.CurrentProcess(), ws)
378 if result == nil {
379 t.Fatal("QueryWorkingSet returned nil for batch of valid pages")
380 }
381 if len(result) != pages {
382 t.Fatalf("expected %d results, got %d", pages, len(result))
383 }
384}
385
386func TestQueryWorkingSetNilOnNilPool(t *testing.T) {
387 // temporarily nil the pool to simulate init failure

Callers

nothing calls this directly

Calls 1

QueryWorkingSetFunction · 0.70

Tested by

no test coverage detected