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/>.
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
)
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
);
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
);
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()
60 int main(int argc
, const char *argv
[])
62 const char testname
[] = "test_background_send";
66 fprintf(stderr
, "usage: %s <configfile>\n", argv
[0]);
70 printf("test: %s\n", testname
);
72 ok
= lp_load_initial_only(argv
[1]);
74 fprintf(stderr
, "lp_load_initial_only(%s) failed\n", argv
[1]);
78 test_background_send(); /* crashes on failure */
80 printf("success: %s\n", testname
);