home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
dax1.exe
/
CLIENT
/
STRESS
/
DOS
/
STRESS.C
< prev
Wrap
Text File
|
1992-07-15
|
7KB
|
172 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: stress.c ║
// ║ abstract: This module is a stress tester for the DAX Engine. ║
// ║ ║
// ║ environment: NetWare 3.x v3.11 ║
// ║ Network C for DOS v2.0 ║
// ║ NetWare C Interface DOS v1.2 ║
// ║ ║
// ║ This software is provided as is and carries no warranty ║
// ║ whatsoever. Novell disclaims and excludes any and all implied ║
// ║ warranties of merchantability, title and fitness for a particular ║
// ║ purpose. Novell does not warrant that the software will satisfy ║
// ║ your requirements or that the software is without defect or error ║
// ║ or that operation of the software will be uninterrupted. You are ║
// ║ using the software at your risk. The software is not a product ║
// ║ of Novell, Inc. or any of subsidiaries. ║
// ║ ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ maintenance history: ║
// ║ level date pi description ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ 001 02/28/92 kl initial release. ║
// ╚════════════════════════════════════════════════════════════════════╝
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include "h/appl.h"
#include "dap/dapapi.h"
#include <nxt.h>
static DAPDATA *dd;
//
// The atexitproc() is called if the application terminates. All we'll do
// here is perform a graceful shutdown... i.e. logout of the Engine
//
atexitproc()
{
if( dd ){
DAPDeAllocateSession(dd);
DAPDeInitialize(dd);
}
}
//
// errorexit() is called if an error is detected on a session. It calls
// the internal Debug API DAPDisplaySessionData, which creates a debug
// file containing relevant info about the session when it failed. i.e. state
//
errorexit(int rc, char *msg)
{
printf("\n\n\t%s. rc = %d\n\tERROR: %s\n",
msg,
rc,
DAPTranslateReturnCode(rc));
DAPDisplaySessionData(dd);
exit(1);
}
#define DEFOUTER 1000
#define DEFINNER 10
main(int argc, char *argv[])
{
int rc;
long x,y,z,oldval;
WORD imStart, imStop;
LONG iter=0L;
LONG outerlimit = DEFOUTER;
LONG innerlimit = DEFINNER;
char *transform = "\r\t\t\t\t\t%s\r";
if( argc == 3 ){
outerlimit = atoi(argv[1]);
innerlimit = atoi(argv[1]);
}
atexit(atexitproc);
if( (dd = DAPInitialize(SERVERNAME, SERVERTYPE)) == NULL ){
printf("Could not initialize DAP\n");
exit(1);
}
printf("Initialized okay...\n");
if( (rc = DAPAllocateSession(dd)) != NULL ){
errorexit(rc,"Allocate Session failed");
}
printf("Attached to server '%s', type '%x'...\n",SERVERNAME,SERVERTYPE);
imStart = IPXGetIntervalMarker();
for(x=0; !kbhit() && x < outerlimit; ++x){
for(y=1; !kbhit() && y < innerlimit; ++y){
if( (rc = DAPAddOperands(dd,x,y,&z)) != NULL ){
if( DAP_CRITICAL_ERROR(rc) ){
errorexit(rc,"Add Request failed");
}
else{
printf(transform,DAPTranslateReturnCode(rc));
}
}
if( x + y != z ) printf("%ld + %ld = %ld?\n",x,y,z);
if( (rc = DAPSubtractOperands(dd,x,y,&z)) != NULL ){
if( DAP_CRITICAL_ERROR(rc) ){
errorexit(rc,"Subtract Request failed");
}
else{
printf(transform,DAPTranslateReturnCode(rc));
}
}
if( x - y != z ) printf("%ld - %ld = %ld?\n",x,y,z);
if( (rc = DAPMultiplyOperands(dd,x,y,&z)) != NULL ){
if( DAP_CRITICAL_ERROR(rc) ){
errorexit(rc,"Multiply Request failed");
}
else{
printf(transform,DAPTranslateReturnCode(rc));
}
}
if( x * y != z ) printf("%ld * %ld = %ld?\n",x,y,z);
if( (rc = DAPDivideOperands(dd,x,y,&z)) != NULL ){
if( DAP_CRITICAL_ERROR(rc) ){
errorexit(rc,"Divide Request failed");
}
else{
printf(transform,DAPTranslateReturnCode(rc));
}
}
if( x / y != z ) printf("%ld / %ld = %ld?\n",x,y,z);
if( (rc = DAPStoreValue(dd,z,&oldval)) != NULL ){
if( DAP_CRITICAL_ERROR(rc) ){
errorexit(rc,"Store Value failed");
}
else{
printf(transform,DAPTranslateReturnCode(rc));
}
}
oldval = z; // remember z, and see if it comes back ok
if( (rc = DAPRecallValue(dd,&z)) != NULL ){
if( DAP_CRITICAL_ERROR(rc) ){
errorexit(rc,"Recall Value failed");
}
else{
printf(transform,DAPTranslateReturnCode(rc));
}
}
if( z != oldval ) printf("%ld != %ld?\n",z,oldval);
++iter;
// printf("\r\t\t\t%ld\r",++iter);
}
}
imStop = IPXGetIntervalMarker();
if( (rc = DAPDeAllocateSession(dd)) != NULL ){
errorexit(rc,"De Allocate Request failed");
}
printf("Detached from server...\n");
DAPDeInitialize(dd);
dd = NULL;
printf("DeInitialized okay...\n");
printf("%ld total operations performed\n",iter*6);
printf("%u - %u = %u ticks, %u secs\n",imStop, imStart, imStop - imStart, (imStop - imStart)/18);
return 0;
}