This is the mail archive of the frysk@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: one frysk-core patch to add PPC64 testcases.


Yong Zheng wrote:
hi,

According to Andrew's advice, we merge the following three testcases
(TestI386Regs.java, TestX8664Regs.java and TestPPC64Regs.java) into one
case: TestRegs.java.
After merging the three cases, the files TestI386Regs.java,
TestX8664Regs.java and TestPPC64Regs.java can be removed from
frysk-core/frysk/proc/.


If it's ok, we will post out the patch for merging TestI386Modify.java,
TestX8664Modify.java and TestPPC64Modify.java.

Here is the patch for adding TestRegs.java. Rebuild frysk on
X86/X86-64/PPC64 based on the cvs head(08-18) and tested. please review.

Much appreciate what you've done.

Looking over the code I see you've inherited some older-nastier code. Rather than attempt to also fix that in parallel, can you check this in and then I'll sort out the old code's mess.

sorry to not reply earlier,
Andrew

On Fri, 2006-08-18 at 11:51 -0400, Andrew Cagney wrote:
Yong Zheng wrote:
hi,

There's no any case for us to test register and memory modification in
PPC64 in frysk. So we write two cases for above purpose. During the
test, we found the PPC64's worksize(got from IsaPPC64.java) should be
8bytes but not 4 bytes. Here is the patch to add PPC64 tests.

2006-08-18 Yong Zheng <zhengyo@cn.ibm.com>

	* frysk/proc/TestPPC64Regs.java: New file for PPC64 test
	* frysk/proc/TestPPC64Modify.java: New file for PPC64 test
	* frysk/pkglibexecdir/funit-ppc64-regs.S: New file for PPC64
	* frysk/pkglibexecdir/funit-ppc64-modify.S: Ditto
	* frysk/Makefile.am: Add PPC64Regs/PPC64Modify tests

	* frysk/proc/IsaPPC64.java (getWordSize): Edit return value
	from 4 to 8

Rather than individual Test<ISA>Regs.java files, I'd prefer to see a single TestRegs.java file that selects the applicable test and runs that, or fails if no test is implemented.

Past experience tells us that, unless unimplemented is detected and treated as a FAIL, the tests won't get implemented - too easy to ignore.

Andrew

------------------------------------------------------------------------

