Annotation of xinu/sys/TEST/test.c.dsk1, revision 1.1

1.1     ! root        1: /* test.c - main */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <xebec.h>
        !             6: #include <dtc.h>
        !             7: #include <disk.h>
        !             8: 
        !             9: #define        NBLOCKS 200
        !            10: 
        !            11: /*------------------------------------------------------------------------
        !            12:  *  main  --  test disk driver
        !            13:  *------------------------------------------------------------------------
        !            14:  */
        !            15: main()
        !            16: {
        !            17:        int     w;                      /* nonzero for write test       */
        !            18:        int     i, j;
        !            19:        char    ch;
        !            20:        char    buff[DBUFSIZ], buf2[DBUFSIZ];
        !            21: 
        !            22:        kprintf("Type R for read-only test, W for read/write test: ");
        !            23:        while ( (ch=getc(CONSOLE)) != 'R' && ch!='W')
        !            24:                ;
        !            25:        w = ch=='W' ? 1 : 0;
        !            26:        if (w)
        !            27:                kprintf("\nPerforming read/write test\n\n");
        !            28:        else
        !            29:                kprintf("\nPerforming only read test\n\n");
        !            30:        kprintf("Test 1: read first %d blocks from disk.\n",NBLOCKS);
        !            31:        for (i=0 ; i<NBLOCKS ; i++)
        !            32:                if (NBLOCKS < 20)
        !            33:                kprintf("Read of block %d is %d\n",i,read(DISK0,buff,i));
        !            34:                else
        !            35:                        read(DISK0,buff,i);
        !            36:        if ( ! w ) {
        !            37:                kprintf("Finshed testing\n");
        !            38:                return;
        !            39:        }
        !            40:        for (j=0 ; j< DBUFSIZ ; j++)
        !            41:                buf2[j] = 'X';
        !            42:        kprintf("\nTest 2: write the first %d blocks\n",NBLOCKS);
        !            43:        for (i=0 ; i < NBLOCKS ; i++)
        !            44:                if (NBLOCKS < 20)
        !            45:                kprintf("Write of block %d is %d\n",i,
        !            46:                        write(DISK0,dskcbuf(buf2),i));
        !            47:                else
        !            48:                        write(DISK0,dskcbuf(buf2),i);
        !            49:        kprintf("\nTest 3: read back and check first %d blocks\n",NBLOCKS);
        !            50:        for (i=0 ; i < NBLOCKS ; i++) {
        !            51:                for (j=0 ; j<DBUFSIZ ; j++)
        !            52:                        buff[j] = '\01';
        !            53:                if (NBLOCKS < 20)
        !            54:                kprintf("Read of block %d got %d\n",i,read(DISK0,buff,i));
        !            55:                else
        !            56:                        read(DISK0,buff,i);
        !            57:                for (j=0 ; j<DBUFSIZ ; j++)
        !            58:                        if (buf2[j] != buff[j])
        !            59:                                kprintf("Error on byte %d 0%o->0%o\n",
        !            60:                                        j,buf2[j],buff[j]);
        !            61:                if (NBLOCKS < 20)
        !            62:                        kprintf("Comparison done\n");
        !            63:        }
        !            64:        kprintf("\n\nFinished all tests\n");
        !            65: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.