Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
/* macro's and define's useful to write test programs and to build test
suites */
/* NOV 83 - Bill Fitler */
/* FEB 84 - Ken Chai */
/*********************** From "C Puzzle Book": ****************************/
#define PR(format,value) printf("\n\tvalue = %format\t",(value))
#define NL printf("\n")
#define PRINT1(f,x1) PR(f,x1); NL
#define PRINT2(f,x1,x2) PR(f,x1); PRINT1(f,x2)
#define PRINT3(f,x1,x2,x3) PR(f,x1); PRINT2(f,x2,x3)
#define PRINT4(f,x1,x2,x3,x4) PR(f,x1); PRINT3(f,x2,x3,x4)
/********************** end of C Puzzle's "defs.h" ***********************/
#define PRINT_EXPR(format,expr) printf("\n\texpr = format\n",(expr))
#define PRE(fmt,expr,val) printf("\n\texpected value of expr = %fmt",val)
#define PRA(fmt,expr) printf("\n\tactual value of expr = %fmt\n",(expr))
#define MODEL_NAME ((sizeof(char *) == 2) ? \
(sizeof(char (*)())==2 ? "small" : "medium") : \
(sizeof(char (*)())==2 ? "compact" : "big") )
#define TRUE_COND(expr) printf("\n\tassertion succeeded: expr\n")
#define FALSE_COND(expr) printf("\n\tassertion failed: expr\n")
#define TEST_OK(expr) if (expr) TRUE_COND(expr)
#define TEST_NOK(expr) if (expr) FALSE_COND(expr)
#define PRS(b,c) printf("\n\t%s: succeeded for %s model", c, b)
#define PRF(b,c) printf("\n\t%s: failed for %s model", c, b)
#define ASSER(a,b) {if (a) PRS(model,b) ; else PRF(model,b); }
#define PRI(format,val) printf("\n\twe expect to see %format", val)
#define ASSERT(cond) {{model=MODEL_NAME;} ; ASSER(cond,bugnum); }
#define ASSRT(cond) ASSER(cond,bugnum)
/* #define PRS68(c) printf("\n\t%s: succeeded", c)
#define PRF68(b) printf("\n\t%s: failed", b)
#define ASSER68(a,b) {if (a) PRS68(b) ; else PRF68(b); }
#define PRI(format,val) printf("\n\twe expect to see %format", val)
#define ASSERT68(cond) ASSER68(cond,bugnum)
#define ASSRT68(cond) ASSER68(cond,bugnum) */
*/
*/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,592 @@
/* streamio.c: tests Unix Stream I/O functions */
/* Modifications: */
/* 1/84 verbose error msgs for 68K whf */
/* 9/83 improved error msgs whf */
/* Runs by itself: just compile and exec. It will tell you which functions
it is testing. */
#include <portab.h>
#include <stdio.h>
/************************************************/
/* Possible file size parameters for each pass: */
#define NUMPASS 4 /* Number of passes for this test */
#define MAXRECMAX 128 /* Maximum record size */
#define NRCHECKS 7 /* Number of random i/o checks */
WORD pass_types[NUMPASS][2] = /* Num records, Len records for each pass */
{
100, MAXRECMAX,
16, 32,
10, 20,
10000, 20
};
/*************************/
/* O.S. dependent values */
#define BYTE_LEVEL 128 /* Size of sectors: PCDOS = 1, CP/M = 128 */
/*********************************************/
/* Possible kinds of File I/O for each case: */
/* Ascii/Binary I/O indicator */
#define AB_ASCII 1
#define AB_BINARY 0
/* Record/Char/Line indicator */
#define RCL_RECORD 1
#define RCL_CHAR 2
#define RCL_LINE 3
#define NUMCASE 6 /* Number of cases per pass */
WORD case_types[NUMCASE][2] = /* AB type, RCL type for each case */
{
AB_BINARY, RCL_RECORD,
AB_BINARY, RCL_LINE,
AB_BINARY, RCL_CHAR,
AB_ASCII, RCL_LINE,
AB_ASCII, RCL_RECORD,
AB_ASCII, RCL_CHAR
};
/*************************************************************************/
/*************************************************************************/
GLOBAL WORD nerrors = 0; /* number of errors reported */
main(ac,av)
int ac;
char **av;
{
int ii, jj, nfiles;
BYTE **files, *calloc();
BYTE *test_dir, *make_fn();
av[0] = "STREAMIO"; /* kludge: DRC doesn't handle */
test_dir = "g:"; /* where we want to do the testing */
nfiles = 0;
files = calloc(NUMPASS*NUMCASE,sizeof(BYTE *));
printf("%s tests the following Stream I/O functions:\n",av[0]);
printf("\tfopen, fclose, freopen, fseek, ftell, rewind\n");
printf("as well as functions listed below.\n");
printf("****************** %s test starting ****************\n",av[0]);
for( ii=0; ii<NUMPASS; ++ii )
{
prt_pass(ii);
for( jj=0; jj<NUMCASE; ++jj )
{
files[nfiles] = make_fn(ii,jj,test_dir);
test(ii,jj,files[nfiles]);
nfiles++;
};
};
for( ii=0; ii<nfiles; ++ii )
{
/* unlink files here */
}
printf("****************** %s test completed *************\n",av[0]);
printf("******************** number errors: %d *************\n",nerrors);
}
prt_pass(pass)
WORD pass;
{
LONG rmax;
WORD rlen;
rmax = pass_types[pass][0];
rlen = pass_types[pass][1];
printf("pass %d:\t\t",pass);
printf("number records = %ld, record length = %d\n",rmax,rlen);
}
BYTE *make_fn(pass,cse,prefix) /* make a filename from all the parameters */
WORD pass,cse;
BYTE *prefix;
{
LONG rmax;
WORD rlen, ab_f, rcl_f;
BYTE ab_ch, rcl_ch, *fp, *calloc();
rmax = pass_types[pass][0];
rlen = pass_types[pass][1];
ab_f = case_types[cse][0];
ab_ch = (ab_f==AB_ASCII) ? 'A' : 'B';
rcl_f = case_types[cse][1];
switch(rcl_f)
{
case RCL_RECORD: rcl_ch = 'R'; break;
case RCL_CHAR: rcl_ch = 'C'; break;
case RCL_LINE: rcl_ch = 'L'; break;
};
fp = calloc(strlen(prefix)+12,1);
sprintf(fp,"%sZ%c%c%.5D.%.3d",prefix,ab_ch,rcl_ch,rmax,rlen);
return fp;
}
prt_case(cse)
WORD cse;
{
WORD ab_f, rcl_f;
ab_f = case_types[cse][0];
rcl_f = case_types[cse][1];
printf("\tcase %d: %s file i/o on ",cse,
(AB_ASCII==ab_f) ? "ASCII" : "BINARY" );
switch(rcl_f)
{
case RCL_RECORD: printf("fread,fwrite"); break;
case RCL_CHAR: printf("fgetc,fputc"); break;
case RCL_LINE: printf("fgets,fputs"); break;
};
printf(" ");
}
/*************************************************************************/
/*************************************************************************/
GLOBAL LONG wrecs; /* records actually written */
GLOBAL LONG rrecs; /* records actually read */
GLOBAL LONG recmax; /* max number of records to write */
GLOBAL WORD reclen; /* length of each record */
GLOBAL WORD ab_flag; /* Ascii/Binary i/o indicator */
GLOBAL WORD rcl_flag; /* Record/Char/Line indicator */
GLOBAL BYTE *filename; /* Name of test file */
GLOBAL WORD all_but_N; /* num records to write in steps 2,3 */
GLOBAL FILE *tfsp; /* Test File Stream Pointer */
GLOBAL BYTE ch_first, ch_last; /* range of chars to write to file */
GLOBAL BYTE rec1[MAXRECMAX+2], rec2[MAXRECMAX+2]; /* record buffers */
GLOBAL WORD chk_cnt; /* count of num rand read checks */
GLOBAL WORD chk_incr; /* read random every chk_incr records*/
GLOBAL LONG chk_recn[NRCHECKS]; /* record numbers to read random */
GLOBAL LONG chk_rpos[NRCHECKS]; /* positions of above records */
LONG ftell();
test(pass,cse,fn)
WORD pass, cse;
BYTE *fn;
{
wrecs = 0; rrecs = 0;
recmax = pass_types[pass][0];
reclen = pass_types[pass][1];
ab_flag = case_types[cse][0];
rcl_flag = case_types[cse][1];
filename = fn;
all_but_N = 5;
ch_first = 0; ch_last = 0xFF;
if( AB_ASCII == ab_flag || RCL_LINE == rcl_flag )
{ /* don't write extra \n in bin files */
ch_first = ' '; ch_last = '~';
}
chk_incr = recmax / NRCHECKS;
for( chk_cnt=0; chk_cnt<NRCHECKS; ++chk_cnt )
chk_recn[chk_cnt] = chk_rpos[chk_cnt] = 0;
chk_cnt = 0;
prt_case(cse); printf("%s tested: ",fn);
#define CHK(xx) if(xx) break
while(1) /* loop once (allow break) */
{
CHK( build_it() );
CHK( grow_it() );
CHK( rand_write() );
CHK( check_it() );
CHK( rcheck_it() );
printf("OK\n");
return;
}
printf("\n\tRecords written/read before failure: %ld/%ld\n\n",
wrecs,rrecs);
++nerrors; /* incr error count */
}
/***************************************************************************/
build_it() /*** build the file ***/
{
LONG rn;
FILE *fopen(), *fopenb();
/* step 1: create the file */
if( ab_flag == AB_ASCII )
tfsp = fopen(filename,"w");
else tfsp = fopenb(filename,"w");
if( NULLPTR == tfsp ) return eprintf("fopen(%s,w) in build_it",
filename);
/* step 2: write & fflush the first record */
rn = 0;
if( capture_pos(rn) ) return FAILURE;
if( write_it(rn) ) return FAILURE;
if( FAILURE == fflush(tfsp) ) return eprintf("fflush in build_it");
/* step 2: write all but all_but_N of the records */
for( rn=1; rn<recmax-all_but_N; ++rn )
{
if( capture_pos(rn) ) return FAILURE;
if( write_it(rn) ) return FAILURE;
}
/* step 3: close file once */
if( FAILURE == fclose(tfsp) ) return eprintf("fclose in build_it");
return SUCCESS;
}
/***************************************************************************/
capture_pos(rn)
LONG rn;
{
if( rn % chk_incr == 0 && chk_cnt < NRCHECKS)
{
chk_recn[chk_cnt] = rn;
if( -1L == (chk_rpos[chk_cnt]=ftell(tfsp)) )
return eprintf("ftell in capture_pos");
++chk_cnt;
}
return SUCCESS;
}
/***************************************************************************/
write_it(rnum)
LONG rnum;
{
WORD rlen, ii;
/* step 1: make a record */
rlen = reclen;
if( rcl_flag == RCL_LINE ) --rlen; /* leave room for newline */
makerec(rec1,rlen,rnum,filename,ch_first,ch_last);
if( rcl_flag == RCL_LINE ) rec1[reclen-1]='\n';
/* step 2: write the record */
switch( rcl_flag )
{
case RCL_RECORD:
if( reclen != fwrite(rec1,1,reclen,tfsp) )
return eprintf("fwrite in write_it");
break;
case RCL_CHAR:
for( ii=0; ii<reclen; ++ii )
if( FAILURE == fputc(rec1[ii],tfsp) )
return eprintf("fputc in write_it");
break;
case RCL_LINE:
if( FAILURE == fputs(rec1,tfsp) )
return eprintf("fputs in write_it");
break;
}
++wrecs; /* incr num records actually written */
return SUCCESS;
}
/***************************************************************************/
grow_it() /*** append to the file ***/
{
LONG rn;
LONG rpos;
FILE *fopen(), *fopenb(), *freopen(), *freopb();
/* step 1: open for append */
if( AB_ASCII == ab_flag )
tfsp = fopen(filename,"a");
else tfsp = fopenb(filename,"a"); /* watch: reclen % 128 != 0 */
if( NULLPTR == tfsp )
return eprintf("fopen(%s,a) in grow_it",filename);
/* step 2: write all_but_N-1 records */
rn = recmax - all_but_N;
if( rn < 0 )
rn = 0;
if( AB_BINARY == ab_flag ) /* make sure we handle reclen */
{
rpos = rn * reclen;
if( fseek(tfsp,rpos,0) )
return eprintf("fseek in grow_it");
}
for( ; rn < recmax - 1; ++rn )
{
if( capture_pos(rn) ) return FAILURE;
if( write_it(rn) ) return FAILURE;
}
/* step 3: reopen file */
if( AB_ASCII == ab_flag )
tfsp = freopen(filename,"a",tfsp);
else tfsp = freopb(filename,"a",tfsp);
if( NULLPTR == tfsp )
return eprintf("freopen(%s,a) in grow_it",filename);
/* step 4: write last record */
if( AB_BINARY == ab_flag ) /* make sure we handle reclen */
{
rpos = rn * reclen;
if( fseek(tfsp,rpos,0) )
return eprintf("fseek in grow_it");
}
for( ; rn < recmax; ++rn )
{
if( capture_pos(rn) ) return FAILURE;
if( write_it(rn) ) return FAILURE;
}
/* step 5: close file again */
if( FAILURE == fclose(tfsp) )
return eprintf("fclose in grow_it");
return SUCCESS;
}
/***************************************************************************/
rand_write() /* write some randomly */
{
WORD ii;
LONG tt, eof_slack;
FILE *fopen(), *fopenb();
/* step 1: open for append */
if( AB_ASCII == ab_flag )
tfsp = fopen(filename,"a");
else tfsp = fopenb(filename,"a"); /* watch: reclen % 128 != 0 */
if( NULLPTR == tfsp )
return eprintf("fopen(%s,a) in rand_write",filename);
/* Step 2: write randomly absolute */
for( ii=0; ii<chk_cnt; ++ii )
{
if( FAILURE == fseek(tfsp,chk_rpos[ii],0) ) {
eprintf("fseek(%ld,0) in rand_write",chk_rpos[ii]);
for( ii=0; ii<chk_cnt; ++ii )
printf("%2.2d %5.5ld %5.5ld\n",ii,chk_recn[ii],
chk_rpos[ii]);
return FAILURE;
}
if( write_it(chk_recn[ii]) )
return FAILURE;
}
/* step 3: write randomly relative */
if( AB_BINARY == ab_flag ) {
/*** compute 'slack' at eof due to inexact nature of
eof for binary files with 128 byte sectors
(goes away on byte level i/o O.S.s ) ********/
if( BYTE_LEVEL > 1 ) {
eof_slack = BYTE_LEVEL - ((recmax*reclen) % BYTE_LEVEL);
if( eof_slack == BYTE_LEVEL )
eof_slack = 0;
} else eof_slack = 0;
tt = -reclen - eof_slack;
if( FAILURE == fseek(tfsp,tt,2) ) /* addr of last record*/
eprintf("fseek(%ld,2) in rand_write",tt);
if( write_it(recmax-1) )
return FAILURE;
tt = 1 - recmax; tt *= reclen; tt -= eof_slack;
if( FAILURE == fseek(tfsp,tt,2) )
eprintf("fseek(%ld,2) in rand_write",tt);
if( write_it(1L) )
return FAILURE;
}
/* step 4: close file again */
if( FAILURE == fclose(tfsp) )
return eprintf("fclose in rand_write");
return SUCCESS;
}
/***************************************************************************/
check_it() /*** check that everything reads ok sequential ***/
{
LONG rn;
FILE *fopen(), *fopenb();
/* step 1: open for read */
if( AB_ASCII == ab_flag )
tfsp = fopen(filename,"r");
else tfsp = fopenb(filename,"r"); /* watch: reclen % 128 != 0 */
if( NULLPTR == tfsp )
return eprintf("fopen(%s,r) in check_it",filename);
/* step2: read sequential */
for( rn=0; rn < recmax; ++rn )
{
if( read_it(rn) )
return FAILURE;
}
/* step 3: close file */
if( FAILURE == fclose(tfsp) )
return eprintf("fclose in check_it");
return SUCCESS;
}
/***************************************************************************/
read_it(rnum)
LONG rnum;
{
WORD rlen, ii;
/* step 1: make a record */
rlen = reclen;
if( rcl_flag == RCL_LINE ) --rlen; /* leave room for newline */
makerec(rec1,rlen,rnum,filename,ch_first,ch_last);
if( rcl_flag == RCL_LINE ) rec1[reclen-1]='\n';
/* step 2: read the record */
switch( rcl_flag )
{
case RCL_RECORD:
if( reclen != fread(rec2,1,reclen,tfsp) )
return eprintf("fread in read_it");
break;
case RCL_CHAR:
for( ii=0; ii<reclen; ++ii )
if( FAILURE == (rec2[ii]=fgetc(tfsp)) )
return eprintf("fgetc in read_it");
break;
case RCL_LINE:
if( FAILURE == fgets(rec2,reclen+1,tfsp) )
return eprintf("fgets in read_it");
break;
}
if( strncmp(rec1,rec2,reclen) != 0 )
return eprintf("ripple mismatch:\n\texpected: '%s'\n\tgot: '%s'",
rec1,rec2);
++rrecs; /* incr num recs actually read */
return SUCCESS;
}
/***************************************************************************/
rcheck_it() /*** check that some of it reads ok randomly ***/
{
WORD ii;
LONG rn;
LONG rpos;
FILE *fopen(), *fopenb();
/* Step 1: open the file */
if( AB_ASCII == ab_flag )
tfsp = fopen(filename,"r");
else tfsp = fopenb(filename,"r");
if( NULLPTR == tfsp )
return eprintf("fopen in rcheck_it");
/* Step 2: read randomly absolute */
for( ii=0; ii<chk_cnt; ++ii )
{
if( FAILURE == fseek(tfsp,chk_rpos[ii],0) )
return eprintf("fseek(%ld,0) in rcheck_it",
chk_rpos[ii]);
if( ftell(tfsp) != chk_rpos[ii] )
return eprintf("ftell in rcheck_it");
if( read_it(chk_recn[ii]) )
return FAILURE;
}
/* Step 3: read randomly relative */
if( FAILURE == rewind(tfsp) )
return eprintf("rewind in rcheck_it");
if( AB_BINARY == ab_flag ) /* do this for BINARY files: */
for( rn=chk_incr,rpos=chk_incr*reclen; rn<recmax; rn+=(1+chk_incr) )
{
if( FAILURE == fseek(tfsp,rpos,1) )
return eprintf("fseek(%ld,1) in rcheck_it",rpos);
if( read_it(rn) )
return FAILURE;
}
/* Step 4: close */
if( FAILURE == fclose(tfsp) )
return eprintf("fclose in rcheck_it");
return SUCCESS;
}
/***************************************************************************/
/***************************************************************************/
/****************************************************************/
/* makerec: builds a rippled record for a given record number */
/* Record looks like: */
/* <record_label><record_number><ripple_pattern> */
/* or <ripple_pattern> if reclabel==NULL */
/****************************************************************/
makerec(record,rlen,recnum,reclabel,clo,chi)
BYTE *record; /* place to make the record */
UWORD rlen; /* size of the record to make */
LONG recnum; /* record number to make */
BYTE *reclabel; /* label to prepend to each record */
WORD clo, chi; /* range of char values for ripple pattern */
{
BYTE lbuf[10]; /* place to hold chars */
BYTE *cp; /* char ptr */
WORD cc; /* char temp */
clo &= 0xFF; chi &= 0xFF; /* defeat sign extension */
if( reclabel != NULLPTR )
{
for( ; *reclabel && rlen>0; --rlen )/* copy label to record */
*record++ = *reclabel++;
sprintf(lbuf,"#%5.5D#",recnum); /* cvt recnum to ascii */
for( cp=lbuf; *cp && rlen>0; --rlen)/* copy recnum into rec */
*record++ = *cp++;
}
cc = recnum % (1 + chi - clo); /* choose new place to start */
cc += clo; /* DRC bug... */
for( ; rlen>0; --rlen ) /* generate ripple pattern */
{
if( cc > chi ) cc = clo; /* ripple range check */
*record++ = cc++;
}
*record++ = NULL; /* insure NULL terminated */
*record++ = NULL; /* insure NULL terminated */
}
/***************************************************************************/
/***************************************************************************/
/************************************************************************
*
* Calling sequence:
* nchrs = eprintf(fmt,arg1,arg2,...argn);
* Where:
* nchrs = # chars output by printf
* fmt -> a string specifying how arg1-n are to be printed.
*
**************************************************************************/
WORD eprintf(fmt,args)
BYTE *fmt,
*args;
{
_doprt(stdout,"\nERROR:\t");
return(_doprt(stdout,fmt,&args));
}
WORD ep_init() /* initiate eprintf for new set of error messages */
{
}
WORD ep_fini() /* wrap up a set of error messages */
{
}
ap up a set of error messages */
{
}
ap up a set of error messages */
{
}


