bc mode v1
This commit is contained in:
310
testinfo.cpp
Normal file
310
testinfo.cpp
Normal file
@@ -0,0 +1,310 @@
|
||||
/*#include <QTest>
|
||||
#include "testinfo.h"
|
||||
#include <windows.h>
|
||||
#include "declarations.h"
|
||||
#include <WDMTMKv2.cpp>
|
||||
|
||||
HANDLE hEvent;
|
||||
TTmkEventData tmkEvD;
|
||||
|
||||
void testInfo::init()
|
||||
{
|
||||
if (isFailed)
|
||||
{
|
||||
qDebug() << "Skip";
|
||||
QSKIP("");
|
||||
}
|
||||
}
|
||||
|
||||
void testInfo::cleanup()
|
||||
{
|
||||
bool a = QTest::currentTestFailed();
|
||||
if (a)
|
||||
isFailed = a;
|
||||
}
|
||||
|
||||
void testInfo::cleanupTestCase()
|
||||
{
|
||||
qDebug() << "TmkClose()";
|
||||
TmkClose();
|
||||
if (hEvent)
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
|
||||
void testInfo::testcreateevent()
|
||||
{
|
||||
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
QVERIFY(hEvent);
|
||||
}
|
||||
|
||||
void testInfo::testTmkOpen()
|
||||
{
|
||||
DWORD a;
|
||||
|
||||
a = TmkOpen();
|
||||
QCOMPARE(a, DWORD(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkgetmaxn()
|
||||
{
|
||||
QCOMPARE(tmkgetmaxn(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testmrtgetmaxn()
|
||||
{
|
||||
QCOMPARE(mrtgetmaxn(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkconfig()
|
||||
{
|
||||
int hTmk = 0;
|
||||
|
||||
QCOMPARE(tmkconfig(hTmk), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkselect()
|
||||
{
|
||||
int hTmk = 0;
|
||||
|
||||
QCOMPARE(tmkselect(hTmk), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testtmkgetinfo()
|
||||
{
|
||||
TTmkConfigData tmkCfg;
|
||||
int hTmk = 0;
|
||||
|
||||
tmkgetinfo(&tmkCfg);
|
||||
QCOMPARE(hTmk, (int)(0)); //Device Number
|
||||
QCOMPARE(tmkCfg.nType, (short)(9)); //Device Type
|
||||
QCOMPARE(tmkCfg.szName, "TA1USB"); //Device Name
|
||||
QCOMPARE(tmkCfg.wPorts1, (unsigned short)(0)); //Device I/O Ports
|
||||
|
||||
if (tmkCfg.wPorts2 == (unsigned short)(0xFFFF)) //Device I/O Ports
|
||||
;
|
||||
else
|
||||
QCOMPARE(tmkCfg.wPorts2, (unsigned short)(0));
|
||||
|
||||
if (tmkCfg.wIrq2 == (unsigned short)(0xFF))
|
||||
QCOMPARE(tmkCfg.wIrq1, (unsigned short)(0)); //Device Interrupt
|
||||
else
|
||||
{
|
||||
QCOMPARE(tmkCfg.wIrq1, (unsigned short)(0)); //Device Interrupts
|
||||
QCOMPARE(tmkCfg.wIrq2, (unsigned short)(0));
|
||||
}
|
||||
|
||||
QCOMPARE(tmkCfg.wIODelay, (unsigned short)(0)); //Device I/O Delay
|
||||
}
|
||||
|
||||
void testInfo::testtmkgethwver()
|
||||
{
|
||||
QCOMPARE(tmkgethwver(), (unsigned short)(11));
|
||||
}
|
||||
|
||||
void testInfo::testbcreset()
|
||||
{
|
||||
QCOMPARE(bcreset(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testbcgetmaxbase()
|
||||
{
|
||||
QCOMPARE(bcgetmaxbase(), (unsigned short)(1023));
|
||||
}
|
||||
|
||||
void testInfo::testbcputgetw()
|
||||
{
|
||||
int fError;
|
||||
unsigned short wBase, wAddr;
|
||||
unsigned short wMaxBase = bcgetmaxbase();
|
||||
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
bcputw(wAddr, wAddr|(wBase<<6));
|
||||
}
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
if (bcgetw(wAddr) != (unsigned short)(wAddr|(wBase<<6)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testbcputgetblk()
|
||||
{
|
||||
int fError;
|
||||
unsigned short awBuf[64];
|
||||
unsigned short wBase, wAddr;
|
||||
unsigned short wMaxBase = bcgetmaxbase();
|
||||
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
awBuf[63-wAddr] = wBase+(wAddr<<8);
|
||||
}
|
||||
bcputblk(0, awBuf, 64);
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wBase = 0; wBase <= wMaxBase; ++wBase)
|
||||
{
|
||||
bcdefbase(wBase);
|
||||
bcgetblk(0, awBuf, 64);
|
||||
for (wAddr = 0; wAddr <= 63; ++wAddr)
|
||||
{
|
||||
if (awBuf[63-wAddr] != (wBase+(wAddr<<8)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtreset()
|
||||
{
|
||||
QCOMPARE(rtreset(), (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtgetmaxpage()
|
||||
{
|
||||
QCOMPARE(rtgetmaxpage(), (unsigned short)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtputgetw()
|
||||
{
|
||||
int fError;
|
||||
unsigned short wPage, wAddr, wSubAddr;
|
||||
unsigned short wMaxPage = rtgetmaxpage();
|
||||
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
rtputw(wAddr, wAddr|(wSubAddr<<8)|(wPage<<13));
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
rtputw(wAddr, (wAddr+32)|(wSubAddr<<8)|(wPage<<13));
|
||||
}
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (rtgetw(wAddr) != (wAddr|(wSubAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (rtgetw(wAddr) != ((wAddr+32)|(wSubAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testrtputgetblk()
|
||||
{
|
||||
int fError;
|
||||
unsigned short awBuf[64];
|
||||
unsigned short wPage, wAddr, wSubAddr;
|
||||
unsigned short wMaxPage = rtgetmaxpage();
|
||||
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
awBuf[31-wAddr] = wSubAddr|(wAddr<<8)|(wPage<<13);
|
||||
rtputblk(0, awBuf, 32);
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
awBuf[31-wAddr] = (wSubAddr+32)|(wAddr<<8)|(wPage<<13);
|
||||
rtputblk(0, awBuf, 32);
|
||||
}
|
||||
}
|
||||
|
||||
fError = 0;
|
||||
for (wPage = 0; wPage <= wMaxPage; ++wPage)
|
||||
{
|
||||
rtdefpage(wPage);
|
||||
for (wSubAddr = 0; wSubAddr <= 0x1F; ++wSubAddr)
|
||||
{
|
||||
rtdefsubaddr(RT_RECEIVE, wSubAddr);
|
||||
rtgetblk(0, awBuf, 32);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (awBuf[31-wAddr] != (wSubAddr|(wAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
rtdefsubaddr(RT_TRANSMIT, wSubAddr);
|
||||
rtgetblk(0, awBuf, 32);
|
||||
for (wAddr = 0; wAddr <= 31; ++wAddr)
|
||||
{
|
||||
if (awBuf[31-wAddr] != ((wSubAddr+32)|(wAddr<<8)|(wPage<<13)))
|
||||
fError = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(fError, (int)(0));
|
||||
}
|
||||
|
||||
void testInfo::testgetInt()
|
||||
{
|
||||
bcreset();
|
||||
tmkdefevent(hEvent, TRUE);
|
||||
tmkgetevd(&tmkEvD);
|
||||
QCOMPARE(tmkEvD.nInt, (int)(0));
|
||||
bcdefbase(0);
|
||||
bcputw(0, 0xFFE1);
|
||||
bcstart(0, CTRL_C_BRCST);
|
||||
|
||||
switch (WaitForSingleObject(hEvent, 1000))
|
||||
{
|
||||
case WAIT_OBJECT_0:
|
||||
ResetEvent(hEvent);
|
||||
qDebug() << "We got interrupt!";
|
||||
break;
|
||||
|
||||
case WAIT_TIMEOUT:
|
||||
qDebug() << "We didn't get interrupt!";
|
||||
break;
|
||||
|
||||
default:
|
||||
qDebug() << "Somebody abandon our interrupt waiting!";
|
||||
break;
|
||||
}
|
||||
|
||||
tmkgetevd(&tmkEvD);
|
||||
QCOMPARE(tmkEvD.nInt, (int)(1));
|
||||
|
||||
tmkdefevent(0,TRUE);
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user