Test the libaries response to read-only or unreadable database, WAL and wal-index files. If a WAL file cannot be opened in read/write mode, return SQLITE_CANTOPEN to the caller.

FossilOrigin-Name: 45bb84c6283d803fc29077fdc2d06fa50ec06a59
diff --git a/test/malloc_common.tcl b/test/malloc_common.tcl
index e86c4f3..07e1b2b 100644
--- a/test/malloc_common.tcl
+++ b/test/malloc_common.tcl
@@ -137,6 +137,7 @@
 # Procedures to save and restore the current file-system state:
 #
 #   faultsim_save
+#   faultsim_restore
 #   faultsim_save_and_close
 #   faultsim_restore_and_reopen
 #   faultsim_delete_and_reopen
@@ -153,13 +154,16 @@
   catch { db close }
   return ""
 }
-proc faultsim_restore_and_reopen {{dbfile test.db}} {
-  catch { db close }
+proc faultsim_restore {} {
   foreach f [glob -nocomplain test.db*] { file delete -force $f }
   foreach f2 [glob -nocomplain sv_test.db*] {
     set f [string range $f2 3 end]
     file copy -force $f2 $f
   }
+}
+proc faultsim_restore_and_reopen {{dbfile test.db}} {
+  catch { db close }
+  faultsim_restore
   sqlite3 db $dbfile
   sqlite3_extended_result_codes db 1
   sqlite3_db_config_lookaside db 0 0 0