Minimal SQLite key-value store for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(build): adapt fuzz tests to new Crowbar and API changes

Update Crowbar.run calls to use (name, test_case list) list format,
add ~name label to Sqlite.Table.create and Openamp.Firmware.install,
add run() functions to openamp fuzz modules.

+31 -36
+31 -36
fuzz/fuzz_sqlite.ml
··· 19 19 Eio_main.run @@ fun env -> 20 20 let cwd = Eio.Stdenv.cwd env in 21 21 let tmp_dir = Eio.Path.(cwd / "_build" / "fuzz_sqlite") in 22 - (try Eio.Path.mkdirs ~exists_ok:true ~perm:0o755 tmp_dir with _ -> ()); 22 + (try Eio.Path.mkdirs ~exists_ok:true ~perm:0o755 tmp_dir with Eio.Io _ -> ()); 23 23 let path = 24 24 Eio.Path.(tmp_dir / Printf.sprintf "fuzz_%d.db" (Random.int 1_000_000)) 25 25 in ··· 28 28 Fun.protect 29 29 ~finally:(fun () -> 30 30 Sqlite.close db; 31 - try Eio.Path.unlink path with _ -> ()) 31 + try Eio.Path.unlink path with Eio.Io _ -> ()) 32 32 (fun () -> f db) 33 33 34 34 (* ============================================================ *) ··· 113 113 let key = truncate key in 114 114 let value = truncate value in 115 115 with_temp_db @@ fun db -> 116 - (try Sqlite.put db key value with _ -> ()); 116 + (try Sqlite.put db key value with Eio.Io _ -> ()); 117 117 check true 118 118 119 119 (** Get must not crash on arbitrary key. *) 120 120 let test_get_crash_safety key = 121 121 let key = truncate key in 122 122 with_temp_db @@ fun db -> 123 - (try ignore (Sqlite.get db key) with _ -> ()); 123 + (try ignore (Sqlite.get db key) with Eio.Io _ -> ()); 124 124 check true 125 125 126 126 (** Delete must not crash on arbitrary key. *) 127 127 let test_delete_crash_safety key = 128 128 let key = truncate key in 129 129 with_temp_db @@ fun db -> 130 - (try Sqlite.delete db key with _ -> ()); 130 + (try Sqlite.delete db key with Eio.Io _ -> ()); 131 131 check true 132 132 133 133 (** Mem must not crash on arbitrary key. *) 134 134 let test_mem_crash_safety key = 135 135 let key = truncate key in 136 136 with_temp_db @@ fun db -> 137 - (try ignore (Sqlite.mem db key) with _ -> ()); 137 + (try ignore (Sqlite.mem db key) with Eio.Io _ -> ()); 138 138 check true 139 139 140 140 (* ============================================================ *) ··· 196 196 (* Register all tests *) 197 197 (* ============================================================ *) 198 198 199 - let () = 200 - (* Core KV operations *) 201 - add_test ~name:"sqlite: roundtrip" [ bytes; bytes ] test_roundtrip; 202 - add_test ~name:"sqlite: delete removes" [ bytes; bytes ] test_delete_removes; 203 - add_test ~name:"sqlite: mem consistent" [ bytes; bytes ] test_mem_consistent; 204 - add_test ~name:"sqlite: overwrite" [ bytes; bytes; bytes ] test_overwrite; 199 + let suite = 200 + ( "sqlite", 201 + [ 202 + (* Core KV operations *) 203 + test_case "roundtrip" [ bytes; bytes ] test_roundtrip; 204 + test_case "delete removes" [ bytes; bytes ] test_delete_removes; 205 + test_case "mem consistent" [ bytes; bytes ] test_mem_consistent; 206 + test_case "overwrite" [ bytes; bytes; bytes ] test_overwrite; 207 + (* Table operations *) 208 + test_case "table isolation" [ bytes; bytes; bytes ] test_table_isolation; 209 + test_case "table roundtrip" [ bytes; bytes ] test_table_roundtrip; 210 + (* Crash safety *) 211 + test_case "put crash safety" [ bytes; bytes ] test_put_crash_safety; 212 + test_case "get crash safety" [ bytes ] test_get_crash_safety; 213 + test_case "delete crash safety" [ bytes ] test_delete_crash_safety; 214 + test_case "mem crash safety" [ bytes ] test_mem_crash_safety; 215 + (* Boundary conditions *) 216 + test_case "empty key" [ bytes ] test_empty_key; 217 + test_case "empty value" [ bytes ] test_empty_value; 218 + test_case "both empty" [ const () ] test_both_empty; 219 + (* Sequence operations *) 220 + test_case "multiple puts" [ bytes; list bytes ] test_multiple_puts; 221 + test_case "put delete put" [ bytes; bytes; bytes ] test_put_delete_put; 222 + ] ) 205 223 206 - (* Table operations *) 207 - add_test ~name:"sqlite: table isolation" [ bytes; bytes; bytes ] 208 - test_table_isolation; 209 - add_test ~name:"sqlite: table roundtrip" [ bytes; bytes ] test_table_roundtrip; 210 - 211 - (* Crash safety *) 212 - add_test ~name:"sqlite: put crash safety" [ bytes; bytes ] 213 - test_put_crash_safety; 214 - add_test ~name:"sqlite: get crash safety" [ bytes ] test_get_crash_safety; 215 - add_test ~name:"sqlite: delete crash safety" [ bytes ] 216 - test_delete_crash_safety; 217 - add_test ~name:"sqlite: mem crash safety" [ bytes ] test_mem_crash_safety; 218 - 219 - (* Boundary conditions *) 220 - add_test ~name:"sqlite: empty key" [ bytes ] test_empty_key; 221 - add_test ~name:"sqlite: empty value" [ bytes ] test_empty_value; 222 - add_test ~name:"sqlite: both empty" [ const () ] test_both_empty; 223 - 224 - (* Sequence operations *) 225 - add_test ~name:"sqlite: multiple puts" 226 - [ bytes; list bytes ] 227 - test_multiple_puts; 228 - add_test ~name:"sqlite: put delete put" [ bytes; bytes; bytes ] 229 - test_put_delete_put 224 + let () = run "sqlite" [ suite ]