@@ -1023,7 +1023,8 @@ func TestProcessModules(t *testing.T) {
1023
1023
1024
1024
func TestQueryWorkingSetEx (t * testing.T ) {
1025
1025
// alloc a shared page
1026
- sharedMemSize := os .Getpagesize ()
1026
+ pageNum := 100
1027
+ sharedMemSize := os .Getpagesize () * pageNum
1027
1028
handle , err := windows .CreateFileMapping (
1028
1029
windows .InvalidHandle ,
1029
1030
nil ,
@@ -1045,24 +1046,28 @@ func TestQueryWorkingSetEx(t *testing.T) {
1045
1046
1046
1047
// accessing it to paging it in
1047
1048
memSlice := unsafe .Slice ((* byte )(unsafe .Pointer (addr )), sharedMemSize )
1048
- memSlice [0 ] = 1
1049
+ for i := range memSlice {
1050
+ memSlice [i ] = 1
1051
+ }
1049
1052
1050
1053
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 ())
1053
1057
}
1054
- infos := []windows.PSAPI_WORKING_SET_EX_INFORMATION {information }
1055
1058
1056
1059
cb := uint32 (uintptr (len (infos )) * unsafe .Sizeof (infos [0 ]))
1057
1060
if err := windows .QueryWorkingSetEx (process , uintptr (unsafe .Pointer (& infos [0 ])), cb ); err != nil {
1058
1061
t .Fatalf ("%+v" , err )
1059
1062
}
1060
1063
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
+ }
1066
1071
}
1067
1072
}
1068
1073
0 commit comments