mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
r26347: More tests.
This commit is contained in:
parent
064a2329e1
commit
5d927b5ca7
@ -554,20 +554,6 @@ struct parm_struct *lp_parm_table(void)
|
|||||||
return parm_table;
|
return parm_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TALLOC_CTX *lp_talloc;
|
|
||||||
|
|
||||||
/******************************************************************* a
|
|
||||||
Free up temporary memory - called from the main loop.
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
void lp_talloc_free(void)
|
|
||||||
{
|
|
||||||
if (!lp_talloc)
|
|
||||||
return;
|
|
||||||
talloc_free(lp_talloc);
|
|
||||||
lp_talloc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Convenience routine to grab string parameters into temporary memory
|
Convenience routine to grab string parameters into temporary memory
|
||||||
and run standard_sub_basic on them. The buffers can be written to by
|
and run standard_sub_basic on them. The buffers can be written to by
|
||||||
@ -975,7 +961,7 @@ double lp_parm_double(struct loadparm_context *lp_ctx,
|
|||||||
{
|
{
|
||||||
const char *value = lp_get_parametric(lp_ctx, service, type, option);
|
const char *value = lp_get_parametric(lp_ctx, service, type, option);
|
||||||
|
|
||||||
if (value)
|
if (value != NULL)
|
||||||
return lp_double(value);
|
return lp_double(value);
|
||||||
|
|
||||||
return default_v;
|
return default_v;
|
||||||
@ -990,7 +976,7 @@ bool lp_parm_bool(struct loadparm_context *lp_ctx,
|
|||||||
{
|
{
|
||||||
const char *value = lp_get_parametric(lp_ctx, service, type, option);
|
const char *value = lp_get_parametric(lp_ctx, service, type, option);
|
||||||
|
|
||||||
if (value)
|
if (value != NULL)
|
||||||
return lp_bool(value);
|
return lp_bool(value);
|
||||||
|
|
||||||
return default_v;
|
return default_v;
|
||||||
|
@ -53,6 +53,50 @@ static bool test_set_option_parametric(struct torture_context *tctx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool test_lp_parm_double(struct torture_context *tctx)
|
||||||
|
{
|
||||||
|
struct loadparm_context *lp_ctx = loadparm_init(tctx);
|
||||||
|
torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=3.4"), "lp_set_option failed");
|
||||||
|
torture_assert(tctx, lp_parm_double(lp_ctx, NULL, "some", "thing", 2.0) == 3.4,
|
||||||
|
"invalid parametric option");
|
||||||
|
torture_assert(tctx, lp_parm_double(lp_ctx, NULL, "some", "bla", 2.0) == 2.0,
|
||||||
|
"invalid parametric option");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool test_lp_parm_bool(struct torture_context *tctx)
|
||||||
|
{
|
||||||
|
struct loadparm_context *lp_ctx = loadparm_init(tctx);
|
||||||
|
torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=true"), "lp_set_option failed");
|
||||||
|
torture_assert(tctx, lp_parm_bool(lp_ctx, NULL, "some", "thing", false) == true,
|
||||||
|
"invalid parametric option");
|
||||||
|
torture_assert(tctx, lp_parm_bool(lp_ctx, NULL, "some", "bla", true) == true,
|
||||||
|
"invalid parametric option");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool test_lp_parm_int(struct torture_context *tctx)
|
||||||
|
{
|
||||||
|
struct loadparm_context *lp_ctx = loadparm_init(tctx);
|
||||||
|
torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=34"), "lp_set_option failed");
|
||||||
|
torture_assert_int_equal(tctx, lp_parm_int(lp_ctx, NULL, "some", "thing", 20), 34,
|
||||||
|
"invalid parametric option");
|
||||||
|
torture_assert_int_equal(tctx, lp_parm_int(lp_ctx, NULL, "some", "bla", 42), 42,
|
||||||
|
"invalid parametric option");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool test_lp_parm_bytes(struct torture_context *tctx)
|
||||||
|
{
|
||||||
|
struct loadparm_context *lp_ctx = loadparm_init(tctx);
|
||||||
|
torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=16K"), "lp_set_option failed");
|
||||||
|
torture_assert_int_equal(tctx, lp_parm_bytes(lp_ctx, NULL, "some", "thing", 20), 16 * 1024,
|
||||||
|
"invalid parametric option");
|
||||||
|
torture_assert_int_equal(tctx, lp_parm_bytes(lp_ctx, NULL, "some", "bla", 42), 42,
|
||||||
|
"invalid parametric option");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx)
|
struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx)
|
||||||
{
|
{
|
||||||
struct torture_suite *suite = torture_suite_create(mem_ctx, "LOADPARM");
|
struct torture_suite *suite = torture_suite_create(mem_ctx, "LOADPARM");
|
||||||
@ -61,6 +105,10 @@ struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx)
|
|||||||
torture_suite_add_simple_test(suite, "set_option", test_set_option);
|
torture_suite_add_simple_test(suite, "set_option", test_set_option);
|
||||||
torture_suite_add_simple_test(suite, "set_option_invalid", test_set_option_invalid);
|
torture_suite_add_simple_test(suite, "set_option_invalid", test_set_option_invalid);
|
||||||
torture_suite_add_simple_test(suite, "set_option_parametric", test_set_option_parametric);
|
torture_suite_add_simple_test(suite, "set_option_parametric", test_set_option_parametric);
|
||||||
|
torture_suite_add_simple_test(suite, "set_lp_parm_double", test_lp_parm_double);
|
||||||
|
torture_suite_add_simple_test(suite, "set_lp_parm_bool", test_lp_parm_bool);
|
||||||
|
torture_suite_add_simple_test(suite, "set_lp_parm_int", test_lp_parm_int);
|
||||||
|
torture_suite_add_simple_test(suite, "set_lp_parm_bytes", test_lp_parm_bytes);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
2
source/selftest/env/Samba4.pm
vendored
2
source/selftest/env/Samba4.pm
vendored
@ -619,7 +619,7 @@ nogroup:x:65534:nobody
|
|||||||
die("Failed to create a valid smb.conf configuration!");
|
die("Failed to create a valid smb.conf configuration!");
|
||||||
}
|
}
|
||||||
|
|
||||||
(system("($self->{bindir}/testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global 2> /dev/null | grep -i \"^$netbiosname\" ) >/dev/null 2>&1") == 0) or die("Failed to create a valid smb.conf configuration!");
|
(system("($self->{bindir}/testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global 2> /dev/null | grep -i \"^$netbiosname\" ) >/dev/null 2>&1") == 0) or die("Failed to create a valid smb.conf configuration! $self->{bindir}/testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global");
|
||||||
|
|
||||||
my @provision_options = ();
|
my @provision_options = ();
|
||||||
push (@provision_options, "NSS_WRAPPER_PASSWD=\"$nsswrap_passwd\"");
|
push (@provision_options, "NSS_WRAPPER_PASSWD=\"$nsswrap_passwd\"");
|
||||||
|
@ -94,9 +94,6 @@ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags)
|
|||||||
DEBUG(10,("smbsrv_recv\n"));
|
DEBUG(10,("smbsrv_recv\n"));
|
||||||
|
|
||||||
packet_recv(smb_conn->packet);
|
packet_recv(smb_conn->packet);
|
||||||
|
|
||||||
/* free up temporary memory */
|
|
||||||
lp_talloc_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user