--- /dev/null 2006-08-18 19:25:03.428380000 +0800
+++ frysk-core/frysk/proc/TestRegs.java 2006-08-21 11:39:48.000000000 +0800
@@ -0,0 +1,467 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2005, 2006, Red Hat Inc.
+//
+// FRYSK is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+// +// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+// +// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+package frysk.proc;
+
+import java.math.BigInteger;
+import java.util.Hashtable;
+import java.util.Observable;
+
+import frysk.sys.SyscallNum;
+
+/**
+ * Check that registers can be accessed.
+ */
+
+public class TestRegs
+ extends SyscallExaminer
+{
+ class TestI386RegsInternals extends SyscallExaminer.Tester
+ {
+ boolean ia32Isa;
+ int syscallNum;
+ long orig_eax;
+ long ebx;
+ long ecx;
+ long edx;
+ long ebp;
+ long esp;
+ long esi;
+ long edi;
+ + // Need to add task observers to the process the moment it is
+ // created, otherwize the creation of the very first task is
+ // missed (giving a mismatch of task created and deleted
+ // notifications.)
+ + class I386TaskEventObserver
+ extends SyscallExaminer.Tester.TaskEventObserver
+ {
+ public Action updateSyscallEnter (Task task)
+ {
+ super.updateSyscallEnter(task);
+ SyscallEventInfo syscall;
+ LinuxIa32 isa;
+ try + {
+ syscall = task.getSyscallEventInfo ();
+ isa = (LinuxIa32)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 == 1) { + orig_eax = isa.getRegisterByName ("orig_eax").get (task);
+ ebx = isa.getRegisterByName ("ebx").get (task);
+ ecx = isa.getRegisterByName ("ecx").get (task);
+ edx = isa.getRegisterByName ("edx").get (task);
+ ebp = isa.getRegisterByName ("ebp").get (task);
+ esi = isa.getRegisterByName ("esi").get (task);
+ edi = isa.getRegisterByName ("edi").get (task);
+ esp = isa.getRegisterByName ("esp").get (task);
+ }
+ return Action.CONTINUE;
+ }
+ }
+
+ class I386RegsTestObserver + extends SyscallExaminer.TaskAddedObserver + {
+ public void update(Observable o, Object obj)
+ {
+ super.update(o, obj);
+ Task task = (Task)obj;
+ if (!isChildOfMine(task.proc))
+ return;
+ I386TaskEventObserver taskEventObserver = new I386TaskEventObserver();
+ Isa isa;
+ try + {
+ isa = task.getIsa();
+ }
+ catch (TaskException e) + {
+ isa = null;
+ }
+ if (isa instanceof LinuxIa32) + {
+ ia32Isa = true;
+ task.requestAddSyscallObserver(taskEventObserver);
+ task.requestAddSignaledObserver(taskEventObserver);
+ }
+ else
+ {
+ // If not ia32, stop immediately
+ ia32Isa = false;
+ Manager.eventLoop.requestStop();
+ }
+ }
+ }
+
+ TestI386RegsInternals ()
+ {
+ super();
+ addTaskAddedObserver(new I386RegsTestObserver());
+ }
+ }
+ + class TestX8664RegsInternals extends SyscallExaminer.Tester
+ {
+ boolean EMT64Isa;
+ int syscallNum;
+ String[] regNames + = new String[] { "orig_rax", "rdi", "rsi", "rdx", "r10", "r8", "r9"};
+ long[] regValues
+ = new long[] + { 1, 2, 3, -4, 0xdeadbeefl, 0xfeeddeadbeefl,
+ // 0xdeadbeefdeadbeef
+ -0x2152411021524111l
+ };
+ Hashtable longResults = new Hashtable();
+ Hashtable bigResults = new Hashtable();
+ + // Need to add task observers to the process the moment it is
+ // created, otherwize the creation of the very first task is
+ // missed (giving a mismatch of task created and deleted
+ // notifications.)
+ + class X8664TaskEventObserver
+ extends SyscallExaminer.Tester.TaskEventObserver
+ {
+ + }
+
+ class LongTaskEventObserver
+ extends X8664TaskEventObserver
+ {
+ public Action updateSyscallEnter (Task task)
+ {
+ super.updateSyscallEnter(task);
+ 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 == 1) + { + for (int i = 0; i < regNames.length; i++)
+ {
+ longResults.put(regNames[i], + new Long(isa.getRegisterByName(regNames[i])
+ .get (task)));
+ }
+ for (int i = 0; i < regNames.length; i++) + {
+ bigResults.put(regNames[i],
+ isa.getRegisterByName(regNames[i])
+ .getBigInteger(task));
+ }
+ + }
+ return Action.CONTINUE;
+ }
+ }
+
+ class X8664RegsTestObserver + extends SyscallExaminer.TaskAddedObserver + {
+ private X8664TaskEventObserver taskEventObserver;
+ + X8664RegsTestObserver(X8664TaskEventObserver teo)
+ {
+ super();
+ taskEventObserver = teo;
+ }
+ + public void update(Observable o, Object obj)
+ {
+ super.update(o, obj);
+ Task task = (Task)obj;
+ if (!isChildOfMine(task.proc))
+ return;
+ Isa isa;
+ try + {
+ isa = task.getIsa();
+ }
+ catch (TaskException e) + {
+ isa = null;
+ }
+ if (isa instanceof LinuxEMT64) + {
+ EMT64Isa = true;
+ task.requestAddSyscallObserver(taskEventObserver);
+ task.requestAddSignaledObserver(taskEventObserver);
+ }
+ else
+ {
+ // If not ia32, stop immediately
+ EMT64Isa = false;
+ Manager.eventLoop.requestStop();
+ }
+ }
+ }
+
+ TestX8664RegsInternals ()
+ {
+ super();
+ addTaskAddedObserver(new X8664RegsTestObserver(new LongTaskEventObserver()));
+ }
+ + void verify() + {
+ for (int i = 0; i < regNames.length; i++) + {
+ assertEquals(regNames[i] + " long value", + regValues[i],
+ ((Long)longResults.get(regNames[i])).longValue());
+ }
+ for (int i = 0; i < regNames.length; i++) + {
+ assertTrue(regNames[i] + " BigInteger value", + BigInteger.valueOf(regValues[i])
+ .compareTo((BigInteger)bigResults.get(regNames[i])) == 0);
+ }
+ assertTrue ("exited", exited);
+ }
+ }
+
+ class TestPPC64RegsInternals extends SyscallExaminer.Tester
+ {
+ long gpr0;
+ long gpr3;
+ long gpr4;
+ long gpr5;
+ + int syscallNum;
+ boolean isPPC64Isa;
+ + // Need to add task observers to the process the moment it is
+ // created, otherwize the creation of the very first task is
+ // missed (giving a mismatch of task created and deleted
+ // notifications.)
+ + class PPC64TaskEventObserver
+ extends SyscallExaminer.Tester.TaskEventObserver
+ {
+ public Action updateSyscallEnter (Task task)
+ {
+ LinuxPPC64 isaPPC64;
+ SyscallEventInfo syscall;
+ + logger.entering("TestPPC64Regs.TaskEventObserver", + "updateSyscallEnter");
+ super.updateSyscallEnter(task);
+ + try
+ {
+ syscall = task.getSyscallEventInfo ();
+ isaPPC64 = (LinuxPPC64)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.SYSexit)
+ {
+ gpr0 = isaPPC64.getRegisterByName ("gpr0").get (task);
+ gpr3 = isaPPC64.getRegisterByName ("gpr3").get (task);
+ gpr4 = isaPPC64.getRegisterByName ("gpr4").get (task);
+ gpr5 = isaPPC64.getRegisterByName ("gpr5").get (task);
+ }
+ + return Action.CONTINUE;
+ }
+ }
+
+ class PPC64RegsTestObserver + extends SyscallExaminer.TaskAddedObserver + {
+ public void update(Observable o, Object obj)
+ {
+ super.update(o, obj);
+ Task task = (Task)obj;
+ + if (!isChildOfMine(task.proc))
+ return;
+ + Isa isa;
+ PPC64TaskEventObserver taskEventObserver = new PPC64TaskEventObserver();
+ + try + {
+ isa = task.getIsa();
+ }
+ catch (TaskException e) + {
+ isa = null;
+ }
+ + if (isa instanceof LinuxPPC64) + {
+ isPPC64Isa = true;
+ task.requestAddSyscallObserver(taskEventObserver);
+ task.requestAddSignaledObserver(taskEventObserver);
+ }
+ else + {
+ //If not PPC64, stop immediately
+ isPPC64Isa = false;
+ Manager.eventLoop.requestStop();
+ }
+ }
+ }
+
+ TestPPC64RegsInternals ()
+ {
+ super();
+ addTaskAddedObserver(new PPC64RegsTestObserver());
+ }
+ }
+ + private void checkI386Regs ()
+ {
+ if (MachineType.getMachineType() != MachineType.IA32)
+ return;
+ TestI386RegsInternals t = new TestI386RegsInternals ();
+ // Create program making an exit syscall");
+ new AttachedDaemonProcess (new String[]
+ {
+ getExecPrefix () + "funit-ia32-regs"
+ }).resume ();
+ assertRunUntilStop ("run \"x86regs\" until exit");
+
+ if (t.ia32Isa) {
+ assertEquals ("orig_eax register", 1, t.orig_eax);
+ assertEquals ("ebx register", 2, t.ebx);
+ assertEquals ("ecx register", 3, t.ecx);
+ assertEquals ("edx register", 4, t.edx);
+ assertEquals ("ebp register", 5, t.ebp);
+ assertEquals ("esi register", 6, t.esi);
+ assertEquals ("edi register", 7, t.edi);
+ assertEquals ("esp register", 8, t.esp);
+
+ assertTrue ("exited", t.exited);
+ }
+ }
+ + private void checkX8664Regs ()
+ {
+ if (MachineType.getMachineType() != MachineType.X8664)
+ return;
+ TestX8664RegsInternals t = new TestX8664RegsInternals();
+ // Create program making an exit syscall");
+ AttachedDaemonProcess child = new AttachedDaemonProcess (new String[]
+ {
+ getExecPrefix () + "funit-x8664-regs"
+ });
+ logger.finest("About to resume funit-x8664-regs");
+ child.resume();
+ assertRunUntilStop ("run \"x86regs\" until exit");
+ if (t.EMT64Isa) + {
+ t.verify();
+ }
+ }
+ + private void checkPPC64Regs ()
+ {
+ if (MachineType.getMachineType() != MachineType.PPC64)
+ return;
+ + TestPPC64RegsInternals t = new TestPPC64RegsInternals();
+ // Create program making an exit syscall");
+ AttachedDaemonProcess child = new AttachedDaemonProcess (new String[]
+ {
+ getExecPrefix () + "funit-ppc64-regs"
+ });
+ logger.finest("About to resume funit-ppc64-regs");
+ child.resume();
+ assertRunUntilStop ("run \"ppc64regs\" until exit");
+
+ if (t.isPPC64Isa)
+ {
+ assertEquals ("syscall", SyscallNum.SYSexit, t.syscallNum);
+ assertEquals ("gpr0 register", 1, t.gpr0);
+ assertEquals ("gpr3 register", 1, t.gpr3);
+ assertEquals ("gpr4 register", 4, t.gpr4);
+ // Left shift 36bits from 0x1
+ assertEquals ("gpr5 register", 0x1000000000L, t.gpr5);
+ + assertTrue ("exited", t.exited);
+ }
+ }
+
+ public void testRegs()
+ {
+ if (MachineType.getMachineType() == MachineType.IA32)
+ checkI386Regs();
+ else if (MachineType.getMachineType() == MachineType.X8664)
+ checkX8664Regs();
+ else if (MachineType.getMachineType() == MachineType.PPC64)
+ checkPPC64Regs();
+ else
+ throw new UnsupportedOperationException(MachineType.getMachineType() + " is not supported now.");
+ }
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]