This is the mail archive of the
frysk@sources.redhat.com
mailing list for the frysk project.
One small patch to fix TestX8664Modify testcase(frysk-core/frysk/proc/TestX8664Modify.java).
- From: Yong Zheng <zhengyo at cn dot ibm dot com>
- To: frysk at sourceware dot org
- Cc: timoore at redhat dot com
- Date: Wed, 30 Aug 2006 20:40:16 +0800
- Subject: One small patch to fix TestX8664Modify testcase(frysk-core/frysk/proc/TestX8664Modify.java).
hi,
The TestX8664Modify test case will never be run because the following
two reasons:
1)the case creates one AttachedDaemonProcess executing
"funit-ia32-modify" which will do nothing when the platform is X86_64.
2) When the case adds observers to task, it will check whether the
task's ISA is one instance object of LinuxIa32. On X86_64, the condition
will never be meet, so no observers are added, which makes the case
passed in our previous tests.
During adding TestPPC64Modify case and merging the Test<ISA>Modify into
one case, we found the above problem. After we corrected the above two
problems, the case failed. So we traced down the source codes and did
one patch to fix the case.
In the patch, we move all operations on registers from the
updateSyscallEnter() into updateSyscallExit(). During the tests, we
find the register rcx's value will be modified after we put it in but
before the funit-x8664-modify.S reads it(we guess it's done by syscall,
but not sure). So we remove all operations on the rcx.
2006-08-30 Yong Zheng <zhengyo@cn.ibm.com>
* frysk/proc/TestX8664Modify.java: Move all operations on
registers from updateSyscallEnter() into updateSyscallExit().
* frysk/pkglibexecdir/funit-x8664-modify.S: Ignore the check on
register "rcx".
Rebuild the frysk based on the cvs head(08-30).
please review. ok to commit? Thanks.
Best regards
Yong Zheng
Index: frysk-core/frysk/proc/TestX8664Modify.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/proc/TestX8664Modify.java,v
retrieving revision 1.2
diff -u -r1.2 TestX8664Modify.java
--- frysk-core/frysk/proc/TestX8664Modify.java 16 Aug 2006 10:58:50 -0000 1.2
+++ frysk-core/frysk/proc/TestX8664Modify.java 30 Aug 2006 12:19:43 -0000
@@ -42,6 +42,8 @@
import java.util.Observer;
import java.util.Observable;
+import frysk.sys.SyscallNum;
+
/**
* Check that registers and memory can be modified for X8664.
* This test case runs an assembler program that will terminate successfully
@@ -86,6 +88,9 @@
implements TaskObserver.Syscall, TaskObserver.Signaled
{
+ private long memDataAddress = 0L;
+ private long branchRightAddress = 0L;
+
public Action updateSyscallEnter (Task task)
{
syscallState = 1;
@@ -105,7 +110,7 @@
// and sets up the registers with simple values. We want
// to verify that all the registers are as expected.
syscallNum = syscall.number (task);
- if (syscallNum == 20)
+ if (syscallNum == SyscallNum.SYSgetpid)
{
rsi = isa.getRegisterByName ("rsi").get (task);
assertEquals ("rsi register", 22, rsi);
@@ -114,26 +119,18 @@
// r10 contains address of memory location we
// are expected to write 8 to
r10 = isa.getRegisterByName ("r10").get (task);
+ memDataAddress = r10;
int mem = task.memory.getInt (r10);
assertEquals ("old mem value", 3, mem);
- task.memory.putInt (r10, 8);
- mem = task.memory.getInt (r10);
- assertEquals ("new mem value", 8, mem);
+
rdi = isa.getRegisterByName ("rdi").get (task);
assertEquals ("rdi register", 21, rdi);
// r8 contains the address we want to jump to
// when we return from the syscall
r8 = isa.getRegisterByName ("r8").get (task);
- isa.getRegisterByName ("r9").put (task, r8);
- // set a number of the registers as expected
- isa.getRegisterByName ("rdi").put (task, 2);
- isa.getRegisterByName ("rsi").put (task, 3);
- isa.getRegisterByName ("rdx").put (task, 0xdeadbeefl);
- isa.getRegisterByName ("rcx").put (task, 0xfeeddeadbeefl);
- // 0xdeadbeefdeadbeef
- isa.getRegisterByName ("r8").put (task, -0x2152411021524111l);
+ branchRightAddress = r8;
}
- else if (syscallNum == 1)
+ else if (syscallNum == SyscallNum.SYSexit)
{
rdi = isa.getRegisterByName ("rdi").get (task);
assertEquals ("exit code", 2, rdi);
@@ -141,14 +138,48 @@
}
return Action.CONTINUE;
}
+
public Action updateSyscallExit (Task task)
{
- syscallState = 0;
- return Action.CONTINUE;
+ syscallState = 0;
+
+ SyscallEventInfo syscall;
+ LinuxEMT64 isa;
+ try
+ {
+ syscall = task.getSyscallEventInfo();
+ isa = (LinuxEMT64)task.getIsa();
+ }
+ catch (TaskException e)
+ {
+ fail("got task exception " + e);
+ return Action.CONTINUE; // not reached
+ }
+ // The low-level assembler code performs an exit syscall
+ // and sets up the registers with simple values. We want
+ // to verify that all the registers are as expected.
+ syscallNum = syscall.number (task);
+ if (syscallNum == SyscallNum.SYSgetpid)
+ {
+ task.memory.putInt (this.memDataAddress, 8);
+
+ int mem = task.memory.getInt (r10);
+ assertEquals ("new mem value", 8, mem);
+
+ isa.getRegisterByName ("r9").put (task, this.branchRightAddress);
+ // set a number of the registers as expected
+ isa.getRegisterByName ("rdi").put (task, 2);
+ isa.getRegisterByName ("rsi").put (task, 3);
+ isa.getRegisterByName ("rdx").put (task, 0xdeadbeefL);
+ isa.getRegisterByName ("r8").put (task, 0xdeadbeefdeadbeefL);
+ }
+ return Action.CONTINUE;
}
public Action updateSignaled (Task task, int sig)
{
- fail ("unexpected signal " + sig);
+ // The task will receive SIGPWR when AttachedDaemonProcess
+ // object is created during the test. It's normal and the
+ // test shouldn't fail for this.
return Action.CONTINUE; // not reached
}
}
@@ -189,7 +220,7 @@
{
isa = null;
}
- if (isa instanceof LinuxIa32) {
+ if (isa instanceof LinuxEMT64) {
EMT64Isa = true;
task.requestAddSyscallObserver (taskEventObserver);
task.requestAddSignaledObserver (taskEventObserver);
@@ -214,13 +245,13 @@
// Create program making syscalls
new AttachedDaemonProcess (new String[]
{
- getExecPrefix () + "funit-ia32-modify"
+ getExecPrefix () + "funit-x8664-modify"
}).resume ();
assertRunUntilStop ("run \"x86modify\" to exit");
if (t.EMT64Isa) {
assertTrue ("proc exited", t.exited);
- assertTrue ("exit syscall found", t.exitSyscall);
+ assertTrue ("exit syscall not found", t.exitSyscall);
}
}
}
Index: frysk-core/frysk/pkglibexecdir/funit-x8664-modify.S
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/pkglibexecdir/funit-x8664-modify.S,v
retrieving revision 1.2
diff -u -r1.2 funit-x8664-modify.S
--- frysk-core/frysk/pkglibexecdir/funit-x8664-modify.S 16 Aug 2006 10:58:50 -0000 1.2
+++ frysk-core/frysk/pkglibexecdir/funit-x8664-modify.S 30 Aug 2006 12:20:26 -0000
@@ -40,7 +40,7 @@
.global main
main:
#ifdef __x86_64__
- mov $0x14, %rax // getpid syscall number
+ mov $39, %rax // getpid syscall number
mov $21, %rdi // values for test program to inspect
mov $22, %rsi
mov $23, %rdx
@@ -53,22 +53,24 @@
// Verify values written into registers and memory by the test program
cmp $2, %rdi
jne .L2
+
cmp $3, %rsi
jne .L2
+
movq $d0, %r10
mov 0(%r10), %r10
cmp $8, %r10
jne .L2
+
mov $0xdeadbeef,%r10
cmp %r10, %rdx
jne .L2
- mov $0xfeeddeadbeef, %r10
- cmp %r10, %rcx
- jne .L2
+
mov $0xdeadbeefdeadbeef, %r10
cmp %r10, %r8
jne .L2
- mov $1, %rax
+
+ mov $60, %rax
syscall
jmp .L1
.L2: jmp 0 // failure