/ Check-in [0fdc7435]
Login

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

Overview
Comment:Enhance multi-process tester integration with the Win32 API.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0fdc743583c67a3a017b9ad812c62a5104b9aee7
User & Date: mistachkin 2013-04-11 00:09:44
Context
2013-04-11
01:16
Have the UNIX VFS issue warnings via sqlite3_log() if a database file is renamed or unlinked or linked to more than one name while the file is open. check-in: e238dcf9 user: drh tags: trunk
00:13
Experimental changes to support a Win32 VSIX package flavor. Closed-Leaf check-in: abedd7cb user: mistachkin tags: vsixWin32
00:09
Enhance multi-process tester integration with the Win32 API. check-in: 0fdc7435 user: mistachkin tags: trunk
2013-04-10
23:48
Add new primary error codes SQLITE_NOTICE and SQLITE_WARNING for use with sqlite3_log(). Add new extended error codes SQLITE_NOTICE_RECOVER_WAL and SQLITE_NOTICE_RECOVER_ROLLBACK to use with sqlite3_log() messages that occur on each recovery. check-in: be7d2c54 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to mptest/mptest.c.

    32     32   **
    33     33   ** where $database is the database to use for testing and $script is a
    34     34   ** test script.
    35     35   */
    36     36   #include "sqlite3.h"
    37     37   #include <stdio.h>
    38     38   #if defined(_WIN32)
    39         -# include <process.h>
           39  +# define WIN32_LEAN_AND_MEAN
           40  +# include <windows.h>
    40     41   #else
    41     42   # include <unistd.h>
    42     43   #endif
    43     44   #include <stdlib.h>
    44     45   #include <string.h>
    45     46   #include <assert.h>
    46     47   #include <ctype.h>
           48  +
           49  +/* The suffix to append to the child command lines, if any */
           50  +#if defined(_WIN32)
           51  +# define CMDLINE_SUFFIX ""
           52  +#else
           53  +# define CMDLINE_SUFFIX "&"
           54  +#endif
    47     55   
    48     56   /* Mark a parameter as unused to suppress compiler warnings */
    49     57   #define UNUSED_PARAMETER(x)  (void)x
    50     58   
    51     59   /* Global data
    52     60   */
    53     61   static struct Global {
................................................................................
   613    621   ** Start up a client process for iClient, if it is not already
   614    622   ** running.  If the client is already running, then this routine
   615    623   ** is a no-op.
   616    624   */
   617    625   static void startClient(int iClient){
   618    626     runSql("INSERT OR IGNORE INTO client VALUES(%d,0)", iClient);
   619    627     if( sqlite3_changes(g.db) ){
   620         -#if !defined(_WIN32)
   621    628       char *zSys;
   622    629       int rc;
   623    630       zSys = sqlite3_mprintf(
   624         -                 "%s \"%s\" --client %d --trace %d %s%s&",
          631  +                 "%s \"%s\" --client %d --trace %d %s%s%s",
   625    632                    g.argv0, g.zDbFile, iClient, g.iTrace,
   626    633                    g.bSqlTrace ? "--sqltrace " : "",
   627         -                 g.bSync ? "--sync " : ""
          634  +                 g.bSync ? "--sync " : "",
          635  +                 CMDLINE_SUFFIX
   628    636       );
          637  +#if !defined(_WIN32)
   629    638       rc = system(zSys);
   630    639       if( rc ) errorMessage("system() fails with error code %d", rc);
   631         -    sqlite3_free(zSys);
   632         -#endif
   633         -#if defined(_WIN32)
   634         -    char *argv[10];
   635         -    char zClient[20];
   636         -    char zTrace[20];
   637         -    argv[0] = g.argv0;
   638         -    argv[1] = g.zDbFile;
   639         -    argv[2] = "--client";
   640         -    sqlite3_snprintf(sizeof(zClient),zClient,"%d",iClient);
   641         -    argv[3] = zClient;
   642         -    argv[4] = "--trace";
   643         -    sqlite3_snprintf(sizeof(zTrace),zTrace,"%d",g.iTrace);
   644         -    argv[5] = zTrace;
   645         -    if( g.bSqlTrace ){
   646         -      argv[6] = "--sqltrace";
   647         -      argv[7] = 0;
   648         -    }else{
   649         -      argv[6] = 0;
          640  +#else
          641  +    {
          642  +      STARTUPINFOA startupInfo;
          643  +      PROCESS_INFORMATION processInfo;
          644  +      memset(&startupInfo, 0, sizeof(startupInfo));
          645  +      startupInfo.cb = sizeof(startupInfo);
          646  +      memset(&processInfo, 0, sizeof(processInfo));
          647  +      rc = CreateProcessA(NULL, zSys, NULL, NULL, FALSE, 0, NULL, NULL,
          648  +                        &startupInfo, &processInfo);
          649  +      if( rc ){
          650  +        CloseHandle(processInfo.hThread);
          651  +        CloseHandle(processInfo.hProcess);
          652  +      }else{
          653  +        errorMessage("CreateProcessA() fails with error code %lu",
          654  +                     GetLastError());
          655  +      }
   650    656       }
   651         -    _spawnv(_P_NOWAIT, g.argv0, (const char*const*)argv);
   652    657   #endif
          658  +    sqlite3_free(zSys);
   653    659     }
   654    660   }
   655    661   
   656    662   /*
   657    663   ** Read the entire content of a file into memory
   658    664   */
   659    665   static char *readFile(const char *zFilename){