From 7f2f29647a5d5906db5a267f614f30607d9162e3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 27 Nov 2012 12:08:33 +0100 Subject: s3:test:wbinfo_sids2xids: test the results with singular calls with filled and with empty cache Signed-off-by: Michael Adam Reviewed-by: Stefan Metzmacher --- source3/script/tests/test_wbinfo_sids2xids.sh | 3 +- source3/script/tests/test_wbinfo_sids2xids_int.py | 37 +++++++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'source3/script') diff --git a/source3/script/tests/test_wbinfo_sids2xids.sh b/source3/script/tests/test_wbinfo_sids2xids.sh index 99d066f3e8..c50060531d 100755 --- a/source3/script/tests/test_wbinfo_sids2xids.sh +++ b/source3/script/tests/test_wbinfo_sids2xids.sh @@ -1,11 +1,12 @@ #!/bin/sh WBINFO="$VALGRIND ${WBINFO:-$BINDIR/wbinfo} $CONFIGURATION" +NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" TEST_INT=`dirname $0`/test_wbinfo_sids2xids_int.py incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -testit "sids2xids" ${TEST_INT} ${WBINFO} || failed=`expr $failed + 1` +testit "sids2xids" ${TEST_INT} ${WBINFO} ${NET} || failed=`expr $failed + 1` testok $0 $failed diff --git a/source3/script/tests/test_wbinfo_sids2xids_int.py b/source3/script/tests/test_wbinfo_sids2xids_int.py index 87db0efed2..8826f53f1f 100755 --- a/source3/script/tests/test_wbinfo_sids2xids_int.py +++ b/source3/script/tests/test_wbinfo_sids2xids_int.py @@ -2,11 +2,17 @@ import sys,os,subprocess -if len(sys.argv) != 2: - print "Usage: test_wbinfo_sids2xids_int.py wbinfo" + +if len(sys.argv) != 3: + print "Usage: test_wbinfo_sids2xids_int.py wbinfo net" sys.exit(1) wbinfo = sys.argv[1] +netcmd = sys.argv[2] + +def flush_cache(): + os.system(netcmd + "cache flush") + domain = subprocess.Popen([wbinfo, "--own-domain"], stdout=subprocess.PIPE).communicate()[0].strip() domsid = subprocess.Popen([wbinfo, "-n", domain + "\\"], @@ -18,6 +24,8 @@ domsid = domsid.split(' ')[0] sids=[ domsid + '-512', 'S-1-5-32-545', domsid + '-513' ] +flush_cache + sids2xids = subprocess.Popen([wbinfo, '--sids-to-unix-ids=' + ','.join(sids)], stdout=subprocess.PIPE).communicate()[0].strip() @@ -34,14 +42,23 @@ for line in sids2xids.split('\n'): gid = '' gids.append(gid) -i=0 +# Check the list produced by the sids-to-xids call with the +# singular variant (sid-to-gid) for each sid in turn. +def check_singular(sids, gids): + i=0 + for sid in sids: + gid = subprocess.Popen([wbinfo, '--sid-to-gid', sid], + stdout=subprocess.PIPE).communicate()[0].strip() + if gid != gids[i]: + print "Expected %s, got %s\n", gid, gids[i] + sys.exit(1) + i+=1 + +# first round: with filled cache +check_singular(sids, gids) -for sid in sids: - gid = subprocess.Popen([wbinfo, '--sid-to-gid', sid], - stdout=subprocess.PIPE).communicate()[0].strip() - if gid != gids[i]: - print "Expected %s, got %s\n", gid, gids[i] - sys.exit(1) - i+=1 +# second round: with empty cache +flush_cache +check_singular(sids, gids) sys.exit(0) -- cgit