selftest: use 'kdc enable fast = no' for fl2000 fl2003
[Samba.git] / testsuite / unittests / test_background_send.c
blobea654287305a5a0d32f88253819c322276a85d5e
1 /*
2 * Unix SMB/CIFS implementation.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "replace.h"
19 #include <assert.h>
20 #include "source3/lib/background.h"
21 #include "source3/include/messages.h"
22 #include "lib/util/talloc_stack.h"
23 #include "source3/param/loadparm.h"
24 #include "dynconfig/dynconfig.h"
26 static int bg_trigger(void *private_data)
28 return 1;
31 static void test_background_send(void)
33 TALLOC_CTX *frame = talloc_stackframe();
34 struct tevent_context *ev = NULL;
35 struct messaging_context *msg_ctx = NULL;
36 struct tevent_req *req = NULL;
37 uint32_t ping_msg = MSG_PING;
39 ev = tevent_context_init(frame);
40 assert(ev != NULL);
42 msg_ctx = messaging_init(frame, ev);
43 assert(msg_ctx != NULL);
45 req = background_job_send(
46 frame, ev, msg_ctx, &ping_msg, 1, 0, bg_trigger, NULL);
47 assert(req != NULL);
50 * Here's the core of this test: TALLOC_FREE msg_ctx before
51 * req. This happens if you use background_job_send() smbd and
52 * don't manually TALLOC_FREE req before exit_server()
54 TALLOC_FREE(msg_ctx);
55 TALLOC_FREE(req);
57 TALLOC_FREE(frame);
60 int main(int argc, const char *argv[])
62 const char testname[] = "test_background_send";
63 bool ok;
65 if (argc != 2) {
66 fprintf(stderr, "usage: %s <configfile>\n", argv[0]);
67 return 1;
70 printf("test: %s\n", testname);
72 ok = lp_load_initial_only(argv[1]);
73 if (!ok) {
74 fprintf(stderr, "lp_load_initial_only(%s) failed\n", argv[1]);
75 return 1;
78 test_background_send(); /* crashes on failure */
80 printf("success: %s\n", testname);
81 return 0;