diff options
Diffstat (limited to 'source3/script')
40 files changed, 2066 insertions, 622 deletions
diff --git a/source3/script/gap.awk b/source3/script/gap.awk deleted file mode 100644 index 11680d10f9..0000000000 --- a/source3/script/gap.awk +++ /dev/null @@ -1,39 +0,0 @@ -BEGIN { hv["0"] = 0; hv["1"] = 1; hv["2"] = 2; hv["3"] = 3; - hv["4"] = 4; hv["5"] = 5; hv["6"] = 6; hv["7"] = 7; - hv["8"] = 8; hv["9"] = 9; hv["A"] = 10; hv["B"] = 11; - hv["C"] = 12; hv["D"] = 13; hv["E"] = 14; hv["F"] = 15; - hv["a"] = 10; hv["b"] = 11; hv["c"] = 12; hv["d"] = 13; - hv["e"] = 14; hv["f"] = 15; - - first = 0; last = 0; idx = 0; -} - -function tonum(str) -{ - num=0; - cnt=1; - while (cnt <= length(str)) { - num *= 16; - num += hv[substr(str,cnt,1)]; - ++cnt; - } - return num; -} - -{ - u = tonum($1); - if (u - last > 6) - { - if (last) - { - printf (" { 0x%04x, 0x%04x, %5d },\n", - first, last, idx); - idx -= u - last - 1; - } - first = u; - } - last = u; -} - -END { printf (" { 0x%04x, 0x%04x, %5d },\n", - first, last, idx); } diff --git a/source3/script/gaptab.awk b/source3/script/gaptab.awk deleted file mode 100644 index a309089cd5..0000000000 --- a/source3/script/gaptab.awk +++ /dev/null @@ -1,48 +0,0 @@ -BEGIN { hv["0"] = 0; hv["1"] = 1; hv["2"] = 2; hv["3"] = 3; - hv["4"] = 4; hv["5"] = 5; hv["6"] = 6; hv["7"] = 7; - hv["8"] = 8; hv["9"] = 9; hv["A"] = 10; hv["B"] = 11; - hv["C"] = 12; hv["D"] = 13; hv["E"] = 14; hv["F"] = 15; - hv["a"] = 10; hv["b"] = 11; hv["c"] = 12; hv["d"] = 13; - hv["e"] = 14; hv["f"] = 15; - - first = 0; last = 0; idx = 0; f = 0; -} - -function tonum(str) -{ - num=0; - cnt=1; - while (cnt <= length(str)) { - num *= 16; - num += hv[substr(str,cnt,1)]; - ++cnt; - } - return num; -} - -function fmt(val) -{ - if (f++ % 8 == 0) - { printf ("\n 0x%02x,", val); } - else - { printf (" 0x%02x,", val); } -} - -{ - u = tonum($1); c = tonum($2); - - if (u - last > 6) - { - if (last) { idx += last - first + 1; } - first = u; - } - else - { - for (m = last+1; m < u; m++) { fmt(0); } - } - - fmt(c); - last = u; -} - -END { print "" } diff --git a/source3/script/gen-8bit-gap.awk b/source3/script/gen-8bit-gap.awk deleted file mode 100644 index 59a1a23be0..0000000000 --- a/source3/script/gen-8bit-gap.awk +++ /dev/null @@ -1,18 +0,0 @@ -BEGIN { - for (i=0; i<256; i++) { - tbl[sprintf("%02x",i)] = "0x0000"; - } -} - -/^<U([[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]])>[[:space:]]*.x([[:xdigit:]][[:xdigit:]])[:space:]*.*$/ { - tbl[substr($2,3,2)]=sprintf("0x%s",substr($1,3,4)); -} - -END { - for(i=0; i<32; i++) { - for(j=0; j<8; j++) { - printf(" %s,", tbl[sprintf("%02x",i*8+j)]); - } - printf "\n" - } -}
\ No newline at end of file diff --git a/source3/script/gen-8bit-gap.sh.in b/source3/script/gen-8bit-gap.sh.in deleted file mode 100755 index 0ceaa8128b..0000000000 --- a/source3/script/gen-8bit-gap.sh.in +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -if test $# -ne 2 ; then - echo "Usage: $0 <charmap file> <CHARSET NAME>" - exit 1 -fi - -CHARMAP=$1 -CHARSETNAME=$2 - -echo "/* " -echo " * Conversion table for $CHARSETNAME charset " -echo " * " -echo " * Conversion tables are generated using $CHARMAP table " -echo " * and source/script/gen-8bit-gap.sh script " -echo " * " -echo " * This program is free software; you can redistribute it and/or modify " -echo " * it under the terms of the GNU General Public License as published by " -echo " * the Free Software Foundation; either version 3 of the License, or " -echo " * (at your option) any later version. " -echo " * " -echo " * This program is distributed in the hope that it will be useful," -echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of " -echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " -echo " * GNU General Public License for more details. " -echo " * " -echo " * You should have received a copy of the GNU General Public License " -echo " * along with this program; if not, see <http://www.gnu.org/licenses/>." -echo " */" - -echo '#include "includes.h"' -echo -echo "static const uint16 to_ucs2[256] = {" -cat "$CHARMAP" | @AWK@ -f @srcdir@/script/gen-8bit-gap.awk -echo "};" -echo -echo "static const struct charset_gap_table from_idx[] = {" -sed -ne 's/^<U\(....\).*/\1/p' \ - "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gap.awk -echo " { 0xffff, 0xffff, 0 }" -echo "};" -echo -echo "static const unsigned char from_ucs2[] = {" -sed -ne 's/^<U\(....\)>[[:space:]]*.x\(..\).*/\1 \2/p' \ - "$CHARMAP" | sort -u | @AWK@ -f @srcdir@/script/gaptab.awk -echo "};" -echo -echo "SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP($CHARSETNAME)" -echo diff --git a/source3/script/installman.sh b/source3/script/installman.sh index ab9bfe506d..b029089ab2 100755 --- a/source3/script/installman.sh +++ b/source3/script/installman.sh @@ -13,14 +13,15 @@ if [ $# -ge 4 ] ; then GROFF=$4 # sh cmd line, including options fi -if test ! -d $SRCDIR../docs/manpages; then +if test ! -d $SRCDIR../bin/docs/manpages; then echo "No manpages present. Development version maybe?" exit 0 fi # Get the configured feature set test -f "${SRCDIR}/config.log" && \ - eval `grep "^[[:alnum:]]*=.*" "${SRCDIR}/config.log"` + eval `grep "^[[:alnum:]]*=.*" "${SRCDIR}/config.log" | + grep -v ^MANDIR | grep -v ^SRCDIR` for lang in $langs; do if [ "X$lang" = XC ]; then @@ -43,7 +44,7 @@ for lang in $langs; do for sect in 1 5 7 8 ; do for m in $langdir/man$sect ; do - for s in $SRCDIR../docs/manpages/$lang/*$sect; do + for s in $SRCDIR../bin/docs/manpages/$lang/*$sect; do MP_BASENAME=`basename $s` # Check if this man page if required by the configured feature set diff --git a/source3/script/mkbuildoptions-waf.awk b/source3/script/mkbuildoptions-waf.awk deleted file mode 100644 index ddb3f6527a..0000000000 --- a/source3/script/mkbuildoptions-waf.awk +++ /dev/null @@ -1,273 +0,0 @@ -BEGIN { - print "/* "; - print " Unix SMB/CIFS implementation."; - print " Build Options for Samba Suite"; - print " Copyright (C) Vance Lankhaar <vlankhaar@linux.ca> 2003"; - print " Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001"; - print " "; - print " This program is free software; you can redistribute it and/or modify"; - print " it under the terms of the GNU General Public License as published by"; - print " the Free Software Foundation; either version 3 of the License, or"; - print " (at your option) any later version."; - print " "; - print " This program is distributed in the hope that it will be useful,"; - print " but WITHOUT ANY WARRANTY; without even the implied warranty of"; - print " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"; - print " GNU General Public License for more details."; - print " "; - print " You should have received a copy of the GNU General Public License"; - print " along with this program; if not, see <http://www.gnu.org/licenses/>." - print "*/"; - print ""; - print "#include \"includes.h\""; - print "#include \"build_env.h\""; - print "#include \"dynconfig.h\""; - print ""; - print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);"; - print "void build_options(bool screen);"; - print ""; - print ""; - print "/****************************************************************************"; - print "helper function for build_options"; - print "****************************************************************************/"; - print "static int output(bool screen, const char *format, ...)"; - print "{"; - print " char *ptr = NULL;"; - print " int ret = 0;"; - print " va_list ap;"; - print " "; - print " va_start(ap, format);"; - print " ret = vasprintf(&ptr,format,ap);"; - print " va_end(ap);"; - print ""; - print " if (screen) {"; - print " d_printf(\"%s\", ptr ? ptr : \"\");"; - print " } else {"; - print " DEBUG(4,(\"%s\", ptr ? ptr : \"\"));"; - print " }"; - print " "; - print " SAFE_FREE(ptr);"; - print " return ret;"; - print "}"; - print ""; - print "/****************************************************************************"; - print "options set at build time for the samba suite"; - print "****************************************************************************/"; - print "void build_options(bool screen)"; - print "{"; - print " if ((DEBUGLEVEL < 4) && (!screen)) {"; - print " return;"; - print " }"; - print ""; - print "#ifdef _BUILD_ENV_H"; - print " /* Output information about the build environment */"; - print " output(screen,\"Build environment:\\n\");"; - print " output(screen,\" Built by: %s@%s\\n\",BUILD_ENV_USER,BUILD_ENV_HOST);"; - print " output(screen,\" Built on: %s\\n\",BUILD_ENV_DATE);"; - print ""; - print " output(screen,\" Built using: %s\\n\",BUILD_ENV_COMPILER);"; - print " output(screen,\" Build host: %s\\n\",BUILD_ENV_UNAME);"; - print " output(screen,\" SRCDIR: %s\\n\",BUILD_ENV_SRCDIR);"; - print " output(screen,\" BUILDDIR: %s\\n\",BUILD_ENV_BUILDDIR);"; - print ""; - print " "; - print "#endif"; - print ""; - - print " /* Output various paths to files and directories */"; - print " output(screen,\"\\nPaths:\\n\");"; - - print " output(screen,\" SBINDIR: %s\\n\", get_dyn_SBINDIR());"; - print " output(screen,\" BINDIR: %s\\n\", get_dyn_BINDIR());"; - print " output(screen,\" SWATDIR: %s\\n\", get_dyn_SWATDIR());"; - - print " output(screen,\" CONFIGFILE: %s\\n\", get_dyn_CONFIGFILE());"; - print " output(screen,\" LOGFILEBASE: %s\\n\", get_dyn_LOGFILEBASE());"; - print " output(screen,\" LMHOSTSFILE: %s\\n\",get_dyn_LMHOSTSFILE());"; - - print " output(screen,\" LIBDIR: %s\\n\",get_dyn_LIBDIR());"; - print " output(screen,\" MODULESDIR: %s\\n\",get_dyn_MODULESDIR());"; - print " output(screen,\" SHLIBEXT: %s\\n\",get_dyn_SHLIBEXT());"; - - print " output(screen,\" LOCKDIR: %s\\n\",get_dyn_LOCKDIR());"; - print " output(screen,\" STATEDIR: %s\\n\",get_dyn_STATEDIR());"; - print " output(screen,\" CACHEDIR: %s\\n\",get_dyn_CACHEDIR());"; - print " output(screen,\" PIDDIR: %s\\n\", get_dyn_PIDDIR());"; - - print " output(screen,\" SMB_PASSWD_FILE: %s\\n\",get_dyn_SMB_PASSWD_FILE());"; - print " output(screen,\" PRIVATE_DIR: %s\\n\",get_dyn_PRIVATE_DIR());"; - print ""; - - -################################################## -# predefine first element of *_ary -# predefine *_i (num of elements in *_ary) - with_ary[0]=""; - with_i=0; - have_ary[0]=""; - have_i=0; - utmp_ary[0]=""; - utmp_i=0; - misc_ary[0]=""; - misc_i=0; - sys_ary[0]=""; - sys_i=0; - headers_ary[0]=""; - headers_i=0; - in_comment = 0; -} - -# capture single line comments -/^\/\* (.*?)\*\// { - last_comment = $0; - next; -} - -# end capture multi-line comments -/(.*?)\*\// { - last_comment = last_comment $0; - in_comment = 0; - next; -} - -# capture middle lines of multi-line comments -in_comment { - last_comment = last_comment $0; - next; -} - -# begin capture multi-line comments -/^\/\* (.*?)/ { - last_comment = $0; - in_comment = 1; - next -} - -################################################## -# if we have an #undef and a last_comment, store it -/^\#define/ { - split($0,a); - comments_ary[a[2]] = last_comment; - last_comment = ""; -} - -################################################## -# for each line, sort into appropriate section -# then move on - -/^\#define WITH/ { - with_ary[with_i++] = a[2]; - # we want (I think) to allow --with to show up in more than one place, so no next -} - - -/^\#define HAVE_UT_UT_/ || /^\#define .*UTMP/ { - utmp_ary[utmp_i++] = a[2]; - next; -} - -/^\#define HAVE_SYS_.*?_H$/ { - sys_ary[sys_i++] = a[2]; - next; -} - -/^\#define HAVE_.*?_H$/ { - headers_ary[headers_i++] = a[2]; - next; -} - -/^\#define HAVE_/ { - have_ary[have_i++] = a[2]; - next; -} - -/^\#define/ { - misc_ary[misc_i++] = a[2]; - next; -} - - -################################################## -# simple sort function -function sort(ARRAY, ELEMENTS) { - for (i = 1; i <= ELEMENTS; ++i) { - for (j = i; (j-1) in ARRAY && (j) in ARRAY && ARRAY[j-1] > ARRAY[j]; --j) { - temp = ARRAY[j]; - ARRAY[j] = ARRAY[j-1]; - ARRAY[j-1] = temp; - } - } - return; -} - - -################################################## -# output code from list of defined -# expects: ARRAY an array of things defined -# ELEMENTS number of elements in ARRAY -# TITLE title for section -# returns: nothing -function output(ARRAY, ELEMENTS, TITLE) { - - # add section header - print "\n\t/* Show " TITLE " */"; - print "\toutput(screen, \"\\n " TITLE ":\\n\");\n"; - - - # sort element using bubble sort (slow, but easy) - sort(ARRAY, ELEMENTS); - - # loop through array of defines, outputting code - for (i = 0; i < ELEMENTS; i++) { - print "#ifdef " ARRAY[i]; - - # I don't know which one to use.... - - print "\toutput(screen, \" " ARRAY[i] "\\n\");"; - #printf "\toutput(screen, \" %s\\n %s\\n\\n\");\n", comments_ary[ARRAY[i]], ARRAY[i]; - #printf "\toutput(screen, \" %-35s %s\\n\");\n", ARRAY[i], comments_ary[ARRAY[i]]; - - print "#endif"; - } - return; -} - -END { - ################################################## - # add code to show various options - print "/* Output various other options (as gleaned from include/config.h.in) */"; - output(sys_ary, sys_i, "System Headers"); - output(headers_ary, headers_i, "Headers"); - output(utmp_ary, utmp_i, "UTMP Options"); - output(have_ary, have_i, "HAVE_* Defines"); - output(with_ary, with_i, "--with Options"); - output(misc_ary, misc_i, "Build Options"); - - ################################################## - # add code to display the various type sizes - print " /* Output the sizes of the various types */"; - print " output(screen, \"\\nType sizes:\\n\");"; - print " output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));"; - print " output(screen, \" sizeof(int): %lu\\n\",(unsigned long)sizeof(int));"; - print " output(screen, \" sizeof(long): %lu\\n\",(unsigned long)sizeof(long));"; - print "#if HAVE_LONGLONG" - print " output(screen, \" sizeof(long long): %lu\\n\",(unsigned long)sizeof(long long));"; - print "#endif" - print " output(screen, \" sizeof(uint8): %lu\\n\",(unsigned long)sizeof(uint8));"; - print " output(screen, \" sizeof(uint16): %lu\\n\",(unsigned long)sizeof(uint16));"; - print " output(screen, \" sizeof(uint32): %lu\\n\",(unsigned long)sizeof(uint32));"; - print " output(screen, \" sizeof(short): %lu\\n\",(unsigned long)sizeof(short));"; - print " output(screen, \" sizeof(void*): %lu\\n\",(unsigned long)sizeof(void*));"; - print " output(screen, \" sizeof(size_t): %lu\\n\",(unsigned long)sizeof(size_t));"; - print " output(screen, \" sizeof(off_t): %lu\\n\",(unsigned long)sizeof(off_t));"; - print " output(screen, \" sizeof(ino_t): %lu\\n\",(unsigned long)sizeof(ino_t));"; - print " output(screen, \" sizeof(dev_t): %lu\\n\",(unsigned long)sizeof(dev_t));"; - - ################################################## - # add code to give information about modules - print " output(screen, \"\\nBuiltin modules:\\n\");"; - print " output(screen, \" %s\\n\", STRING_STATIC_MODULES);"; - - print "}"; - -} diff --git a/source3/script/mkbuildoptions.awk b/source3/script/mkbuildoptions.awk index 9a82da288c..122489edd3 100644 --- a/source3/script/mkbuildoptions.awk +++ b/source3/script/mkbuildoptions.awk @@ -21,7 +21,7 @@ BEGIN { print ""; print "#include \"includes.h\""; print "#include \"build_env.h\""; - print "#include \"dynconfig.h\""; + print "#include \"dynconfig/dynconfig.h\""; print ""; print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);"; print "void build_options(bool screen);"; @@ -237,7 +237,7 @@ function output(ARRAY, ELEMENTS, TITLE) { END { ################################################## # add code to show various options - print "/* Output various other options (as gleaned from include/config.h.in) */"; + print "/* Output various other options (as gleaned from include/autoconf/config.h.in) */"; output(sys_ary, sys_i, "System Headers"); output(headers_ary, headers_i, "Headers"); output(utmp_ary, utmp_i, "UTMP Options"); diff --git a/source3/script/mkversion.sh b/source3/script/mkversion.sh index 5ad197dd56..eba8f9ef90 100755 --- a/source3/script/mkversion.sh +++ b/source3/script/mkversion.sh @@ -4,11 +4,11 @@ VERSION_FILE=$1 OUTPUT_FILE=$2 if test -z "$VERSION_FILE";then - VERSION_FILE="VERSION" + VERSION_FILE="../VERSION" fi if test -z "$OUTPUT_FILE";then - OUTPUT_FILE="include/version.h" + OUTPUT_FILE="include/autoconf/version.h" fi SOURCE_DIR=$3 @@ -20,6 +20,7 @@ SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE` SAMBA_VERSION_TP_RELEASE=`sed -n 's/^SAMBA_VERSION_TP_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` +SAMBA_VERSION_BETA_RELEASE=`sed -n 's/^SAMBA_VERSION_BETA_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE` @@ -55,6 +56,9 @@ if test -n "${SAMBA_VERSION_REVISION}";then elif test -n "${SAMBA_VERSION_TP_RELEASE}";then SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}tp${SAMBA_VERSION_TP_RELEASE}" echo "#define SAMBA_VERSION_TP_RELEASE ${SAMBA_VERSION_TP_RELEASE}" >> $OUTPUT_FILE +elif test -n "${SAMBA_VERSION_BETA_RELEASE}";then + SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}beta${SAMBA_VERSION_BETA_RELEASE}" + echo "#define SAMBA_VERSION_BETA_RELEASE ${SAMBA_VERSION_BETA_RELEASE}" >> $OUTPUT_FILE elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then ## maybe add "3.0.22pre2" SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}" @@ -108,7 +112,7 @@ if test -n "${SAMBA_VERSION_VENDOR_FUNCTION}"; then fi if test -n "${SAMBA_VERSION_VENDOR_SUFFIX}";then - echo "#define SAMBA_VERSION_VENDOR_SUFFIX ${SAMBA_VERSION_VENDOR_SUFFIX}" >> $OUTPUT_FILE + echo "#define SAMBA_VERSION_VENDOR_SUFFIX \"${SAMBA_VERSION_VENDOR_SUFFIX}\"" >> $OUTPUT_FILE SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}-${SAMBA_VERSION_VENDOR_SUFFIX}" if test -n "${SAMBA_VERSION_VENDOR_PATCH}";then echo "#define SAMBA_VERSION_VENDOR_PATCH ${SAMBA_VERSION_VENDOR_PATCH}" >> $OUTPUT_FILE @@ -121,7 +125,7 @@ fi ## Add a release nickname ## if test -n "${SAMBA_VERSION_RELEASE_NICKNAME}";then - echo "#define SAMBA_VERSION_RELEASE_NICKNAME ${SAMBA_VERSION_RELEASE_NICKNAME}" >> $OUTPUT_FILE + echo "#define SAMBA_VERSION_RELEASE_NICKNAME \"${SAMBA_VERSION_RELEASE_NICKNAME}\"" >> $OUTPUT_FILE SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING} (${SAMBA_VERSION_RELEASE_NICKNAME})" fi diff --git a/source3/script/tests/gdb_backtrace b/source3/script/tests/gdb_backtrace deleted file mode 100755 index 826381e900..0000000000 --- a/source3/script/tests/gdb_backtrace +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -BASENAME=`basename $0` - -if [ -n "$VALGRIND" -o -n "$SMBD_VALGRIND" ]; then - echo "${BASENAME}: Not running debugger under valgrind" - exit 1 -fi - -# we want everything on stderr, so the program is not disturbed -exec 1>&2 - -BASENAME=`basename $0` -UNAME=`uname` - -PID=$1 -BINARY=$2 - -test x"${PID}" = x"" && { - echo "Usage: ${BASENAME} <pid> [<binary>]" - exit 1 -} - -DB_LIST="gdb" -case "${UNAME}" in - # - # on Tru64 we need to try ladebug first - # because gdb crashes itself... - # - OSF1) - DB_LIST="ladebug ${DB_LIST}" - ;; -esac - -for DB in ${DB_LIST}; do - DB_BIN=`which ${DB} 2>/dev/null | grep '^/'` - test x"${DB_BIN}" != x"" && { - break - } -done - -test x"${DB_BIN}" = x"" && { - echo "${BASENAME}: ERROR: No debugger found." - exit 1 -} - -# -# we first try to use /proc/${PID}/exe -# then fallback to the binary from the commandline -# then we search for the commandline argument with -# 'which' -# -test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe" -test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe" -test -f "${BINARY}" || BINARY=`which ${BINARY}` - -test -f "${BINARY}" || { - echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'." - exit 1 -} - -echo "${BASENAME}: Trying to use ${DB_BIN} on ${BINARY} on PID ${PID}" - -BATCHFILE_PRE=/tmp/gdb_backtrace_pre.$$ -BATCHFILE_MAIN=/tmp/gdb_backtrace_main.$$ -case "${DB}" in - ladebug) -cat << EOF > ${BATCHFILE_PRE} -set \$stoponattach -EOF - -cat << EOF > ${BATCHFILE_MAIN} -where -quit -EOF - ${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}" - ;; - gdb) -cat << EOF > ${BATCHFILE_MAIN} -set height 1000 -bt full -quit -EOF - ${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}" - ;; -esac -/bin/rm -f ${BATCHFILE_PRE} ${BATCHFILE_MAIN} diff --git a/source3/script/tests/stream-depot/run.sh b/source3/script/tests/stream-depot/run.sh new file mode 100755 index 0000000000..38ef283294 --- /dev/null +++ b/source3/script/tests/stream-depot/run.sh @@ -0,0 +1,36 @@ +#!/bin/sh +if [ $# -lt 2 ]; then +cat <<EOF +Usage: run.sh VFSTEST PREFIX +EOF +exit 1; +fi + +TESTBASE=`dirname $0` +VFSTEST=$1 +PREFIX=$2 +shift 2 +ADDARGS="$*" + +VFSTEST_PREFIX=vfstest +VFSTEST_TMPDIR=$(mktemp -d ${PREFIX}/${VFSTEST_PREFIX}_XXXXXX) + +incdir=`dirname $0`/../../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +cd $VFSTEST_TMPDIR || exit 1 + +testit "vfstest" $VFSTEST -f $TESTBASE/vfstest.cmd $ADDARGS || failed=`expr $failed + 1` +testname=".streams check" +subunit_start_test $testname +NUM=`find .streams | wc -l` +if [ $NUM -ne 3 ] ; then +echo "streams_depot left ${NUM} in .streams, expected 3" | subunit_fail_test $testname + failed=`expr $failed + 1` +else + subunit_pass_test $testname +fi + +exit $failed diff --git a/source3/script/tests/stream-depot/vfstest.cmd b/source3/script/tests/stream-depot/vfstest.cmd new file mode 100644 index 0000000000..1400546cf7 --- /dev/null +++ b/source3/script/tests/stream-depot/vfstest.cmd @@ -0,0 +1,5 @@ +connect +mkdir x +open x:y RC 0770 +unlink x:y +rmdir x diff --git a/source3/script/tests/test_failure.sh b/source3/script/tests/test_failure.sh index 8af0f3afff..4980fb0920 100755 --- a/source3/script/tests/test_failure.sh +++ b/source3/script/tests/test_failure.sh @@ -4,12 +4,8 @@ # # Copyright (C) 2011 Michael Adam <obnox@samba.org> -# include the blackbox subunit infrastructure -# if not run from classical s3 test script: -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { - incdir=`dirname $0`/../../../testprogs/blackbox - . $incdir/subunit.sh -} +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh failed=0 diff --git a/source3/script/tests/test_local_s3.sh b/source3/script/tests/test_local_s3.sh index de867c959e..d5a3d474ed 100755 --- a/source3/script/tests/test_local_s3.sh +++ b/source3/script/tests/test_local_s3.sh @@ -9,10 +9,8 @@ EOF exit 1; fi -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 diff --git a/source3/script/tests/test_net_conf.sh b/source3/script/tests/test_net_conf.sh new file mode 100755 index 0000000000..6d3d2a1eec --- /dev/null +++ b/source3/script/tests/test_net_conf.sh @@ -0,0 +1,971 @@ +#!/bin/sh +# +# Blackbox test for net [rpc] conf. +# +# Copyright (C) 2011 Vicentiu Ciorbaru <cvicentiu@gmail.com> + +if [ $# -lt 3 ]; then +cat <<EOF +Usage: test_net_conf.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION [rpc] +EOF +exit 1; +fi + +SCRIPTDIR="$1" +SERVERCONFFILE="$2" +NET="$3" +CONFIGURATION="$4" +RPC="$5" + +LOGDIR_PREFIX="conf_test" + +# remove old logs: +for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do + echo "removing old directory ${OLDDIR}" + rm -rf ${OLDDIR} +done + + +NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" +DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) +LOG=$DIR/log + + +if test "x${RPC}" = "xrpc" ; then + NETCMD="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc" +else + NETCMD="${NET}" +fi + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +SED_INVALID_PARAMS="{ +s/lock directory/;&/g +s/lock dir/;&/g +s/modules dir/;&/g +s/logging/;&/g +s/status/;&/g +s/logdir/;&/g +s/read prediction/;&/g +s/mkprofile/;&/g +s/valid chars/;&/g +s/timesync/;&/g +s/sambaconf/;&/g +s/logtype/;&/g +s/servername/;&/g +s/postscript/;&/g +}" + +REGPATH="HKLM\Software\Samba" + +log_print() { + RC=$? + echo "CMD: $*" >>$LOG + echo "RC: $RC" >> $LOG + return $RC +# echo -n . +} + +test_conf_addshare() +{ + echo '\nTesting conf addshare' >> $LOG + echo ------------------------- >> $LOG + echo '\nDropping existing configuration' >> $LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + +#create a lot of shares + for i in $(seq 1 100); do + if [ $(($i % 2)) -eq 0 ]; then + $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ + "test comment" >>$DIR/addshare_exp \ + 2>>$DIR/addshare_exp + log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ + "test comment" + else + $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \ + "test comment" >>$DIR/addshare_exp \ + 2>>$DIR/addshare_exp + log_print $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \ + "test comment" + fi + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + done + + $NETCMD conf listshares > $DIR/listshares_out + log_print $NETCMD conf listshares + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + for i in $(seq 1 100); do + grep "share$i" $DIR/listshares_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not found" | tee -a $LOG + return 1 + fi + done + +#check the integrity of the shares +#if it fails, it can also point to an error in showshare + for i in $(seq 1 100); do + $NETCMD conf showshare share$i > $DIR/showshare_out + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "path" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not found" | tee -a $LOG + return 1 + fi + + if [ $(($i % 2)) -eq 0 ]; then + grep "read only *= *no" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + else + grep "read only *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + fi + + if [ $(($i % 2)) -eq 0 ]; then + grep "guest ok *= *no" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + else + grep "guest ok *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + fi + + grep "comment *= *test comment" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + done + + echo '\nTaking a conf snapshot for later use' >> $LOG + $NETCMD conf list > $DIR/conf_import_in + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } +} + +test_conf_addshare_existing() +{ +#try adding an already existing share + echo '\nAdding an already existing share' >>$LOG + $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \ + "test comment" >>$DIR/addshare_exp \ + 2>>$DIR/addshare_exp + log_print $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \ + "test comment" + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + test -z `cat $DIR/addshare_exp` && { + echo "ERROR: addshare output does not match" >> $LOG + return 1 + } + + return 0 +} + +test_conf_addshare_usage() +{ +#check to see if command prints usage + echo '\nChecking usage' >>$LOG + $NETCMD conf addshare > $DIR/addshare_usage_exp + log_print $NETCMD conf addshare + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf addshare" $DIR/addshare_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_delshare() +{ + echo '\nTesting conf delshare' >>$LOG + echo ------------------------- >> $LOG + echo -n '\n' >> $LOG + + $NETCMD conf delshare share1 + log_print $NETCMD conf delshare share1 + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf listshares > $DIR/listshares_out + log_print $NETCMD conf listshares + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "share1$" $DIR/listshares_out >/dev/null 2>>$LOG + if [ "$?" = "0" ]; then + echo "ERROR: delshare did not delete 'share1'" | tee -a $LOG + return 1 + fi +} + +test_conf_delshare_empty() +{ + echo '\nAttempting to delete non_existing share' + $NETCMD conf delshare share1 + log_print $NETCMD conf delshare share1 + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + +} + +test_conf_delshare_usage() +{ + echo '\nChecking usage' >>$LOG + $NETCMD conf delshare > $DIR/delshare_usage_exp + log_print $NETCMD conf delshare + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf delshare" $DIR/delshare_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_drop() +{ + + echo '\nTesting conf drop' >> $LOG + echo ------------------------- >> $LOG + echo '\nDropping existing configuration' >> $LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + +#check to see if listing the configuration yields a blank file + $NETCMD conf list 1>>$DIR/list_out + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + test -z "`cat $DIR/list_out`" || { + echo "ERROR: Expected list output did not match" | tee -a $LOG + return 1 + } +} + +test_conf_drop_empty() +{ +#Drop an empty config, see if conf drop fails + echo '\nAttempting to drop an empty configuration' >>$LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + +#check to see if listing the configuration yields a blank file + $NETCMD conf list 1>>$DIR/list_out + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + test -z "`cat $DIR/list_out`" || { + echo ERROR:Expected list output did not match >> $LOG + return 1 + } +} + +test_conf_drop_usage() +{ +#check to see if command prints usage + echo '\nChecking usage' >>$LOG + $NETCMD conf drop extra_arg > $DIR/drop_usage_exp + log_print $NETCMD conf drop extra_arg + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "$RPC *conf drop" $DIR/drop_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_setparm() +{ + echo '\nTesting conf setparm' >> $LOG + echo ------------------------- >> $LOG + + echo '\nDropping existing configuration' >> $LOG + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf setparm share1 "read only" yes + log_print $NETCMD conf setparm share1 "read only" yes + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf setparm share1 "path" /tmp/test_path + log_print $NETCMD conf setparm share1 "path" /tmp/test_path + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf showshare share1 > $DIR/setparm_showshare_out + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "read only *= *yes" $DIR/setparm_showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setparm did not set correctly" | tee -a $LOG + return 1 + fi + + grep "path *= */tmp/test_path" $DIR/setparm_showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setparm did not set correctly" | tee -a $LOG + return 1 + fi +} + +test_conf_setparm_existing() +{ + + echo '\nSetting already existing param with the same value' + $NETCMD conf setparm share1 "read only" yes + log_print $NETCMD conf setparm share1 "read only" yes + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf setparm share1 "read only" yes + log_print $NETCMD conf setparm share1 "read only" yes + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "read only *= *yes" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setparm did not set correctly" | tee -a $LOG + return 1 + fi + + $NETCMD conf setparm share1 "read only" no + log_print $NETCMD conf setparm share1 "read only" no + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "read only *= *no" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setparm did not set correctly" | tee -a $LOG + return 1 + fi +} + +test_conf_setparm_usage() +{ + echo '\nChecking usage' >>$LOG + $NETCMD conf setparm > $DIR/setparm_usage_exp + log_print $NETCMD conf setparm + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "$RPC *conf setparm" $DIR/setparm_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setparm no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_delparm_delete_existing() +{ + echo '\nTesting conf delparm' >> $LOG + echo ------------------------- >> $LOG + echo -n '\n' >>$LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf addshare share1 /tmp "writeable=y" "guest_ok=n" \ + "test comment" + log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ + "test comment" + + $NETCMD conf delparm share1 "path" + log_print $NETCMD conf delparm share1 "path" + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf showshare share1 > $DIR/delparm_showshare_out + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + +#test to see what delparm did delete and how + grep "read only *= *no" $DIR/delparm_showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: delparm did not delete correctly" | tee -a $LOG + return 1 + fi + + grep "path *= */tmp" $DIR/delparm_showshare_out >/dev/null 2>>$LOG + if [ "$?" = "0" ]; then + echo "ERROR: delparm did not delete correctly" | tee -a $LOG + return 1 + fi +} + +test_conf_delparm_delete_non_existing() +{ + echo '\nDelete non existing share' >> $LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf delparm share1 "path" + log_print $NETCMD conf delparm share1 "path" + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } +} + +test_conf_delparm_usage() +{ + + echo '\nChecking usage' >>$LOG + $NETCMD conf delparm > $DIR/delparm_usage_exp + log_print $NETCMD conf delparm + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf delparm" $DIR/delparm_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: delparm no/wrong usage message printed" | tee -a $LOG + return 1 + fi + +} + +test_conf_getparm() +{ + + echo '\nTesting conf getparm' >> $LOG + echo ------------------------- >> $LOG + echo -n '\n' >>$LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + return 1 + } + + $NETCMD conf addshare share1 /tmp/path_test "writeable=n" "guest_ok=n" \ + "test comment" + log_print $NETCMD conf addshare share$i /tmp/path_test "writeable=n" "guest_ok=n" \ + "test comment" + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf getparm share1 "read only" >$DIR/getparm_out + log_print $NETCMD conf getparm share1 "read only" + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf getparm share1 "read only" >$DIR/getparm_out + log_print $NETCMD conf getparm share1 "read only" + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + echo yes >$DIR/getparm_exp + diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG + if [ "$?" = "1" ]; then + echo "ERROR: getparm did not print correctly" | tee -a $LOG + return 1 + fi + + $NETCMD conf getparm share1 "path" >$DIR/getparm_out + log_print $NETCMD conf getparm share1 "path" + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + echo /tmp/path_test >$DIR/getparm_exp + diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG + if [ "$?" = "1" ]; then + echo "ERROR: getparm did not print correctly" | tee -a $LOG + return 1 + fi +} + +test_conf_getparm_usage() +{ + echo '\nChecking usage' >>$LOG + $NETCMD conf getparm > $DIR/getparm_usage_exp + log_print $NETCMD conf getparm + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf getparm" $DIR/getparm_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: getparm no/wrong usage message printed" | tee -a $LOG + return 1 + fi + +} + +test_conf_getparm_non_existing() +{ + echo '\nTesting getparm non existing' >>$LOG + $NETCMD conf getparm fictional_share fictional_param + log_print $NETCMD conf getparm fictional_share fictional_param + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + $NETCMD conf getparm share1 fictional_param + log_print $NETCMD conf getparm share1 fictional_param + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } +} + +test_conf_setincludes() +{ + echo '\nTesting conf setincludes' >> $LOG + echo ------------------------- >> $LOG + echo '\nDropping existing configuration' >> $LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf addshare tmp_share /tmp + log_print $NETCMD conf addshare tmp_share /tmp + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3 + log_print $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3 + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf list > $DIR/setincludes_list_out + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "include *= */tmp/include1$" $DIR/setincludes_list_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setincludes did not set correctly" | tee -a $LOG + return 1 + fi + + grep "include *= */tmp/include2$" $DIR/setincludes_list_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setincludes did not set correctly" | tee -a $LOG + return 1 + fi + + grep "include *= */tmp/include3$" $DIR/setincludes_list_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: setincludes did not set correctly" | tee -a $LOG + return 1 + fi + +} + +test_conf_setincludes_usage() +{ + echo '\nChecking usage' >>$LOG + $NETCMD conf setincludes > $DIR/setincludes_usage_exp + log_print $NETCMD conf setincludes + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf setincludes" $DIR/setincludes_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_getincludes() +{ + $NETCMD conf getincludes tmp_share > $DIR/getincludes_out + log_print $NETCMD conf getincludes tmp_share + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "include *= */tmp/include1$" $DIR/getincludes_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: getincludes did not print correctly" | tee -a $LOG + return 1 + fi + + grep "include *= */tmp/include2$" $DIR/getincludes_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: getincludes did not print correctly" | tee -a $LOG + return 1 + fi + grep "include *= */tmp/include3$" $DIR/getincludes_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: getincludes did not print correctly" | tee -a $LOG + return 1 + fi +} + +test_conf_getincludes_usage() +{ + $NETCMD conf getincludes > $DIR/getincludes_usage_exp + log_print $NETCMD conf getincludes + + grep "$RPC *conf getincludes" $DIR/getincludes_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_delincludes() +{ + echo '\nTesting conf delincludes' >> $LOG + echo ------------------------- >> $LOG + + $NETCMD conf delincludes tmp_share + log_print $NETCMD conf delincludes tmp_share + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf list > $DIR/delincludes_list_out + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "include" $DIR/delincludes_list_out >/dev/null 2>>$LOG + if [ "$?" = "0" ]; then + echo "ERROR: delincludes did not delete correctly" | tee -a $LOG + return 1 + fi +} + +test_conf_delincludes_empty() +{ + $NETCMD conf delincludes tmp_share + log_print $NETCMD conf delincludes tmp_share + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf delincludes fictional_share + log_print $NETCMD conf delincludes fictional_share + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + return 0 +} + +test_conf_delincludes_usage() +{ + echo '\nChecking usage' >>$LOG + $NETCMD conf delincludes > $DIR/delincludes_usage_exp + log_print $NETCMD conf delincludes + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf delincludes" $DIR/delincludes_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +test_conf_import() +{ + echo '\nTesting conf import' >> $LOG + echo ------------------------- >> $LOG + echo '\nDropping existing configuration' >> $LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf import $DIR/conf_import_in + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf list > $DIR/conf_import_out + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + diff -q $DIR/conf_import_in $DIR/conf_import_out >> $LOG + if [ "$?" = "1" ]; then + echo "ERROR: import failed" | tee -a $LOG + return 1 + fi +} + +test_conf_import_usage() +{ + echo '\nChecking usage' >>$LOG + $NETCMD conf import > $DIR/import_usage_exp + log_print $NETCMD conf import + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf import" $DIR/import_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: conf import no/wrong usage message printed" | tee -a $LOG + return 1 + fi +} + +CONF_FILES=$SERVERCONFFILE + + testit "conf_drop" \ + test_conf_drop \ + || failed=`expr $failed + 1` + + testit "conf_drop_empty" \ + test_conf_drop_empty \ + || failed=`expr $failed + 1` + + testit "conf_drop_usage" \ + test_conf_drop_usage \ + || failed=`expr $failed + 1` + + testit "conf_addshare" \ + test_conf_addshare \ + || failed=`expr $failed + 1` + + testit "conf_addshare_existing" \ + test_conf_addshare_existing \ + || failed=`expr $failed + 1` + + testit "conf_addshare_usage" \ + test_conf_addshare_usage \ + || failed=`expr $failed + 1` + + testit "conf_delshare" \ + test_conf_delshare \ + || failed=`expr $failed + 1` + + testit "conf_delshare_empty" \ + test_conf_delshare_empty \ + || failed=`expr $failed + 1` + + testit "conf_delshare_usage" \ + test_conf_delshare_usage \ + || failed=`expr $failed + 1` + + testit "conf_setparm" \ + test_conf_setparm \ + || failed=`expr $failed + 1` + + testit "conf_setparm_existing" \ + test_conf_setparm_existing \ + || failed=`expr $failed + 1` + + testit "conf_setparm_usage" \ + test_conf_setparm_usage \ + || failed=`expr $failed + 1` + + testit "conf_delparm_delete_existing" \ + test_conf_delparm_delete_existing \ + || failed=`expr $failed + 1` + + testit "conf_delparm_delete_non_existing" \ + test_conf_delparm_delete_non_existing \ + || failed=`expr $failed + 1` + + testit "conf_delparm_delete_usage" \ + test_conf_delparm_usage \ + || failed=`expr $failed + 1` + + testit "conf_getparm" \ + test_conf_getparm \ + || failed=`expr $failed + 1` + + testit "conf_getparm_usage" \ + test_conf_getparm_usage \ + || failed=`expr $failed + 1` + + testit "conf_setincludes" \ + test_conf_setincludes \ + || failed=`expr $failed + 1` + + testit "conf_setincludes_usage" \ + test_conf_setincludes_usage \ + || failed=`expr $failed + 1` + + testit "conf_getincludes" \ + test_conf_getincludes \ + || failed=`expr $failed + 1` + + testit "conf_getincludes_usage" \ + test_conf_getincludes_usage \ + || failed=`expr $failed + 1` + + testit "conf_delincludes" \ + test_conf_delincludes \ + || failed=`expr $failed + 1` + + testit "conf_delincludes_empty" \ + test_conf_delincludes_usage \ + || failed=`expr $failed + 1` + + testit "conf_delincludes_usage" \ + test_conf_delincludes_empty \ + || failed=`expr $failed + 1` + + testit "conf_import" \ + test_conf_import \ + || failed=`expr $failed + 1` + + testit "conf_import_usage" \ + test_conf_import_usage \ + || failed=`expr $failed + 1` + + if [ $failed -eq 0 ]; then + rm -r $DIR + fi + +testok $0 $failed + diff --git a/source3/script/tests/test_net_misc.sh b/source3/script/tests/test_net_misc.sh index 015b5026a7..566694be74 100755 --- a/source3/script/tests/test_net_misc.sh +++ b/source3/script/tests/test_net_misc.sh @@ -4,24 +4,23 @@ if [ $# -lt 3 ]; then cat <<EOF -Usage: test_net_misc.sh SCRIPTDIR SERVERCONFFILE CONFIGURATION +Usage: test_net_misc.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION EOF exit 1; fi SCRIPTDIR="$1" SERVERCONFFILE="$2" -CONFIGURATION="$3" +NET="$3" +CONFIGURATION="$4" NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" NETTIME="${NET} time" NETLOOKUP="${NET} lookup" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 diff --git a/source3/script/tests/test_net_registry.sh b/source3/script/tests/test_net_registry.sh index 21c452d6e1..5158d61275 100755 --- a/source3/script/tests/test_net_registry.sh +++ b/source3/script/tests/test_net_registry.sh @@ -9,15 +9,16 @@ if [ $# -lt 3 ]; then cat <<EOF -Usage: test_net_registry.sh SCRIPTDIR SERVERCONFFILE CONFIGURATION RPC +Usage: test_net_registry.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION RPC EOF exit 1; fi SCRIPTDIR="$1" SERVERCONFFILE="$2" -CONFIGURATION="$3" -RPC="$4" +NET="$3" +CONFIGURATION="$4" +RPC="$5" NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" @@ -27,10 +28,8 @@ else NETREG="${NET} registry" fi -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 diff --git a/source3/script/tests/test_net_registry_check.sh b/source3/script/tests/test_net_registry_check.sh new file mode 100755 index 0000000000..4b2c542034 --- /dev/null +++ b/source3/script/tests/test_net_registry_check.sh @@ -0,0 +1,146 @@ +#!/bin/sh +# +# Blackbox tests for the "net registry check" command. +# +# Copyright (C) 2011 Björn Baumbach <bb@sernet.de> + +if [ $# -lt 5 ]; then + echo "Usage: test_net_registry.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION DBWRAP_TOOL" + exit 1 +fi + +SCRIPTDIR="$1" +SERVERCONFFILE="$2" +NET="$3" +CONFIGURATION="$4" +DBWRAP_TOOL="$5" + +NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" + +NETREG="${NET} registry" +REGORIG="$(grep 'state directory = ' $SERVERCONFFILE | sed 's/[^=]*=//')/registry.tdb" +REG=$REGORIG.wip + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +# run registry check and filter allowed errors +regcheck() +{ + ALLOWEDERR="Check database:|INFO: version =" + ERRSTR=$(${NETREG} check $REG $@ 2>&1 | egrep -v "$ALLOWEDERR") +} + +# try to repair registry +regrepair() +{ + regcheck -a +} + +# check if $ERRSTR contains expected error +checkerr() +{ + EXPERR=$1 + + ERRCNT=$(echo "$ERRSTR" | grep "$EXPERR" | wc -l) + return $ERRCNT +} + +regchecknrepair() +{ + EXPERR="$1" + EXPERRCNT="$2" + + regcheck + checkerr "$EXPERR" + test "x$?" = "x$ERRCNT" || { + echo "Expected $EXPERRCNT of error $EXPERR. Received $ERRCNT" + return 1 + } + + regrepair + regcheck + test "x$ERRSTR" = "x" || { + echo "Error: Can't repair database" + return 1 + } +} + +test_simple() +( + ERRSTR="" + cp $REGORIG $REG + + regcheck + test "x$ERRSTR" = "x" || { + echo $ERRSTR + return 1 + } +) + +test_damage() +{ + diff $REGORIG $REG +} + +test_duplicate() +( + ERRSTR="" + $DBWRAP_TOOL $REG store 'HKLM/SOFTWARE' hex '02000000534F4654574152450053595354454D00' + + regchecknrepair "Duplicate subkeylist" 1 +) + +test_slashes() +( + ERRSTR="" + $DBWRAP_TOOL $REG store 'HKLM/SOFTWARE' hex '02000000534F4654574152450053595354454D00' + + regchecknrepair "Unnormal key:" 1 +) + +test_uppercase() +( + ERRSTR="" + $DBWRAP_TOOL $REG store 'HKLM\Software' hex '02000000534F4654574152450053595354454D00' + + regchecknrepair "Unnormal key:" 1 +) + +test_strangeletters() +( + ERRSTR="" + $DBWRAP_TOOL $REG store 'HKLM\SOFTWARE' hex '02000000534F4654574FABFABFABFAB354454D00' + + regchecknrepair "Conversion error: Incomplete multibyte sequence" 1 +) + +testit "simple" \ + test_simple || \ + failed=`expr $failed + 1` + +testit "damages_registry" \ + test_damage || \ + failed=`expr $failed + 1` + +testit "duplicate" \ + test_duplicate || \ + failed=`expr $failed + 1` + +testit "slashes" \ + test_slashes || \ + failed=`expr $failed + 1` + +testit "uppercase" \ + test_uppercase || \ + failed=`expr $failed + 1` + +#Can't repair this atm +#testit "strangeletters" \ +# test_strangeletters || \ +# failed=`expr $failed + 1` + +testok $0 $failed + diff --git a/source3/script/tests/test_net_registry_roundtrip.sh b/source3/script/tests/test_net_registry_roundtrip.sh index f3c43af081..f2158879e3 100755 --- a/source3/script/tests/test_net_registry_roundtrip.sh +++ b/source3/script/tests/test_net_registry_roundtrip.sh @@ -7,28 +7,28 @@ if [ $# -lt 3 ]; then cat <<EOF -Usage: test_net_registry_roundtrip.sh SCRIPTDIR SERVERCONFFILE CONFIGURATION +Usage: test_net_registry_roundtrip.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION RPC EOF exit 1; fi SCRIPTDIR="$1" SERVERCONFFILE="$2" -CONFIGURATION="$3" - -NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" +NET="$3" +CONFIGURATION="$4" +RPC="$5" +NET="$VALGRIND ${NET} $CONFIGURATION" if test "x${RPC}" = "xrpc" ; then - NETREG="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry" + NETCMD="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc" else - NETREG="${NET} registry" + NETCMD="${NET}" fi -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { + incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 @@ -66,31 +66,31 @@ conf_roundtrip_step() { LOGDIR_PREFIX="conf_roundtrip" conf_roundtrip() -{ - local DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) - local LOG=$DIR/log +( + DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) + LOG=$DIR/log echo conf_roundtrip $1 > $LOG sed -e "$SED_INVALID_PARAMS" $1 >$DIR/conf_in - conf_roundtrip_step $NET conf drop + conf_roundtrip_step $NETCMD conf drop test "x$?" = "x0" || { return 1 } - test -z "$($NET conf list)" 2>>$LOG + test -z "$($NETCMD conf list)" 2>>$LOG if [ "$?" = "1" ]; then echo "ERROR: conf drop failed" | tee -a $LOG return 1 fi - conf_roundtrip_step $NET conf import $DIR/conf_in + conf_roundtrip_step $NETCMD conf import $DIR/conf_in test "x$?" = "x0" || { return 1 } - conf_roundtrip_step $NET conf list > $DIR/conf_exp + conf_roundtrip_step $NETCMD conf list > $DIR/conf_exp test "x$?" = "x0" || { return 1 } @@ -101,28 +101,28 @@ conf_roundtrip() return 1 fi - conf_roundtrip_step $NET -d10 registry export $REGPATH $DIR/conf_exp.reg + conf_roundtrip_step $NETCMD -d10 registry export $REGPATH $DIR/conf_exp.reg test "x$?" = "x0" || { return 1 } - conf_roundtrip_step $NET conf drop + conf_roundtrip_step $NETCMD conf drop test "x$?" = "x0" || { return 1 } - test -z "$($NET conf list)" 2>>$LOG + test -z "$($NETCMD conf list)" 2>>$LOG if [ "$?" = "1" ]; then echo "ERROR: conf drop failed" | tee -a $LOG return 1 fi - conf_roundtrip_step $NET registry import $DIR/conf_exp.reg + conf_roundtrip_step $NETCMD registry import $DIR/conf_exp.reg test "x$?" = "x0" || { return 1 } - conf_roundtrip_step $NET conf list >$DIR/conf_out + conf_roundtrip_step $NETCMD conf list >$DIR/conf_out test "x$?" = "x0" || { return 1 } @@ -133,7 +133,7 @@ conf_roundtrip() return 1 fi - conf_roundtrip_step $NET registry export $REGPATH $DIR/conf_out.reg + conf_roundtrip_step $NETCMD registry export $REGPATH $DIR/conf_out.reg test "x$?" = "x0" || { return 1 } @@ -144,9 +144,9 @@ conf_roundtrip() return 1 fi rm -r $DIR -} +) -CONF_FILES=${CONF_FILES:-$(find $SRCDIR/ -name '*.conf' | grep -v examples/logon | xargs grep -l "\[global\]")} +CONF_FILES=$SERVERCONFFILE # remove old logs: for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do diff --git a/source3/script/tests/test_ntlm_auth_diagnostics.sh b/source3/script/tests/test_ntlm_auth_diagnostics.sh new file mode 100755 index 0000000000..6e0c3eef42 --- /dev/null +++ b/source3/script/tests/test_ntlm_auth_diagnostics.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then +cat <<EOF +Usage: test_ntlm_auth_diagnostics.sh NTLM_AUTH DOMAIN USERNAME PASSWORD +EOF +exit 1; +fi + +NTLM_AUTH=$1 +DOMAIN=$2 +USERNAME=$3 +PASSWORD=$4 +shift 4 + +ADDARGS="$*" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +testit "ntlm_auth" $VALGRIND $NTLM_AUTH --domain=$DOMAIN --username=$USERNAME --password=$PASSWORD --diagnostics $ADDARGS || failed=`expr $failed + 1` + +testok $0 $failed diff --git a/source3/script/tests/test_ntlm_auth_krb5.sh b/source3/script/tests/test_ntlm_auth_krb5.sh new file mode 100755 index 0000000000..5989d01046 --- /dev/null +++ b/source3/script/tests/test_ntlm_auth_krb5.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +if [ $# -lt 2 ]; then +cat <<EOF +Usage: test_ntlm_auth_s3.sh PYTHON SRC3DIR NTLM_AUTH CCACHE SERVER +EOF +exit 1; +fi + +PYTHON=$1 +SRC3DIR=$2 +NTLM_AUTH=$3 +CCACHE=$4 +SERVER=$5 +shift 5 +ADDARGS="$*" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +KRB5CCNAME=$CCACHE +export KRB5CCNAME + +# --server-use-winbindd is set so we know it isn't cheating and using the hard-coded passwords + +testit "ntlm_auth with krb5 gss-spnego-client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --target-hostname=$SERVER --target-service=host --client-helper=gss-spnego-client --server-helper=gss-spnego --server-use-winbindd || failed=`expr $failed + 1` + + +testok $0 $failed diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh index 4f84982503..ca7a952b74 100755 --- a/source3/script/tests/test_ntlm_auth_s3.sh +++ b/source3/script/tests/test_ntlm_auth_s3.sh @@ -2,26 +2,32 @@ if [ $# -lt 2 ]; then cat <<EOF -Usage: test_ntlm_auth_s3.sh PYTHON SRC3DIR +Usage: test_ntlm_auth_s3.sh PYTHON SRC3DIR NTLM_AUTH EOF exit 1; fi PYTHON=$1 SRC3DIR=$2 -shift 2 +NTLM_AUTH=$3 +DOMAIN=$4 +USERNAME=$5 +PASSWORD=$6 +shift 6 ADDARGS="$*" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 -testit "ntlm_auth" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $BINDIR/ntlm_auth $ADDARGS || failed=`expr $failed + 1` +testit "ntlm_auth" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS || failed=`expr $failed + 1` # This should work even with NTLMv2 -testit "ntlm_auth" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $BINDIR/ntlm_auth $ADDARGS --client-domain=fOo --server-domain=fOo || failed=`expr $failed + 1` +testit "ntlm_auth with specified domain" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo || failed=`expr $failed + 1` +testit "ntlm_auth against winbindd" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd $ADDARGS || failed=`expr $failed + 1` +testit "ntlm_auth with NTLMSSP client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo --client-helper=ntlmssp-client-1 --server-helper=gss-spnego || failed=`expr $failed + 1` +testit "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo --client-helper=gss-spnego-client --server-helper=gss-spnego || failed=`expr $failed + 1` +testit "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server against winbind" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd --client-helper=gss-spnego-client --server-helper=gss-spnego $ADDARGS || failed=`expr $failed + 1` testok $0 $failed diff --git a/source3/script/tests/test_pthreadpool.sh b/source3/script/tests/test_pthreadpool.sh index 79e578effa..b1c7c6da11 100755 --- a/source3/script/tests/test_pthreadpool.sh +++ b/source3/script/tests/test_pthreadpool.sh @@ -3,15 +3,18 @@ incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -TESTPROG=$BINDIR/pthreadpooltest - if [ ! -x $BINDIR/pthreadpooltest ] ; then - TESTPROG=/bin/true + # Some machines don't have /bin/true, simulate it + cat >$BINDIR/pthreadpooltest <<EOF +#!/bin/sh +exit 0 +EOF + chmod +x $BINDIR/pthreadpooltest fi failed=0 -testit "pthreadpool" $VALGRIND $TESTPROG || +testit "pthreadpool" $VALGRIND $BINDIR/pthreadpooltest || failed=`expr $failed + 1` testok $0 $failed diff --git a/source3/script/tests/test_registry_upgrade.sh b/source3/script/tests/test_registry_upgrade.sh new file mode 100755 index 0000000000..4e97153fec --- /dev/null +++ b/source3/script/tests/test_registry_upgrade.sh @@ -0,0 +1,195 @@ +#!/bin/sh +# +# Test for registry upgrades. +# +# Copyright (C) 2011 Björn Baumbach <bb@sernet.de> + +if [ $# -lt 2 ]; then + echo "Usage: test_registry_upgrade.sh NET DBWRAP_TOOL" + exit 1 +fi + +SCRIPT_DIR=$(dirname $0) +BASE_DIR="${SCRIPT_DIR}/../../.." + +NET="$1" +DBWRAP_TOOL="$2" +DATADIR="${BASE_DIR}/testdata/samba3" +WORKSPACE="${PREFIX}/registry_upgrade" +CONFIG_FILE="${WORKSPACE}/smb.conf" +CONFIGURATION="--configfile=${CONFIG_FILE}" + +NETCMD="$NET $CONFIGURATION" + +incdir="${BASE_DIR}/testprogs/blackbox" +. $incdir/subunit.sh + +failed=0 + +REGPATH="HKLM\Software\Samba" + +LOGDIR_PREFIX="registry_upgrade" + +registry_check() +( + CHECKNO="$1" + CHECKDIFF="$2" + REGVER="" + ALLOWEDERR="INFO: version =|Check database:|overwrite registry format version 0 with 1|no INFO/version found" + + test "x$CHECKNO" = "x0" && { + REGVER="--reg-version=1" + } + + echo "Registry check $CHECKNO" | tee -a $LOG + CHECK="$($NETCMD registry check $REGVER 2>&1)" + RC=$? + + ERRORSTR="$(echo "$CHECK" | grep -vE $ALLOWEDERR )" + test "x$RC" = "x0" || { + echo "upgrade check $CHECKNO failed:" | tee -a $LOG + return 1 + } + + test "x$ERRORSTR" = "x" || { + echo "upgrade check $CHECKNO failed:" | tee -a $LOG + echo "reason: $CHECK" | tee -a $LOG + return 1 + } + + test "x$CHECKDIFF" = "xcheckdiff" && { + $NETCMD registry export 'HKLM' $WORKSPACE/export_${CHECKNO}.reg >> $LOG + test "x$?" = "x0" || { + echo "Error: 'net registry export HKLM' failed" | tee -a $LOG + } + + diff -q $WORKSPACE/export_0.reg $WORKSPACE/export_${CHECKNO}.reg >> $LOG + test "x$?" = "x0" || { + echo "Error: $WORKSPACE/export_0.reg differs from $WORKSPACE/export_${CHECKNO}.reg" | tee -a $LOG + return 1 + } + } + + return 0 +) + +registry_upgrade() +{ + echo registry_upgrade $1 | tee -a $LOG + + cp -v $DATADIR/registry.tdb $WORKSPACE/registry.tdb >> $LOG 2>&1 + + REGISTRY="${WORKSPACE}/registry.tdb" + + test -e $REGISTRY || { + echo "Error: Database file not available" | tee -a $LOG + return 1 + } + + # create config file + echo '[global]' > ${CONFIG_FILE} + echo " state directory = ${WORKSPACE}" >> ${CONFIG_FILE} + + # set database INFO/version to 1 + #$DBWRAP_TOOL $REGISTRY store 'INFO/version' uint32 1 + #test "x$?" = "x0" || { + # echo "Error: Can not set INFO/version" >> $LOG + # return 1 + #} + + # check original registry.tdb + echo "$REGISTRY" | tee -a $LOG + registry_check 0 + test "x$?" = "x0" || { + echo "Error: initial 'registry_check 0' failed" | tee -a $LOG + return 1 + } + + # trigger upgrade + echo "$NETCMD registry enumerate $REGPATH" >> $LOG + $NETCMD registry enumerate $REGPATH >> $LOG + test "x$?" = "x0" || { + echo "Error: 'net registry enumerate $REGPATH' failed" | tee -a $LOG + return 1 + } + + # check upgraded database + registry_check 1 + test "x$?" = "x0" || { + echo "Error: 'registry_check 1' after upgrade failed" | tee -a $LOG + return 1 + } + + # export database for diffs + $NETCMD registry export 'HKLM' $WORKSPACE/export_0.reg | tee -a $LOG + test "x$?" = "x0" || { + echo "Error 'net registry export' failed" | tee -a $LOG + return 1 + } + + # remove version string + $DBWRAP_TOOL $REGISTRY delete INFO/version | tee -a $LOG + test "x$?" = "x0" || { + echo "Error: Can not remove INFO/version key from registry" | tee -a $LOG + return 1 + } + + # trigger upgrade on upgraded database + echo "$NETCMD registry enumerate $REGPATH" >> $LOG + $NETCMD registry enumerate $REGPATH >> $LOG 2>&1 + test "x$?" = "x0" || { + echo "Error: 'net registry enumerate $REGPATH' failed" | tee -a $LOG + return 1 + } + + # check upgraded database again + registry_check 2 checkdiff + test "x$?" = "x0" || { + echo "Error: 'registry_check 2' after upgrade failed" | tee -a $LOG + return 1 + } + + # set database INFO/version to version 2 + $DBWRAP_TOOL $REGISTRY store 'INFO/version' uint32 2 + test "x$?" = "x0" || { + echo "Error: Can not set INFO/version" | tee -a $LOG + return 1 + } + + # trigger upgrade + $NETCMD registry enumerate $REGPATH >> $LOG + test "x$?" = "x0" || { + echo "Error: 'net registry enumerate $REGPATH' failed" | tee -a $LOG + return 1 + } + + # check upgraded database again + registry_check 3 checkdiff + test "x$?" = "x0" || { + echo "Error: 'registry_check 3' after upgrade failed" | tee -a $LOG + return 1 + } +} + +# remove old logs +for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do + echo "removing old directory ${OLDDIR}" + rm -rf ${OLDDIR} +done + +# remove old workspace +rm -rf $WORKSPACE + +mkdir $WORKSPACE + +DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) +LOG=$DIR/log + +testit "registry_upgrade" registry_upgrade || failed=`expr $failed + 1` + +if [ $failed -eq 0 ]; then + rm -r $DIR +fi + +testok $0 $failed + diff --git a/source3/script/tests/test_rpcclient.sh b/source3/script/tests/test_rpcclient.sh new file mode 100755 index 0000000000..6c293166a2 --- /dev/null +++ b/source3/script/tests/test_rpcclient.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then +cat <<EOF +Usage: test_rpcclient.sh ccache binding <rpcclient commands> +EOF +exit 1; +fi + +KRB5CCNAME=$1 +shift 1 +export KRB5CCNAME +ADDARGS="$*" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh +testit "rpcclient" $VALGRIND $BINDIR/rpcclient -c 'getusername' $ADDARGS || failed=`expr $failed + 1` + +testok $0 $failed diff --git a/source3/script/tests/test_smbclient_auth.sh b/source3/script/tests/test_smbclient_auth.sh index fb1212fbcf..39880950bb 100755 --- a/source3/script/tests/test_smbclient_auth.sh +++ b/source3/script/tests/test_smbclient_auth.sh @@ -4,7 +4,7 @@ if [ $# -lt 4 ]; then cat <<EOF -Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD <smbclient arguments> +Usage: test_smbclient_auth.sh SERVER SERVER_IP USERNAME PASSWORD SMBCLIENT <smbclient arguments> EOF exit 1; fi @@ -13,14 +13,13 @@ SERVER="$1" SERVER_IP="$2" USERNAME="$3" PASSWORD="$4" -SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient}" -shift 4 +SMBCLIENT="$5" +SMBCLIENT="$VALGRIND ${SMBCLIENT}" +shift 5 ADDARGS="$*" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} testit "smbclient //$SERVER/guestonly" $SMBCLIENT //$SERVER/guestonly $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 -c quit $ADDARGS testit "smbclient //$SERVER/guestonly as anon" $SMBCLIENT //$SERVER/guestonly $CONFIGURATION -U% -I $SERVER_IP -p 139 -c quit $ADDARGS diff --git a/source3/script/tests/test_smbclient_krb5.sh b/source3/script/tests/test_smbclient_krb5.sh new file mode 100755 index 0000000000..02117dc335 --- /dev/null +++ b/source3/script/tests/test_smbclient_krb5.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then +cat <<EOF +Usage: test_smbclient.sh ccache smbclient3 server <smbclient args> +EOF +exit 1; +fi + +KRB5CCNAME=$1 +export KRB5CCNAME +SMBCLIENT3=$2 +SERVER=$3 +shift 3 +ADDARGS="$*" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh +testit "smbclient" $VALGRIND $SMBCLIENT3 //$SERVER/tmp -c 'ls' -k $ADDARGS || failed=`expr $failed + 1` + +testok $0 $failed diff --git a/source3/script/tests/test_smbclient_machine_auth.sh b/source3/script/tests/test_smbclient_machine_auth.sh new file mode 100755 index 0000000000..f67256d19b --- /dev/null +++ b/source3/script/tests/test_smbclient_machine_auth.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# this runs the file serving tests that are expected to pass with samba3 against shares with various options + +if [ $# -lt 2 ]; then +cat <<EOF +Usage: test_smbclient_machine_auth.sh SERVER SMBCLIENT <smbclient arguments> +EOF +exit 1; +fi + +SERVER="$1" +SMBCLIENT="$2" +SMBCLIENT="$VALGRIND ${SMBCLIENT}" +shift 2 +ADDARGS="$*" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +testit "smbclient //$SERVER/tmp" $SMBCLIENT //$SERVER/tmp --machine-pass -I $SERVER_IP -p 139 -c quit $ADDARGS diff --git a/source3/script/tests/test_smbclient_posix_large.sh b/source3/script/tests/test_smbclient_posix_large.sh new file mode 100755 index 0000000000..0aee7afcc0 --- /dev/null +++ b/source3/script/tests/test_smbclient_posix_large.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then +cat <<EOF +Usage: test_smbclient_posix_large.sh ccache smbclient3 server prefix <smbclient args> +EOF +exit 1; +fi + +KRB5CCNAME=$1 +export KRB5CCNAME +SMBCLIENT3=$2 +SERVER=$3 +PREFIX=$4 +shift 4 +ADDARGS="$*" + +# Test that a noninteractive smbclient does not prompt +test_large_write_read() +{ + + cat > $PREFIX/largefile-script <<EOF +posix +put $PREFIX/largefile largefile +get largefile $PREFIX/largefile2 +rm largefile +quit +EOF + + cmd='$SMBCLIENT3 //$SERVER/xcopy_share $ADDARGS < $PREFIX/largefile-script 2>&1' + eval echo "$cmd" + out=`eval $cmd` + + if [ $? != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + echo "$out" | grep "getting file" >/dev/null 2>&1 + + if [ $? = 0 ] ; then + true + else + echo did not get success message + false + fi +} + +rm -f $PREFIX/largefile +dd if=/dev/zero of=$PREFIX/largefile skip=$((20*1024*1024)) count=1 bs=1 + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +testit "smbclient large posix write read" test_large_write_read || failed=`expr $failed + 1` + +testit "cmp of read and written files" cmp $PREFIX/largefile $PREFIX/largefile2 || failed=`expr $failed + 1` +rm -f $PREFIX/largefile2 + +testok $0 $failed diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 772802f77b..3341c62f4b 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -4,27 +4,28 @@ if [ $# -lt 7 ]; then cat <<EOF -Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD USERID LOCAL_PATH PREFIX +Usage: test_smbclient_s3.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD USERID LOCAL_PATH PREFIX SMBCLIENT WBINFO EOF exit 1; fi -SERVER="$1" -SERVER_IP="$2" -USERNAME="$3" -PASSWORD="$4" -USERID="$5" -LOCAL_PATH="$6" -PREFIX="$7" -SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient}" -WBINFO="$VALGRIND ${WBINFO:-$BINDIR/wbinfo}" -shift 7 +SERVER="${1}" +SERVER_IP="${2}" +DOMAIN="${3}" +USERNAME="${4}" +PASSWORD="${5}" +USERID="${6}" +LOCAL_PATH="${7}" +PREFIX="${8}" +SMBCLIENT="${9}" +WBINFO="${10}" +SMBCLIENT="$VALGRIND ${SMBCLIENT}" +WBINFO="$VALGRIND ${WBINFO}" +shift 10 ADDARGS="$*" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 @@ -133,7 +134,7 @@ EOF # Test creating a good symlink and deleting it by path. test_good_symlink() { - tmpfile=/tmp/smbclient.in.$$ + tmpfile=$PREFIX/smbclient.in.$$ slink_name="$LOCAL_PATH/slink" slink_target="$LOCAL_PATH/slink_target" @@ -183,7 +184,7 @@ EOF test_read_only_dir() { prompt="NT_STATUS_ACCESS_DENIED making remote directory" - tmpfile=/tmp/smbclient.in.$$ + tmpfile=$PREFIX/smbclient.in.$$ ## ## We can't do this as non-root. We always have rights to @@ -219,6 +220,7 @@ EOF if [ $ret != 0 ] ; then echo "$out" echo "failed writing into read-only directory with error $ret" + false return fi @@ -236,11 +238,55 @@ EOF fi } + +# Test sending a message +test_message() +{ + tmpfile=$PREFIX/message_in.$$ + + cat > $tmpfile <<EOF +Test message from pid $$ +EOF + + cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD -M $SERVER -p 139 $ADDARGS -n msgtest < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed sending message to $SERVER with error $ret" + false + rm -f $tmpfile + return + fi + + # The server writes this into a file message.msgtest, via message.%m to test the % sub code + cmd='$SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmpguest -p 139 $ADDARGS -c "get message.msgtest $PREFIX/message_out.$$" 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed getting sent message from $SERVER with error $ret" + false + return + fi + + if [ cmp $PREFIX/message_out.$$ $tmpfile != 0 ] ; then + echo "failed comparison of message from $SERVER" + false + return + fi + true +} + # Test reading an owner-only file (logon as guest) fails. test_owner_only_file() { prompt="NT_STATUS_ACCESS_DENIED opening remote file" - tmpfile=/tmp/smbclient.in.$$ + tmpfile=$PREFIX/smbclient.in.$$ ## ## We can't do this as non-root. We always have rights to @@ -296,7 +342,7 @@ EOF # Test accessing an msdfs path. test_msdfs_link() { - tmpfile=/tmp/smbclient.in.$$ + tmpfile=$PREFIX/smbclient.in.$$ prompt=" msdfs-target " cat > $tmpfile <<EOF @@ -366,6 +412,14 @@ EOF test_ccache_access() { $WBINFO --ccache-save="${USERNAME}%${PASSWORD}" + ret=$? + + if [ $ret != 0 ] ; then + echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='${PASSWORD}')" + false + return + fi + $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}%" \ -c quit 2>&1 ret=$? @@ -377,6 +431,14 @@ test_ccache_access() fi $WBINFO --ccache-save="${USERNAME}%GarBage" + ret=$? + + if [ $ret != 0 ] ; then + echo "wbinfo failed to store creds in cache (user='${USERNAME}', pass='GarBage')" + false + return + fi + $SMBCLIENT //$SERVER_IP/tmp -C -U "${USERNAME}%" \ -c quit 2>&1 ret=$? @@ -390,6 +452,43 @@ test_ccache_access() $WBINFO --logoff } +# Test authenticating using the winbind ccache +test_auth_file() +{ + tmpfile=$PREFIX/smbclient.in.$$ + cat > $tmpfile <<EOF +username=${USERNAME} +password=${PASSWORD} +domain=${DOMAIN} +EOF + $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile \ + -c quit 2>&1 + ret=$? + rm $tmpfile + + if [ $ret != 0 ] ; then + echo "smbclient failed to use auth file" + false + return + fi + + cat > $tmpfile <<EOF +username=${USERNAME} +password=xxxx +domain=${DOMAIN} +EOF + $SMBCLIENT //$SERVER_IP/tmp --authentication-file=$tmpfile\ + -c quit 2>&1 + ret=$? + rm $tmpfile + + if [ $ret -eq 0 ] ; then + echo "smbclient succeeded with wrong auth file credentials" + false + return + fi +} + LOGDIR_PREFIX=test_smbclient_s3 # possibly remove old logdirs: @@ -445,6 +544,14 @@ testit "ccache access works for smbclient" \ test_ccache_access || \ failed=`expr $failed + 1` +testit "sending a message to the remote server" \ + test_message || \ + failed=`expr $failed + 1` + +testit "using an authentication file" \ + test_auth_file || \ + failed=`expr $failed + 1` + testit "rm -rf $LOGDIR" \ rm -rf $LOGDIR || \ failed=`expr $failed + 1` diff --git a/source3/script/tests/test_smbclient_tarmode.sh b/source3/script/tests/test_smbclient_tarmode.sh new file mode 100755 index 0000000000..331ba20219 --- /dev/null +++ b/source3/script/tests/test_smbclient_tarmode.sh @@ -0,0 +1,181 @@ +#!/bin/sh + +# this runs a simple tarmode test + +if [ $# -lt 7 ]; then +cat <<EOF +Usage: test_smbclient_tarmode.sh SERVER SERVER_IP USERNAME PASSWORD LOCAL_PATH PREFIX SMBCLIENT [create|extract] <smbclient arguments> +EOF +exit 1; +fi + +SERVER="$1" +SERVER_IP="$2" +USERNAME="$3" +PASSWORD="$4" +LOCAL_PATH="$5" +PREFIX="$6" +SMBCLIENT="$7" +SMBCLIENT="$VALGRIND ${SMBCLIENT}" +shift 7 +ADDARGS="$*" + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh + +FAILCOUNT=0 + +# Check command is available +have_command() { + type "$1" > /dev/null 2>&1 + return $? +} + +# Create a test corpus +create_test_data() { + + local DIR="$1" + local BS=1024 + local NUM_FILES=10 + local NORND_COUNT=25 + + # Bomb if dir exists + if [ -e "$DIR" ]; then + echo "Test data directory '$DIR' already exists!" + false + return + fi + + if ! mkdir -p "$DIR" > /dev/null 2>&1; then + echo "Couldn't create test data directory '$DIR'" + false + return + fi + + local I=1 + if have_command "od"; then # Use random file sizes + local RND_COUNT + for RND_COUNT in `od -An -N$NUM_FILES -tu1 < /dev/urandom`; do + if ! dd if=/dev/urandom of="$DIR/file.$I" bs=$BS count=$RND_COUNT > /dev/null 2>&1; then + echo "Couldn't create test file '$DIR/file.$I' (random size)" + false + return + fi + I=`expr $I + 1` + done + else # Fallback to same file sizes + while [ $I -le $NUM_FILES ]; do + if ! dd if=/dev/urandom of="$DIR/file.$I" bs=$BS count=$NORND_COUNT > /dev/null 2>&1; then + echo "Couldn't create test file '$DIR/file.$I' (static size)" + false + return + fi + I=`expr $I + 1` + done + fi + + true + return + +} + +# Check that two directories are equivalent (In Data content) +validate_data() { + local DIR1="$1" + local DIR2="$2" + + diff -r "$DIR1" "$DIR2" + return $? +} + +# Test tarmode -Tc +test_tarmode_creation() { + + # Clear temp data + rm -rf -- "$PREFIX"/tarmode > /dev/null 2>&1 + rm -f "$PREFIX"/tarmode.tar > /dev/null 2>&1 + rm -rf "$LOCAL_PATH"/tarmode > /dev/null 2>&1 + + # Build the test data + if ! create_test_data "$LOCAL_PATH/tarmode"; then + echo "Test data creation failed" + false + return + fi + + # Create tarfile with smbclient + if ! $SMBCLIENT //$SERVER/tmp $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ + $ADDARGS -c "tarmode full" -Tc "$PREFIX/tarmode.tar" "/tarmode"; then + echo "Couldn't create tar file with tarmode -Tc" + false + return + fi + + # Extract data to verify + if ! tar -xf "$PREFIX/tarmode.tar" -C "$PREFIX"; then + echo "Couldn't extract data from created tarfile" + false + return + fi + + # Verify data + if ! validate_data "$PREFIX/tarmode" "$LOCAL_PATH/tarmode"; then + echo "Data not equivalent" + false + return + fi + + true + return + +} + +# Test tarmode -Tx +test_tarmode_extraction() { + + # Clear temp data + rm -rf -- "$PREFIX"/tarmode > /dev/null 2>&1 + rm -f "$PREFIX"/tarmode.tar > /dev/null 2>&1 + rm -rf "$LOCAL_PATH"/tarmode > /dev/null 2>&1 + + # Build the test data + if ! create_test_data "$PREFIX/tarmode"; then + echo "Test data creation failed" + false + return + fi + + # Create tarfile to extract on client + if ! tar -cf "$PREFIX/tarmode.tar" -C "$PREFIX" tarmode; then + echo "Couldn't create tar archive" + false + return + fi + + # Extract tarfile with smbclient + if ! $SMBCLIENT //$SERVER/tmp $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ + $ADDARGS -c "tarmode full" -Tx "$PREFIX/tarmode.tar"; then + echo "Couldn't extact tar file with tarmode -Tx" + false + return + fi + + # Verify data + if ! validate_data "$PREFIX/tarmode" "$LOCAL_PATH/tarmode"; then + echo "Data not equivalent" + false + return + fi + + true + return + +} + +testit "test_tarmode_creation" \ + test_tarmode_creation || FAILCOUNT=`expr $FAILCOUNT + 1` + +testit "test_tarmode_extraction" \ + test_tarmode_extraction || FAILCOUNT=`expr $FAILCOUNT + 1` + +testok $0 $FAILCOUNT diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh index ca64fa283d..07d940faa1 100755 --- a/source3/script/tests/test_smbtorture_s3.sh +++ b/source3/script/tests/test_smbtorture_s3.sh @@ -4,7 +4,7 @@ if [ $# -lt 4 ]; then cat <<EOF -Usage: test_smbtorture_s3.sh TEST UNC USERNAME PASSWORD <smbtorture args> +Usage: test_smbtorture_s3.sh TEST UNC USERNAME PASSWORD SMBTORTURE <smbtorture args> EOF exit 1; fi @@ -13,17 +13,16 @@ t="$1" unc="$2" username="$3" password="$4" -shift 4 +SMBTORTURE="$5" +shift 5 ADDARGS="$*" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 -testit "smbtorture" $VALGRIND $BINDIR/smbtorture $unc -U"$username"%"$password" $ADDARGS $t || failed=`expr $failed + 1` +testit "smbtorture" $VALGRIND $SMBTORTURE $unc -U"$username"%"$password" $ADDARGS $t || failed=`expr $failed + 1` testok $0 $failed diff --git a/source3/script/tests/test_success.sh b/source3/script/tests/test_success.sh index 09e7264536..fe63fb51a9 100755 --- a/source3/script/tests/test_success.sh +++ b/source3/script/tests/test_success.sh @@ -4,12 +4,8 @@ # # Copyright (C) 2011 Michael Adam <obnox@samba.org> -# include the blackbox subunit infrastructure -# if not run from classical s3 test script: -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { - incdir=`dirname $0`/../../../testprogs/blackbox - . $incdir/subunit.sh -} +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh failed=0 diff --git a/source3/script/tests/test_testparm_s3.sh b/source3/script/tests/test_testparm_s3.sh index bced6e7e19..c9682f0dd1 100755 --- a/source3/script/tests/test_testparm_s3.sh +++ b/source3/script/tests/test_testparm_s3.sh @@ -17,10 +17,8 @@ LOCAL_PATH="$1" TEMP_CONFFILE=${LOCAL_PATH}/smb.conf.tmp TESTPARM="$VALGRIND ${TESTPARM:-$BINDIR/testparm} --suppress-prompt --skip-logic-checks" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} failed=0 diff --git a/source3/script/tests/test_wbinfo_s3.sh b/source3/script/tests/test_wbinfo_s3.sh index 860e7c5afc..91a9f45b3a 100755 --- a/source3/script/tests/test_wbinfo_s3.sh +++ b/source3/script/tests/test_wbinfo_s3.sh @@ -9,10 +9,8 @@ fi ADDARGS="$*" -test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh -} testit "wbinfo" $VALGRIND $BINDIR/wbinfo $ADDARGS || failed=`expr $failed + 1` diff --git a/source3/script/tests/test_wbinfo_sids2xids.sh b/source3/script/tests/test_wbinfo_sids2xids.sh index 5bb33ee065..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 ${NET:-$BINDIR/wbinfo} $CONFIGURATION" +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..1b79e005dc 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() @@ -26,7 +34,7 @@ gids=[] for line in sids2xids.split('\n'): result = line.split(' ')[2:] - if result[0] == 'gid': + if result[0] == 'gid' or result[0] == 'uid/gid': gid = result[1] else: gid = '' @@ -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) diff --git a/source3/script/tests/vfstest-acl/run.sh b/source3/script/tests/vfstest-acl/run.sh new file mode 100755 index 0000000000..ea7a4cbb28 --- /dev/null +++ b/source3/script/tests/vfstest-acl/run.sh @@ -0,0 +1,52 @@ +#!/bin/sh +if [ $# -lt 2 ]; then +cat <<EOF +Usage: run.sh VFSTEST PREFIX +EOF +exit 1; +fi + +TESTBASE=`dirname $0` +VFSTEST=$1 +PREFIX=$2 +shift 2 +ADDARGS="$*" + +VFSTEST_PREFIX=vfstest +VFSTEST_TMPDIR=$(mktemp -d ${PREFIX}/${VFSTEST_PREFIX}_XXXXXX) + +incdir=`dirname $0`/../../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +cd $VFSTEST_TMPDIR || exit 1 + +test_vfstest() +{ + cmd='$VFSTEST -f $TESTBASE/vfstest.cmd $ADDARGS ' + out=`eval $cmd` + ret=$? + rm -f $tmpfile + + if [ $ret != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + echo "$out" | grep "NT_STATUS_ACCESS_DENIED" >/dev/null 2>&1 + + if [ $? = 0 ] ; then + # got ACCESS_DENIED .. fail + echo vfstest got NT_STATUS_ACCESS_DENIED + false + else + true + fi +} + +testit "vfstest" test_vfstest || failed=`expr $failed + 1` + +exit $failed diff --git a/source3/script/tests/vfstest-acl/vfstest.cmd b/source3/script/tests/vfstest-acl/vfstest.cmd new file mode 100644 index 0000000000..61686717ec --- /dev/null +++ b/source3/script/tests/vfstest-acl/vfstest.cmd @@ -0,0 +1,15 @@ +connect +open x RC 0700 +sys_acl_get_file . 0 +sys_acl_get_file . 1 +get_nt_acl . +set_nt_acl . G:DAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU) +get_nt_acl . +sys_acl_get_file . 0 +sys_acl_get_file . 1 +get_nt_acl x +sys_acl_get_file x 0 +set_nt_acl x G:DAD:P(A;OICI;0x001f01ff;;;BA)(A;OICI;0x001200a9;;;SO)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU) +get_nt_acl x +sys_acl_get_file x 0 + diff --git a/source3/script/tests/xattr-tdb-1/run.sh b/source3/script/tests/xattr-tdb-1/run.sh new file mode 100755 index 0000000000..ea7a4cbb28 --- /dev/null +++ b/source3/script/tests/xattr-tdb-1/run.sh @@ -0,0 +1,52 @@ +#!/bin/sh +if [ $# -lt 2 ]; then +cat <<EOF +Usage: run.sh VFSTEST PREFIX +EOF +exit 1; +fi + +TESTBASE=`dirname $0` +VFSTEST=$1 +PREFIX=$2 +shift 2 +ADDARGS="$*" + +VFSTEST_PREFIX=vfstest +VFSTEST_TMPDIR=$(mktemp -d ${PREFIX}/${VFSTEST_PREFIX}_XXXXXX) + +incdir=`dirname $0`/../../../../testprogs/blackbox +. $incdir/subunit.sh + +failed=0 + +cd $VFSTEST_TMPDIR || exit 1 + +test_vfstest() +{ + cmd='$VFSTEST -f $TESTBASE/vfstest.cmd $ADDARGS ' + out=`eval $cmd` + ret=$? + rm -f $tmpfile + + if [ $ret != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + echo "$out" | grep "NT_STATUS_ACCESS_DENIED" >/dev/null 2>&1 + + if [ $? = 0 ] ; then + # got ACCESS_DENIED .. fail + echo vfstest got NT_STATUS_ACCESS_DENIED + false + else + true + fi +} + +testit "vfstest" test_vfstest || failed=`expr $failed + 1` + +exit $failed diff --git a/source3/script/tests/xattr-tdb-1/vfstest.cmd b/source3/script/tests/xattr-tdb-1/vfstest.cmd new file mode 100644 index 0000000000..5eb7158619 --- /dev/null +++ b/source3/script/tests/xattr-tdb-1/vfstest.cmd @@ -0,0 +1,6 @@ +connect +open x RC 0700 +setxattr x y z +listxattr x +stat x +unlink x |