11c1c560b88d430fd2c6967a86d2e87109806357
max
  Fri Jan 24 09:15:03 2014 -0800
corrections after code review refs #12524. These changes probably don'tneed to reviewed anymore, as Angie has already seen them, I copied them into
the ticket #12524.

diff --git src/lib/tests/udcTest.c src/lib/tests/udcTest.c
index 41d4663..c52bc9f 100644
--- src/lib/tests/udcTest.c
+++ src/lib/tests/udcTest.c
@@ -1,41 +1,43 @@
 /* udcTest -- test the URL data cache */
 
 // suggestions from Mark: 1. try setvbuf, to make FILE * unbuffered -- does that help?
 //                        2. *if* need to do own buffering, consider mmap()
 //                           (kernel handles buffering)
 
 #include <sys/wait.h>
 #include "common.h"
 #include "errabort.h"
 #include "options.h"
 #include "portable.h"
 #include "udc.h"
 
 
 static struct optionSpec options[] = {
+    {"size",    OPTION_BOOLEAN},
     {"raBuf",    OPTION_BOOLEAN},
     {"fork",     OPTION_BOOLEAN},
     {"protocol", OPTION_STRING},
     {"seed",     OPTION_INT},
     {NULL, 0},
 };
 
 boolean raBuf = FALSE;   /* exercise the read-ahead buffer */
 boolean doFork = FALSE;
 char *protocol = "ftp";
 unsigned int seed = 0;
+int size = 0;
 
 // Local copy (reference file) and URL for testing:
 #define THOUSAND_HIVE "/hive/data/outside/1000genomes/ncbi/ftp-trace.ncbi.nih.gov/1000genomes/"
 #define THOUSAND_FTP "ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/pilot_data/data/"
 #define CHR3_SLX_BAM "NA12878/alignment/NA12878.chrom3.SLX.maq.SRP000032.2009_07.bam"
 #define CHR4_SLX_BAM "NA12878/alignment/NA12878.chrom4.SLX.maq.SRP000032.2009_07.bam"
 
 // Use typical size range of bgzip-compressed data blocks:
 #define MIN_BLK_SIZE 20000
 #define MAX_BLK_SIZE 30000
 
 // Read at most this many consecutive blocks:
 #define MAX_BLOCKS 100
 
 void openSeekRead(char *filename, bits64 offset, bits64 len, char *buf)
@@ -276,30 +278,36 @@
     if (delta < 0)  // do not let unsigned offset go below 0
 	if (-delta > offset)
     	    delta = -offset;  
 
     offset += delta;
 
     if (offset > fSize)
 	offset = fSize;
 
     }
 
 udcFileClose(&udcf);
 return gotError;
 
 }
+
+bool testSize(char *url, long int  size) 
+{
+return (udcFileSize(url)==size)   ;
+}
+
 boolean testReadAheadBuffer(char *url, char *localCopy)
 /* Open a udcFile, read different random locations, and check for errors. */
 {
 boolean gotError = FALSE;
 gotError |= testReadAheadBufferMode(url, localCopy, -1);  // near beginning of file
 gotError |= testReadAheadBufferMode(url, localCopy, 0);   // anywherer in file
 gotError |= testReadAheadBufferMode(url, localCopy, 1);   // near end of file
 return gotError;
 }
 
 
 boolean testInterleaved(char *url, char *localCopy)
 /* Open two udcFile handles to the same file, read probably-different random locations,
  * read from probably-overlapping random locations, and check for errors. */
 {
@@ -398,30 +406,31 @@
     if (gotErrorChild)
 	verbose(1, "Parent can see child got error.\n");
     gotErrorParent |= checkCacheFiles(sameOffset, max(offsetParent, offsetChild), url, localCopy);
     return (gotErrorParent || gotErrorChild);
     }
 errAbort("testConcurrent: control should never reach this point.");
 return TRUE;
 }
 
 
 int main(int argc, char *argv[])
 /* Set up test params and run tests. */
 {
 boolean gotError = FALSE;
 optionInit(&argc, argv, options);
+size = optionExists("size");
 raBuf = optionExists("raBuf");
 doFork = optionExists("fork");
 protocol = optionVal("protocol", protocol);
 seed = optionInt("seed", seed);
 
 char *host = getenv("HOST");
 if (host == NULL || !startsWith("hgwdev", host))
     {
     // So that we don't break "make test" on other machines, use stdout and exit 0:
     puts("Sorry, this must be run on hgwdev (with HOST=hgwdev)");
     exit(0);
     }
 errAbortDebugnPushPopErr();
 char tmp[256];
 safef(tmp, sizeof tmp, "/data/tmp/%s/udcCache", getenv("USER"));
@@ -430,31 +439,33 @@
     {
     long now = clock1();
     printf("Seeding random with unix time %ld\n", now);
     srand(now);
     }
 else
     {
     printf("Seeding random with option -seed=%d\n", seed);
     srand(seed);
     }
 
 if (sameString(protocol, "http"))
     {
     char *httpUrl = "http://hgwdev.cse.ucsc.edu/~angie/wgEncodeCshlRnaSeqAlignmentsK562ChromatinShort.bb";
     char *httpLocalCopy = "/gbdb/hg18/bbi/wgEncodeCshlRnaSeqAlignmentsK562ChromatinShort.bb";
-    if (raBuf)
+    if (size)
+	gotError |= testSize(httpUrl, 117209441222);
+    else if (raBuf)
 	gotError |= testReadAheadBuffer(httpUrl, httpLocalCopy);
     else if (doFork)
 	gotError |= testConcurrent(httpUrl, httpLocalCopy);
     else
 	gotError |= testInterleaved(httpUrl, httpLocalCopy);
     }
 else if (sameString(protocol, "ftp"))
     {
     char *ftpUrl = THOUSAND_FTP CHR4_SLX_BAM;
     char *ftpLocalCopy = THOUSAND_HIVE CHR4_SLX_BAM;
     if (raBuf)
 	gotError |= testReadAheadBuffer(ftpUrl, ftpLocalCopy);
     else if (doFork)
 	gotError |= testConcurrent(ftpUrl, ftpLocalCopy);
     else