3 # Copyright (c) Pavel Filipenský <pfilipensky@samba.org>
7 echo "Usage: test_winbind_call_depth_trace SMBCONTROL CONFIGURATION PREFIX TESTENV"
17 incdir
=$
(dirname "$0")/..
/..
/..
/testprogs
/blackbox
18 .
"$incdir"/subunit.sh
22 PREFIX_ABS
="$(readlink -f "${PREFIX}")"
23 # Strip from TESTENV the ':local' if present
24 TESTENV_SUBDIR
=${TESTENV%:*}
26 LOGFILE
="${PREFIX_ABS}/${TESTENV_SUBDIR}/logs/log.winbindd"
27 # Add support for "WINBINDD_DONT_LOG_STDOUT=1"
28 if [ ! -r "${LOGFILE}" ]; then
29 TEST_LOGFILE
="${PREFIX_ABS}/${TESTENV_SUBDIR}/winbindd_test.log"
30 subunit_start_test
"test winbind call depth trace"
31 subunit_skip_test
"test winbind call depth trace" <<EOF
32 Test is skipped, we need $LOGFILE but have only $TEST_LOGFILE which is missing debug headers (they are not printed to stdout).
39 get_winbind_loglevel
()
41 s1
=$
(${SMBCONTROL} "${CONFIGURATION}" winbind debuglevel
)
42 # We need to get the all level from output like this:
43 # "PID 664474: all:1 tdb:1 printdrivers:1 lanman:1 smb:1 rpc_parse:1 rpc_srv:1 rpc_cli:1 passdb:1 sam:1..."
44 # 1. remove PID 664474:
46 # "all:1 tdb:1 printdrivers:1 lanman:1 smb:1 rpc_parse:1 rpc_srv:1 rpc_cli:1 passdb"
47 # 2. remove " tdb:1 printdrivers:1 ..."
51 saved_level
=${s3#all:}
54 # Example of trace line
55 # [2023/01/25 00:20:33.307038, 5, pid=535581, effective(0, 0), real(0, 0), class=winbind, traceid=78, depth=4] ../../source3/winbindd/wb_group_members.c:310(wb_group_members_send)
56 test_winbind_call_depth_trace
()
60 # If loglevel < 10, set it to 10.
61 if [ "$saved_level" -lt 10 ]; then
62 ${SMBCONTROL} "${CONFIGURATION}" winbind debug
10
65 COUNT1
=$
(grep -c wb_group_members_send
"$LOGFILE")
70 # Restore loglevel, if it was changed.
71 if [ "$saved_level" -lt 10 ]; then
72 ${SMBCONTROL} "${CONFIGURATION}" winbind debug
"$saved_level"
75 if [ $ret != 0 ]; then
76 echo "Command 'id ADDOMAIN/alice' failed!"
80 # Check that there are more lines with wb_group_members_send
81 COUNT2
=$
(grep -c wb_group_members_send
"$LOGFILE")
82 if [ "$COUNT1" -eq "$COUNT2" ]; then
83 echo "The number of the trace lines in $LOGFILE has not increased."
87 # Test that the depth of last line with 'wb_group_members_send' is: depth=4
88 COUNT3
=$
(grep wb_group_members_send
"$LOGFILE" |
tail -1 |
grep -c depth
=4)
89 if [ "$COUNT3" -ne 1 ]; then
90 echo "The last line with wb_group_members_send should have depth=4."
94 # Test that the indentation of the line below last 'wb_group_members_send' is indented by 2+4*4 spaces:
95 COUNT4
=$
(grep -A1 wb_group_members_send
"$LOGFILE" |
tail -1|
grep -c '^ WB command group_members start')
96 if [ "$COUNT4" -ne 1 ]; then
97 echo "The line after the last line with wb_group_members_send should be indented by 18 spaces."
108 echo "Test is for ad_member only, but called for ${TESTENV}." | subunit_fail_test
"test winbind call depth trace"
112 testit
"test winbind call depth trace" test_winbind_call_depth_trace || failed
=$
((failed
+ 1))
113 testok
"$0" "$failed"