/ Check-in [aea6e0ff]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:For lsmtest, use a more portable means of setting open() files to binary.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: aea6e0ffd33f41482f1b53b9f21b77add2865abda4eec1d9ee197177f74f43d0
User & Date: mistachkin 2017-07-07 21:15:24
Context
2017-07-07
21:20
Fix comment in the Win32 VFS for lsm1. check-in: 12a421bc user: mistachkin tags: trunk
21:15
For lsmtest, use a more portable means of setting open() files to binary. check-in: aea6e0ff user: mistachkin tags: trunk
20:35
Adjust copy_file() lsmtest function so it works properly for locked database files on Win32. check-in: 54a38555 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm-test/lsmtest.h.

    10     10   #include <stdlib.h>
    11     11   #include <string.h>
    12     12   #include <stdio.h>
    13     13   
    14     14   #ifdef __cplusplus
    15     15   extern "C" {
    16     16   #endif
           17  +
           18  +#ifndef _O_BINARY
           19  +# define _O_BINARY (0)
           20  +#endif
    17     21   
    18     22   #ifdef _WIN32
    19     23   # include "windows.h"
    20     24   # define gettimeofday win32GetTimeOfDay
    21     25   # define F_OK  (0)
    22     26   # define sleep(sec) Sleep(1000 * (sec))
    23     27   # define usleep(usec) Sleep(((usec) + 999) / 1000)

Changes to ext/lsm1/lsm-test/lsmtest6.c.

   265    265       int fd1;
   266    266       int fd2;
   267    267       off_t sz;
   268    268       off_t i;
   269    269       struct stat buf;
   270    270       u8 *aBuf;
   271    271   
   272         -    fd1 = open(zFrom, O_RDONLY, 0644);
   273         -    fd2 = open(zTo, O_RDWR | O_CREAT, 0644);
          272  +    fd1 = open(zFrom, O_RDONLY | _O_BINARY, 0644);
          273  +    fd2 = open(zTo, O_RDWR | O_CREAT | _O_BINARY, 0644);
   274    274   
   275    275       fstat(fd1, &buf);
   276    276       sz = buf.st_size;
   277    277       ftruncate(fd2, sz);
   278    278   
   279    279       aBuf = testMalloc(4096);
   280    280       for(i=0; i<sz; i+=4096){

Changes to ext/lsm1/lsm-test/lsmtest_io.c.

   223    223     if( pgsz<=0 ){
   224    224       testPrintError("Ridiculous page size: %d", pgsz);
   225    225       return -1;
   226    226     }
   227    227     aData = malloc(pgsz);
   228    228     memset(aData, 0x77, pgsz);
   229    229   
   230         -  ctx.fd = open(zFile, O_RDWR|O_CREAT, 0644);
          230  +  ctx.fd = open(zFile, O_RDWR|O_CREAT|_O_BINARY, 0644);
   231    231     if( ctx.fd<0 ){
   232    232       perror("open: ");
   233    233       return -1;
   234    234     }
   235    235   
   236    236     if( nArg==2 ){
   237    237       readStdin(&zStdin);

Changes to ext/lsm1/lsm-test/lsmtest_main.c.

  1236   1236     }else{
  1237   1237       printf("Sync after each %d blocks.\n", nSync);
  1238   1238     }
  1239   1239   
  1240   1240     printf("Preparing file... ");
  1241   1241     fflush(stdout);
  1242   1242     unlink("writer.out");
  1243         -  fd = open("writer.out", O_RDWR|O_CREAT, 0664);
         1243  +  fd = open("writer.out", O_RDWR|O_CREAT|_O_BINARY, 0664);
  1244   1244     if( fd<0 ){
  1245   1245       testPrintError("open(): %d - %s\n", errno, strerror(errno));
  1246   1246       return -1;
  1247   1247     }
  1248   1248     testTimeInit();
  1249   1249     for(i=0; i<nBlock; i++){
  1250   1250       int iPg;
................................................................................
  1519   1519   #ifdef LSM_DEBUG_MEM
  1520   1520     FILE *pReport = 0;              /* lsm malloc() report file */
  1521   1521     const char *zReport = "malloc.txt generated";
  1522   1522   #else
  1523   1523     const char *zReport = "malloc.txt NOT generated";
  1524   1524   #endif
  1525   1525   
  1526         -#if defined(_MSC_VER) || defined(__MSVCRT__)
  1527         -  _set_fmode(_O_BINARY);
  1528         -#endif
  1529         -
  1530   1526     testMallocInstall(tdb_lsm_env());
  1531   1527   
  1532   1528     if( argc<2 ){
  1533   1529       testPrintError("Usage: %s sub-command ?args...?\n", argv[0]);
  1534   1530       return -1;
  1535   1531     }
  1536   1532