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"
27 #include "lib/global_contexts.h"
29 bool run_local_dbwrap_ctdb1(int dummy
)
31 struct db_context
*db
= NULL
;
36 struct messaging_context
*msg_ctx
;
38 msg_ctx
= global_messaging_context();
51 perror("db_open_ctdb failed");
55 res
= dbwrap_transaction_start(db
);
57 fprintf(stderr
, "dbwrap_transaction_start failed");
60 res
= dbwrap_transaction_cancel(db
);
62 fprintf(stderr
, "dbwrap_transaction_cancel failed");
66 res
= dbwrap_transaction_start(db
);
68 fprintf(stderr
, "dbwrap_transaction_start failed");
72 status
= dbwrap_store_uint32_bystring(db
, "foo", 1);
73 if (!NT_STATUS_IS_OK(status
)) {
74 fprintf(stderr
, "store_uint32 failed: %s\n",
78 status
= dbwrap_fetch_uint32_bystring(db
, "foo", &val
);
79 if (!NT_STATUS_IS_OK(status
)) {
80 fprintf(stderr
, "fetch_uint32 failed: %s\n",
85 fprintf(stderr
, "fetch_uint32 gave %u, expected 1",
90 status
= dbwrap_store_uint32_bystring(db
, "bar", 5);
91 if (!NT_STATUS_IS_OK(status
)) {
92 fprintf(stderr
, "store_uint32 failed: %s\n",
96 status
= dbwrap_fetch_uint32_bystring(db
, "bar", &val
);
97 if (!NT_STATUS_IS_OK(status
)) {
98 fprintf(stderr
, "fetch_uint32 failed: %s\n",
103 fprintf(stderr
, "fetch_uint32 gave %u, expected 5",
108 status
= dbwrap_store_uint32_bystring(db
, "foo", 2);
109 if (!NT_STATUS_IS_OK(status
)) {
110 fprintf(stderr
, "store_uint32 failed: %s\n",
114 status
= dbwrap_fetch_uint32_bystring(db
, "foo", &val
);
115 if (!NT_STATUS_IS_OK(status
)) {
116 fprintf(stderr
, "fetch_uint32 failed: %s\n",
121 fprintf(stderr
, "fetch_uint32 gave %u, expected 2",
126 res
= dbwrap_transaction_commit(db
);
128 fprintf(stderr
, "dbwrap_transaction_commit failed");
133 * check that the values have reached the disk
135 status
= dbwrap_fetch_uint32_bystring(db
, "foo", &val
);
136 if (!NT_STATUS_IS_OK(status
)) {
137 fprintf(stderr
, "fetch_uint32 failed: %s\n",
142 fprintf(stderr
, "fetch_uint32 gave %u, expected 1",
147 status
= dbwrap_fetch_uint32_bystring(db
, "bar", &val
);
148 if (!NT_STATUS_IS_OK(status
)) {
149 fprintf(stderr
, "fetch_uint32 failed: %s\n",
154 fprintf(stderr
, "fetch_uint32 gave %u, expected 1",