/ Check-in [7cc515ed]
Login

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

Overview
Comment:Make sure code *compiles* with each OMIT and ENABLE option. Mostly changes to test modules.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7cc515edc9cade2bc6c74699b3e4153bf2b74ebb
User & Date: shaneh 2011-02-09 19:55:20
Context
2011-02-10
00:08
Refactor the cost function in the query planner. Give extra cost (thus reduce likelihood of selection) to full table scans. check-in: 878da276 user: drh tags: trunk
2011-02-09
19:55
Make sure code *compiles* with each OMIT and ENABLE option. Mostly changes to test modules. check-in: 7cc515ed user: shaneh tags: trunk
18:19
Do not report corruption if the the db size header field is greater than the file size on disk unless the two change-counter header fields are identical. Fix for ticket [89b8c9ac54]. check-in: 00c4596f user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

configure became a regular file.

install-sh became a regular file.

Changes to src/expr.c.

3247
3248
3249
3250
3251
3252
3253

3254
3255
3256
3257
3258
3259
3260
3261

3262
3263
3264
3265
3266
3267
3268
....
3388
3389
3390
3391
3392
3393
3394

3395
3396
3397
3398
3399
3400
3401
3402
3403
3404

3405
3406
3407
3408
3409
3410
3411
      break;
    }
    case TK_BETWEEN: {
      testcase( jumpIfNull==0 );
      exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
      break;
    }

    case TK_IN: {
      int destIfFalse = sqlite3VdbeMakeLabel(v);
      int destIfNull = jumpIfNull ? dest : destIfFalse;
      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
      sqlite3VdbeAddOp2(v, OP_Goto, 0, dest);
      sqlite3VdbeResolveLabel(v, destIfFalse);
      break;
    }

    default: {
      r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);
      sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0);
      testcase( regFree1==0 );
      testcase( jumpIfNull==0 );
      break;
    }
................................................................................
      break;
    }
    case TK_BETWEEN: {
      testcase( jumpIfNull==0 );
      exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
      break;
    }

    case TK_IN: {
      if( jumpIfNull ){
        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
      }else{
        int destIfNull = sqlite3VdbeMakeLabel(v);
        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
        sqlite3VdbeResolveLabel(v, destIfNull);
      }
      break;
    }

    default: {
      r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);
      sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0);
      testcase( regFree1==0 );
      testcase( jumpIfNull==0 );
      break;
    }







>








>







 







>










>







3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
....
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
      break;
    }
    case TK_BETWEEN: {
      testcase( jumpIfNull==0 );
      exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);
      break;
    }
#ifndef SQLITE_OMIT_SUBQUERY
    case TK_IN: {
      int destIfFalse = sqlite3VdbeMakeLabel(v);
      int destIfNull = jumpIfNull ? dest : destIfFalse;
      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
      sqlite3VdbeAddOp2(v, OP_Goto, 0, dest);
      sqlite3VdbeResolveLabel(v, destIfFalse);
      break;
    }
#endif
    default: {
      r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);
      sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0);
      testcase( regFree1==0 );
      testcase( jumpIfNull==0 );
      break;
    }
................................................................................
      break;
    }
    case TK_BETWEEN: {
      testcase( jumpIfNull==0 );
      exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);
      break;
    }
#ifndef SQLITE_OMIT_SUBQUERY
    case TK_IN: {
      if( jumpIfNull ){
        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
      }else{
        int destIfNull = sqlite3VdbeMakeLabel(v);
        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
        sqlite3VdbeResolveLabel(v, destIfNull);
      }
      break;
    }
#endif
    default: {
      r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);
      sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0);
      testcase( regFree1==0 );
      testcase( jumpIfNull==0 );
      break;
    }

Changes to src/tclsqlite.c.

2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
....
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
      zProfile = Tcl_GetStringFromObj(objv[2], &len);
      if( zProfile && len>0 ){
        pDb->zProfile = Tcl_Alloc( len + 1 );
        memcpy(pDb->zProfile, zProfile, len+1);
      }else{
        pDb->zProfile = 0;
      }
