aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Gong <gong.chen@linux.intel.com>2012-08-22 11:51:55 +0800
committerChen Gong <gong.chen@linux.intel.com>2012-09-12 03:17:06 -0400
commitdfb61fa2d57f4704610884f9407d2beb5510fd89 (patch)
treec298261bd76a046fa8fba202facfe2e04bc12d21
parent209568e38e58680f38009de2ed80f022fe8404cf (diff)
downloadmce-test-dfb61fa2d57f4704610884f9407d2beb5510fd89.tar.gz
Update pfa test case
On some platforms original PFA case can't work well because of no actual reading/writing action in time. This patch enhances the reading/writing operations to ensure the error can be triggered. Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
-rw-r--r--cases/function/pfa/pfa.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/cases/function/pfa/pfa.c b/cases/function/pfa/pfa.c
index 97dfe3b..a6df354 100644
--- a/cases/function/pfa/pfa.c
+++ b/cases/function/pfa/pfa.c
@@ -39,13 +39,13 @@ struct pagemaps {
unsigned long long present:1;
};
+static int pagesize;
/*
* get information about address from /proc/{pid}/pagemap
*/
unsigned long long vtop(unsigned long long addr)
{
- static int pagesize;
struct pagemaps pinfo;
unsigned int pinfo_size = sizeof pinfo;
long offset;
@@ -76,6 +76,7 @@ unsigned long long vtop(unsigned long long addr)
int main()
{
char *p;
+ long total, i;
unsigned long long phys, newphys;
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
@@ -90,12 +91,28 @@ int main()
fflush(stdout);
for (;;) {
+ for (i = 0; i < pagesize; i += sizeof(int)) {
+ total += *(int*)(p + i);
+ *(int*)(p + i) = total;
+ }
+
newphys = vtop((unsigned long long)p);
- if (phys != newphys) {
+ if (phys == newphys) {
+ for (i = 0; i < pagesize; i += sizeof(int)) {
+ total += *(int*)(p + i);
+ *(int*)(p + i) = i;
+ }
+ sleep(2);
+ newphys = vtop((unsigned long long)p);
+ if (phys != newphys) {
+ printf("Page was replaced. New physical address = 0x%llx\n", newphys);
+ fflush(stdout);
+ phys = newphys;
+ }
+ } else {
printf("Page was replaced. New physical address = 0x%llx\n", newphys);
fflush(stdout);
phys = newphys;
}
- sleep(1);
}
}