1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- /*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * Author: hakanai
- */
- #include <stdio.h>
- #include <assert.h>
- #include <string.h>
- #include <libsdb.h>
- #include <unistd.h>
- #define TFILE "/tmp/oosaAest39ax.sdb"
- static int simple_lock_test() {
- sdb_header_t header;
- sdb_t db;
- assert(sdb_open(TFILE, &db) == SDB_OK);
- assert(sdb_create_header(&header) == SDB_OK);
- assert(sdb_write_header(&db, &header) == SDB_OK);
- assert(sdb_set_lock(&db, 1) == SDB_OK);
- assert(sdb_read_header(&db, &header) == SDB_OK);
- assert(header.lock == 1);
- assert(sdb_get_lock(&db) == true);
- assert(sdb_set_lock(&db, 0) == SDB_OK);
- assert(sdb_read_header(&db, &header) == SDB_OK);
- assert(header.lock == 0);
- assert(sdb_get_lock(&db) == false);
- sdb_close(&db);
- return 0;
- }
- int main() {
- assert(!simple_lock_test());
- unlink(TFILE);
- return 0;
- }
|