@@ -1023,7 +1023,8 @@ func TestProcessModules(t *testing.T) {
10231023
10241024func TestQueryWorkingSetEx (t * testing.T ) {
10251025 // alloc a shared page
1026- sharedMemSize := os .Getpagesize ()
1026+ pageNum := 100
1027+ sharedMemSize := os .Getpagesize () * pageNum
10271028 handle , err := windows .CreateFileMapping (
10281029 windows .InvalidHandle ,
10291030 nil ,
@@ -1045,24 +1046,28 @@ func TestQueryWorkingSetEx(t *testing.T) {
10451046
10461047 // accessing it to paging it in
10471048 memSlice := unsafe .Slice ((* byte )(unsafe .Pointer (addr )), sharedMemSize )
1048- memSlice [0 ] = 1
1049+ for i := range memSlice {
1050+ memSlice [i ] = 1
1051+ }
10491052
10501053 process := windows .CurrentProcess ()
1051- information := windows.PSAPI_WORKING_SET_EX_INFORMATION {
1052- VirtualAddress : addr ,
1054+ infos := make ([]windows.PSAPI_WORKING_SET_EX_INFORMATION , pageNum )
1055+ for i := 0 ; i < pageNum ; i ++ {
1056+ infos [i ].VirtualAddress = addr + uintptr (i * os .Getpagesize ())
10531057 }
1054- infos := []windows.PSAPI_WORKING_SET_EX_INFORMATION {information }
10551058
10561059 cb := uint32 (uintptr (len (infos )) * unsafe .Sizeof (infos [0 ]))
10571060 if err := windows .QueryWorkingSetEx (process , uintptr (unsafe .Pointer (& infos [0 ])), cb ); err != nil {
10581061 t .Fatalf ("%+v" , err )
10591062 }
10601063
1061- if ! infos [0 ].VirtualAttributes .Valid () {
1062- t .Errorf ("memory location not valid" )
1063- }
1064- if ! infos [0 ].VirtualAttributes .Shared () {
1065- t .Errorf ("memory location not shared" )
1064+ for i := 0 ; i < pageNum ; i ++ {
1065+ if ! infos [i ].VirtualAttributes .Valid () {
1066+ t .Errorf ("memory location not valid" )
1067+ }
1068+ if ! infos [i ].VirtualAttributes .Shared () {
1069+ t .Errorf ("memory location not shared" )
1070+ }
10661071 }
10671072}
10681073
0 commit comments