Line data Source code
1 : #include "../common/tdb_private.h" 2 : #include "../common/io.c" 3 : #include "../common/tdb.c" 4 : #include "../common/lock.c" 5 : #include "../common/freelist.c" 6 : #include "../common/traverse.c" 7 : #include "../common/transaction.c" 8 : #include "../common/error.c" 9 : #include "../common/open.c" 10 : #include "../common/check.c" 11 : #include "../common/hash.c" 12 : #include "../common/mutex.c" 13 : #include "tap-interface.h" 14 : #include <stdlib.h> 15 : #include "logging.h" 16 : 17 1 : int main(int argc, char *argv[]) 18 : { 19 : struct tdb_context *tdb; 20 : TDB_DATA key, data; 21 : 22 : plan_tests(3); 23 1 : tdb = tdb_open_ex( 24 : "test/circular_freelist.tdb", 25 : 0, 26 : TDB_DEFAULT, 27 : O_RDWR, 28 : 0600, 29 : &taplogctx, 30 : NULL); 31 : 32 1 : ok1(tdb); 33 : 34 : /* 35 : * All freelist records are just 1 byte key and value. Insert 36 : * something that will walk the whole freelist and hit the 37 : * circle. 38 : */ 39 1 : key.dsize = strlen("x"); 40 1 : key.dptr = discard_const_p(uint8_t, "x"); 41 1 : data.dsize = strlen("too long"); 42 1 : data.dptr = discard_const_p(uint8_t, "too long"); 43 : 44 1 : ok1(tdb_store(tdb, key, data, TDB_INSERT) == -1); 45 1 : ok1(tdb_error(tdb) == TDB_ERR_CORRUPT); 46 : 47 1 : tdb_close(tdb); 48 : 49 1 : return exit_status(); 50 : }