File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,653 @@
/* Compiler Test Program Part II - version 4.0 plus */
#define DOHIST '\!'
#define QUOTED 128
struct lbits {
unsigned b1 : 4;
unsigned b2 : 12;
} low;
struct hbits {
unsigned b1 : 12;
unsigned b2 : 4;
} ;
struct hbits high; /* be sure global decl ok... */
int err;
int globali = -32768;
unsigned globalu = 44000;
char ca[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
long lconst1 = 5 * 9;
long lconst2 = 5L * 9;
long lconst3 = 5 * 9L;
long lconst4 = 5L * 9L;
long lconst5 = (long)(5 * 9);
char c0[] = {
0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15,
};
int i0[] = {
0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15,
};
long l0[] = {
0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15,
};
struct Proto {
char P_id;
int (*P_turnon)();
int (*P_rdmsg)();
int (*P_wrmsg)();
int (*P_rddata)();
int (*P_wrdata)();
int (*P_turnoff)();
};
extern int gturnon(), gturnoff();
extern int grdmsg(), grddata();
extern int gwrmsg(), gwrdata();
struct Proto Ptbl[] = {
'g', gturnon, grdmsg, gwrmsg, grddata, gwrdata, gturnoff,
'\0'
};
struct nroff {
int a;
char *p;
char *ctag[5];
char *zz;
};
struct nroff star = {
1,
"pstring...",
"zero",
"one",
"two",
"three",
"four",
"zzstring"
};
struct {
int a[2];
char b[2];
long c[2];
char *d[2];
} sa = {
1, 2,
'a', 'b',
3, 4,
"abc", "def"
};
int gturnon() {}
int gturnoff() {}
int grdmsg() {}
int grddata() {}
int gwrmsg() {}
int gwrdata() {}
main()
{
l_vs_i();
rl_vs_i();
l_vs_ri();
rl_vs_ri();
v40();
v41();
v42();
v42_a();
if (!err)
printf("Far Freaking Out\n");
else
printf("Tough Luck.....\n");
}
l_vs_i() /* longs versus ints... v. 4.0 addition */
{
long autol, autol1;
int i;
i = 3;
autol = autol1 = 100;
autol1 *= i;
autol =autol * i;
if (autol1 != autol) error(0x00);
autol = autol1 = 100;
autol1 /= i;
autol =autol / i;
if (autol1 != autol) error(0x01);
autol = autol1 = 100;
autol1 += i;
autol =autol + i;
if (autol1 != autol) error(0x02);
autol = autol1 = 100;
autol1 -= i;
autol =autol - i;
if (autol1 != autol) error(0x03);
autol = autol1 = 100;
autol1 %= i;
autol =autol % i;
if (autol1 != autol) error(0x04);
autol = autol1 = 100;
autol1 <<= i;
autol =autol << i;
if (autol1 != autol) error(0x05);
autol = autol1 = 100;
autol1 >>= i;
autol =autol >> i;
if (autol1 != autol) error(0x06);
autol = autol1 = 100;
autol1 &= i;
autol =autol & i;
if (autol1 != autol) error(0x07);
autol = autol1 = 100;
autol1 |= i;
autol =autol | i;
if (autol1 != autol) error(0x08);
autol = autol1 = 100;
autol1 ^= i;
autol =autol ^ i;
if (autol1 != autol) error(0x09);
}
rl_vs_i() /* register longs versus ints... v. 4.0 addition */
{
register long regl, regl1;
int i;
i = 3;
regl = regl1 = 100;
regl1 *= i;
regl = regl * i;
if (regl1 != regl) error(0x10);
regl = regl1 = 100;
regl1 /= i;
regl = regl / i;
if (regl1 != regl) error(0x11);
regl = regl1 = 100;
regl1 += i;
regl = regl + i;
if (regl1 != regl) error(0x12);
regl = regl1 = 100;
regl1 -= i;
regl = regl - i;
if (regl1 != regl) error(0x13);
regl = regl1 = 100;
regl1 %= i;
regl = regl % i;
if (regl1 != regl) error(0x14);
regl = regl1 = 100;
regl1 <<= i;
regl = regl << i;
if (regl1 != regl) error(0x15);
regl = regl1 = 100;
regl1 >>= i;
regl = regl >> i;
if (regl1 != regl) error(0x16);
regl = regl1 = 100;
regl1 &= i;
regl = regl & i;
if (regl1 != regl) error(0x17);
regl = regl1 = 100;
regl1 |= i;
regl = regl | i;
if (regl1 != regl) error(0x18);
regl = regl1 = 100;
regl1 ^= i;
regl = regl ^ i;
if (regl1 != regl) error(0x19);
}
l_vs_ri() /* longs versus register ints... v. 4.0 addition */
{
long autol, autol1;
register int i;
i = 2;
autol = autol1 = 100;
autol1 *= i;
autol =autol * i;
if (autol1 != autol) error(0x20);
autol = autol1 = 100;
autol1 /= i;
autol =autol / i;
if (autol1 != autol) error(0x21);
autol = autol1 = 100;
autol1 += i;
autol =autol + i;
if (autol1 != autol) error(0x22);
autol = autol1 = 100;
autol1 -= i;
autol =autol - i;
if (autol1 != autol) error(0x23);
autol = autol1 = 100;
autol1 %= i;
autol =autol % i;
if (autol1 != autol) error(0x24);
autol = autol1 = 100;
autol1 <<= i;
autol =autol << i;
if (autol1 != autol) error(0x25);
autol = autol1 = 100;
autol1 >>= i;
autol =autol >> i;
if (autol1 != autol) error(0x26);
autol = autol1 = 100;
autol1 &= i;
autol =autol & i;
if (autol1 != autol) error(0x27);
autol = autol1 = 100;
autol1 |= i;
autol =autol | i;
if (autol1 != autol) error(0x28);
autol = autol1 = 100;
autol1 ^= i;
autol =autol ^ i;
if (autol1 != autol) error(0x29);
}
rl_vs_ri() /* reg longs versus reg ints... v. 4.0 addition */
{
register long regl, regl1;
register int i;
i = 3;
regl = regl1 = 100;
regl1 *= i;
regl = regl * i;
if (regl1 != regl) error(0x30);
regl = regl1 = 100;
regl1 /= i;
regl = regl / i;
if (regl1 != regl) error(0x31);
regl = regl1 = 100;
regl1 += i;
regl = regl + i;
if (regl1 != regl) error(0x32);
regl = regl1 = 100;
regl1 -= i;
regl = regl - i;
if (regl1 != regl) error(0x33);
regl = regl1 = 100;
regl1 %= i;
regl = regl % i;
if (regl1 != regl) error(0x34);
regl = regl1 = 100;
regl1 <<= i;
regl = regl << i;
if (regl1 != regl) error(0x35);
regl = regl1 = 100;
regl1 >>= i;
regl = regl >> i;
if (regl1 != regl) error(0x36);
regl = regl1 = 100;
regl1 &= i;
regl = regl & i;
if (regl1 != regl) error(0x37);
regl = regl1 = 100;
regl1 |= i;
regl = regl | i;
if (regl1 != regl) error(0x38);
regl = regl1 = 100;
regl1 ^= i;
regl = regl ^ i;
if (regl1 != regl) error(0x39);
}
v40() /* 4.0 fixed and tested */
{
long l, l1;
register int i;
/* bit assignments */
low.b1 = high.b2;
high.b1 = low.b2;
l = l1 = 45L;
/* non-code-generating simple expressions */
l *= 1L;
if (l != l1) error(0x40);
l += 0L;
if (l != l1) error(0x41);
l -= 0L;
if (l != l1) error(0x42);
l *= 0L;
if (l != 0L) error(0x43);
l1 %= 1L;
if (l1 != 0L) error(0x44);
/*SMC Bug - not properly extending i register on stack*/
i = 2;
ca[i] = f();
if( ca[i] != f() ) error(0x45);
}
f()
{
return(0);
}
struct xyzzytype {
long x, y, z;
char *xyz, xyzzy;
} saray1[3], saray2[4];
#define max(x,y) ((x > y) ? 'x' : 'y')
#define strings(s1,s2) "s1s2"
#define substitute(x) "x,"
v40a() /* bug fixes and enhancements for v 4.0 ammended */
{
char ch, *s, *t;
ch = max(3,9);
if(ch != '9') error(0x50);
s = strings(s,t);
if (strcmp(s,"s1s2") != 0) error(0x51);
s = substitute(5);
if (strcmp(s,"5,") != 0) error(0x52);
saray2[0].y = 4L; saray2[0].xyzzy = 'p'; saray2[0].x = 450L;
saray1[2] = saray2[0];
}
int v41_testvalue;
v41()
{
register char *p;
register int i;
register int j;
int form;
long m, n;
long al[10];
int aray[3][4][5];
aray[2][3][4] = 4; /* multi dimensional arrays */
if (aray[2][3][4] != 4) error(0x53);
if (lconst1 != 45) error(0x54); /* long constant initialization */
if (lconst2 != 45) error(0x55);
if (lconst3 != 45) error(0x56);
if (lconst4 != 45) error(0x57);
if (lconst5 != 45) error(0x58);
m = 12; n = -1; /* arrays involving long mult for indices */
al[2] = 33L;
n = al[m + n * 10];
if (n != 33L) error(0x59);
al[2L] = 31L; /* arrays involving long indices */
n = al[2];
if (n != 31L) error(0x5a);
1 ? 0 : 2;
1 ? (form = 0) : (form = 1);
if (form != 0) error(0x5b);
form = 3;
0 ? (form = form | ( 1 << 0)) : (form = form & ~(1<<0));
if (form != 2) error(0x5c);
form = 3;
0 ? (form |= (1 << 0)) : (form &= ~(1 << 0));
if (form != 2) error(0x5d);
for( i = 0; i < sizeof(ca); i++ )
ca[i] = i;
i = 0;
p = ca;
if( ca[*p++]++ != 0 ) error(0x61);
if( p != &ca[1] ) error(0x62);
if( ca[0] != 1 ) error(0x63);
if( ca[i+=1]++ != 1 ) error(0x64);
if( i != 1 ) error(0x65);
if( ca[1] != 2 ) error(0x66);
if( ca[i+= *p++]++ != 3 ) error(0x67);
if( i != 3 ) error(0x68);
if( p != &ca[2] ) error(0x69);
if( ca[3] != 4 ) error(0x6a);
j = 1;
i = j++ && j++;
if( j != 3 ) error(0x6b);
if( i != 1 ) error(0x6c);
j = 0;
i = j++ && j++;
if( j != 1 ) error(0x6d);
if( i != 0 ) error(0x6e);
j = 1;
i = --j || --j;
if( j != -1 ) error(0x6f);
if( i != 1 ) error(0x70);
j = 1;
i = j ? --j : --j;
if( j != 0 ) error(0x71);
if( i != 0 ) error(0x72);
v41_testvalue = 128;
if (v41_testvalue != ((long) 128)) error(0x73);
if (v41_testvalue != ((int)(long) 128)) error(0x74);
if (v41_testvalue != (int)((long) 128)) error(0x75);
v41_testvalue = 128 * 3;
if (v41_testvalue != (int)((long) 128*3)) error(0x76);
if ((long)p & 0x80000000);
}
struct qtest {
int sar[10];
};
struct zip {
int i; char c[6]; int j;
} zippo[] = {
0, "zero", 00,
1, "one", 11,
2, "two", 22,
3, "three", 33,
4, 'fo', "ur", 44,
5, "five", 55,
6, 'si', 'x', 0, 0, 0, 66,
7, 'se', 've', 'n\0', 77,
0
};
struct Abit {
char x0;
char x1:1;
int x2:1;
int x3:1;
} bit1;
struct Bbit {
char bx1;
int bx2:1;
int bx3:1;
} bit2;
v42()
{
int case_val, index, tmp;
int aar[10];
struct qtest a;
v41_testvalue = 128 * 3;
if (v41_testvalue != ((int)(long) 128*3)) error(0x80);
case_val = 0200| 'P';
switch(case_val) {
case (0200|'P'): break;
default: error(0x81); break;
}
if (sizeof(a.sar) != sizeof(aar)) error(0x82);
index = 2;
aar[index+1] = 'c';
if (aar[index+'\01'] != 'c') error(0x83);
if (c0[3] != 3) error(0x84);
if (i0[5] != 5) error(0x85);
if (l0[12] != 12) error(0x86);
if (eqstr(zippo[1].c,"one")==0) error(0x87);
if (eqstr(zippo[4].c,"four")==0) error(0x88);
if (eqstr(zippo[6].c,"six")==0) error(0x89);
if (eqstr(zippo[7].c,"seven")==0) error(0x8a);
tmp = 'd';
index = tmp - 'a';
if (ca[index] != ca[tmp - 'a']) error(0x8b);
if (sizeof(struct Proto) != 26) error(0x8c);
if ((sizeof(struct Proto)*2) != sizeof(Ptbl)) error(0x8d);
tmp = 0x7000;
switch(tmp & 0xf000) {
default:
case_val = tmp&0xf000; error(0x8e); printf("val == %x\n",case_val);
case 0x7000:
break;
}
}
struct termio {
int c_iflag;
int c_oflag;
int c_cflag;
int c_lflag;
int c_line;
char c_cc[8];
};
struct termio ttys;
int ttysave;
v42_a()
{
long l;
bit1.x2 = 1;
bit1.x3 = 0;
bit2.bx2 = 1;
bit2.bx3 = 0;
if( bit1.x2 != bit2.bx2) error(0x90);
if( bit1.x3 != bit2.bx3) error(0x91);
if (ch_test() != (DOHIST|QUOTED)) error(0x92);
l = 0x8000L;
if (!(l & 0x8000)) error(0x93);
if (iox(0, (('T'<<8)|1), &ttys) >= 0)
ttysave = ttys.c_oflag;
if (eqstr(star.ctag[3],"three")==0) error(0x94);
if (sa.a[1] != 2) error(0x95);
if (sa.b[1] != 'b') error(0x96);
if (sa.c[1] != 4) error(0x97);
if (eqstr(sa.d[1],"def")==0) error(0x98);
}
iox(i,j,k)
int i, j;
long k;
{
return (1);
}
eqstr(ap1,ap2)
char *ap1, *ap2;
{
register char *p1, *p2;
p1 = ap1;
p2 = ap2;
while(*p1) {
if(*p1++ != *p2++)
return(0);
}
if(*p2)
return(0);
return(1);
}
ch_test()
{
return(DOHIST|QUOTED);
}
error(ernum)
int ernum;
{
printf("error %x\n",ernum);
err++;
}

error(ernum)
int ernum;
{
printf("error %x\n",ernum);
err++;
}

error(ernum)
int ernum;
{
printf("error %x\n",ernum);
err++;
}

error(ernum)
int ernum;
{
printf("error %x\n",ernum);
err++;

View File

@@ -0,0 +1,681 @@
/* Compiler Test Program Part III - version 4.2 plus */
char *version = "%W% %G%";
int x1[5] = { 0, 1, 2, 3, 4, };
int x2[5] = { 0, 1, 2, 3, 4 };
int x3[5] = { 0, 1, 2, 3, };
unsigned u = -1;
char arc[5][3] = {
0x1111, 0x1111, 0x1111, 0x1111, 0x1111,
0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff /* should have warnings on init */
};
int ari[5][3] = {
0x1111, 0x1111, 0x1111, 0x1111, 0x1111,
0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff /* should have 1 warning on init */
};
unsigned int aru[5][3] = {
0x1111, 0x1111, 0x1111, 0x1111, 0x1111,
0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff /* should have 1 warning on init */
};
long arl[5][3] = {
0x1111, 0x1111, 0x1111, 0x1111, 0x1111,
0xffff, 0x1ffff, 0xffff, 0xffff, 0xffff
};
short ars[2][2] = {
0|0100000, 1|0100000, 0xffff, 0x8000|0x040
};
struct Mstruct {
int ar[3];
char c;
} *mtab[] = {
0, 1, 2, 'c'
};
typedef int tdefa[(5)];
typedef int tdefb [10+(2)];
tdefa a;
tdefb b;
int ff[(5)];
struct atype {
int a;
long b;
int c;
} A[] = {
{ 1, 1, 1 },
{ 2, 2, 2 },
{ 3, 3, 3 },
};
struct atype *mikeC[] = { /* better not have any warnings on init... */
0xf1e010,
0xf1e011,
0xf1e012,
0xf1e013,
0,
};
struct btype {
char *p1;
int i;
char c;
} B = {
"This is a string.....",
35,
'p'
};
int err;
char string[] = "9876543210";
int fun1(), fun2();
struct {
int sz;
int (*func)();
} fun[2] = { 1, fun1, 2, fun2 };
int fglobal;
int global1 = 4, global2 = 5;
main()
{
v42();
test();
test2();
aray();
do_stass();
do_sizeof();
dbra_tst();
new_test();
if (err)
printf("Tough Luck...\n");
else
printf("Far Freaking Out...\n");
}
error(ernum)
int ernum;
{
printf("error %x\n",ernum);
err++;
}
short mstype;
typedef struct MODES {
short imap;
} MODER, *pMODER;
static MODER amode;
pMODER vmode;
v42()
{
int i;
struct test {
int a;
long b;
struct {
char c;
int d;
}y;
} x;
if (A[0].b != 1) error(0x1);
if (A[1].c != 2) error(0x2);
if (A[2].a != 3) error(0x3);
x.y.d = 3;
x.a = 0;
{
if (!x.y.d) error(0x4);
}
if (x.a) error(0x5);
{
char *s = &string;
int i;
i = *s - '0';
if (i != 9) error(0x5);
}
{
register int regi;
int i;
if ((i=f(3)) > f(1)) ; else error(0x6);
if ((regi=f(3)) > f(1)) ; else error(0x7);
}
if (1) {
short count = 0;
mstype = 33;
}
if (mstype != 33) error(0x8);
ff[i=0] = 33;
if (ff[0] != 33) error(0x9);
if(!main) error(0x10);
vmode = &amode;
}
f(val)
int val;
{
return(val);
}
struct fi_index {
long fi_flags;
unsigned fi_count;
char fi_groupid;
char fi_nlinks;
int fi_ownerid;
long fi_fsize;
long fi_findblk;
int fi_dev;
int fi_lock;
int fi_spdev;
char *fi_rlocks;
};
char ca[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int ica[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
char cb[10] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
char cc[10] = { '01', '23', '45', '67', '89' };
struct A {
int a;
long b;
} atype[] = {
0, 3,
1, 4,
2, 5
};
int three[3][3][3] = {
0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2
};
/*char ar_test[0xf0000];*/
aray()
{
register int n;
register char c, *bp;
register struct fi_index *fip;
struct fi_index xxx;
fip = &xxx;
xxx.fi_fsize = 3;
n = 5000;
if( n > (4096 - fip->fi_fsize) ) {
n = 4096 - fip->fi_fsize;
if (n != (4096 - fip->fi_fsize)) error(0x20);
}
else
error(0x21);
if (ca[3] != 3) error(0x22);
if (ica[7] != 7) error(0x23);
if (cb[5] != '5') error(0x24);
if (cc[8] != '8') error(0x25);
if (atype[2].a != 2) error(0x26);
if (atype[0].b != 3) error(0x27);
if (three[0][0][2] != 0) error(0x28);
if (three[1][1][1] != 1) error(0x29);
if (three[2][2][0] != 2) error(0x2a);
/*
ar_test[0xa000L] = '7'; bp = &ar_test[0];
c = bp[0xa000L];
if (c != '7') error(0x2b);
ar_test[0x10000] = 'T';
c = bp[0x10000];
if (c != 'T') error(0x2c);
*/
}
struct {
int _a, _a1, _a2, _a3, _a4;
long _b, _b1, _b2, _b3, _b4;
char _c, _c2, _c3, _c4;
} st, *pt, st2, *pt2, sa[3];
do_stass()
{
pt = &st; pt2 = &st2;
st._b4 = 3; st2._b4 = 9;
st = st2;
if (st._b4 != st2._b4) error(0x28);
pt->_b1 = 55; pt2->_b1 = 34;
*pt = *pt2;
if (pt->_b1 != pt2->_b1) error(0x29);
st = *pt;
*pt = st;
sa[0]._c4 = 'd'; sa[1]._c4 = '8';
sa[1] = sa[0];
if (sa[0]._c4 != sa[1]._c4) error(0x2a);
}
struct sz_struc {
int za[10];
char zc;
char zb[3];
struct xxx {
char zd[5];
long ze[2];
}zf;
} *s, t;
int szaray[10];
typedef struct TDS {
char st;
unsigned fConstant : 1;
unsigned width : 7;
unsigned bt : 4;
unsigned tq1 : 2;
unsigned tq2 : 2;
unsigned tq3 : 2;
unsigned tq4 : 2;
unsigned tq5 : 2;
unsigned tq6 : 2;
} TDR, *pTDR;
typedef struct {
char sbVar[8];
TDR td;
long valTy;
} TYR, *pTYR;
TYR vrgTySpc[] = { /* test of short element initialization */
{"$cBad", '\0', '\0', '\0', '\0', 0},
0
};
struct one {
struct two *p2;
struct one *p1;
};
struct two {
int atwo, btwo, ctwo, dtwo;
};
struct one xyzzy[] = {
0, 0
};
char szof[10];
struct AAAAA {
char a[3];
int b[3];
long c[3];
double d[3];
char e[3][3];
int f[3][3];
long g[3][3];
double h[3][3];
char i;
int j;
long k;
float l;
} *abcdef;
do_sizeof()
{
char nx[sizeof szof];
char ny[sizeof (szof)];
int i;
long l;
char *p;
int *pi;
if ( sizeof(vrgTySpc) != (2 * sizeof(TYR)) ) error(0x30);
if ( sizeof(s->za) != 20 ) error(0x31);
if ( sizeof(s->zb) != 3 ) error(0x32);
if ( sizeof(s->zf) != 14 ) error(0x33);
if ( sizeof(s->zf.ze) != 8 ) error(0x34);
if ( sizeof(szaray) != 20 ) error(0x35);
if ( sizeof(t.za) != 20 ) error(0x36);
if ( sizeof(s->za[4]) != 2 ) error(0x37);
if ( sizeof(t.zc) != 1 ) error(0x38);
if ( sizeof(p) != 4 ) error(0x39);
if ( sizeof(pi) != 4 ) error(0x3a);
if ( sizeof(xyzzy) != 8 ) error(0x3b);
if ( sizeof(l) != 4 ) error(0x3c);
if ( sizeof(*p) != 1 ) error(0x3d);
if ( sizeof(*pi) != 2 ) error(0x3e);
if ( sizeof(szaray[4]) != 2 ) error(0x3f);
if ( sizeof(struct one) != 8) error(0x40);
if ( sizeof(nx) != sizeof ny) error(0x41);
if ( sizeof(ny) != 10) error(0x42);
if ( sizeof(abcdef->a) != 3) error(0x43);
if ( sizeof(abcdef->b) != 6) error(0x44);
if ( sizeof(abcdef->c) != 12) error(0x45);
if ( sizeof(abcdef->d) != 12) error(0x46);
if ( sizeof(abcdef->e) != 9) error(0x47);
if ( sizeof(abcdef->f) != 18) error(0x48);
if ( sizeof(abcdef->g) != 36) error(0x49);
if ( sizeof(abcdef->h) != 36) error(0x4a);
if ( sizeof(abcdef->i) != 1) error(0x4b);
if ( sizeof(abcdef->j) != 2) error(0x4c);
if ( sizeof(abcdef->k) != 4) error(0x4d);
if ( sizeof(abcdef->l) != 4) error(0x4e);
}
typedef long ADRT;
ADRT vfp;
int PutState()
{
vfp = 1; /* just needs to compile.... */
}
struct saxer {
struct saxer *ptr;
unsigned int u_incr;
int i_incr;
} john[4];
typedef long X;
X typey;
#define STL 0x400L
struct xx {
int a, b;
};
test()
{
register struct saxer *p, *q;
register short mask;
int dp, z, *zp;
long l, lo;
register char rc;
register int ri;
char c;
int i;
struct xx xa[8/sizeof(struct xx)];
struct xx xd[8/4];
dp = 0x720;
mask = ((dp&0xff)<<1) -1;
if (mask != 0x3f) error(0x50);
l = 0x7777ff30;
casttest((int)(l&0xff)); /* error 0x51 */
lo = 0;
l = STL - lo;
if (l != 0x400L) error(0x52);
l = 0xffffffff;
if (!(l & 0x80000000)) error(0x53);
l &= 0x80000000;
if (l != 0x80000000) error(0x54);
mask = 1;
l = 0xf;
mask += (l&1);
if (mask != 2) error(0x55);
z = 1;
(*fun[z].func)();
if (fglobal != 3) error(0x56);
typey = 0x71234;
fun1(typey); /* error 0x57 */
z = 34;
z &= 0;
if (z) error(0x58);
p = &john[0]; q = &john[0];
p->u_incr = 2;
p->i_incr = 2;
p += p->u_incr;
q += q->i_incr;
if (p != q) error(0x59);
if (sizeof(xa) != sizeof(xd)) error(0x5a);
zp = &z;
*zp = 34;
*zp != 0;
if (*zp != 34) error(0x5b);
if (global1 != 4) error(0x5c);
if (global2 != 5) error(0x5d);
rc = 6; c = 8; ri = 2; i = 4;
c /= ri;
if (c != 4) error(0x5e);
c /= i;
if (c != 1) error(0x5f);
rc /= 2;
if (rc != 3) error(0x60);
}
casttest(i)
int i;
{
if (i != 0x30) error(0x51);
}
fun1(l)
long l;
{
fglobal = 2;
if (l != 0x71234) error(0x57);
}
fun2()
{
fglobal = 3;
}
char *shifts[4] = { "as", "ls", "rox", "ro" };
test2()
{
int i;
long l;
int y();
char *mnem;
int opcode;
l = 0xfe00; /* hex constant should be int value, which should go neg */
if (l > 0) error(0x61);
l = 32768;
if (l < 0) error(0x62);
f2(fun2,fun2); /* error 0x63 */
mnem = shifts[(opcode>>9)&3];
is_512L(0x64,512L); /* error 0x64 */
is_512L(0x65,(long)512); /* error 0x65 */
i = 512;
l = 512;
is_512L(0x66,l); /* error 0x66 */
is_512L(0x67,(long)i); /* error 0x67 */
l = 500; i = 12;
is_512L(0x68,l+i); /* error 0x68 */
is_512L(0x69,512L*1); /* error 0x69 */
is_512L(0x6a,511L+1); /* error 0x6a */
is_512L(0x6b,1*512L); /* error 0x6b */
is_512L(0x6c,1+511L); /* error 0x6c */
is_512L(0x6d,(long)(512*1));/* error 0x6d */
is_512L(0x6e,513L-1); /* error 0x6e */
is_512L(0x6f,512L/1); /* error 0x6f */
}
is_512L(enum,lval)
int enum;
long lval;
{
if (lval != 512L)
error(enum);
}
static f2(a1,a2)
char *a1, *a2;
{
if (a1 != a2) error(0x63);
}
int i_global;
dbra_tst()
{
register long reg_l;
register int localreg;
int local;
long local_l;
local_l = i_global = local = localreg = reg_l = 1L;
if(--i_global == -1) error(0x70);
if(--local == -1) error(0x71);
if(--localreg == -1) error(0x72);
if(--local_l == -1) error(0x73);
if(--reg_l == -1) error(0x74);
if(--i_global == -1) ; else error(0x75);
if(--local == -1) ; else error(0x76);
if(--localreg == -1) ; else error(0x77);
if(--local_l == -1L) ; else error(0x78);
if(--reg_l == -1L) ; else error(0x79);
}
typedef char TBOOL;
TBOOL tboolx[2], tbooly[(2)];
struct xtype {
char *p1;
char *ar[20];
char *p2;
};
struct xtype newff = {
"p1",
"zero",
"one",
};
char *xfp = "abc";
struct xtype ff0 = {
0L,
1L,
2L,
3L,
4L,
5L,
6L,
7L,
};
struct xtype ff1 = {
"p1",
"zero",
"one",
"two",
"three",
"four",
"five",
"p2",
};
struct xtype ff2 = {
"p1",
"zero",
"one",
"two",
"three",
"four",
"five",
"p2"
};
struct xtype ff3 = {
"p1",
"zero",
"one",
"two",
"three",
"four",
"five",
};
struct xtype ff4 = {
"p1",
"zero",
"one",
"two",
"three",
"four",
"five"
};
struct xtype ff5 = {
"p1",
"zero",
"one",
"two",
};
struct xtype ff6 = {
"p1",
"zero",
"one",
"two"
};
new_test()
{
char *cp;
extern int err;
char str[9];
int i;
unsigned u;
/* typedef and paren'd strangeness */
if(sizeof(tboolx) != sizeof(tbooly)) error(0x80);
if(sizeof(tbooly) != 2) error(0x81);
tboolx[1] = 1; tbooly[1] = 1;
cp = tboolx;
if(*(cp+1) != 1) error(0x82);
cp = tbooly;
if(*(cp+1) != 1) error(0x83);
/* assignment as a subscript */
str[i=0] = 3;
if(str[i] != 3) error(0x84);
if(i != 0) error(0x85);
/* structure pointer array initializations */
newff.ar[1] = "xyz";
if(*xfp != 'a' || *(xfp+1) != 'b' || *(xfp+2) != 'c') error(0x86);
/* unsigned increment to pointer */
cp = str; i = u = 3;
*(cp+i) = 'c';
if (*(cp+u) != 'c') error(0x87);
}
ned increment to pointer */
cp = str; i = u = 3;
*(cp+i) = 'c';
if (*(cp+u) != 'c') error(0x87);
}
ned increment to pointer */
cp = str; i = u = 3;
*(cp+i) = 'c';
if (*(cp+u) != 'c') error(0x87);
}
ned increment to pointer */
cp = str; i = u = 3;
*(cp+i) = 'c';

View File

@@ -0,0 +1,644 @@
/* Post 4.2 compilers */
char *version = "%W% %G%";
struct xxx {
int x;
char m,n,o,p;
};
struct zzz {
int b;
struct aaa {
int f;
char g, h, i, j;
} bb[3];
int c;
} A = {
1,
2, 'a', 'b', 'c', 'd',
3, 'e', 'f', 'g', 'h'
};
struct yyy {
int a;
struct xxx y[3];
int q;
} B = {
1,
2, 'a', 'b', 'c', 'd',
3, 'e', 'f', 'g', 'h'
};
char ar[3][3] = { 'a', 'b', 'c', 'd', 'e' };
int x[2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, };
int errors;
main()
{
xtest();
ytest();
ztest();
dec_inc();
div_test();
s_u_test();
next_to_last_test();
last_test();
if(!errors)
printf("Far Freaking Out\n");
else
printf("Tough Luck\n");
}
error(enum)
int enum;
{
printf("error %x\n",enum);
errors++;
}
char *xstr1 = "8999999988";
char *xstr2 = "8999999988";
char *xstr3 = "8999999988";
xtest()
{
register char *rcp, rc;
char *cp, c;
int i;
long *laddr;
int *iaddr;
short *saddr;
long addr;
if(A.bb[1].i != 'g') error(0x1);
if(A.bb[1].i != B.y[1].o) error(0x2);
if(A.c != 0) error(0x3);
if(B.y[3].f != 0) error(0x4);
i = 257;
i = (char)(i + 3);
if (i != 4) error(0x5);
saddr = laddr = iaddr = addr = 0xff000;
if(laddr != addr) error(0x6);
if(iaddr != addr) error(0x7);
if(saddr != addr) error(0x8);
rcp = &xstr1[6];
while((*rcp)++ == '9')
*rcp-- = '0';
rcp = &xstr2[7];
while((*--rcp)++ == '9')
*rcp = '0';
cp = &xstr3[7];
while((*--cp)++ == '9')
*cp = '0';
if(strcmp(xstr1,"9000000988") != 0) error(0x9);
if(strcmp(xstr2,"9000000988") != 0) error(0xa);
if(strcmp(xstr3,"9000000988") != 0) error(0xb);
rc = '9';
rc = *rcp++ = '3';
if(rc != '3') error(0xc);
if(*(rcp-1) != '3') error(0xd);
c = '8';
c = (char)0;
if(c != '\0') error(0xe);
if(multest() != 4) error(0xf);
}
struct bfs {
int bf1: 1;
} bfx, *bfa[3] = { (char *)-1, &bfx, (char *)-1} ;
char xar[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
dec_inc()
{
register struct bfs **bfp;
register char *p, *q, c;
bfx.bf1 = 0;
bfp = &bfa[2];
(*--bfp)->bf1 += 1;
if( bfx.bf1 != 1 ) error(0x10);
p = &xar[10];
(*--p)++;
if( xar[9] != 10 || p != &xar[9] ) error(0x11);
c = (*--p)++;
if( c != 8 || xar[8] != 9 || p != &xar[8] ) error(0x12);
c = 7;
if( (*--p)++ != c || xar[7] != 8 || p != &xar[7] ) error(0x13);
p = &xar[0];
(*p++)++;
if( xar[0] != 1 || p != &xar[1] ) error(0x14);
c = (*p++)++;
if( c != 1 || xar[1] != 2 || p != &xar[2] ) error(0x15);
c = 2;
if( (*p++)++ != c || xar[2] != 3 || p != &xar[3] ) error(0x16);
--(*--p);
if( xar[2] != 2 || p != &xar[2] ) error(0x17);
c = --(*--p);
if( c != 1 || xar[1] != 1 || p != &xar[1] ) error(0x18);
c = 0;
if( --(*--p) != c || xar[0] != 0 || p != &xar[0] ) error(0x19);
--(*p++);
if( xar[0] != -1 || p != &xar[1] ) error(0x1a);
c = --(*p++);
if( c != 0 || xar[1] != 0 || p != &xar[2] ) error(0x1b);
c = 1;
if( --(*p++) != c || xar[2] != 1 || p != &xar[3] ) error(0x1c);
}
multest()
{
char *s;
register int i;
int j;
s = &j;
*s = 2;
s[1] = 0;
i = 2;
return(i * *s);
}
div_test()
{
int i, i2;
long l, l2;
register int ri, ri2;
register long rl, rl2;
rl2 = l2 = 70000;
ri = rl2 / 10;
rl = rl2 / 10;
i = l2 / 10;
l = l2 / 10;
if(ri != i) error(0x20);
if(rl != l) error(0x21);
if(i != 7000) error(0x22);
if(i != l) error(0x23);
i2 = ri2 = 1;
ri = rl2 / ri2;
rl = rl2 / ri2;
i = l2 / i2;
l = l2 / i2;
if(ri != i) error(0x24);
if(rl != l) error(0x25);
if(rl != rl2) error(0x26);
if(ri == rl) error(0x27);
}
struct fcbflags {
unsigned online : 1;
unsigned buffer_dirty : 1;
unsigned open_mode : 2;
unsigned device_type : 3;
unsigned file_type : 2;
unsigned unbuffered : 1;
};
struct fcb {
int fcbfd;
char *fcpfp;
struct fcbflags fcbflg;
char name;
};
#define ONE 1
#define TWO 2
#define IADDRESS ((int *)0xfff900)
#define CADDRESS ((char *)0xfff900)
#define LADDRESS ((long *)0xfff900)
#define SADDRESS ((struct device *)0xfff900)
struct device {
int mts;
char mtc;
long mtl;
int mti;
};
struct exec {
int xx[19];
int y;
};
typedef char *charp;
struct t {
char *p1;
char *p2;
} ht1 = { 0, ((charp) 30) },
ht2 = { 0, 0 };
ytest()
{
register struct fcb *p;
register long rl;
register int *rpi;
register long *rpl;
register int ri1, ri2;
struct fcb fs;
long a;
int i, j, ari[5];
long l, arl[5];
char buf[40];
struct exec hdr, hdr2;
/* bit field arguments */
i = 1; p = &fs;
p->fcbflg.unbuffered = (i == 0) ? 0 : 1;
if (!p->fcbflg.unbuffered) error(0x30);
i = 0;
p->fcbflg.unbuffered = (i == 0) ? 0 : 1;
if (p->fcbflg.unbuffered) error(0x31);
/* constant coersion */
l = 32768;
if (l != 32768L) error(0x32);
l = 32 * 1024;
if (l != 32768L) error(0x33);
/* long to integer conversions including as parameters and return values */
l = 0xf00030;
ctest(0x34,0x35,(int)l,27); /* errors 34 & 35 */
ctest2(0x36,(int)l); /* error 36 */
l = 0xfff30;
ctest(0x37,0x38,((int)l)&0xff,27); /* errors 37 & 38 */
ctest2(0x39,((int)l)&0xff); /* error 39 */
ctest(0x3a,0x3b,(int)(l&0xff),27); /* errors 3a & 3b */
ctest2(0x3c,(int)(l&0xff)); /* errors 3c */
if(func1(1) != 0x30) error(0x3d);
if(func1(2) != 0x30) error(0x3e);
if(func1(3) != 0x30) error(0x3f);
/* equal-shift tests */
rpi = &ari[3]; rpl = &arl[3];
*rpi = 0x3f02;
*rpi++ >>= 1;
if(ari[3] != 0x1f81) error(0x40);
*--rpi <<= 2;
if(ari[3] != 0x7e04) error(0x41);
*rpl = 0x6af010;
*rpl++ >>= 4;
if(arl[3] != 0x6af01) error(0x42);
*--rpl <<=5;
if(arl[3] != 0xd5e020) error(0x43);
/* sethy-ulman easy expression */
i = 10; j = 3;
a = (long)i * (long)i - (long)j * (long)j;
if(a != 91) error(0x44);
/* tricky coercion of constant to integer pointer with array subscript */
/* indexing off of int/long/char/struct pointers */
l = &IADDRESS[TWO];
if(l != 0xfff904) error(0x45);
l = &LADDRESS[TWO];
if(l != 0xfff908) error(0x46);
l = &CADDRESS[TWO];
if(l != 0xfff902) error(0x47);
l = &(SADDRESS->mtc);
if(l != 0xfff902) error(0x48);
l = &(SADDRESS->mtl);
if(l != 0xfff904) error(0x49);
l = &(SADDRESS->mti);
if(l != 0xfff908) error(0x4a);
/* structure assigned to non structure item... */
hdr.y = 3; hdr2.y = 5;
*(struct exec *)buf = hdr;
hdr2 = *(struct exec *)buf;
if(hdr2.y != 3) error(0x4b);
/* typedef cast inside structure initialization */
if(ht1.p2 != 30) error(0x4c);
/* indexing test with register index variables */
i = j = ri1 = ri2 = 1;
if (x[ri1][ri2][ri1] != x[1][1][1]) error(0x4d);
if (x[i][j][i] != x[1][1][1]) error(0x4e);
}
struct zxx {
int a,b,c,d,e;
};
ztest()
{
register long longtmp;
int i, j, k;
char *cp1, *cp2;
int *ip1, *ip2;
long *lp1, *lp2, l;
struct zxx *sp1, *sp2;
/* int's cast to pointers... */
i = 0x234;
cp1 = i; cp2 = (char *)i;
ip1 = i; ip2 = (int *)i;
lp1 = i; lp2 = (long *)i;
sp1 = i; sp2 = (struct zxx *)i;
if(cp1 != cp2) error(0x70);
if(ip1 != ip2) error(0x71);
if(lp1 != lp2) error(0x72);
if(sp1 != sp2) error(0x73);
/* long easy code skeleton tests */
i = 0x24; j = 0x11;
/* addition.... */
k = i * i + j * j;
longtmp = (long)i * (long)i + (long)j * (long)j;
l = (long)i * (long)i + (long)j * (long)j;
if(longtmp != l) error(0x74);
if(k != l) error(0x75);
/* subtraction.... */
k = i * i - j * j;
longtmp = (long)i * (long)i - (long)j * (long)j;
l = (long)i * (long)i - (long)j * (long)j;
if(longtmp != l) error(0x76);
if(k != l) error(0x77);
/* exclusive or.... */
k = i * i ^ j * j;
longtmp = (long)i * (long)i ^ (long)j * (long)j;
l = (long)i * (long)i ^ (long)j * (long)j;
if(longtmp != l) error(0x78);
if(k != l) error(0x79);
/* inclusive or.... */
k = i * i | j * j;
longtmp = (long)i * (long)i | (long)j * (long)j;
l = (long)i * (long)i | (long)j * (long)j;
if(longtmp != l) error(0x7a);
if(k != l) error(0x7b);
}
struct _b {
long y;
int x;
} bs;
union rec {
struct _b l;
struct {
char c;
int w;
} f;
} recs;
struct ty {
int c;
} tys;
struct _a {
int x;
} as;
union one {
int a;
long b;
struct {
int y;
int x;
} q;
} ones, f1, f2;
struct two {
int a;
long b;
struct {
int y;
int x;
} q;
} twos;
struct _x {
long a;
int b,c,d,e,f;
};
struct _y {
int t;
struct _x s;
} _yz = {
33,
{ 1, 2, 3, 4, 5 }
};
struct _y _yq = { 33, 1, 2, 3, 4, 5 };
struct _s1 {
int a;
int b;
};
struct _s2 {
struct _s1 c;
int d;
};
struct _s2 test0 = { { 10, 20 }, 30 };
struct _s2 test1 = { { 10, 20 } };
struct _s2 test2 = { { 10 }, 30 };
struct _s2 test3 = { 10, 20, 30 };
s_u_test()
{
bs.y = 1;
bs.x = 2;
recs.l.y = 3;
recs.l.x = 4;
tys.c = 'a';
as.x = 5;
if(bs.y != 1) error(0x50);
if(bs.x != 2) error(0x51);
if(recs.l.y != 3) error(0x52);
if(recs.l.x != 4) error(0x53);
if(tys.c != 'a') error(0x54);
if(as.x != 5) error(0x55);
recs.f.c = 'b';
recs.f.w = 6;
if(recs.f.c != 'b') error(0x56);
if(recs.f.w != 6) error(0x57);
if(tys.c != 'a') error(0x58);
twos.a = 7;
twos.b = 8;
twos.q.y = 9;
twos.q.x = 10;
ones.a = 11; f1.b = 0; f2.b = 0;
if(twos.a != 7) error(0x59);
if(twos.b != 8) error(0x5a);
if(twos.q.y != 9) error(0x5b);
if(twos.q.x != 10) error(0x5c);
if(ones.a != 11) error(0x5d);
ones.b = 12;
if(ones.b != 12) error(0x5e);
if(f1.b != 0) error(0x5f);
if(f2.b != 0) error(0x60);
f1.b = f2.b = 0;
ones.q.y = 13;
if(ones.q.y != 13) error(0x61);
if(f1.b != 0) error(0x62);
if(f2.b != 0) error(0x63);
f1.b = f2.b = 0;
ones.q.x = 14;
if(ones.q.x != 14) error(0x64);
if(f1.b != 0) error(0x65);
if(f2.b != 0) error(0x66);
/* initialization tests */
if(_yz.s.c != 3) error(0x67);
if(_yq.s.c != 3) error(0x68);
if(test0.d != 30) error(0x69);
if(test0.c.b != 20) error(0x6a);
if(test1.d != 0) error(0x6b);
if(test2.c.b != 0) error(0x6c);
if(test3.c.b != 20) error(0x6d);
if(test3.d != 30) error(0x6e);
if(test2.d != 30) error(0x6f);
}
ctest(err1,err2,value1,value2) /* value1 had better be an integer !!! */
int err1, err2, value1, value2;
{
if(value1 != 0x30) error(err1);
if(value2 != 27) error(err2);
}
ctest2(err,value) /* value had better be an integer !!! */
int err, value;
{
if(value != 0x30) error(err);
}
func1(ret) /* had better return an integer....... */
int ret;
{
long l;
l = 0xf0030;
if(ret==1) return((int)l);
l = 0xfff30;
if(ret==2) return(((int)l)&0xff);
return((int)(l&0xff)); /* return 3 */
}
struct {
char x_p[3][3];
} *p_ca2, ca2;
int artl();
struct {
int ss_x_z;
int (*ss_ff)();
} sff[] = {3, 0L, 4, &artl};
next_to_last_test()
{
char ch;
int x, y;
char ar[9];
register char c;
/* defined character constants handled properly ?? */
x = '\0';
if(x != 0) error(0x80);
x = '\f';
if(x != 014) error(0x81);
x = '\t';
if(x != 011) error(0x82);
x = '\n';
if(x != 012) error(0x83);
x = '\r';
if(x != 015) error(0x84);
x = '\b';
if(x != 010) error(0x85);
x = '\\';
if(x != 0134) error(0x86);
/* character indices... */
ar[1] = '5'; ar[2] = '6'; x = 1;
ar[ c = (x==1) ? 2 : 1 ] = '3';
if (c != 2) error(0x87);
if(ar[2] != '3') error(0x88);
ar[c & ~128] = '5';
if(ar[2] != '5') error(0x89);
/* array indices incrementing with pointers and other strange things */
p_ca2 = &ca2;
ca2.x_p[1][1] = 'c';
x = 1; y = 1;
p_ca2->x_p[x][y++] = 'd';
if(ca2.x_p[1][1] != 'd') error(0x8a);
if(y != 2) error(0x8b);
/* struct with function arg return */
x = 1;
x = (*sff[x].ss_ff)();
if (x != 4) error(0x8c);
/* character's compared to integer and long constants */
ch = 127;
if(ch > 0xffffff) error(0x8d);
if(ch > 0xfff) error(0x8e);
if(ch != 127) error(0x8f);
}
struct {
char *a;
char *b;
char *c[3];
} flxtv = {
"one",
"two",
"three",
"four",
"five"
};
char ln[3] = "ab";
struct atbh1 { unsigned sevensta:16, sevenstb:4; };
struct atbh2 { unsigned a:4, b:4, c:4; };
last_test()
{
struct atbh1 x;
struct atbh2 y;
int i;
char c, *cp;
/* bit field manipulation */
x.sevensta = 2;
x.sevenstb = 1;
if(x.sevensta != 2) error(0x90);
if(x.sevenstb != 1) error(0x91);
y.a = 3; y.b = 2; y.c = 1;
i = (int)y.a;
if (i != 3) error(0x92);
i = (int)y.b;
if (i != 2) error(0x93);
i = (int)y.c;
if (i != 1) error(0x94);
/* character manipulation */
i = ln[0] * ln[1];
if(i != 9506) error(0x95);
cp = ln;
c = 0xf4;
*cp++ |= (c & 0xf);
if(ln[0] != 0x65) error(0x96); /* 'a' | 0x4 */
cp = flxtv.c[1];
if(*cp != 'f' || *(cp+1) != 'o' || *(cp+2) != 'u' || *(cp+3) != 'r')
error(0x97);
}
artl(last_test)
int last_test; /* argument with same name as function !!! */
{
last_test = 4;
return(last_test);
}
 as function !!! */
{
last_test = 4;
return(last_test);
}
 as function !!! */
{
last_test = 4;
return(last_test);
}
 as function !!! */
{
last_test = 4;

Binary file not shown.