From 6b749f225e8d1c910820a6576952f130e72bab84 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Jun 2006 19:30:00 +0000 Subject: r16526: Add torture_setup_server() with test. (This used to be commit 6a1ed8ad756b97f61d4af9df2c7a7d889a2d09ef) --- source4/torture/local/torture.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source4/torture/local/torture.c') diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c index ed601b663f..76581540a1 100644 --- a/source4/torture/local/torture.c +++ b/source4/torture/local/torture.c @@ -22,6 +22,7 @@ #include "includes.h" #include "torture/torture.h" +#include "system/wait.h" #include "torture/util.h" static BOOL test_tempdir(struct torture_context *torture, @@ -38,12 +39,42 @@ static BOOL test_tempdir(struct torture_context *torture, return True; } +static BOOL test_setup_server(struct torture_context *torture, + const void *_data) +{ + pid_t pid; + + torture_assert_ntstatus_ok(torture, torture_setup_server(torture, + "./script/tests/mktestsetup.sh", + "./bin/smbd", &pid), + "starting smbd failed"); + + torture_assert(torture, pid > 0, "Pid invalid"); + + torture_comment(torture, "Created smbd with pid %d", pid); + + kill(pid, SIGINT); + + waitpid(pid, NULL, 0); + + torture_assert_ntstatus_equal(torture, torture_setup_server(torture, + "./invalid-script", + "./bin/smbd", &pid), + NT_STATUS_UNSUCCESSFUL, + "invalid script specified"); + + torture_assert(torture, pid == -1, "Pid not -1 after failure"); + + return True; +} + struct torture_suite *torture_local_torture(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-TORTURE"); torture_suite_add_simple_tcase(suite, "tempdir", test_tempdir, NULL); + torture_suite_add_simple_tcase(suite, "setup server", test_setup_server, NULL); return suite; } -- cgit