From 55373cd1a97cff486ed311da5f26a0b5bad002af Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Mon, 2 Mar 2009 16:10:07 +0000 Subject: [PATCH] * fixed tests for systems where the page size <> 4096 git-svn-id: trunk@12852 - --- tests/test/tparray13.pp | 34 +++++++++++++++++++++++++--------- tests/test/tparray7.pp | 29 ++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/tests/test/tparray13.pp b/tests/test/tparray13.pp index 1bda413b2d..d60f4fe5ae 100644 --- a/tests/test/tparray13.pp +++ b/tests/test/tparray13.pp @@ -133,28 +133,44 @@ $518787,$219852,$48BD56,$827F40,$3CC0A6,$E79AF6 var i: longint; {$ifdef unix} - p,p2: pbyte; + p,p2,p3: pbyte; bp: paa; + mapsize: ptruint; + first: boolean; {$endif} begin if (sizeof(b)<>3*length(results)) then error(48); {$ifdef unix} { check for reading past end of array } - repeat - p := fpmmap(nil,4096,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); - p2 := fpmmap(nil,4096,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); - until (ptruint(p2) = ptruint(p) + 4096); - fpmunmap(p2,4096); - move(b,pbyte(ptruint(p)+4096-sizeof(b))^,sizeof(b)); - bp := paa(ptruint(p)+4096-sizeof(b)); + mapsize:=4096; + { look for a place where we can map one page and are certain that there's + no valid page right behind it + } + for i:=1 to 18 do + begin + p:=fpmmap(nil,mapsize*3,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); + if (p<>pointer(-1)) then + begin + fpmunmap(p,mapsize*3); + p2:=fpmmap(p,mapsize,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); + if (p2=p) then + break; + p2:=pointer(-1); + end; + end; + if (p2 = pointer(-1)) then + { didn't find a suitable mapping } + exit; + move(b,pbyte(ptruint(p)+mapsize-sizeof(b))^,sizeof(b)); + bp := paa(ptruint(p)+mapsize-sizeof(b)); for i := low(results) to high(results) do if bp^[i] <> results[i] then begin writeln(i); error(49); end; - fpmunmap(p,4096); + fpmunmap(p,mapsize); {$else} for i := low(results) to high(results) do if b[i] <> results[i] then diff --git a/tests/test/tparray7.pp b/tests/test/tparray7.pp index ea96d1f8c5..f469f71d22 100644 --- a/tests/test/tparray7.pp +++ b/tests/test/tparray7.pp @@ -229,18 +229,33 @@ var {$ifdef unix} p,p2: pbyte; bp: paa; + mapsize: ptruint; {$else} b: tb; {$endif} begin {$ifdef unix} - { check for reading/writing past end of array } - repeat - p := fpmmap(nil,4096,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); - p2 := fpmmap(nil,4096,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); - until (ptruint(p2) = ptruint(p) + 4096); - fpmunmap(p2,4096); - fillchar(p^,4096,$ff); + { check for reading past end of array } + mapsize:=4096; + { look for a place where we can map one page and are certain that there's + no valid page right behind it + } + for i:=1 to 18 do + begin + p:=fpmmap(nil,mapsize*3,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); + if (p<>pointer(-1)) then + begin + fpmunmap(p,mapsize*3); + p2:=fpmmap(p,mapsize,PROT_READ or PROT_WRITE,MAP_PRIVATE or MAP_ANONYMOUS,-1,0); + if (p2=p) then + break; + p2:=pointer(-1); + end; + end; + if (p2 = pointer(-1)) then + { didn't find a suitable mapping } + exit; + fillchar(p^,mapsize,$ff); bp := paa(ptruint(p)+4096-sizeof(tb)); for i := low(results) to high(results) do begin