2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Volker Lendecke 2012
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "torture/proto.h"
22 #include "system/filesys.h"
23 #include "lib/dbwrap/dbwrap.h"
24 #include "lib/dbwrap/dbwrap_ctdb.h"
26 #include "lib/messages_ctdb.h"
28 bool run_local_dbwrap_ctdb(int dummy)
30 struct db_context *db = NULL;
35 struct messaging_context *msg_ctx;
37 msg_ctx = global_messaging_context();
39 db = db_open_ctdb(talloc_tos(), msg_ctx, "torture.tdb",
41 O_RDWR, 0755, DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
43 perror("db_open_ctdb failed");
47 res = dbwrap_transaction_start(db);
49 fprintf(stderr, "dbwrap_transaction_start failed");
52 res = dbwrap_transaction_cancel(db);
54 fprintf(stderr, "dbwrap_transaction_cancel failed");
58 res = dbwrap_transaction_start(db);
60 fprintf(stderr, "dbwrap_transaction_start failed");
64 status = dbwrap_store_uint32_bystring(db, "foo", 1);
65 if (!NT_STATUS_IS_OK(status)) {
66 fprintf(stderr, "store_uint32 failed: %s\n",
70 status = dbwrap_fetch_uint32_bystring(db, "foo", &val);
71 if (!NT_STATUS_IS_OK(status)) {
72 fprintf(stderr, "fetch_uint32 failed: %s\n",
77 fprintf(stderr, "fetch_uint32 gave %u, expected 1",
82 status = dbwrap_store_uint32_bystring(db, "bar", 5);
83 if (!NT_STATUS_IS_OK(status)) {
84 fprintf(stderr, "store_uint32 failed: %s\n",
88 status = dbwrap_fetch_uint32_bystring(db, "bar", &val);
89 if (!NT_STATUS_IS_OK(status)) {
90 fprintf(stderr, "fetch_uint32 failed: %s\n",
95 fprintf(stderr, "fetch_uint32 gave %u, expected 5",
100 status = dbwrap_store_uint32_bystring(db, "foo", 2);
101 if (!NT_STATUS_IS_OK(status)) {
102 fprintf(stderr, "store_uint32 failed: %s\n",
106 status = dbwrap_fetch_uint32_bystring(db, "foo", &val);
107 if (!NT_STATUS_IS_OK(status)) {
108 fprintf(stderr, "fetch_uint32 failed: %s\n",
113 fprintf(stderr, "fetch_uint32 gave %u, expected 2",
118 res = dbwrap_transaction_commit(db);
120 fprintf(stderr, "dbwrap_transaction_commit failed");
125 * check that the values have reached the disk
127 status = dbwrap_fetch_uint32_bystring(db, "foo", &val);
128 if (!NT_STATUS_IS_OK(status)) {
129 fprintf(stderr, "fetch_uint32 failed: %s\n",
134 fprintf(stderr, "fetch_uint32 gave %u, expected 1",
139 status = dbwrap_fetch_uint32_bystring(db, "bar", &val);
140 if (!NT_STATUS_IS_OK(status)) {
141 fprintf(stderr, "fetch_uint32 failed: %s\n",
146 fprintf(stderr, "fetch_uint32 gave %u, expected 1",