Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tests for a couple of previously untested branches in the ota code. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | ota-update |
Files: | files | file ages | folders |
SHA1: |
a3c1bc5d5e3f4b197f48cbbc240608e9 |
User & Date: | dan 2015-02-19 13:36:02.845 |
Context
2015-02-19
| ||
14:41 | Merge latest trunk changes with this branch. (check-in: 6f5888a5e4 user: dan tags: ota-update) | |
13:36 | Add tests for a couple of previously untested branches in the ota code. (check-in: a3c1bc5d5e user: dan tags: ota-update) | |
2015-02-18
| ||
20:17 | Add new file ota12.test, containing tests for applying ota updates to live databases with other active reader/writer clients. (check-in: 0864d127fe user: dan tags: ota-update) | |
Changes
Changes to ext/ota/ota3.test.
︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 204 205 | while {[ota step]=="SQLITE_OK" && [file exists test.db-wal]==0} {} ota close } {SQLITE_OK} do_test 5.3 { expr {[file size test.db-wal] > (1024 * 1200)} } 1 finish_test | > > | 195 196 197 198 199 200 201 202 203 204 205 206 207 | while {[ota step]=="SQLITE_OK" && [file exists test.db-wal]==0} {} ota close } {SQLITE_OK} do_test 5.3 { expr {[file size test.db-wal] > (1024 * 1200)} } 1 do_test 6.1 { sqlite3ota_internal_test } {} finish_test |
Added ext/ota/otafault2.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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 47 48 49 50 51 52 53 54 55 56 57 58 | # 2014 October 22 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # if {![info exists testdir]} { set testdir [file join [file dirname [info script]] .. .. test] } source $testdir/tester.tcl source $testdir/malloc_common.tcl set ::testprefix otafault2 forcedelete ota.db do_execsql_test 1.0 { CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y)); INSERT INTO target VALUES(1, 2, 3); INSERT INTO target VALUES(4, 5, 6); ATTACH 'ota.db' AS ota; CREATE TABLE ota.data_target(x, y, z, ota_control); INSERT INTO data_target VALUES(7, 8, 9, 0); INSERT INTO data_target VALUES(1, 11, 12, 0); DETACH ota; } db close forcecopy test.db test.db-bak forcecopy ota.db ota.db-bak do_faultsim_test 1 -faults oom* -prep { forcecopy test.db-bak test.db forcecopy ota.db-bak ota.db forcedelete test.db-oal test.db-wal ota.db-journal sqlite3ota ota test.db ota.db } -body { while {[ota step]=="SQLITE_OK"} { } ota close } -test { faultsim_test_result \ {1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: target.x}} \ {1 SQLITE_CONSTRAINT} \ {1 SQLITE_NOMEM} \ {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}} \ {1 {SQLITE_NOMEM - out of memory}} } finish_test |
Changes to ext/ota/sqlite3ota.c.
︙ | ︙ | |||
1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 | int iCookie = 1000000; sqlite3_stmt *pStmt; p->rc = prepareAndCollectError(p->db, &pStmt, &p->zErrmsg, "PRAGMA schema_version" ); if( p->rc==SQLITE_OK ){ if( SQLITE_ROW==sqlite3_step(pStmt) ){ iCookie = sqlite3_column_int(pStmt, 0); } p->rc = sqlite3_finalize(pStmt); } if( p->rc==SQLITE_OK ){ otaMPrintfExec(p, "PRAGMA schema_version = %d", iCookie+1); | > > > > > | 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 | int iCookie = 1000000; sqlite3_stmt *pStmt; p->rc = prepareAndCollectError(p->db, &pStmt, &p->zErrmsg, "PRAGMA schema_version" ); if( p->rc==SQLITE_OK ){ /* Coverage: it may be that this sqlite3_step() cannot fail. There ** is already a transaction open, so the prepared statement cannot ** throw an SQLITE_SCHEMA exception. The only database page the ** statement reads is page 1, which is guaranteed to be in the cache. ** And no memory allocations are required. */ if( SQLITE_ROW==sqlite3_step(pStmt) ){ iCookie = sqlite3_column_int(pStmt, 0); } p->rc = sqlite3_finalize(pStmt); } if( p->rc==SQLITE_OK ){ otaMPrintfExec(p, "PRAGMA schema_version = %d", iCookie+1); |
︙ | ︙ |
Changes to ext/ota/test_ota.c.
︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | } zName = Tcl_GetString(objv[1]); sqlite3ota_destroy_vfs(zName); return TCL_OK; } int SqliteOta_Init(Tcl_Interp *interp){ static struct { char *zName; Tcl_ObjCmdProc *xProc; } aObjCmd[] = { { "sqlite3ota", test_sqlite3ota }, { "sqlite3ota_create_vfs", test_sqlite3ota_create_vfs }, { "sqlite3ota_destroy_vfs", test_sqlite3ota_destroy_vfs }, }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); } return TCL_OK; } | > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } zName = Tcl_GetString(objv[1]); sqlite3ota_destroy_vfs(zName); return TCL_OK; } /* ** Tclcmd: sqlite3ota_internal_test */ static int test_sqlite3ota_internal_test( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; if( objc!=1 ){ Tcl_WrongNumArgs(interp, 1, objv, ""); return TCL_ERROR; } db = sqlite3ota_db(0); if( db!=0 ){ Tcl_AppendResult(interp, "sqlite3ota_db(0)!=0", 0); return TCL_ERROR; } return TCL_OK; } int SqliteOta_Init(Tcl_Interp *interp){ static struct { char *zName; Tcl_ObjCmdProc *xProc; } aObjCmd[] = { { "sqlite3ota", test_sqlite3ota }, { "sqlite3ota_create_vfs", test_sqlite3ota_create_vfs }, { "sqlite3ota_destroy_vfs", test_sqlite3ota_destroy_vfs }, { "sqlite3ota_internal_test", test_sqlite3ota_internal_test }, }; int i; for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); } return TCL_OK; } |
︙ | ︙ |