Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | General test coverage improvements. (CVS 3022) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
153940af5af4f775fa3b1784931d3fd1 |
User & Date: | danielk1977 2006-01-24 10:58:22.000 |
Context
2006-01-24
| ||
11:30 | Coverage improvements for main.c. (CVS 3023) (check-in: 50964ef9b0 user: danielk1977 tags: trunk) | |
10:58 | General test coverage improvements. (CVS 3022) (check-in: 153940af5a user: danielk1977 tags: trunk) | |
02:19 | Sqlite3_analyzer reports an error if it runs into trouble. (CVS 3021) (check-in: 388b926228 user: drh tags: trunk) | |
Changes
Changes to main.mk.
︙ | ︙ | |||
119 120 121 122 123 124 125 126 127 128 129 130 131 132 | # Source code to the test files. # TESTSRC = \ $(TOP)/src/btree.c \ $(TOP)/src/date.c \ $(TOP)/src/func.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ $(TOP)/src/pragma.c \ $(TOP)/src/printf.c \ $(TOP)/src/server.c \ $(TOP)/src/test1.c \ | > | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | # Source code to the test files. # TESTSRC = \ $(TOP)/src/btree.c \ $(TOP)/src/date.c \ $(TOP)/src/func.c \ $(TOP)/src/os.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ $(TOP)/src/pragma.c \ $(TOP)/src/printf.c \ $(TOP)/src/server.c \ $(TOP)/src/test1.c \ |
︙ | ︙ |
Changes to src/os.c.
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | } int sqlite3OsSync(OsFile *id, int fullsync){ return id->pMethod->xSync(id, fullsync); } void sqlite3OsSetFullSync(OsFile *id, int value){ id->pMethod->xSetFullSync(id, value); } int sqlite3OsFileHandle(OsFile *id){ return id->pMethod->xFileHandle(id); } int sqlite3OsFileSize(OsFile *id, i64 *pSize){ return id->pMethod->xFileSize(id, pSize); } int sqlite3OsLock(OsFile *id, int lockType){ return id->pMethod->xLock(id, lockType); } int sqlite3OsUnlock(OsFile *id, int lockType){ | > > > > > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | } int sqlite3OsSync(OsFile *id, int fullsync){ return id->pMethod->xSync(id, fullsync); } void sqlite3OsSetFullSync(OsFile *id, int value){ id->pMethod->xSetFullSync(id, value); } #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) /* This method is currently only used while interactively debugging the ** pager. More specificly, it can only be used when sqlite3DebugPrintf() is ** included in the build. */ int sqlite3OsFileHandle(OsFile *id){ return id->pMethod->xFileHandle(id); } #endif int sqlite3OsFileSize(OsFile *id, i64 *pSize){ return id->pMethod->xFileSize(id, pSize); } int sqlite3OsLock(OsFile *id, int lockType){ return id->pMethod->xLock(id, lockType); } int sqlite3OsUnlock(OsFile *id, int lockType){ |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.203 2006/01/24 10:58:22 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(ret)); return TCL_OK; } #endif /* ** Usage: sqlite_abort ** ** Shutdown the process immediately. This is not a clean shutdown. ** This command is used to test the recoverability of a database in ** the event of a program crash. | > > > > > > > > > > > > > > | 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 | Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC); return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewBooleanObj(ret)); return TCL_OK; } #endif /* ** Usage: sqlite3_libversion_number ** */ static int test_libversion_number( ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ int objc, /* Number of arguments */ Tcl_Obj *CONST objv[] /* Command arguments */ ){ Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_libversion_number())); return TCL_OK; } /* ** Usage: sqlite_abort ** ** Shutdown the process immediately. This is not a clean shutdown. ** This command is used to test the recoverability of a database in ** the event of a program crash. |
︙ | ︙ | |||
1831 1832 1833 1834 1835 1836 1837 | return TCL_ERROR; } return TCL_OK; } /* | | > > > > > > | | | | | | | 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 | return TCL_ERROR; } return TCL_OK; } /* ** Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES ** ** Test the sqlite3_bind_text16 interface. STMT is a prepared statement. ** N is the index of a wildcard in the prepared statement. This command ** binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes ** long. */ static int test_bind_text16( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ #ifndef SQLITE_OMIT_UTF16 sqlite3_stmt *pStmt; int idx; int bytes; char *value; int rc; void (*xDel)() = (objc==6?SQLITE_STATIC:SQLITE_TRANSIENT); Tcl_Obj *oStmt = objv[objc-4]; Tcl_Obj *oN = objv[objc-3]; Tcl_Obj *oString = objv[objc-2]; Tcl_Obj *oBytes = objv[objc-1]; if( objc!=5 && objc!=6){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetStringFromObj(objv[0], 0), " STMT N VALUE BYTES", 0); return TCL_ERROR; } if( getStmtPointer(interp, Tcl_GetString(oStmt), &pStmt) ) return TCL_ERROR; if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR; value = (char*)Tcl_GetByteArrayFromObj(oString, 0); if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR; rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, xDel); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ return TCL_ERROR; } #endif /* SQLITE_OMIT_UTF16 */ return TCL_OK; |
︙ | ︙ | |||
3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 | { "sqlite_malloc_outstanding", sqlite_malloc_outstanding, 0}, #endif { "sqlite3_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, #ifndef SQLITE_OMIT_SHARED_CACHE { "sqlite3_enable_shared_cache", test_enable_shared, 0 }, #endif }; static int bitmask_size = sizeof(Bitmask)*8; int i; extern int sqlite3_os_trace; extern int sqlite3_where_trace; extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; | > | 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 | { "sqlite_malloc_outstanding", sqlite_malloc_outstanding, 0}, #endif { "sqlite3_test_errstr", test_errstr, 0 }, { "tcl_variable_type", tcl_variable_type, 0 }, #ifndef SQLITE_OMIT_SHARED_CACHE { "sqlite3_enable_shared_cache", test_enable_shared, 0 }, #endif { "sqlite3_libversion_number", test_libversion_number, 0 }, }; static int bitmask_size = sizeof(Bitmask)*8; int i; extern int sqlite3_os_trace; extern int sqlite3_where_trace; extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; |
︙ | ︙ |
Changes to src/test6.c.
︙ | ︙ | |||
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | return sqlite3OsLockState(((crashFile*)id)->pBase); } /* ** Return the underlying file handle. */ int crashFileHandle(OsFile *id){ return sqlite3OsFileHandle(((crashFile*)id)->pBase); } /* ** This vector defines all the methods that can operate on an OsFile ** for the crash tester. */ static const IoMethod crashIoMethod = { | > > > | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | return sqlite3OsLockState(((crashFile*)id)->pBase); } /* ** Return the underlying file handle. */ int crashFileHandle(OsFile *id){ #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) return sqlite3OsFileHandle(((crashFile*)id)->pBase); #endif return 0; } /* ** This vector defines all the methods that can operate on an OsFile ** for the crash tester. */ static const IoMethod crashIoMethod = { |
︙ | ︙ |
Changes to src/utf.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.37 2006/01/24 10:58:22 danielk1977 Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx |
︙ | ︙ | |||
475 476 477 478 479 480 481 482 483 484 485 486 487 488 | ** in pZ (or up until the first pair of 0x00 bytes, whichever comes first). */ int sqlite3utf16ByteLen(const void *zIn, int nChar){ int c = 1; char const *z = zIn; int n = 0; if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){ while( c && ((nChar<0) || n<nChar) ){ READ_UTF16BE(z, c); n++; } }else{ while( c && ((nChar<0) || n<nChar) ){ READ_UTF16LE(z, c); | > > > > > > > > > | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | ** in pZ (or up until the first pair of 0x00 bytes, whichever comes first). */ int sqlite3utf16ByteLen(const void *zIn, int nChar){ int c = 1; char const *z = zIn; int n = 0; if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){ /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here ** and in other parts of this file means that at one branch will ** not be covered by coverage testing on any single host. But coverage ** will be complete if the tests are run on both a little-endian and ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE ** macros are constant at compile time the compiler can determine ** which branch will be followed. It is therefore assumed that no runtime ** penalty is paid for this "if" statement. */ while( c && ((nChar<0) || n<nChar) ){ READ_UTF16BE(z, c); n++; } }else{ while( c && ((nChar<0) || n<nChar) ){ READ_UTF16LE(z, c); |
︙ | ︙ |
Changes to test/malloc.test.
︙ | ︙ | |||
10 11 12 13 14 15 16 | #*********************************************************************** # This file attempts to check the library in an out-of-memory situation. # When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special # command (sqlite_malloc_fail N) which causes the N-th malloc to fail. This # special feature is used to see what happens in the library if a malloc # were to really fail due to an out-of-memory situation. # | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #*********************************************************************** # This file attempts to check the library in an out-of-memory situation. # When compiled with -DSQLITE_DEBUG=1, the SQLite library accepts a special # command (sqlite_malloc_fail N) which causes the N-th malloc to fail. This # special feature is used to see what happens in the library if a malloc # were to really fail due to an out-of-memory situation. # # $Id: malloc.test,v 1.30 2006/01/24 10:58:23 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Only run these tests if memory debugging is turned on. # if {[info command sqlite_malloc_stat]==""} { |
︙ | ︙ | |||
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | if {$msg=="out of memory"} {error $msg} set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]] binary scan $utf16 c* bytes if {[llength $bytes]==0} { error "out of memory" } } # Ensure that no file descriptors were leaked. do_test malloc-99.X { catch {db close} set sqlite_open_file_count } {0} sqlite_malloc_fail 0 finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | if {$msg=="out of memory"} {error $msg} set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]] binary scan $utf16 c* bytes if {[llength $bytes]==0} { error "out of memory" } } # This test is aimed at coverage testing. Specificly, it is supposed to # cause a malloc() only used when converting between the two utf-16 # encodings to fail (i.e. little-endian->big-endian). It only actually # hits this malloc() on little-endian hosts. # set static_string "\x00h\x00e\x00l\x00l\x00o" for {set l 0} {$l<10} {incr l} { append static_string $static_string } append static_string "\x00\x00" do_malloc_test 19 -tclprep { execsql { PRAGMA encoding = "UTF16be"; CREATE TABLE abc(a, b, c); } } -tclbody { unset -nocomplain ::STMT set r [catch { set ::STMT [sqlite3_prepare $::DB {SELECT ?} -1 DUMMY] sqlite3_bind_text16 -static $::STMT 1 $static_string 112 } msg] if {$r} {error [string range $msg 4 end]} set msg } -cleanup { if {[info exists ::STMT]} { sqlite3_finalize $::STMT } } unset static_string # Ensure that no file descriptors were leaked. do_test malloc-99.X { catch {db close} set sqlite_open_file_count } {0} sqlite_malloc_fail 0 finish_test |
Changes to test/tclsqlite.test.
︙ | ︙ | |||
11 12 13 14 15 16 17 | # This file implements regression tests for TCL interface to the # SQLite library. # # Actually, all tests are based on the TCL interface, so the main # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # This file implements regression tests for TCL interface to the # SQLite library. # # Actually, all tests are based on the TCL interface, so the main # interface is pretty well tested. This file contains some addition # tests for fringe issues that the main test suite does not cover. # # $Id: tclsqlite.test,v 1.51 2006/01/24 10:58:23 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Check the error messages generated by tclsqlite # if {[sqlite3 -has-codec]} { |
︙ | ︙ | |||
443 444 445 446 447 448 449 450 | do_test tcl-11.2 { db exists {SELECT 0 FROM t4 WHERE x==4} } {1} do_test tcl-11.3 { db exists {SELECT 1 FROM t4 WHERE x==8} } {0} finish_test | > > > > > > > | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | do_test tcl-11.2 { db exists {SELECT 0 FROM t4 WHERE x==4} } {1} do_test tcl-11.3 { db exists {SELECT 1 FROM t4 WHERE x==8} } {0} do_test tcl-12.1 { unset -nocomplain a b c version set version [db version] scan $version "%d.%d.%d" a b c expr $a*1000000 + $b*1000 + $c } [sqlite3_libversion_number] finish_test |