#ifndef SQLITE_OMIT_TRACE
      if( pDb->zProfile ){
        pDb->interp = interp;
        sqlite3_profile(pDb->db, DbProfileHandler, pDb);
      }else{
        sqlite3_profile(pDb->db, 0, 0);
      }
#endif
................................................................................
      zTrace = Tcl_GetStringFromObj(objv[2], &len);
      if( zTrace && len>0 ){
        pDb->zTrace = Tcl_Alloc( len + 1 );
        memcpy(pDb->zTrace, zTrace, len+1);
      }else{
        pDb->zTrace = 0;
      }
#ifndef SQLITE_OMIT_TRACE
      if( pDb->zTrace ){
        pDb->interp = interp;
        sqlite3_trace(pDb->db, DbTraceHandler, pDb);
      }else{
        sqlite3_trace(pDb->db, 0, 0);
      }
#endif







|







 







|







2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
....
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
      zProfile = Tcl_GetStringFromObj(objv[2], &len);
      if( zProfile && len>0 ){
        pDb->zProfile = Tcl_Alloc( len + 1 );
        memcpy(pDb->zProfile, zProfile, len+1);
      }else{
        pDb->zProfile = 0;
      }
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
      if( pDb->zProfile ){
        pDb->interp = interp;
        sqlite3_profile(pDb->db, DbProfileHandler, pDb);
      }else{
        sqlite3_profile(pDb->db, 0, 0);
      }
#endif
................................................................................
      zTrace = Tcl_GetStringFromObj(objv[2], &len);
      if( zTrace && len>0 ){
        pDb->zTrace = Tcl_Alloc( len + 1 );
        memcpy(pDb->zTrace, zTrace, len+1);
      }else{
        pDb->zTrace = 0;
      }
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
      if( pDb->zTrace ){
        pDb->interp = interp;
        sqlite3_trace(pDb->db, DbTraceHandler, pDb);
      }else{
        sqlite3_trace(pDb->db, 0, 0);
      }
#endif

Changes to src/test1.c.

5637
5638
5639
5640
5641
5642
5643

5644

5645
5646
5647
5648
5649
5650
5651
     { "pcache_stats",       test_pcache_stats, 0  },
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
     { "sqlite3_unlock_notify", test_unlock_notify, 0  },
#endif
     { "sqlite3_wal_checkpoint",   test_wal_checkpoint, 0  },
     { "sqlite3_wal_checkpoint_v2",test_wal_checkpoint_v2, 0  },
     { "test_sqlite3_log",         test_sqlite3_log, 0  },

     { "print_explain_query_plan", test_print_eqp, 0  },

  };
  static int bitmask_size = sizeof(Bitmask)*8;
  int i;
  extern int sqlite3_sync_count, sqlite3_fullsync_count;
  extern int sqlite3_opentemp_count;
  extern int sqlite3_like_count;
  extern int sqlite3_xferopt_count;







>

>







5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
     { "pcache_stats",       test_pcache_stats, 0  },
#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
     { "sqlite3_unlock_notify", test_unlock_notify, 0  },
#endif
     { "sqlite3_wal_checkpoint",   test_wal_checkpoint, 0  },
     { "sqlite3_wal_checkpoint_v2",test_wal_checkpoint_v2, 0  },
     { "test_sqlite3_log",         test_sqlite3_log, 0  },
#ifndef SQLITE_OMIT_EXPLAIN
     { "print_explain_query_plan", test_print_eqp, 0  },
#endif
  };
  static int bitmask_size = sizeof(Bitmask)*8;
  int i;
  extern int sqlite3_sync_count, sqlite3_fullsync_count;
  extern int sqlite3_opentemp_count;
  extern int sqlite3_like_count;
  extern int sqlite3_xferopt_count;

Changes to src/test_func.c.

145
146
147
148
149
150
151

152
153




154
155
156
157
158
159
160
}

/*
** The following aggregate function, test_agg_errmsg16(), takes zero 
** arguments. It returns the text value returned by the sqlite3_errmsg16()
** API function.
*/

void sqlite3BeginBenignMalloc(void);
void sqlite3EndBenignMalloc(void);




