/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to mptest/mptest.c.

32
33
34
35
36
37
38

39
40
41
42
43
44
45
46







47
48
49
50
51
52
53
...
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627

628

629
630
631
632
633
634

635
636
637
638
639
640
641
642
643
644
645
646
647
648
649


650
651

652

653
654
655
656
657
658
659
**
** where $database is the database to use for testing and $script is a
** test script.
*/
#include "sqlite3.h"
#include <stdio.h>
#if defined(_WIN32)

# include <process.h>
#else
# include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>








/* Mark a parameter as unused to suppress compiler warnings */
#define UNUSED_PARAMETER(x)  (void)x

/* Global data
*/
static struct Global {
................................................................................
** Start up a client process for iClient, if it is not already
** running.  If the client is already running, then this routine
** is a no-op.
*/
static void startClient(int iClient){
  runSql("INSERT OR IGNORE INTO client VALUES(%d,0)", iClient);
  if( sqlite3_changes(g.db) ){
#if !defined(_WIN32)
    char *zSys;
    int rc;
    zSys = sqlite3_mprintf(
                 "%s \"%s\" --client %d --trace %d %s%s&",
                 g.argv0, g.zDbFile, iClient, g.iTrace,
                 g.bSqlTrace ? "--sqltrace " : "",
                 g.bSync ? "--sync " : ""

    );

    rc = system(zSys);
    if( rc ) errorMessage("system() fails with error code %d", rc);
    sqlite3_free(zSys);
#endif
#if defined(_WIN32)
    char *argv[10];

    char zClient[20];
    char zTrace[20];
    argv[0] = g.argv0;
    argv[1] = g.zDbFile;
    argv[2] = "--client";
    sqlite3_snprintf(sizeof(zClient),zClient,"%d",iClient);
    argv[3] = zClient;
    argv[4] = "--trace";
    sqlite3_snprintf(sizeof(zTrace),zTrace,"%d",g.iTrace);
    argv[5] = zTrace;
    if( g.bSqlTrace ){
      argv[6] = "--sqltrace";
      argv[7] = 0;
    }else{
      argv[6] = 0;


    }
    _spawnv(_P_NOWAIT, g.argv0, (const char*const*)argv);

#endif

  }
}

/*
** Read the entire content of a file into memory
*/
static char *readFile(const char *zFilename){







>
|







>
>
>
>
>
>
>







 







<



|


|
>

>


<
|
<
<
>
|
|
|
|
|
|
|
|
|
|
<
<
<
|
<
>
>
|
<
>

>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
621
622
623
624
625
626
627

628
629
630
631
632
633
634
635
636
637
638
639

640


641
642
643
644
645
646
647
648
649
650
651



652

653
654
655

656
657
658
659
660
661
662
663
664
665
**
** where $database is the database to use for testing and $script is a
** test script.
*/
#include "sqlite3.h"
#include <stdio.h>
#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#else
# include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>

/* The suffix to append to the child command lines, if any */
#if defined(_WIN32)
# define CMDLINE_SUFFIX ""
#else
# define CMDLINE_SUFFIX "&"
#endif

/* Mark a parameter as unused to suppress compiler warnings */
#define UNUSED_PARAMETER(x)  (void)x

/* Global data
*/
static struct Global {
................................................................................
** Start up a client process for iClient, if it is not already
** running.  If the client is already running, then this routine
** is a no-op.
*/
static void startClient(int iClient){
  runSql("INSERT OR IGNORE INTO client VALUES(%d,0)", iClient);
  if( sqlite3_changes(g.db) ){

    char *zSys;
    int rc;
    zSys = sqlite3_mprintf(
                 "%s \"%s\" --client %d --trace %d %s%s%s",
                 g.argv0, g.zDbFile, iClient, g.iTrace,
                 g.bSqlTrace ? "--sqltrace " : "",
                 g.bSync ? "--sync " : "",
                 CMDLINE_SUFFIX
    );
#if !defined(_WIN32)
    rc = system(zSys);
    if( rc ) errorMessage("system() fails with error code %d", rc);

#else


    {
      STARTUPINFOA startupInfo;
      PROCESS_INFORMATION processInfo;
      memset(&startupInfo, 0, sizeof(startupInfo));
      startupInfo.cb = sizeof(startupInfo);
      memset(&processInfo, 0, sizeof(processInfo));
      rc = CreateProcessA(NULL, zSys, NULL, NULL, FALSE, 0, NULL, NULL,
                        &startupInfo, &processInfo);
      if( rc ){
        CloseHandle(processInfo.hThread);
        CloseHandle(processInfo.hProcess);



      }else{

        errorMessage("CreateProcessA() fails with error code %lu",
                     GetLastError());
      }

    }
#endif
    sqlite3_free(zSys);
  }
}

/*
** Read the entire content of a file into memory
*/
static char *readFile(const char *zFilename){