home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ibmtool.zip
/
stress.c
< prev
next >
Wrap
Text File
|
1997-11-07
|
12KB
|
385 lines
/******************************************************************************/
/* */
/* FILE: STRESS.C */
/* */
/* PURPOSE: This file contains the IBMTOOL portion of the stress test. */
/* */
/* FUNCTIONS: PutStressParms */
/* TTStress */
/* StressWksta */
/* */
/* GLOBAL DATA ACCESSED */
/* int CurrMenuOpt */
/* BOOLEAN TokenRing */
/* ULONG hWedge */
/* SERVICECHAR MACMSC */
/* CTRLFRAME ControlFrame */
/* */
/******************************************************************************/
#define INCL_SUB
#define INCL_BASE
#define INCL_DOS
#include <os2.h>
#include <stdio.h>
#include <stdarg.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "ndis.h"
#include "ibmtool.h"
#include "ioctl.h"
#define CTL_KEY 0x0004
#define DEFAULT_TOLERANCE 10000
#define DEFAULT_FRAMECOUNT 100000
DWORD StressTolerance;
void PutStressParms (BYTE far *data)
{
// Put stress parameters in control frame data
// FrameCount, Tolerance, Data Error Break Flag, Data Checking Flag
*(DWORD *) data = WedgeCommon->StressCnt;
data += sizeof (DWORD);
*(DWORD *) data = StressTolerance;
data += sizeof (DWORD);
*(WORD *) data = WedgeCommon->StopOnErr;
data += sizeof (WORD);
*(WORD *) data = WedgeCommon->CheckData;
}
int TTStress ()
{
// STRESS [FrameCount] [Tolerance] ["NOSTOP"] ["NOCHK"]
// 1) get parameters
// 2) send out broadcast frame to alert workstation(s)
// 3) set stress mode to TRUE
// 4) loop; display totals, monitor kbd, check for control frames
// 5) set stress mode to FALSE
char *token;
BOOLEAN UserHalt = FALSE;
WORD CheckDataSave = WedgeCommon->CheckData;
USHORT tempmenu;
KBDKEYINFO KbdInfo;
// initialize stress parameters
WedgeCommon->StopOnErr = TRUE;
WedgeCommon->CheckData = TRUE;
WedgeCommon->StressCnt = DEFAULT_FRAMECOUNT;
StressTolerance = DEFAULT_TOLERANCE;
/* get stress parameters from command */
// get the frame count (optional)
if ((token = strtok (NULL, "\n\t ")))
{
if ((WedgeCommon->StressCnt = GetNumericParm (token)) < 0)
return TT_INVALID_PARAMETER;
}
// get the StressTolerance (optional)
if ((token = strtok (NULL, "\n\t ")))
{
if ((StressTolerance = GetNumericParm (token)) < 0)
return TT_INVALID_PARAMETER;
}
// get the integrity parameter (optional)
if ((token = strtok (NULL, "\n\t ")))
{
if (!stricmp (token, "NOSTOP"))
WedgeCommon->StopOnErr = FALSE;
else
return TT_INVALID_PARAMETER;
}
// get the int 3 parameter (optional)
if ((token = strtok (NULL, "\n\t ")))
{
if (!stricmp (token, "NOCHK"))
WedgeCommon->CheckData = FALSE;
else
return TT_INVALID_PARAMETER;
}
/* set stress mode to TRUE */
WedgeCommon->StressMode = TRUE;
/* query all current workstations to make sure their still there */
WkstaStressCnt = QueryWorkStations ();
/* send out a broadcast frame to alert workstation(s) */
SendControlFrame (CCSTRESS);
// save current info display
tempmenu = CurrMenuOpt;
CurrMenuOpt = -1;
// clear counters
WedgeCommon->TotalRx =
WedgeCommon->TotalTx =
WedgeCommon->TotalRxErr =
WedgeCommon->TotalTxErr =
WedgeCommon->TotalTxNoRsrc = 0L;
// display the stress screen
ShowStressScr ();
KbdInfo.fsState = 0;
// loop
// SERVER is done being stressed when:
// 1) ^H is entered OR
// 2) StressTolerance is exceeded OR
// 3) All WORKSTATIONS have sent the CCENDSTRESS control frame
while (WedgeCommon->StressMode)
{
KbdCharIn (&KbdInfo, IO_NOWAIT, 0);
if ((KbdInfo.fsState & CTL_KEY) && (KbdInfo.chScan == 0x0023))
{
SendControlFrame (CCSRVSTOP);
WedgeCommon->StressMode = FALSE;
UserHalt = TRUE;
}
if (WedgeCommon->TotalTxNoRsrc > StressTolerance)
WedgeCommon->StressMode = FALSE;
CheckIndications ();
if (WkstaStressCnt == 0)
WedgeCommon->StressMode = FALSE;
UpdateStressScr ();
} /* endwhile */
if (UserHalt)
aprintf (3, 17, 0x1E, " Stress Test Incomplete ");
else
{
aprintf (3, 17, 0x1E, " Stress Test Complete - ");
if (WedgeCommon->TotalTxNoRsrc > StressTolerance)
{
PrintMsg (RED, "STRESS TOLERANCE EXCEEDED");
aprintf (3, 49, 0x1C, "FAIL ");
}
if (WedgeCommon->TotalRxErr != 0L)
{
PrintMsg (RED, "RECEIVE DATA ERRORS");
aprintf (3, 49, 0x1C, "FAIL ");
}
else if (WkstaStressCnt != 0)
{
PrintMsg (RED, "Stressing WORKSTATION(s) have not checked in");
PrintMsg (RED, " Verify that all stations are transmitting and receiving");
aprintf (3, 49, 0x1C, "FAIL ");
}
else
aprintf (3, 49, 0x1A, "PASS ");
}
KbdInfo.fsState = 0;
KbdCharIn (&KbdInfo, IO_WAIT, 0);
while ((!(KbdInfo.fsState & CTL_KEY)) && (KbdInfo.chScan != 0x0023))
KbdCharIn (&KbdInfo, IO_WAIT, 0);
/* set stress mode to FALSE */
WedgeCommon->StressMode = FALSE;
// restore check data flag
WedgeCommon->CheckData = CheckDataSave;
// clear counters
WedgeCommon->TotalRx =
WedgeCommon->TotalTx =
WedgeCommon->TotalRxErr =
WedgeCommon->TotalTxErr =
WedgeCommon->TotalTxNoRsrc = 0L;
// restore the info display
SelectMenuOpt (tempmenu);
return SUCCESS;
}
void StressWksta ()
{
BYTE far *StressData,
far *StressDataPhys,
*data;
BOOLEAN UserQuit = FALSE, UserHalt = FALSE;
USHORT i, j,
tempmenu,
offset;
WORD CheckDataSave = WedgeCommon->CheckData;
KBDKEYINFO KbdInfo;
IOCTLDATA IOData;
IOCTLDATA far *IODataPtr = &IOData;
// get stress parameters out of the control frame
data = (BYTE *) ControlFrame.pData;
WedgeCommon->StressCnt = *(DWORD *) data;
data += sizeof (DWORD);
StressTolerance = *(DWORD *) data;
WedgeCommon->StopOnErr = *(WORD *) data;
WedgeCommon->CheckData = *(WORD *) data;
// save current info display
tempmenu = CurrMenuOpt;
CurrMenuOpt = -1;
// clear counters
WedgeCommon->TotalRx =
WedgeCommon->TotalTx =
WedgeCommon->TotalRxErr =
WedgeCommon->TotalTxErr =
WedgeCommon->TotalTxNoRsrc = 0L;
// display the stress screen
ShowStressScr ();
/* set up the StressData for WEDGE's use */
StressData = (BYTE far *) _fcalloc (MACMSC.MscMaxFrame, sizeof (BYTE));
IOData.ReqCode = VIRT_TO_PHYS;
IOData.Length = 0;
IOData.SrcDataPtr = (void far *) StressData;
IOData.DestDataPtr = NULL;
GenIoctl ((void far *) IODataPtr, hWedge);
StressDataPhys = IOData.SrcDataPtr;
for (i=0; i<MACMSC.MscMaxFrame; i++)
StressData[MACMSC.MscMaxFrame-i-1] = (BYTE) ((i + 1) & 0xFF);
offset = 0;
if (TokenRing)
{
StressData[offset++] = 0x10;
StressData[offset++] = 0x40;
}
_fmemcpy ((void far *) (StressData + offset),
(void far *) WedgeCommon->ServerAddr,
MACMSC.MscStnAdrSz);
offset += MACMSC.MscStnAdrSz;
_fmemcpy ((void far *) (StressData + offset),
(void far *) MACMSC.MscCurrStnAdr,
MACMSC.MscStnAdrSz);
// we haven't heard from SERVER yet
ServerStressAck = FALSE;
// set stress mode to TRUE
WedgeCommon->StressMode = TRUE;
// loop
// WORKSTATIONS are done stressing when:
// 1) ^H is entered OR
// 2) StressTolerance is exceeded OR
// 3) StressCnt = 0
while (WedgeCommon->StressMode)
{
KbdCharIn (&KbdInfo, IO_NOWAIT, 0);
if ((KbdInfo.fsState & CTL_KEY) && (KbdInfo.chScan == 0x0023))
{
UserHalt = TRUE;
WedgeCommon->StressMode = FALSE;
// restore check data flag
WedgeCommon->CheckData = CheckDataSave;
break;
}
else if ((WedgeCommon->TotalTxNoRsrc > StressTolerance) ||
(!WedgeCommon->StressCnt) ||
ServerStressAck)
WedgeCommon->StressMode = FALSE;
else
{
IOData.ReqCode = STRESSTX;
IOData.Length = WedgeCommon->HeaderLen - 2;
IOData.SrcDataPtr = (void far *) StressData;
IOData.DestDataPtr = (void far *) StressDataPhys;
GenIoctl ((void far *) IODataPtr, hWedge);
}
CheckIndications ();
UpdateStressScr ();
} /* endwhile */
if (UserHalt)
aprintf (3, 17, 0x1E, " Stress Test Incomplete ");
else
{
aprintf (3, 17, 0x1E, " Stress Test Complete - ");
if (WedgeCommon->TotalTxNoRsrc > StressTolerance)
{
// we're not transmitting, so don't bother sending ENDSTRESS message
PrintMsg (RED, "Stress tolerance exceeded");
aprintf (3, 49, 0x1C, "FAIL ");
}
else
{
// send ENDSTRESS frame to SERVER until he responds
KbdInfo.fsState = 0;
while (!ServerStressAck)
{
// allow user to intervene in case we're really dead
KbdCharIn (&KbdInfo, IO_NOWAIT, 0);
if ((KbdInfo.fsState & CTL_KEY) && (KbdInfo.chScan == 0x0023))
{
UserQuit = TRUE;
break;
}
SendControlFrame (CCENDSTRESS);
for (i=0; i<20; ++i)
{
CheckIndications ();
if (ServerStressAck) break;
DosSleep (100);
} /* endfor */
} /* endwhile */
if (WedgeCommon->TotalRxErr != 0L)
{
PrintMsg (RED, "RECEIVE DATA ERRORS");
aprintf (3, 49, 0x1C, "FAIL ");
}
else if (WedgeCommon->StressCnt != 0L && !UserHalt)
{
aprintf (3, 17, 0x1E, " Stress Test Incomplete ");
PrintMsg (RED, "Not all stress frames transmitted");
}
else if (!ServerStressAck)
{
PrintMsg (RED, "Server did not acknowledge END OF STRESS message");
aprintf (3, 49, 0x1C, "FAIL ");
}
else
aprintf (3, 49, 0x1A, "PASS ");
}
} /* endif */
if (!UserQuit)
{
// insist user intervene - so that display doesn't go away
KbdInfo.fsState = 0;
KbdCharIn (&KbdInfo, IO_WAIT, 0);
while ((!(KbdInfo.fsState & CTL_KEY)) && (KbdInfo.chScan != 0x0023))
KbdCharIn (&KbdInfo, IO_WAIT, 0);
}
/* set stress mode to FALSE */
WedgeCommon->StressMode = FALSE;
// free stress data buffer
_ffree (StressData);
// clear counters
WedgeCommon->TotalRx =
WedgeCommon->TotalTx =
WedgeCommon->TotalRxErr =
WedgeCommon->TotalTxErr =
WedgeCommon->TotalTxNoRsrc = 0L;
// restore the info display
SelectMenuOpt (tempmenu);
}