| 397 | } |
| 398 | |
| 399 | func TestQueryWorkingSetPoolExhaustion(t *testing.T) { |
| 400 | // create a tiny pool and exhaust it |
| 401 | tiny, err := newPool(1) |
| 402 | if err != nil { |
| 403 | t.Fatalf("newPool failed: %v", err) |
| 404 | } |
| 405 | defer tiny.close() |
| 406 | |
| 407 | saved := p |
| 408 | p = tiny |
| 409 | defer func() { p = saved }() |
| 410 | |
| 411 | // hold the only worker |
| 412 | held := tiny.acquire(50 * time.Millisecond) |
| 413 | if held == nil { |
| 414 | t.Fatal("could not acquire the only worker") |
| 415 | } |
| 416 | defer tiny.release(held, false) |
| 417 | |
| 418 | // now QueryWorkingSet should fail gracefully |
| 419 | ws := []sys.MemoryWorkingSetExInformation{{VirtualAddress: 0x1000}} |
| 420 | result := QueryWorkingSet(windows.CurrentProcess(), ws) |
| 421 | if result != nil { |
| 422 | t.Error("expected nil when pool is exhausted") |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | func TestQueryWorkingSetPoolSingletonInit(t *testing.T) { |
| 427 | // reset the singleton so poolOnce triggers again |