1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

tests: adapt logging test for s3.

There is one knownfail, where it seems an smb.conf like

   log file = foo
   log level = 2 tdb:2@baa ldb:3

will send the ldb logs to 'baa' instead of 'foo' (i.e., the last
opened log file, rather than the default log file).

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2022-06-08 14:40:36 +12:00 committed by Andrew Bartlett
parent c668b5caa9
commit ab949131b5
4 changed files with 29 additions and 6 deletions

View File

@ -26,6 +26,10 @@
#include "includes.h"
#include "lib/cmdline/cmdline.h"
#ifdef USING_CMDLINE_S3
#include "lib/util/debug_s3.h"
#endif
#define BINARY_NAME "test_s4_logging"
static int log_level = 1;
@ -163,17 +167,18 @@ static int init_daemon(TALLOC_CTX *mem_ctx,
poptFreeContext(pc);
#ifdef USING_CMDLINE_S3
reopen_logs();
#endif
return 0;
}
int main(int argc, const char *argv[])
{
TALLOC_CTX *mem_ctx = NULL;
int rc;
const char *error = NULL;
mem_ctx = talloc_init("crazy-logging-test-server.c#main");
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (mem_ctx == NULL) {
exit(ENOMEM);
}

View File

@ -375,3 +375,12 @@ else:
'popt']),
local_include=False,
for_selftest=True)
bld.SAMBA_BINARY('test_s3_logging',
source='tests/test_s4_logging.c',
deps=' '.join(['CMDLINE_S3',
'samba-util',
'popt']),
cflags="-D USING_CMDLINE_S3",
local_include=False,
for_selftest=True)

View File

@ -22,7 +22,8 @@ from samba.tests import TestCaseInTempDir
from pprint import pprint
HERE = os.path.dirname(__file__)
SERVER = os.path.join(HERE, '../../../../bin/test_s4_logging')
S4_SERVER = os.path.join(HERE, '../../../../bin/test_s4_logging')
S3_SERVER = os.path.join(HERE, '../../../../bin/test_s3_logging')
CLASS_LIST = ["all", "tdb", "printdrivers", "lanman", "smb",
"rpc_parse", "rpc_srv", "rpc_cli", "passdb", "sam", "auth",
@ -39,7 +40,7 @@ CLASS_CODES = {k: i for i, k in enumerate(CLASS_LIST)}
class S4LoggingTests(TestCaseInTempDir):
server = S4_SERVER
def _write_smb_conf(self,
default_level=2,
default_file="default",
@ -112,7 +113,7 @@ class S4LoggingTests(TestCaseInTempDir):
return expected
def _run_s4_logger(self, log_level, *extra_args):
cmd = [SERVER,
cmd = [self.server,
'-s', self.smbconf,
'-L', str(log_level),
*extra_args]
@ -371,3 +372,10 @@ class S4LoggingTests(TestCaseInTempDir):
expected_lines.extend([x.strip() for x in v])
self.assert_string_contains(stderr, expected_lines)
class S3LoggingTests(S4LoggingTests):
server = S3_SERVER
# These tests were developed for testing the test_logger when
# linked against CMDLINE_S4 (see lib/util/wscript_build), but can
# also run when linked against CMDLINE_S3.

View File

@ -0,0 +1 @@
samba.tests.logfiles.*S3LoggingTests.test_all_different_ways_cmdline_d\b