SQLite Forum

launch backup_malloc.test error
Login
Hi all. We're currently on SQLite 3.32.2, and we've been noticed that testcase mallocAll.test would fail because of backup_malloc.test doesn't close db.

backup_malloc.test did not close all files: 1

In the latest version of backup_malloc.test, the problem still exist. So is it correct that close db and db2 when finalize the backup. 

origin testcase backup_malloc.test : 

do_faultsim_test 3 -faults oom* -prep {
  catch { db close }
  catch { db2 close }

  forcedelete test2.db
  sqlite3 db2 test2.db
  sqlite3 db test.db
  sqlite3_backup B db2 main db main
} -body {

  set rc [B step 50]
  if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
    error "out of memory"
  }

} -test {
  faultsim_test_result {0 {}} 
  faultsim_integrity_check
  
  # Finalize the backup.
  catch { B finish }
}

modified testcase backup_malloc.test : 
do_faultsim_test 3 -faults oom* -prep {
  catch { db close }
  catch { db2 close }

  forcedelete test2.db
  sqlite3 db2 test2.db
  sqlite3 db test.db
  sqlite3_backup B db2 main db main
} -body {

  set rc [B step 50]
  if {$rc == "SQLITE_NOMEM" || $rc == "SQLITE_IOERR_NOMEM"} {
    error "out of memory"
  }

} -test {
  faultsim_test_result {0 {}} 
  faultsim_integrity_check
  
  # Finalize the backup.
  catch { B finish }
  catch {db close}
  catch {db2 close}
}

Thank you!

Liziqi