static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){
}
static void test_agg_errmsg16_final(sqlite3_context *ctx){
#ifndef SQLITE_OMIT_UTF16
  const void *z;
  sqlite3 * db = sqlite3_context_db_handle(ctx);
  sqlite3_aggregate_context(ctx, 2048);







>


>
>
>
>







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
}

/*
** The following aggregate function, test_agg_errmsg16(), takes zero 
** arguments. It returns the text value returned by the sqlite3_errmsg16()
** API function.
*/
#ifndef SQLITE_OMIT_BUILTIN_TEST
void sqlite3BeginBenignMalloc(void);
void sqlite3EndBenignMalloc(void);
#else
  #define sqlite3BeginBenignMalloc()
  #define sqlite3EndBenignMalloc()
#endif
static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){
}
static void test_agg_errmsg16_final(sqlite3_context *ctx){
#ifndef SQLITE_OMIT_UTF16
  const void *z;
  sqlite3 * db = sqlite3_context_db_handle(ctx);
  sqlite3_aggregate_context(ctx, 2048);

Changes to src/test_multiplex.c.

19
20
21
22
23
24
25














26
27
28
29
30
31
32
..
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
** file size of the underlying file system.
**
*/
#include "sqlite3.h"
#include <string.h>
#include <assert.h>
#include "sqliteInt.h"















/************************ Shim Definitions ******************************/

/* This is the limit on the chunk size.  It may be changed by calling
** the sqlite3_multiplex_set() interface.
*/
#define SQLITE_MULTIPLEX_CHUNK_SIZE 0x40000000
................................................................................
** to exceed the limits imposed by the file system.
**
** There is an instance of the following object for each defined multiplex
** group.
*/
struct multiplexGroup {
  sqlite3_file **pReal;            /* Handles to each chunk */
  char *bOpen;                     /* 0 if chunk not opened */
  char *zName;                     /* Base filename of this group */
  int nName;                       /* Length of base filename */
  int flags;                       /* Flags used for original opening */
  multiplexGroup *pNext, *pPrev;   /* Doubly linked list of all group objects */
};

/*







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
** file size of the underlying file system.
**
*/
#include "sqlite3.h"
#include <string.h>
#include <assert.h>
#include "sqliteInt.h"

/*
** For a build without mutexes, no-op the mutex calls.
*/
#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0
#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
#define sqlite3_mutex_free(X)
#define sqlite3_mutex_enter(X)
#define sqlite3_mutex_try(X)      SQLITE_OK
#define sqlite3_mutex_leave(X)
#define sqlite3_mutex_held(X)     ((void)(X),1)
#define sqlite3_mutex_notheld(X)  ((void)(X),1)
#endif /* SQLITE_THREADSAFE==0 */


/************************ Shim Definitions ******************************/

/* This is the limit on the chunk size.  It may be changed by calling
** the sqlite3_multiplex_set() interface.
*/
#define SQLITE_MULTIPLEX_CHUNK_SIZE 0x40000000
................................................................................
** to exceed the limits imposed by the file system.
**
** There is an instance of the following object for each defined multiplex
** group.
*/
struct multiplexGroup {
  sqlite3_file **pReal;            /* Handles to each chunk */
  char *bOpen;                     /* array of bools - 0 if chunk not opened */
  char *zName;                     /* Base filename of this group */
  int nName;                       /* Length of base filename */
  int flags;                       /* Flags used for original opening */
  multiplexGroup *pNext, *pPrev;   /* Doubly linked list of all group objects */
};

/*

Changes to tool/omittest.tcl.

4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
..
42
43
44
45
46
47
48

49
50
51
52

53
54
55
56
57
58
59
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
..
87
88
89
90
91
92
93



94
95
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118


119
120
121
122
123
124
125





126
127
128
129
130
131
132
...
133
134
135
136
137
138
139
140
141
142
143
144
145
146


147
148
149

150
151
152

153
154
155
156
157

158
159
160
161
162
163
164
165
166
167
168
169

170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

185
186
187
188


189
190
191


























192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210







211
212
213
214
215
216
# Documentation for this script. This may be output to stderr
# if the script is invoked incorrectly.
set ::USAGE_MESSAGE {
This Tcl script is used to test the various compile time options 
available for omitting code (the SQLITE_OMIT_xxx options). It
should be invoked as follows:

    <script> ?-makefile PATH-TO-MAKEFILE?

The default value for ::MAKEFILE is "../Makefile.linux.gcc".



This script builds the testfixture program and runs the SQLite test suite
once with each SQLITE_OMIT_ option defined and then once with all options
defined together. Each run is performed in a seperate directory created
as a sub-directory of the current directory by the script. The output
of the build is saved in <sub-directory>/build.log. The output of the
test-suite is saved in <sub-directory>/test.log.
................................................................................
# test in. The second parameter is a list of OMIT symbols to define
# when doing so. For example:
#
#     run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
#
#
proc run_quick_test {dir omit_symbol_list} {

  # Compile the value of the OPTS Makefile variable.
  set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG -DSQLITE_NO_SYNC" 
  if {$::tcl_platform(platform)=="windows"} {
    append opts " -DSQLITE_OS_WIN=1"

  } elseif {$::tcl_platform(platform)=="os2"} {
    append opts " -DSQLITE_OS_OS2=1"
  } else {
    append opts " -DSQLITE_OS_UNIX=1"
  }
  foreach sym $omit_symbol_list {
    append opts " -D${sym}=1"
................................................................................
  puts -nonewline "Building $dir..."
  flush stdout
catch {
  file copy -force ./config.h $dir
  file copy -force ./libtool $dir
}
  set rc [catch {
    exec make -C $dir -f $::MAKEFILE testfixture OPTS=$opts >& $dir/build.log
  }]
  if {$rc} {
    puts "No good. See $dir/build.log."
    return
  } else {
    puts "Ok"
  }
................................................................................
  }
  if {![file exists $sqlite3_dummy]} {
    set wr [open $sqlite3_dummy w]
    puts $wr "dummy"
    close $wr
  }




  # Run the test suite.
  puts -nonewline "Testing $dir..."
  flush stdout
  set rc [catch {
    exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
  }]
  if {$rc} {
    puts "No good. See $dir/test.log."
  } else {
    puts "Ok"

  }
}


# This proc processes the command line options passed to this script.
# Currently the only option supported is "-makefile", default
# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
# option.
#
proc process_options {argv} {
  if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} {
      set ::MAKEFILE ../Makefile                        ;# Default value
  } else {
      set ::MAKEFILE ../Makefile.linux-gcc              ;# Default value
  }


  for {set i 0} {$i < [llength $argv]} {incr i} {
    switch -- [lindex $argv $i] {
      -makefile {
        incr i
        set ::MAKEFILE [lindex $argv $i]
      }
  





      default {
        puts stderr [string trim $::USAGE_MESSAGE]
        exit -1
      }
    }
    set ::MAKEFILE [file normalize $::MAKEFILE]
  }
................................................................................
}

# Main routine.
#

proc main {argv} {
  # List of SQLITE_OMIT_XXX symbols supported by SQLite.
  set ::SYMBOLS [list                  \
    SQLITE_OMIT_ALTERTABLE             \
    SQLITE_OMIT_ANALYZE                \
    SQLITE_OMIT_ATTACH                 \
    SQLITE_OMIT_AUTHORIZATION          \
    SQLITE_OMIT_AUTOINCREMENT          \
    SQLITE_OMIT_AUTOINIT               \


    SQLITE_OMIT_AUTOVACUUM             \
    SQLITE_OMIT_BETWEEN_OPTIMIZATION   \
    SQLITE_OMIT_BLOB_LITERAL           \

    SQLITE_OMIT_BUILTIN_TEST           \
    SQLITE_OMIT_CAST                   \
    SQLITE_OMIT_CHECK                  \

    SQLITE_OMIT_COMPLETE               \
    SQLITE_OMIT_COMPOUND_SELECT        \
    SQLITE_OMIT_CONFLICT_CLAUSE        \
    SQLITE_OMIT_DATETIME_FUNCS         \
    SQLITE_OMIT_DECLTYPE               \

    off_SQLITE_OMIT_DISKIO                 \
    SQLITE_OMIT_EXPLAIN                \
    SQLITE_OMIT_FLAG_PRAGMAS           \
    SQLITE_OMIT_FLOATING_POINT         \
    SQLITE_OMIT_FOREIGN_KEY            \
    SQLITE_OMIT_GET_TABLE              \
    SQLITE_OMIT_GLOBALRECOVER          \
    SQLITE_OMIT_INCRBLOB               \
    SQLITE_OMIT_INTEGRITY_CHECK        \
    SQLITE_OMIT_LIKE_OPTIMIZATION      \
    SQLITE_OMIT_LOAD_EXTENSION         \
    SQLITE_OMIT_LOCALTIME              \

    SQLITE_OMIT_MEMORYDB               \
    SQLITE_OMIT_OR_OPTIMIZATION        \
    SQLITE_OMIT_PAGER_PRAGMAS          \
    SQLITE_OMIT_PRAGMA                 \
    SQLITE_OMIT_PROGRESS_CALLBACK      \
    SQLITE_OMIT_QUICKBALANCE           \
    SQLITE_OMIT_REINDEX                \
    SQLITE_OMIT_SCHEMA_PRAGMAS         \
    SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
    SQLITE_OMIT_SHARED_CACHE           \
    SQLITE_OMIT_SUBQUERY               \
    SQLITE_OMIT_TCL_VARIABLE           \
    SQLITE_OMIT_TEMPDB                 \
    SQLITE_OMIT_TRACE                  \
    SQLITE_OMIT_TRIGGER                \

    SQLITE_OMIT_UTF16                  \
    SQLITE_OMIT_VACUUM                 \
    SQLITE_OMIT_VIEW                   \
    SQLITE_OMIT_VIRTUALTABLE           \


    SQLITE_OMIT_XFER_OPT               \
  ]



























  # Process any command line options.
  process_options $argv
  
  # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT 
  # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
  # and the latter is currently incompatible with the test suite (this should
  # be fixed, but it will be a lot of work).
  set allsyms [list]
  foreach s $::SYMBOLS {
    if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
      lappend allsyms $s
    }
  }
  run_quick_test test_OMIT_EVERYTHING $allsyms

  # Now try one quick.test with each of the OMIT symbols defined. Included
  # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
  # know they will fail. It's good to be reminded of this from time to time.
  foreach sym $::SYMBOLS {







    set dirname "test_[string range $sym 7 end]"
    run_quick_test $dirname $sym
  }
}

main $argv







|


>
>







 







>




>







 







|







 







>
>
>
|
|
|
|
|
|
|
|
|
|
>











|

|

>
>







>
>
>
>
>







 







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

|
|
|
|
|
|
>
|
|
|
|
>
>
|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|





|









|
>
>
>
>
>
>
>






4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173

174
175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# Documentation for this script. This may be output to stderr
# if the script is invoked incorrectly.
set ::USAGE_MESSAGE {
This Tcl script is used to test the various compile time options 
available for omitting code (the SQLITE_OMIT_xxx options). It
should be invoked as follows:

    <script> ?-makefile PATH-TO-MAKEFILE? ?-skip_run?

The default value for ::MAKEFILE is "../Makefile.linux.gcc".

If -skip_run option is given then only the compile part is attempted.

This script builds the testfixture program and runs the SQLite test suite
once with each SQLITE_OMIT_ option defined and then once with all options
defined together. Each run is performed in a seperate directory created
as a sub-directory of the current directory by the script. The output
of the build is saved in <sub-directory>/build.log. The output of the
test-suite is saved in <sub-directory>/test.log.
................................................................................
# test in. The second parameter is a list of OMIT symbols to define
# when doing so. For example:
#
#     run_quick_test /tmp/testdir {SQLITE_OMIT_TRIGGER SQLITE_OMIT_VIEW}
#
#
proc run_quick_test {dir omit_symbol_list} {
  set target "testfixture"
  # Compile the value of the OPTS Makefile variable.
  set opts "-DSQLITE_MEMDEBUG -DSQLITE_DEBUG -DSQLITE_NO_SYNC" 
  if {$::tcl_platform(platform)=="windows"} {
    append opts " -DSQLITE_OS_WIN=1"
    set target "testfixture.exe"
  } elseif {$::tcl_platform(platform)=="os2"} {
    append opts " -DSQLITE_OS_OS2=1"
  } else {
    append opts " -DSQLITE_OS_UNIX=1"
  }
  foreach sym $omit_symbol_list {
    append opts " -D${sym}=1"
................................................................................
  puts -nonewline "Building $dir..."
  flush stdout
catch {
  file copy -force ./config.h $dir
  file copy -force ./libtool $dir
}
  set rc [catch {
    exec make -C $dir -f $::MAKEFILE $target OPTS=$opts >& $dir/build.log
  }]
  if {$rc} {
    puts "No good. See $dir/build.log."
    return
  } else {
    puts "Ok"
  }
................................................................................
  }
  if {![file exists $sqlite3_dummy]} {
    set wr [open $sqlite3_dummy w]
    puts $wr "dummy"
    close $wr
  }

  if {$::SKIP_RUN} {
      puts "Skip testing $dir."
  } else {
    # Run the test suite.
    puts -nonewline "Testing $dir..."
    flush stdout
    set rc [catch {
      exec make -C $dir -f $::MAKEFILE test OPTS=$opts >& $dir/test.log
    }]
    if {$rc} {
      puts "No good. See $dir/test.log."
    } else {
      puts "Ok"
    }
  }
}


# This proc processes the command line options passed to this script.
# Currently the only option supported is "-makefile", default
# "../Makefile.linux-gcc". Set the ::MAKEFILE variable to the value of this
# option.
#
proc process_options {argv} {
  if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} {
      set ::MAKEFILE ./Makefile                         ;# Default value
  } else {
      set ::MAKEFILE ./Makefile.linux-gcc               ;# Default value
  }
  set ::SKIP_RUN 0                                      ;# Default to attempt test

  for {set i 0} {$i < [llength $argv]} {incr i} {
    switch -- [lindex $argv $i] {
      -makefile {
        incr i
        set ::MAKEFILE [lindex $argv $i]
      }
  
      -skip_run {
        incr i
        set ::SKIP_RUN 1
      }

      default {
        puts stderr [string trim $::USAGE_MESSAGE]
        exit -1
      }
    }
    set ::MAKEFILE [file normalize $::MAKEFILE]
  }
................................................................................
}

# Main routine.
#

proc main {argv} {
  # List of SQLITE_OMIT_XXX symbols supported by SQLite.
  set ::OMIT_SYMBOLS [list \
    SQLITE_OMIT_ALTERTABLE \
    SQLITE_OMIT_ANALYZE \
    SQLITE_OMIT_ATTACH \
    SQLITE_OMIT_AUTHORIZATION \
    SQLITE_OMIT_AUTOINCREMENT \
    SQLITE_OMIT_AUTOINIT \
    SQLITE_OMIT_AUTOMATIC_INDEX \
    SQLITE_OMIT_AUTORESET \
    SQLITE_OMIT_AUTOVACUUM \
    SQLITE_OMIT_BETWEEN_OPTIMIZATION \
    SQLITE_OMIT_BLOB_LITERAL \
    SQLITE_OMIT_BTREECOUNT \
    SQLITE_OMIT_BUILTIN_TEST \
    SQLITE_OMIT_CAST \
    SQLITE_OMIT_CHECK \
    SQLITE_OMIT_COMPILEOPTION_DIAGS \
    SQLITE_OMIT_COMPLETE \
    SQLITE_OMIT_COMPOUND_SELECT \

    SQLITE_OMIT_DATETIME_FUNCS \
    SQLITE_OMIT_DECLTYPE \
    SQLITE_OMIT_DEPRECATED \
    xxxSQLITE_OMIT_DISKIO \
    SQLITE_OMIT_EXPLAIN \
    SQLITE_OMIT_FLAG_PRAGMAS \
    SQLITE_OMIT_FLOATING_POINT \
    SQLITE_OMIT_FOREIGN_KEY \
    SQLITE_OMIT_GET_TABLE \

    SQLITE_OMIT_INCRBLOB \
    SQLITE_OMIT_INTEGRITY_CHECK \
    SQLITE_OMIT_LIKE_OPTIMIZATION \
    SQLITE_OMIT_LOAD_EXTENSION \
    SQLITE_OMIT_LOCALTIME \
    SQLITE_OMIT_LOOKASIDE \
    SQLITE_OMIT_MEMORYDB \
    SQLITE_OMIT_OR_OPTIMIZATION \
    SQLITE_OMIT_PAGER_PRAGMAS \
    SQLITE_OMIT_PRAGMA \
    SQLITE_OMIT_PROGRESS_CALLBACK \
    SQLITE_OMIT_QUICKBALANCE \
    SQLITE_OMIT_REINDEX \
    SQLITE_OMIT_SCHEMA_PRAGMAS \
    SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS \
    SQLITE_OMIT_SHARED_CACHE \
    SQLITE_OMIT_SUBQUERY \
    SQLITE_OMIT_TCL_VARIABLE \
    SQLITE_OMIT_TEMPDB \
    SQLITE_OMIT_TRACE \
    SQLITE_OMIT_TRIGGER \
    SQLITE_OMIT_TRUNCATE_OPTIMIZATION \
    SQLITE_OMIT_UTF16 \
    SQLITE_OMIT_VACUUM \
    SQLITE_OMIT_VIEW \
    SQLITE_OMIT_VIRTUALTABLE \
    SQLITE_OMIT_WAL \
    SQLITE_OMIT_WSD \
    SQLITE_OMIT_XFER_OPT \
  ]

  set ::ENABLE_SYMBOLS [list \
    SQLITE_DISABLE_DIRSYNC \
    SQLITE_DISABLE_LFS \
    SQLITE_ENABLE_ATOMIC_WRITE \
    xxxSQLITE_ENABLE_CEROD \
    SQLITE_ENABLE_COLUMN_METADATA \
    SQLITE_ENABLE_EXPENSIVE_ASSERT \
    xxxSQLITE_ENABLE_FTS1 \
    xxxSQLITE_ENABLE_FTS2 \
    SQLITE_ENABLE_FTS3 \
    SQLITE_ENABLE_FTS3_PARENTHESIS \
    SQLITE_ENABLE_FTS4 \
    xxxSQLITE_ENABLE_ICU \
    SQLITE_ENABLE_IOTRACE \
    SQLITE_ENABLE_LOAD_EXTENSION \
    SQLITE_ENABLE_LOCKING_STYLE \
    SQLITE_ENABLE_MEMORY_MANAGEMENT \
    SQLITE_ENABLE_MEMSYS3 \
    SQLITE_ENABLE_MEMSYS5 \
    SQLITE_ENABLE_OVERSIZE_CELL_CHECK \
    SQLITE_ENABLE_RTREE \
    SQLITE_ENABLE_STAT2 \
    SQLITE_ENABLE_UNLOCK_NOTIFY \
    SQLITE_ENABLE_UPDATE_DELETE_LIMIT \
  ]

  # Process any command line options.
  process_options $argv

  # First try a test with all OMIT symbols except SQLITE_OMIT_FLOATING_POINT 
  # and SQLITE_OMIT_PRAGMA defined. The former doesn't work (causes segfaults)
  # and the latter is currently incompatible with the test suite (this should
  # be fixed, but it will be a lot of work).
  set allsyms [list]
  foreach s $::OMIT_SYMBOLS {
    if {$s!="SQLITE_OMIT_FLOATING_POINT" && $s!="SQLITE_OMIT_PRAGMA"} {
      lappend allsyms $s
    }
  }
  run_quick_test test_OMIT_EVERYTHING $allsyms

  # Now try one quick.test with each of the OMIT symbols defined. Included
  # are the OMIT_FLOATING_POINT and OMIT_PRAGMA symbols, even though we
  # know they will fail. It's good to be reminded of this from time to time.
  foreach sym $::OMIT_SYMBOLS {
    set dirname "test_[string range $sym 7 end]"
    run_quick_test $dirname $sym
  }

  # Try the ENABLE/DISABLE symbols one at a time.  
  # We don't do them all at once since some are conflicting.
  foreach sym $::ENABLE_SYMBOLS {
    set dirname "test_[string range $sym 7 end]"
    run_quick_test $dirname $sym
  }
}

main $argv