00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #define HELLO_PENTIUM "test/pentium/hello"
00014
00015 #include "ProcTest.h"
00016 #include "BinaryFile.h"
00017 #include "BinaryFileStub.h"
00018 #include "pentiumfrontend.h"
00019
00020 #include <sstream>
00021 #include <map>
00022
00023
00024
00025
00026
00027
00028
00029 #define MYTEST(name) \
00030 suite->addTest(new CppUnit::TestCaller<ProcTest> ("testProc", \
00031 &ProcTest::name, *this))
00032
00033 void ProcTest::registerTests(CppUnit::TestSuite* suite) {
00034
00035 MYTEST(testName);
00036 }
00037
00038 int ProcTest::countTestCases () const
00039 { return 2; }
00040
00041
00042
00043
00044
00045
00046
00047
00048 void ProcTest::setUp () {
00049 }
00050
00051
00052
00053
00054
00055
00056
00057
00058 void ProcTest::tearDown () {
00059 delete m_proc;
00060 }
00061
00062
00063
00064
00065
00066 void ProcTest::testName () {
00067 Prog* prog = new Prog();
00068 BinaryFile *pBF = new BinaryFileStub();
00069 CPPUNIT_ASSERT(pBF != 0);
00070 std::string nm("default name");
00071 BinaryFileFactory bff;
00072 pBF = bff.Load(HELLO_PENTIUM);
00073 FrontEnd *pFE = new PentiumFrontEnd(pBF, prog, &bff);
00074 CPPUNIT_ASSERT(pFE != 0);
00075 prog->setFrontEnd(pFE);
00076 CPPUNIT_ASSERT(prog);
00077 pFE->readLibraryCatalog();
00078 m_proc = new UserProc(prog, nm, 20000);
00079 std::string actual(m_proc->getName());
00080 CPPUNIT_ASSERT_EQUAL(std::string("default name"), actual);
00081
00082 std::string name("printf");
00083 LibProc lp(prog, name, 30000);
00084 actual = lp.getName();
00085 CPPUNIT_ASSERT_EQUAL(name, actual);
00086
00087 ADDRESS a = lp.getNativeAddress();
00088 ADDRESS expected = 30000;
00089 CPPUNIT_ASSERT_EQUAL(expected, a);
00090 a = m_proc->getNativeAddress();
00091 expected = 20000;
00092 CPPUNIT_ASSERT_EQUAL(expected, a);
00093
00094 delete prog;
00095
00096 }
00097