mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
ctdb-tests: Remove unused functions and stubs
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
58db0dbeda
commit
6c5f7c0003
@ -85,13 +85,6 @@ setup_date ()
|
||||
export FAKE_DATE_OUTPUT="$1"
|
||||
}
|
||||
|
||||
setup_generic ()
|
||||
{
|
||||
setup_shares
|
||||
setup_dbdir
|
||||
setup_date
|
||||
}
|
||||
|
||||
setup_tcp_listen ()
|
||||
{
|
||||
export FAKE_TCP_LISTEN="$*"
|
||||
@ -246,17 +239,6 @@ ipv4_host_addr_to_net ()
|
||||
|
||||
# CTDB fakery
|
||||
|
||||
# Evaluate an expression that probably calls functions or uses
|
||||
# variables from the CTDB functions file. This is used for test
|
||||
# initialisation.
|
||||
eventscript_call ()
|
||||
{
|
||||
(
|
||||
. "$CTDB_BASE/functions"
|
||||
"$@"
|
||||
)
|
||||
}
|
||||
|
||||
setup_numnodes ()
|
||||
{
|
||||
export FAKE_CTDB_NUMNODES="${1:-3}"
|
||||
@ -299,22 +281,6 @@ ctdb_set_pnn ()
|
||||
mkdir -p "$CTDB_SCRIPT_VARDIR"
|
||||
}
|
||||
|
||||
setup_ctdb ()
|
||||
{
|
||||
setup_generic
|
||||
|
||||
setup_public_addresses
|
||||
}
|
||||
|
||||
validate_percentage ()
|
||||
{
|
||||
case "$1" in
|
||||
[0-9]|[0-9][0-9]|100) return 0 ;;
|
||||
*) echo "WARNING: ${1} is an invalid percentage${2:+\" in }${2}${2:+\"}"
|
||||
return 1
|
||||
esac
|
||||
}
|
||||
|
||||
ctdb_get_interfaces ()
|
||||
{
|
||||
# The echo/subshell forces all the output onto 1 line.
|
||||
@ -363,13 +329,6 @@ ctdb_get_1_public_address ()
|
||||
ctdb_get_my_public_addresses | { head -n 1 ; cat >/dev/null ; }
|
||||
}
|
||||
|
||||
ctdb_not_implemented ()
|
||||
{
|
||||
export CTDB_NOT_IMPLEMENTED="$1"
|
||||
ctdb_not_implemented="\
|
||||
DEBUG: ctdb: command \"$1\" not implemented in stub"
|
||||
}
|
||||
|
||||
# Check the routes against those that are expected. $1 is the number
|
||||
# of assigned IPs to use (<num>, all), defaulting to 1. If $2 is
|
||||
# "default" then expect default routes to have been added.
|
||||
@ -416,17 +375,6 @@ EOF
|
||||
|
||||
######################################################################
|
||||
|
||||
setup_nfs_ganesha ()
|
||||
{
|
||||
setup_nfs "$@"
|
||||
export CTDB_NFS_CALLOUT="${CTDB_BASE}/nfs-ganesha-callout"
|
||||
if [ "$1" != "down" ] ; then
|
||||
export CTDB_MANAGES_NFS="yes"
|
||||
fi
|
||||
|
||||
export CTDB_NFS_SKIP_SHARE_CHECK="yes"
|
||||
}
|
||||
|
||||
|
||||
nfs_load_config ()
|
||||
{
|
||||
|
@ -1,109 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
prog="netstat"
|
||||
|
||||
# Pretty that we're the shell and that this command could not be
|
||||
# found.
|
||||
if [ "$FAKE_NETSTAT_NOT_FOUND" = "yes" ] ; then
|
||||
echo "sh: ${prog}: command not found" >&2
|
||||
exit 127
|
||||
fi
|
||||
|
||||
usage ()
|
||||
{
|
||||
cat >&2 <<EOF
|
||||
Usage: $prog [ -t | --unix ] [ -n ] [ -a ] [ -l ]
|
||||
|
||||
A fake netstat stub that prints items depending on the variables
|
||||
FAKE_NETSTAT_TCP_ESTABLISHED, FAKE_TCP_LISTEN,
|
||||
FAKE_NETSTAT_UNIX_LISTEN, depending on command-line options.
|
||||
|
||||
Note that -n is ignored.
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Defaults.
|
||||
tcp=false
|
||||
unix=false
|
||||
all=false
|
||||
listen=false
|
||||
|
||||
parse_options ()
|
||||
{
|
||||
# $POSIXLY_CORRECT means that the command passed to onnode can
|
||||
# take options and getopt won't reorder things to make them
|
||||
# options to this script.
|
||||
_temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "tnalh" -l unix -l help -- "$@")
|
||||
|
||||
[ $? != 0 ] && usage
|
||||
|
||||
eval set -- "$_temp"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-n) shift ;;
|
||||
-a) all=true ; shift ;;
|
||||
-t) tcp=true ; shift ;;
|
||||
-l) listen=true ; shift ;;
|
||||
--unix) unix=true ; shift ;;
|
||||
--) shift ; break ;;
|
||||
-h|--help|*) usage ;; # * shouldn't happen, so this is reasonable.
|
||||
esac
|
||||
done
|
||||
|
||||
[ $# -gt 0 ] && usage
|
||||
|
||||
# If neither -t or --unix specified then print all.
|
||||
$tcp || $unix || { tcp=true ; unix=true ; }
|
||||
}
|
||||
|
||||
parse_options "$@"
|
||||
|
||||
if $tcp ; then
|
||||
if $listen ; then
|
||||
echo "Active Internet connections (servers only)"
|
||||
elif $all ; then
|
||||
echo "Active Internet connections (servers and established)"
|
||||
else
|
||||
echo "Active Internet connections (w/o servers)"
|
||||
fi
|
||||
|
||||
echo "Proto Recv-Q Send-Q Local Address Foreign Address State"
|
||||
|
||||
tcp_fmt="tcp 0 0 %-23s %-23s %s\n"
|
||||
for i in $FAKE_NETSTAT_TCP_ESTABLISHED ; do
|
||||
src="${i%|*}"
|
||||
dst="${i#*|}"
|
||||
printf "$tcp_fmt" $src $dst "ESTABLISHED"
|
||||
done
|
||||
while read src dst ; do
|
||||
printf "$tcp_fmt" $src $dst "ESTABLISHED"
|
||||
done <"$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
|
||||
|
||||
if $all || $listen ; then
|
||||
for i in $FAKE_TCP_LISTEN ; do
|
||||
printf "$tcp_fmt" $i "0.0.0.0:*" "LISTEN"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if $unix ; then
|
||||
if $listen ; then
|
||||
echo "Active UNIX domain sockets (servers only)"
|
||||
elif $all ; then
|
||||
echo "Active UNIX domain sockets (servers and established)"
|
||||
else
|
||||
echo "Active UNIX domain sockets (w/o servers)"
|
||||
fi
|
||||
|
||||
echo "Proto RefCnt Flags Type State I-Node Path"
|
||||
|
||||
unix_fmt="unix 2 [ ACC ] STREAM LISTENING %-8d %s\n"
|
||||
if $all || $listen ; then
|
||||
for i in $FAKE_NETSTAT_UNIX_LISTEN ; do
|
||||
printf "$unix_fmt" 12345 "$i"
|
||||
done
|
||||
fi
|
||||
fi
|
@ -1,75 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
prog="nmap"
|
||||
|
||||
# Pretty that we're the shell and that this command could not be
|
||||
# found.
|
||||
if [ "$FAKE_NMAP_NOT_FOUND" = "yes" ] ; then
|
||||
echo "sh: ${prog}: command not found" >&2
|
||||
exit 127
|
||||
fi
|
||||
|
||||
usage ()
|
||||
{
|
||||
cat >&2 <<EOF
|
||||
Usage: $prog -n -oG - -PS 127.0.0.1 -p <port>[,<port> ...]
|
||||
|
||||
A fake nmap stub that prints items depending on the variable
|
||||
FAKE_TCP_LISTEN and the ports specified.
|
||||
|
||||
Note that all options apart from -p are ignored.
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
ports=""
|
||||
|
||||
parse_options ()
|
||||
{
|
||||
_temp=$(getopt -n "$prog" -a -o "np:" -l help -l PS: -l oG: -- "$@")
|
||||
|
||||
[ $? != 0 ] && usage
|
||||
|
||||
eval set -- "$_temp"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-n) shift ;;
|
||||
--oG|--PS) shift 2 ;;
|
||||
-p) ports="${ports}${ports:+ }${2//,/ }" ; shift 2 ;;
|
||||
--) shift ; break ;;
|
||||
-h|--help|*) usage ;; # * shouldn't happen, so this is reasonable.
|
||||
esac
|
||||
done
|
||||
|
||||
[ $# -gt 0 ] && usage
|
||||
|
||||
[ -n "$ports" ] || usage
|
||||
}
|
||||
|
||||
# For printing out...
|
||||
args="$*"
|
||||
|
||||
parse_options "$@"
|
||||
|
||||
port_states=""
|
||||
|
||||
for p in $ports ; do
|
||||
pn=$(getent services "$p" | sed -e 's@[[:space:]].*@@')
|
||||
for i in $FAKE_TCP_LISTEN ; do
|
||||
lp="${i##*:}"
|
||||
if [ "$p" = "$lp" ] ; then
|
||||
port_states="${port_states}${port_states:+, }${p}/open/tcp//${pn}///"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
port_states="${port_states}${port_states:+, }${p}/closed/tcp//${pn}///"
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
# Nmap 5.21 scan initiated $(date) as: nmap $args
|
||||
Host: 127.0.0.1 () Status: Up
|
||||
Host: 127.0.0.1 () Ports: $port_states
|
||||
# Nmap done at $(date) -- 1 IP address (1 host up) scanned in 0.04 seconds
|
||||
EOF
|
Loading…
Reference in New Issue
Block a user