[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/CircularLog RandRWC.nc, 1.1.2.2, 1.1.2.3

David Gay idgay at users.sourceforge.net
Wed May 31 16:56:15 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/storage/CircularLog
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv18229/CircularLog

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	RandRWC.nc 
Log Message:
fix circular log test app


Index: RandRWC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/storage/CircularLog/Attic/RandRWC.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** RandRWC.nc	31 May 2006 23:39:13 -0000	1.1.2.2
--- RandRWC.nc	31 May 2006 23:56:12 -0000	1.1.2.3
***************
*** 34,37 ****
--- 34,39 ----
      SIZE = 1024L * 256,
      NWRITES = SIZE / 512,
+     RECSIZE = 32,
+     NRECS = 16
    };
  
***************
*** 65,72 ****
    }
    
!   uint8_t data[512], rdata[512];
    int count, testCount;
-   uint32_t len;
-   uint16_t offset;
    message_t reportmsg;
  
--- 67,72 ----
    }
    
!   uint8_t data[NRECS * RECSIZE], rdata[RECSIZE];
    int count, testCount;
    message_t reportmsg;
  
***************
*** 106,127 ****
    }
  
-   void setParameters() {
-     len = ((rand() >> 10) + 1) * 7;
-     offset = rand() >> 8;
-     if (offset + len > sizeof data)
-       offset = sizeof data - len;
-   }
- 
    void nextRead() {
!     setParameters();
!     scheck(call LogRead.read(rdata, len));
    }
  
    event void LogRead.readDone(void* buf, storage_len_t rlen, error_t result) __attribute__((noinline)) {
!     if (len != 0 && rlen == 0)
        done();
!     else if (scheck(result) && bcheck(rlen == len && buf == rdata) &&
! 	     bcheck(call LogRead.currentOffset() % 7 == 0))
!       nextRead();
    }
  
--- 106,129 ----
    }
  
    void nextRead() {
!     scheck(call LogRead.read(rdata, RECSIZE));
    }
  
    event void LogRead.readDone(void* buf, storage_len_t rlen, error_t result) __attribute__((noinline)) {
!     if (rlen == 0)
        done();
!     else if (scheck(result) && bcheck(rlen == RECSIZE && buf == rdata))
!       {
! 	int i;
! 
! 	/* It must be one of our possible records */
! 	for (i = 0; i < sizeof data; i += RECSIZE)
! 	  if (memcmp(buf, data + i, RECSIZE) == 0)
! 	    {
! 	      nextRead();
! 	      return;
! 	    }
! 	bcheck(FALSE);
!       }
    }
  
***************
*** 134,139 ****
      else
        {
! 	setParameters();
! 	scheck(call LogWrite.append(data + offset, len));
        }
    }
--- 136,142 ----
      else
        {
! 	int offset = ((rand() >> 8) % NRECS) * RECSIZE;
! 
! 	scheck(call LogWrite.append(data + offset, RECSIZE));
        }
    }



More information about the Tinyos-2-commits mailing list