Merge remote-tracking branch 'bbannier/topic/bbannier/more-autoformating'

* bbannier/topic/bbannier/more-autoformating:
  Format Python scripts with yapf.
  Format shell scripts with shfmt.
This commit is contained in:
Tim Wojtulewicz 2021-12-01 10:32:34 -07:00
commit e7412e257f
40 changed files with 422 additions and 394 deletions

View file

@ -6,3 +6,14 @@ repos:
rev: 'v13.0.0'
hooks:
- id: clang-format
- repo: https://github.com/maxwinterstein/shfmt-py
rev: 3.3.1.8
hooks:
- id: shfmt
args: ["-w", "-i", "4", "-ci"]
- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.31.0
hooks:
- id: yapf

2
.style.yapf Normal file
View file

@ -0,0 +1,2 @@
[style]
column_limit=100

13
CHANGES
View file

@ -1,3 +1,16 @@
4.2.0-dev.406 | 2021-12-01 10:32:34 -0700
* Format Python scripts with yapf. (Benjamin Bannier, Corelight)
We also add a very basic yapf configuration file. Most of the changes in
this patch were performed automatically, but we broke one overly long
string into multiple components on `src/make_dbg_constants.py`.
* Format shell scripts with shfmt. (Benjamin Bannier, Corelight)
All changes in this patch were performed automatically with `shfmt` with
configuration flags specified in `.pre-commit-config.yaml`.
4.2.0-dev.403 | 2021-12-01 10:25:32 -0700
* fix btest comment to more accurately describe the test (Vern Paxson, Corelight)

View file

@ -1 +1 @@
4.2.0-dev.403
4.2.0-dev.406

View file

@ -1,6 +1,6 @@
#! /usr/bin/env bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. ${SCRIPT_DIR}/common.sh
set -e

View file

@ -3,10 +3,10 @@
# On Cirrus, oversubscribe the CPUs when on Linux. This uses Cirrus' "greedy" feature.
if [[ "${CIRRUS_OS}" == linux ]]; then
if [[ -n "${ZEEK_CI_CPUS}" ]]; then
ZEEK_CI_CPUS=$(( 2 * ${ZEEK_CI_CPUS} ))
ZEEK_CI_CPUS=$((2 * ${ZEEK_CI_CPUS}))
fi
if [[ -n "${ZEEK_CI_BTEST_JOBS}" ]]; then
ZEEK_CI_BTEST_JOBS=$(( 2 * ${ZEEK_CI_BTEST_JOBS} ))
ZEEK_CI_BTEST_JOBS=$((2 * ${ZEEK_CI_BTEST_JOBS}))
fi
fi

View file

@ -8,6 +8,6 @@ set -x
env ASSUME_ALWAYS_YES=YES pkg bootstrap
pkg install -y bash git cmake swig bison python3 base64
pkg upgrade -y curl
pyver=`python3 -c 'import sys; print(f"py{sys.version_info[0]}{sys.version_info[1]}")'`
pyver=$(python3 -c 'import sys; print(f"py{sys.version_info[0]}{sys.version_info[1]}")')
pkg install -y $pyver-sqlite3 $pyver-pip
pip install junit2html

View file

@ -1,13 +1,12 @@
#! /usr/bin/env bash
function banner
{
function banner {
local msg="${1}"
printf "+--------------------------------------------------------------+\n"
printf "| %-60s |\n" "$(date)"
printf "| %-60s |\n" "${msg}"
printf "+--------------------------------------------------------------+\n"
}
}
set -e
@ -52,8 +51,8 @@ if [[ -n "${CIRRUS_CI}" ]] && [[ "${CIRRUS_REPO_OWNER}" == "zeek" ]] && [[ ! -d
fi
banner "Trying to clone zeek-testing-private git repo"
echo "${ZEEK_TESTING_PRIVATE_SSH_KEY}" > cirrus_key.b64
base64 -d cirrus_key.b64 > cirrus_key
echo "${ZEEK_TESTING_PRIVATE_SSH_KEY}" >cirrus_key.b64
base64 -d cirrus_key.b64 >cirrus_key
rm cirrus_key.b64
chmod 600 cirrus_key
git --version

View file

@ -17,8 +17,8 @@ for fuzzer_path in ${fuzzers}; do
if [[ -e ${corpus} ]]; then
echo "Fuzzer: ${fuzzer_exe} ${corpus}"
( rm -rf corpus && mkdir corpus ) || result=1
( cd corpus && unzip ../${corpus} >/dev/null ) || result=1
(rm -rf corpus && mkdir corpus) || result=1
(cd corpus && unzip ../${corpus} >/dev/null) || result=1
${fuzzer_path} corpus/* >${fuzzer_exe}.out 2>${fuzzer_exe}.err
if [[ $? -eq 0 ]]; then
@ -36,5 +36,4 @@ for fuzzer_path in ${fuzzers}; do
echo "-----------------------------------------"
done
exit ${result}

View file

@ -16,47 +16,41 @@ if [[ -z "${CIRRUS_CI}" ]]; then
ZEEK_CI_BTEST_RETRIES=2
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
. ${SCRIPT_DIR}/common.sh
function pushd
{
command pushd "$@" > /dev/null || exit 1
}
function pushd {
command pushd "$@" >/dev/null || exit 1
}
function popd
{
command popd "$@" > /dev/null || exit 1
}
function popd {
command popd "$@" >/dev/null || exit 1
}
function banner
{
function banner {
local msg="${1}"
printf "+--------------------------------------------------------------+\n"
printf "| %-60s |\n" "$(date)"
printf "| %-60s |\n" "${msg}"
printf "+--------------------------------------------------------------+\n"
}
}
function run_unit_tests
{
function run_unit_tests {
banner "Running unit tests"
pushd build
( . ./zeek-path-dev.sh && zeek --test ) || result=1
(. ./zeek-path-dev.sh && zeek --test) || result=1
popd
return 0
}
}
function prep_artifacts
{
function prep_artifacts {
banner "Prepare artifacts"
[[ -d .tmp ]] && rm -rf .tmp/script-coverage && tar -czf tmp.tar.gz .tmp
junit2html btest-results.xml btest-results.html
}
}
function run_btests
{
function run_btests {
banner "Running baseline tests: zeek"
pushd testing/btest
@ -73,10 +67,9 @@ function run_btests
prep_artifacts
popd
return 0
}
}
function run_external_btests
{
function run_external_btests {
# Commenting out this line in btest.cfg causes the script profiling/coverage
# to be disabled. We do this for the sanitizer build right now because of a
# fairly significant performance bug when running tests.
@ -120,7 +113,7 @@ function run_external_btests
else
banner "Skipping private tests (not available for PRs)"
fi
}
}
banner "Start tests: ${ZEEK_CI_CPUS} cpus, ${ZEEK_CI_BTEST_JOBS} btest jobs"

View file

@ -1,15 +1,15 @@
#! /usr/bin/env bash
unset ZEEK_DISABLE_ZEEKYGEN;
unset ZEEK_DISABLE_ZEEKYGEN
# If running this from btest, unset any of the environment
# variables that alter default script values.
unset ZEEK_DEFAULT_LISTEN_ADDRESS;
unset ZEEK_DEFAULT_LISTEN_RETRY;
unset ZEEK_DEFAULT_CONNECT_RETRY;
unset ZEEK_DEFAULT_LISTEN_ADDRESS
unset ZEEK_DEFAULT_LISTEN_RETRY
unset ZEEK_DEFAULT_CONNECT_RETRY
dir="$( cd "$( dirname "$0" )" && pwd )"
source_dir="$( cd $dir/.. && pwd )"
dir="$(cd "$(dirname "$0")" && pwd)"
source_dir="$(cd $dir/.. && pwd)"
build_dir=$source_dir/build
conf_file=$build_dir/zeekygen-test.conf
output_dir=$source_dir/doc
@ -21,15 +21,14 @@ fi
case $output_dir in
/*) ;;
*) output_dir=`pwd`/$output_dir ;;
*) output_dir=$(pwd)/$output_dir ;;
esac
cd $build_dir
. zeek-path-dev.sh
export ZEEK_SEED_FILE=$source_dir/testing/btest/random.seed
function run_zeek
{
function run_zeek {
ZEEK_ALLOW_INIT_ERRORS=1 zeek -X $conf_file zeekygen >/dev/null 2>$zeek_error_file
if [ $? -ne 0 ]; then
@ -37,23 +36,22 @@ function run_zeek
echo "See stderr in $zeek_error_file"
exit 1
fi
}
}
scripts_output_dir=$output_dir/scripts
rm -rf $scripts_output_dir
printf "script\t*\t$scripts_output_dir/" > $conf_file
printf "script\t*\t$scripts_output_dir/" >$conf_file
echo "Generating $scripts_output_dir/"
run_zeek
script_ref_dir=$output_dir/script-reference
mkdir -p $script_ref_dir
function generate_index
{
function generate_index {
echo "Generating $script_ref_dir/$2"
printf "$1\t*\t$script_ref_dir/$2\n" > $conf_file
printf "$1\t*\t$script_ref_dir/$2\n" >$conf_file
run_zeek
}
}
generate_index "script_index" "autogenerated-script-index.rst"
generate_index "package_index" "autogenerated-package-index.rst"

144
configure vendored
View file

@ -118,7 +118,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
CXXFLAGS C++ compiler flags
"
sourcedir="$( cd "$( dirname "$0" )" && pwd )"
sourcedir="$(cd "$(dirname "$0")" && pwd)"
if [ ! -e "$sourcedir/cmake/COPYING" ] && [ -d "$sourcedir/.git" ]; then
echo "\
@ -128,8 +128,8 @@ This typically means that you performed a non-recursive git clone of
Zeek. To check out the required subdirectories, please execute:
( cd $sourcedir && git submodule update --recursive --init )
" >&2;
exit 1;
" >&2
exit 1
fi
# Function to append a CMake cache entry definition to the
@ -137,14 +137,14 @@ fi
# $1 is the cache entry variable name
# $2 is the cache entry variable type
# $3 is the cache entry variable value
append_cache_entry () {
append_cache_entry() {
CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
}
# Function to remove a CMake cache entry definition from the
# CMakeCacheEntries variable
# $1 is the cache entry variable name
remove_cache_entry () {
remove_cache_entry() {
CMakeCacheEntries="$CMakeCacheEntries -U $1"
# Even with -U, cmake still warns by default if
@ -156,22 +156,22 @@ remove_cache_entry () {
builddir=build
prefix=/usr/local/zeek
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
append_cache_entry ZEEK_ROOT_DIR PATH $prefix
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
append_cache_entry ZEEK_ROOT_DIR PATH $prefix
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $prefix/share/zeek
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
append_cache_entry ENABLE_DEBUG BOOL false
append_cache_entry ENABLE_PERFTOOLS BOOL false
append_cache_entry ENABLE_JEMALLOC BOOL false
append_cache_entry BUILD_SHARED_LIBS BOOL true
append_cache_entry INSTALL_AUX_TOOLS BOOL true
append_cache_entry INSTALL_BTEST BOOL true
append_cache_entry INSTALL_BTEST_PCAPS BOOL true
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL true
append_cache_entry INSTALL_ZEEKCTL BOOL true
append_cache_entry INSTALL_ZKG BOOL true
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
append_cache_entry ENABLE_DEBUG BOOL false
append_cache_entry ENABLE_PERFTOOLS BOOL false
append_cache_entry ENABLE_JEMALLOC BOOL false
append_cache_entry BUILD_SHARED_LIBS BOOL true
append_cache_entry INSTALL_AUX_TOOLS BOOL true
append_cache_entry INSTALL_BTEST BOOL true
append_cache_entry INSTALL_BTEST_PCAPS BOOL true
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL true
append_cache_entry INSTALL_ZEEKCTL BOOL true
append_cache_entry INSTALL_ZKG BOOL true
append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING
append_cache_entry ZEEK_SANITIZERS STRING ""
append_cache_entry ZEEK_SANITIZERS STRING ""
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING ""
has_enable_mobile_ipv6=0
@ -179,12 +179,12 @@ has_enable_mobile_ipv6=0
# parse arguments
while [ $# -ne 0 ]; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-*=*) optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//') ;;
*) optarg= ;;
esac
case "$1" in
--help|-h)
--help | -h)
echo "${usage}" 1>&2
exit 1
;;
@ -198,110 +198,110 @@ while [ $# -ne 0 ]; do
builddir=$optarg
;;
--build-type=*)
append_cache_entry CMAKE_BUILD_TYPE STRING $optarg
append_cache_entry CMAKE_BUILD_TYPE STRING $optarg
if [ $(echo "$optarg" | tr [:upper:] [:lower:]) = "debug" ]; then
append_cache_entry ENABLE_DEBUG BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
fi
;;
--generator=*)
CMakeGenerator="$optarg"
;;
--ccache)
append_cache_entry ENABLE_CCACHE BOOL true
append_cache_entry ENABLE_CCACHE BOOL true
;;
--toolchain=*)
append_cache_entry CMAKE_TOOLCHAIN_FILE PATH $optarg
append_cache_entry CMAKE_TOOLCHAIN_FILE PATH $optarg
;;
--include-plugins=*)
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING $optarg
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING $optarg
;;
--prefix=*)
prefix=$optarg
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
append_cache_entry ZEEK_ROOT_DIR PATH $optarg
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
append_cache_entry ZEEK_ROOT_DIR PATH $optarg
;;
--libdir=*)
append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg
append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg
;;
--plugindir=*)
append_cache_entry ZEEK_PLUGIN_DIR PATH $optarg
append_cache_entry ZEEK_PLUGIN_DIR PATH $optarg
;;
--python-dir=*)
append_cache_entry ZEEK_PYTHON_DIR PATH $optarg
append_cache_entry ZEEK_PYTHON_DIR PATH $optarg
;;
--python-prefix=*)
append_cache_entry ZEEK_PYTHON_PREFIX PATH $optarg
append_cache_entry ZEEK_PYTHON_PREFIX PATH $optarg
;;
--python-home=*)
append_cache_entry ZEEK_PYTHON_HOME PATH $optarg
append_cache_entry ZEEK_PYTHON_HOME PATH $optarg
;;
--scriptdir=*)
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $optarg
user_set_scriptdir="true"
;;
--conf-files-dir=*)
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $optarg
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $optarg
user_set_conffilesdir="true"
;;
--localstatedir=*)
append_cache_entry ZEEK_LOCAL_STATE_DIR PATH $optarg
append_cache_entry ZEEK_LOCAL_STATE_DIR PATH $optarg
;;
--spooldir=*)
append_cache_entry ZEEK_SPOOL_DIR PATH $optarg
append_cache_entry ZEEK_SPOOL_DIR PATH $optarg
;;
--logdir=*)
append_cache_entry ZEEK_LOG_DIR PATH $optarg
append_cache_entry ZEEK_LOG_DIR PATH $optarg
;;
--mandir=*)
append_cache_entry ZEEK_MAN_INSTALL_PATH PATH $optarg
append_cache_entry ZEEK_MAN_INSTALL_PATH PATH $optarg
;;
--enable-coverage)
append_cache_entry ENABLE_COVERAGE BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
append_cache_entry ENABLE_COVERAGE BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
;;
--enable-fuzzers)
append_cache_entry ZEEK_ENABLE_FUZZERS BOOL true
;;
--enable-debug)
append_cache_entry ENABLE_DEBUG BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
;;
--enable-mobile-ipv6)
has_enable_mobile_ipv6=1
;;
--enable-perftools)
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry ENABLE_PERFTOOLS BOOL true
;;
--enable-perftools-debug)
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
;;
--sanitizers=*)
append_cache_entry ZEEK_SANITIZERS STRING $optarg
append_cache_entry ZEEK_SANITIZERS STRING $optarg
;;
--enable-jemalloc)
append_cache_entry ENABLE_JEMALLOC BOOL true
append_cache_entry ENABLE_JEMALLOC BOOL true
;;
--enable-static-broker)
append_cache_entry BUILD_STATIC_BROKER BOOL true
append_cache_entry BUILD_STATIC_BROKER BOOL true
;;
--enable-static-binpac)
append_cache_entry BUILD_STATIC_BINPAC BOOL true
append_cache_entry BUILD_STATIC_BINPAC BOOL true
;;
--enable-cpp-tests)
append_cache_entry ENABLE_ZEEK_UNIT_TESTS BOOL true
append_cache_entry ENABLE_ZEEK_UNIT_TESTS BOOL true
;;
--enable-zeek-client)
append_cache_entry INSTALL_ZEEK_CLIENT BOOL true
append_cache_entry INSTALL_ZEEK_CLIENT BOOL true
;;
--disable-zeekctl)
append_cache_entry INSTALL_ZEEKCTL BOOL false
append_cache_entry INSTALL_ZEEKCTL BOOL false
;;
--disable-auxtools)
append_cache_entry INSTALL_AUX_TOOLS BOOL false
append_cache_entry INSTALL_AUX_TOOLS BOOL false
;;
--disable-archiver)
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL false
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL false
;;
--disable-btest)
append_cache_entry INSTALL_BTEST BOOL false
@ -310,10 +310,10 @@ while [ $# -ne 0 ]; do
append_cache_entry INSTALL_BTEST_PCAPS BOOL false
;;
--disable-python)
append_cache_entry DISABLE_PYTHON_BINDINGS BOOL true
append_cache_entry DISABLE_PYTHON_BINDINGS BOOL true
;;
--disable-broker-tests)
append_cache_entry BROKER_DISABLE_TESTS BOOL true
append_cache_entry BROKER_DISABLE_TESTS BOOL true
append_cache_entry BROKER_DISABLE_DOC_EXAMPLES BOOL true
;;
--disable-zkg)
@ -329,10 +329,10 @@ while [ $# -ne 0 ]; do
append_cache_entry PCAP_ROOT_DIR PATH $optarg
;;
--with-binpac=*)
append_cache_entry BINPAC_EXE_PATH PATH $optarg
append_cache_entry BINPAC_EXE_PATH PATH $optarg
;;
--with-bifcl=*)
append_cache_entry BIFCL_EXE_PATH PATH $optarg
append_cache_entry BIFCL_EXE_PATH PATH $optarg
;;
--with-flex=*)
append_cache_entry FLEX_EXECUTABLE PATH $optarg
@ -350,30 +350,30 @@ while [ $# -ne 0 ]; do
append_cache_entry GooglePerftools_ROOT_DIR PATH $optarg
;;
--with-jemalloc=*)
append_cache_entry JEMALLOC_ROOT_DIR PATH $optarg
append_cache_entry ENABLE_JEMALLOC BOOL true
append_cache_entry JEMALLOC_ROOT_DIR PATH $optarg
append_cache_entry ENABLE_JEMALLOC BOOL true
;;
--with-python=*)
append_cache_entry PYTHON_EXECUTABLE PATH $optarg
append_cache_entry PYTHON_EXECUTABLE PATH $optarg
;;
--with-python-lib=*)
append_cache_entry PYTHON_LIBRARY PATH $optarg
append_cache_entry PYTHON_LIBRARY PATH $optarg
;;
--with-python-inc=*)
append_cache_entry PYTHON_INCLUDE_DIR PATH $optarg
append_cache_entry PYTHON_INCLUDE_PATH PATH $optarg
append_cache_entry PYTHON_INCLUDE_DIR PATH $optarg
append_cache_entry PYTHON_INCLUDE_PATH PATH $optarg
;;
--with-swig=*)
append_cache_entry SWIG_EXECUTABLE PATH $optarg
append_cache_entry SWIG_EXECUTABLE PATH $optarg
;;
--with-broker=*)
append_cache_entry BROKER_ROOT_DIR PATH $optarg
append_cache_entry BROKER_ROOT_DIR PATH $optarg
;;
--with-caf=*)
append_cache_entry CAF_ROOT PATH $optarg
append_cache_entry CAF_ROOT PATH $optarg
;;
--with-libkqueue=*)
append_cache_entry LIBKQUEUE_ROOT_DIR PATH $optarg
append_cache_entry LIBKQUEUE_ROOT_DIR PATH $optarg
;;
--binary-package)
append_cache_entry BINARY_PACKAGING_MODE BOOL true
@ -400,15 +400,15 @@ done
if [ -z "$CMakeCommand" ]; then
# prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL)
if command -v cmake3 >/dev/null 2>&1 ; then
if command -v cmake3 >/dev/null 2>&1; then
CMakeCommand="cmake3"
elif command -v cmake >/dev/null 2>&1 ; then
elif command -v cmake >/dev/null 2>&1; then
CMakeCommand="cmake"
else
echo "This package requires CMake, please install it first."
echo "Then you may use this script to configure the CMake build."
echo "Note: pass --cmake=PATH to use cmake in non-standard locations."
exit 1;
exit 1
fi
fi
@ -442,8 +442,8 @@ else
"$CMakeCommand" $CMakeCacheEntries $sourcedir
fi
echo "# This is the command used to configure this build" > config.status
echo $command >> config.status
echo "# This is the command used to configure this build" >config.status
echo $command >>config.status
chmod u+x config.status
if [ $has_enable_mobile_ipv6 -eq 1 ]; then

View file

@ -53,11 +53,15 @@ namespace zeek::detail {\n
void init_global_dbg_constants () {
''' % inputfile
def outputrecord():
global init_str, enum_str
if dbginfo["names"]:
dbginfo["name_init"] = "const char * const names[] = {\n\t\t\t%s\n\t\t};\n" % ",\n\t\t\t".join(dbginfo["names"])
dbginfo["name_init"] = "const char * const names[] = {\n"\
"\t\t\t%s\n"\
"\t\t};\n" \
% ",\n\t\t\t".join(dbginfo["names"])
else:
dbginfo["name_init"] = "const char * const names[] = { };\n"
@ -68,16 +72,25 @@ def outputrecord():
enum_str += "\t%s,\n" % dbginfo["cmd"]
def initdbginfo():
return {"cmd": "", "name_init": "", "num_names": 0, "names": [],
"resume": "false", "help": "", "repeatable": "false"}
return {
"cmd": "",
"name_init": "",
"num_names": 0,
"names": [],
"resume": "false",
"help": "",
"repeatable": "false"
}
dbginfo = initdbginfo()
inputf = open(inputfile, "r")
for line in inputf:
line = line.strip()
if not line or line.startswith("//"): # skip empty lines and comments
if not line or line.startswith("//"): # skip empty lines and comments
continue
fields = line.split(":", 1)
@ -95,9 +108,9 @@ for line in inputf:
dbginfo[f1] = f2
elif f1 == "names":
# put quotes around the strings
dbginfo[f1] = [ '"%s"' % n for n in f2.split() ]
dbginfo[f1] = ['"%s"' % n for n in f2.split()]
elif f1 == "help":
dbginfo[f1] = f2.replace('"', '\\"') # escape quotation marks
dbginfo[f1] = f2.replace('"', '\\"') # escape quotation marks
elif f1 in ("resume", "repeatable"):
dbginfo[f1] = f2
else:

View file

@ -16,7 +16,7 @@ cd $test
grep -c '^namespace' $gen
mv $gen $build/
cd $build
ninja >& errs || echo build for $1 failed
ninja >&errs || echo build for $1 failed
export -n ZEEK_GEN_CPP
cd $test

View file

@ -15,7 +15,7 @@ cp $build/CPP-hashes.dat .
grep -c '^namespace' $gen
mv $gen $build
cd $build
ninja >& errs || echo build for $1 failed
ninja >&errs || echo build for $1 failed
export -n ZEEK_ADD_CPP
cd $test

View file

@ -15,4 +15,4 @@ echo >$gen
grep -c '^namespace' $gen
mv $gen $so
cd $build
ninja >& errs || echo test suite build failed
ninja >&errs || echo test suite build failed

View file

@ -13,7 +13,7 @@ cp $build/CPP-hashes.dat .
grep -c '^namespace' $gen
mv $gen $build/
cd $build
ninja >& errs || echo build for $1 failed
ninja >&errs || echo build for $1 failed
export -n ZEEK_ADD_CPP
cd $test

View file

@ -10,11 +10,10 @@
error_count=0
error_msg()
{
error_count=$((error_count+1))
echo "$@" 1>&2;
}
error_msg() {
error_count=$((error_count + 1))
echo "$@" 1>&2
}
if [ $# -ne 2 ]; then
print "incorrect arguments"
@ -29,7 +28,7 @@ for f in $all_loads; do
done
if [ $error_count -gt 0 ]; then
exit 1;
exit 1
fi
exit 0

View file

@ -60,4 +60,3 @@ EOF
cat >activate.zeek <<EOF
@load-plugin Demo::Foo
EOF

View file

@ -16,69 +16,69 @@
# 4a. Analyze .gcov files generated and create summary file
# 4b. Send .gcov files to appropriate path
#
CURR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Location of script
BASE="$( cd "$CURR" && cd ../../ && pwd )"
CURR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Location of script
BASE="$(cd "$CURR" && cd ../../ && pwd)"
TMP="${CURR}/tmp.$$"
mkdir -p $TMP
# DEFINE CLEANUP PROCESS
function finish {
rm -rf $TMP
rm -rf $TMP
}
trap finish EXIT
# DEFINE CRUCIAL FUNCTIONS FOR COVERAGE CHECKING
function check_file_coverage {
GCOVDIR="$1"
GCOVDIR="$1"
for i in $GCOVDIR/*.gcov; do
# Effective # of lines: starts with a number (# of runs in line) or ##### (line never run)
TOTAL=$(cut -d: -f 1 "$i" | sed 's/ //g' | grep -v "^[[:alpha:]]" | grep -v "-" | wc -l)
for i in $GCOVDIR/*.gcov; do
# Effective # of lines: starts with a number (# of runs in line) or ##### (line never run)
TOTAL=$(cut -d: -f 1 "$i" | sed 's/ //g' | grep -v "^[[:alpha:]]" | grep -v "-" | wc -l)
# Count number of lines never run
UNRUN=$(grep "#####" "$i" | wc -l)
# Count number of lines never run
UNRUN=$(grep "#####" "$i" | wc -l)
# Lines in code are either run or unrun
RUN=$(($TOTAL - $UNRUN))
# Lines in code are either run or unrun
RUN=$(($TOTAL - $UNRUN))
# Avoid division-by-zero problems:
PERCENTAGE=0.000
[ $RUN -gt 0 ] && PERCENTAGE=$(bc <<< "scale=3; 100*$RUN/$TOTAL")
# Avoid division-by-zero problems:
PERCENTAGE=0.000
[ $RUN -gt 0 ] && PERCENTAGE=$(bc <<<"scale=3; 100*$RUN/$TOTAL")
# Find correlation between % of lines run vs. "Runs"
echo -e "$PERCENTAGE\t$RUN\t$TOTAL\t$(grep "0:Runs" "$i" | sed 's/.*://')\t$i"
done
# Find correlation between % of lines run vs. "Runs"
echo -e "$PERCENTAGE\t$RUN\t$TOTAL\t$(grep "0:Runs" "$i" | sed 's/.*://')\t$i"
done
}
function check_group_coverage {
DATA="$1" # FILE CONTAINING COVERAGE DATA
SRC_FOLDER="$2" # WHERE ZEEK WAS COMPILED
OUTPUT="$3"
DATA="$1" # FILE CONTAINING COVERAGE DATA
SRC_FOLDER="$2" # WHERE ZEEK WAS COMPILED
OUTPUT="$3"
# Prints all the relevant directories
DIRS=$(for i in $(cut -f 5 "$DATA"); do basename "$i" | sed 's/#[^#]*$//'; done \
| sort | uniq | sed 's/^.*'"${SRC_FOLDER}"'//' | grep "^#s\+" )
# "Generalize" folders unless it's from analyzers
DIRS=$(for i in $DIRS; do
if !(echo "$i" | grep "src#analyzer"); then
echo "$i" | cut -d "#" -f 1,2,3
fi
done | sort | uniq )
# Prints all the relevant directories
DIRS=$(for i in $(cut -f 5 "$DATA"); do basename "$i" | sed 's/#[^#]*$//'; done |
sort | uniq | sed 's/^.*'"${SRC_FOLDER}"'//' | grep "^#s\+")
# "Generalize" folders unless it's from analyzers
DIRS=$(for i in $DIRS; do
if !(echo "$i" | grep "src#analyzer"); then
echo "$i" | cut -d "#" -f 1,2,3
fi
done | sort | uniq)
for i in $DIRS; do
# For elements in #src, we only care about the files direclty in the directory.
if [[ "$i" = "#src" ]]; then
RUN=$(echo $(grep "$i#[^#]\+$" $DATA | grep "$SRC_FOLDER$i\|build$i" | cut -f 2) | tr " " "+" | bc)
TOTAL=$(echo $(grep "$i#[^#]\+$" $DATA | grep "$SRC_FOLDER$i\|build$i" | cut -f 3) | tr " " "+" | bc)
else
RUN=$(echo $(grep "$i" $DATA | cut -f 2) | tr " " "+" | bc)
TOTAL=$(echo $(grep "$i" $DATA | cut -f 3) | tr " " "+" | bc)
fi
for i in $DIRS; do
# For elements in #src, we only care about the files direclty in the directory.
if [[ "$i" = "#src" ]]; then
RUN=$(echo $(grep "$i#[^#]\+$" $DATA | grep "$SRC_FOLDER$i\|build$i" | cut -f 2) | tr " " "+" | bc)
TOTAL=$(echo $(grep "$i#[^#]\+$" $DATA | grep "$SRC_FOLDER$i\|build$i" | cut -f 3) | tr " " "+" | bc)
else
RUN=$(echo $(grep "$i" $DATA | cut -f 2) | tr " " "+" | bc)
TOTAL=$(echo $(grep "$i" $DATA | cut -f 3) | tr " " "+" | bc)
fi
PERCENTAGE=$( echo "scale=3;100*$RUN/$TOTAL" | bc | tr "\n" " " )
printf "%-50s\t%12s\t%6s %%\n" "$i" "$RUN/$TOTAL" $PERCENTAGE \
| sed 's|#|/|g' >>$OUTPUT
done
PERCENTAGE=$(echo "scale=3;100*$RUN/$TOTAL" | bc | tr "\n" " ")
printf "%-50s\t%12s\t%6s %%\n" "$i" "$RUN/$TOTAL" $PERCENTAGE |
sed 's|#|/|g' >>$OUTPUT
done
}
# 1. Run test suite
@ -89,7 +89,7 @@ echo -n "Checking for coverage files... "
for pat in gcda gcno; do
if [ -z "$(find "$BASE" -name "*.$pat" 2>/dev/null)" ]; then
echo "no .$pat files, nothing to do"
exit 0
exit 0
fi
done
echo "ok"
@ -97,24 +97,24 @@ echo "ok"
# 3a. Run gcov (-p to preserve path) and move into tmp directory
# ... if system does not have gcov installed, exit with message.
echo -n "Creating coverage files... "
if which gcov > /dev/null 2>&1; then
( cd "$TMP" && find "$BASE" -name "*.o" -exec gcov -p {} > /dev/null 2>&1 \; )
NUM_GCOVS=$(find "$TMP" -name *.gcov | wc -l)
if [ $NUM_GCOVS -eq 0 ]; then
echo "no gcov files produced, aborting"
exit 1
fi
if which gcov >/dev/null 2>&1; then
(cd "$TMP" && find "$BASE" -name "*.o" -exec gcov -p {} \; >/dev/null 2>&1)
NUM_GCOVS=$(find "$TMP" -name *.gcov | wc -l)
if [ $NUM_GCOVS -eq 0 ]; then
echo "no gcov files produced, aborting"
exit 1
fi
# Account for '^' that occurs in macOS due to LLVM
# This character seems to be equivalent to ".." (up 1 dir)
for file in $(ls $TMP/*.gcov | grep '\^'); do
mv $file "$(sed 's/#[^#]*#\^//g' <<< "$file")"
done
# Account for '^' that occurs in macOS due to LLVM
# This character seems to be equivalent to ".." (up 1 dir)
for file in $(ls $TMP/*.gcov | grep '\^'); do
mv $file "$(sed 's/#[^#]*#\^//g' <<<"$file")"
done
echo "ok, $NUM_GCOVS coverage files"
echo "ok, $NUM_GCOVS coverage files"
else
echo "gcov is not installed on system, aborting"
exit 1
echo "gcov is not installed on system, aborting"
exit 1
fi
# 3b. Prune gcov files that fall outside of the Zeek tree:
@ -134,7 +134,7 @@ echo "ok, $NUM_GCOVS coverage files remain"
echo -n "Creating summary file... "
DATA="${TMP}/data.txt"
SUMMARY="$CURR/coverage.log"
check_file_coverage "$TMP" > "$DATA"
check_file_coverage "$TMP" >"$DATA"
check_group_coverage "$DATA" ${BASE##*/} $SUMMARY
echo "ok"

View file

@ -14,10 +14,10 @@ function finish {
rm -rf "$TMP"
}
function verify_run {
if bash -c "$1" > /dev/null 2>&1; then
echo ${2:-"ok"}
if bash -c "$1" >/dev/null 2>&1; then
echo ${2:-"ok"}
else
die ${3:-"error, abort"}
die ${3:-"error, abort"}
fi
}
trap finish EXIT
@ -50,37 +50,37 @@ Usage: $0 <options>
exit 1
}
while (( "$#" )); do
while (("$#")); do
case "$1" in
--html)
HTML_REPORT=1
if [ ${#2} -eq 0 ]; then
COVERAGE_HTML_DIR="coverage-html"
shift 1
else
COVERAGE_HTML_DIR=$2
shift 2
fi
;;
--coveralls)
if [ ${#2} -eq 0 ]; then
echo "ERROR: Coveralls repo token must be passed with --coveralls argument."
echo
usage
fi
--html)
HTML_REPORT=1
if [ ${#2} -eq 0 ]; then
COVERAGE_HTML_DIR="coverage-html"
shift 1
else
COVERAGE_HTML_DIR=$2
shift 2
fi
;;
--coveralls)
if [ ${#2} -eq 0 ]; then
echo "ERROR: Coveralls repo token must be passed with --coveralls argument."
echo
usage
fi
HTML_REPORT=0
COVERALLS_REPO_TOKEN=$2
shift 2
;;
--help)
usage
shift 1
;;
*)
COVERAGE_HTML_DIR="${1:-"coverage-html"}"
shift 1
;;
HTML_REPORT=0
COVERALLS_REPO_TOKEN=$2
shift 2
;;
--help)
usage
shift 1
;;
*)
COVERAGE_HTML_DIR="${1:-"coverage-html"}"
shift 1
;;
esac
done
@ -96,7 +96,7 @@ fi
REMOVE_TARGETS="*.yy *.ll *.y *.l \*/bro.dir/\* *.bif \*/zeek.dir/\* \*/src/3rdparty/\* \*/src/zeek/3rdparty/\* \*/auxil/\* "
# 1. Move to base dir, create tmp dir
cd ../../;
cd ../../
mkdir "$TMP"
# 2. Check for .gcno and .gcda file presence
@ -104,7 +104,7 @@ echo -n "Checking for coverage files... "
for pat in gcda gcno; do
if [ -z "$(find . -name "*.$pat" 2>/dev/null)" ]; then
echo "no .$pat files, nothing to do"
exit 0
exit 0
fi
done
echo "ok"
@ -112,8 +112,8 @@ echo "ok"
# 3. If lcov does not exist, abort process.
echo -n "Checking for lcov... "
verify_run "which lcov" \
"lcov installed on system, continue" \
"lcov not installed, abort"
"lcov installed on system, continue" \
"lcov not installed, abort"
# 4. Create a "tracefile" through lcov, which is necessary to create output later on.
echo -n "Creating tracefile for output generation... "
@ -142,9 +142,9 @@ else
# If we're being called by Cirrus, add some additional information to the output.
if [ -n "${CIRRUS_BUILD_ID}" ]; then
coveralls_cmd="${coveralls_cmd} --service-name=cirrus --service-job-id=${CIRRUS_BUILD_ID}"
coveralls_cmd="${coveralls_cmd} --service-name=cirrus --service-job-id=${CIRRUS_BUILD_ID}"
else
coveralls_cmd="${coveralls_cmd} --service-name=local"
coveralls_cmd="${coveralls_cmd} --service-name=local"
fi
coveralls_cmd="${coveralls_cmd} ${COVERAGE_FILE_CLEAN}"

View file

@ -3,14 +3,14 @@
# Helper script for creating new external testing repos. See the
# README for details.
cwd=`pwd`
cwd=$(pwd)
if [ -z "$1" ]; then
echo "usage: $0 <name> [<dst-repo-url>]"
exit 1
fi
name=`pwd`/$1
name=$(pwd)/$1
repo=$2
if [ -e $name ]; then
@ -29,10 +29,10 @@ done
ln -s ../subdir-btest.cfg ./btest.cfg
cp $cwd/`dirname $0`/skel/test.skeleton tests
cp $cwd/`dirname $0`/skel/traces.cfg .
cp $cwd/`dirname $0`/skel/Makefile .
cp $cwd/`dirname $0`/skel/.gitignore .
cp $cwd/$(dirname $0)/skel/test.skeleton tests
cp $cwd/$(dirname $0)/skel/traces.cfg .
cp $cwd/$(dirname $0)/skel/Makefile .
cp $cwd/$(dirname $0)/skel/.gitignore .
git add * .gitignore

View file

@ -16,12 +16,12 @@ else
rm -f $diag
fi
rc=0;
rc=0
files_cwd=`ls $@`
files_baseline=`cd $TEST_BASELINE && ls $@`
files_cwd=$(ls $@)
files_baseline=$(cd $TEST_BASELINE && ls $@)
for i in `echo $files_cwd $files_baseline | sort | uniq`; do
for i in $(echo $files_cwd $files_baseline | sort | uniq); do
if [[ "$i" != "loaded_scripts.log" && "$i" != "prof.log" && "$i" != "debug.log" && "$i" != "stats.log" && "$i" != broker_*.log ]]; then
if [[ "$i" == "reporter.log" ]]; then
@ -33,11 +33,11 @@ for i in `echo $files_cwd $files_baseline | sort | uniq`; do
fi
if ! btest-diff $i; then
echo "" >>$diag
echo "#### btest-diff $i" >>$diag
echo "" >>$diag
cat $diag.tmp >>$diag
rc=1
echo "" >>$diag
echo "#### btest-diff $i" >>$diag
echo "" >>$diag
cat $diag.tmp >>$diag
rc=1
fi
fi
done

View file

@ -3,6 +3,6 @@
# Returns a list of git repositories found in subdirs of the
# current directory.
for i in `find . -type d`; do
for i in $(find . -type d); do
test -e $i/.git && echo $i
done

View file

@ -5,7 +5,7 @@
# traces.cfg must consist of lines of the form "<url> [<http-user>[:<http-password>]]"
if [ "$1" == "" ]; then
echo "usage: `basename $0` <traces-directory>"
echo "usage: $(basename $0) <traces-directory>"
exit 1
fi
@ -18,7 +18,7 @@ cfg=traces.cfg
for p in .proxy ../.proxy; do
if [ -e $p ]; then
proxy=`cat $p | head -1 | awk '{print $1}'`
proxy=$(cat $p | head -1 | awk '{print $1}')
echo Using proxy $proxy ...
proxy="ALL_PROXY=$proxy"
break
@ -37,16 +37,16 @@ cat $cfg | while read line; do
continue
fi
url=`echo $line | awk '{print $1}'`
auth=`echo $line | awk '{print $2}'`
url=$(echo $line | awk '{print $1}')
auth=$(echo $line | awk '{print $2}')
file=$1/`echo $url | sed 's#^.*/##g'`
file=$1/$(echo $url | sed 's#^.*/##g')
fp=$file.md5sum
if [ "$auth" != "" ]; then
auth="-u $auth"
# Hide the hostname and directory names in output messages
safe_url=`echo $url | sed 's#/[A-Za-z].*/#/[hidden]/#'`
safe_url=$(echo $url | sed 's#/[A-Za-z].*/#/[hidden]/#')
else
safe_url=$url
fi
@ -66,7 +66,7 @@ cat $cfg | while read line; do
download=1
fi
else
download=1
download=1
fi
if [ "$download" = "1" ]; then
@ -77,9 +77,9 @@ cat $cfg | while read line; do
}
echo
mv $fp.tmp $fp
#else
# echo "`basename $file` already available."
fi
#else
# echo "`basename $file` already available."
fi
rm -f $fp.tmp

View file

@ -56,4 +56,5 @@ for k in stats:
num_covered += 1
if len(stats) > 0:
print("%s/%s (%.1f%%) Zeek script statements covered." % (num_covered, len(stats), float(num_covered)/len(stats)*100))
print("%s/%s (%.1f%%) Zeek script statements covered." %
(num_covered, len(stats), float(num_covered) / len(stats) * 100))

View file

@ -2,4 +2,4 @@
#
# Default canonifier used with the tests in testing/btest/*.
`dirname $0`/diff-remove-timestamps
$(dirname $0)/diff-remove-timestamps

View file

@ -3,28 +3,27 @@
# Default canonifier used with the trace-based tests in testing/external/*.
if [ $# != 1 ]; then
echo "usage: `basename $0` <filename>"
echo "usage: $(basename $0) <filename>"
exit 1
fi
filename=`basename $1`
filename=$(basename $1)
addl="cat"
if [ "$filename" == "capture_loss.log" ]; then
addl="`dirname $0`/diff-remove-fractions"
addl="$(dirname $0)/diff-remove-fractions"
fi
if [ "$filename" == "ssh.log" ]; then
addl="`dirname $0`/diff-remove-fields remote_location"
addl="$(dirname $0)/diff-remove-fields remote_location"
fi
`dirname $0`/diff-remove-timestamps \
| `dirname $0`/diff-remove-uids \
| `dirname $0`/diff-remove-file-ids \
| `dirname $0`/diff-remove-x509-names \
| `dirname $0`/diff-sort-conn-service \
| `dirname $0`/diff-sort-set-elements \
| `dirname $0`/diff-sort \
| eval $addl
$(dirname $0)/diff-remove-timestamps |
$(dirname $0)/diff-remove-uids |
$(dirname $0)/diff-remove-file-ids |
$(dirname $0)/diff-remove-x509-names |
$(dirname $0)/diff-sort-conn-service |
$(dirname $0)/diff-sort-set-elements |
$(dirname $0)/diff-sort |
eval $addl

View file

@ -2,11 +2,11 @@
#
# Replace absolute paths with the basename.
if [ `uname` == "Linux" ]; then
sed="sed -r"
if [ $(uname) == "Linux" ]; then
sed="sed -r"
else
sed="sed -E"
sed="sed -E"
fi
$sed 's#/+#/#g' | \
$sed 's#/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\2#g'
$sed 's#/+#/#g' |
$sed 's#/([^ :/]{1,}/){1,}([^ :/]{1,})#<...>/\2#g'

View file

@ -4,7 +4,7 @@
# prefix.
if [ $# != 1 ]; then
echo "usage: `basename $0` <field prefix>"
echo "usage: $(basename $0) <field prefix>"
exit 1
fi

View file

@ -3,4 +3,3 @@
# Replace fractions of double value (i.e., 3.14 -> 3.x).
sed 's/\.[0-9]\{1,\}/.X/g'

View file

@ -3,10 +3,10 @@
# Replace timestamps in the #start/end markers in logs.
# Get us "modern" regexps with sed.
if [ `uname` == "Linux" ]; then
sed="sed -r"
if [ $(uname) == "Linux" ]; then
sed="sed -r"
else
sed="sed -E"
sed="sed -E"
fi
$sed 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g'

View file

@ -3,10 +3,10 @@
# Replace anything which looks like timestamps with XXXs (including the #start/end markers in logs).
# Get us "modern" regexps with sed.
if [ `uname` == "Linux" ]; then
sed="sed -r"
if [ $(uname) == "Linux" ]; then
sed="sed -r"
else
sed="sed -E"
sed="sed -E"
fi
$sed -e 's/(^|[^0-9])([0-9]{9,10}\.[0-9]{1,8})/\1XXXXXXXXXX.XXXXXX/g' -e 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g'
$sed -e 's/(^|[^0-9])([0-9]{9,10}\.[0-9]{1,8})/\1XXXXXXXXXX.XXXXXX/g' -e 's/^ *#(open|close).(19|20)..-..-..-..-..-..$/#\1 XXXX-XX-XX-XX-XX-XX/g'

View file

@ -8,11 +8,11 @@ if [ "$TMP" == "" ]; then
TMP=/tmp
fi
tmp=$TMP/`basename $0`.$$.tmp
tmp=$TMP/$(basename $0).$$.tmp
cat >$tmp
echo "### NOTE: This file has been sorted with `basename $0`."
echo "### NOTE: This file has been sorted with $(basename $0)."
cat $tmp | grep ^#
cat $tmp | grep -v ^# | sort -s

View file

@ -2,14 +2,14 @@
#
# Just writes the arguments and stdin to a file, to compare with diff
echo "------- cmdline args -----------" >> sendmail.out
echo "$*" >> sendmail.out
echo "----------- stdin --------------" >> sendmail.out
echo "------- cmdline args -----------" >>sendmail.out
echo "$*" >>sendmail.out
echo "----------- stdin --------------" >>sendmail.out
while IFS= read -r line; do
# Strip out the user agent, which is version dependent
if [[ $line == "User-Agent: Zeek/"* ]]; then
printf 'User-Agent: Zeek/$zeek_version()\n' >> sendmail.out
printf 'User-Agent: Zeek/$zeek_version()\n' >>sendmail.out
else
printf '%s\n' "$line" >> sendmail.out
printf '%s\n' "$line" >>sendmail.out
fi
done

View file

@ -2,8 +2,8 @@
import http.server as BaseHTTPServer
class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/plain")
@ -34,17 +34,21 @@ class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if __name__ == "__main__":
from optparse import OptionParser
p = OptionParser()
p.add_option("-a", "--addr", type="string", default="localhost",
p.add_option("-a",
"--addr",
type="string",
default="localhost",
help=("listen on given address (numeric IP or host name), "
"an empty string (the default) means INADDR_ANY"))
p.add_option("-p", "--port", type="int", default=32123,
help="listen on given TCP port number")
p.add_option("-m", "--max", type="int", default=-1,
p.add_option("-p", "--port", type="int", default=32123, help="listen on given TCP port number")
p.add_option("-m",
"--max",
type="int",
default=-1,
help="max number of requests to respond to, -1 means no max")
options, args = p.parse_args()
httpd = BaseHTTPServer.HTTPServer((options.addr, options.port),
MyRequestHandler)
httpd = BaseHTTPServer.HTTPServer((options.addr, options.port), MyRequestHandler)
if options.max == -1:
httpd.serve_forever()
else:

View file

@ -41,8 +41,8 @@ if [ "$file_hash" != "$head_hash" ]; then
read -p "[Y/n] " choice
case "$choice" in
n|N) echo "Skipped '$repo_base'";;
*) echo $head_hash > $hash_file && git add $hash_file && echo "Updated '$file_base'";;
n | N) echo "Skipped '$repo_base'" ;;
*) echo $head_hash >$hash_file && git add $hash_file && echo "Updated '$file_base'" ;;
esac
else
echo " none"

View file

@ -3,8 +3,8 @@
# Sleeps until a file comes into existence.
if [[ $# -ne 2 ]]; then
>&2 echo "usage: $0 <file to wait for> <max secs to wait>"
exit 1
echo >&2 "usage: $0 <file to wait for> <max secs to wait>"
exit 1
fi
wait_file=$1
@ -12,13 +12,12 @@ max_wait=$2
wait_count=0
while [[ ! -e $wait_file ]]; do
let "wait_count += 1"
let "wait_count += 1"
if [[ $wait_count -ge $max_wait ]]; then
>&2 echo "error: file '$wait_file' does not exist after $max_wait seconds"
exit 1
fi
if [[ $wait_count -ge $max_wait ]]; then
echo >&2 "error: file '$wait_file' does not exist after $max_wait seconds"
exit 1
fi
sleep 1
sleep 1
done

View file

@ -22,9 +22,9 @@ add_path() {
# $1: existing path
# $2: path to add
if test -z "$2" || test "$1" = "$2" ||
echo "$1" | grep -q "^$2:" 2>/dev/null ||
echo "$1" | grep -q ":$2:" 2>/dev/null ||
echo "$1" | grep -q ":$2$" 2>/dev/null; then
echo "$1" | grep -q "^$2:" 2>/dev/null ||
echo "$1" | grep -q ":$2:" 2>/dev/null ||
echo "$1" | grep -q ":$2$" 2>/dev/null; then
echo "$1"
return
fi
@ -69,81 +69,81 @@ Toplevel installation directories for third-party components:
"
}
if [ $# -eq 0 ] ; then
usage 1>&2
exit 1
if [ $# -eq 0 ]; then
usage 1>&2
exit 1
fi
while [ $# -ne 0 ]; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
-*=*) optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//') ;;
*) optarg= ;;
esac
case $1 in
--binpac_root)
echo $binpac_root
;;
--bro_dist) # For compatibility with legacy Bro plugins.
echo $zeek_dist
;;
--broker_root)
echo $broker_root
;;
--bropath) # For compatibility with legacy Bro plugins.
echo $zeekpath
;;
--btest_tools_dir)
echo $btest_tools_dir
;;
--build_type)
echo $build_type
;;
--caf_root)
echo $caf_root
;;
--cmake_dir)
echo $cmake_dir
;;
--config_dir)
echo $config_dir
;;
--include_dir)
echo $include_dir
;;
--lib_dir)
echo $lib_dir
;;
--plugin_dir)
echo $plugin_dir
;;
--prefix)
echo $prefix
;;
--python_dir)
echo $python_dir
;;
--script_dir)
echo $script_dir
;;
--site_dir)
echo $site_dir
;;
--version)
echo $version
;;
--zeek_dist)
echo $zeek_dist
;;
--zeekpath)
echo $zeekpath
;;
*)
usage 1>&2
exit 1
;;
esac
shift
case $1 in
--binpac_root)
echo $binpac_root
;;
--bro_dist) # For compatibility with legacy Bro plugins.
echo $zeek_dist
;;
--broker_root)
echo $broker_root
;;
--bropath) # For compatibility with legacy Bro plugins.
echo $zeekpath
;;
--btest_tools_dir)
echo $btest_tools_dir
;;
--build_type)
echo $build_type
;;
--caf_root)
echo $caf_root
;;
--cmake_dir)
echo $cmake_dir
;;
--config_dir)
echo $config_dir
;;
--include_dir)
echo $include_dir
;;
--lib_dir)
echo $lib_dir
;;
--plugin_dir)
echo $plugin_dir
;;
--prefix)
echo $prefix
;;
--python_dir)
echo $python_dir
;;
--script_dir)
echo $script_dir
;;
--site_dir)
echo $site_dir
;;
--version)
echo $version
;;
--zeek_dist)
echo $zeek_dist
;;
--zeekpath)
echo $zeekpath
;;
*)
usage 1>&2
exit 1
;;
esac
shift
done
exit 0

View file

@ -6,7 +6,7 @@
# exit code.
function deprecated {
cat >&2 <<EOF
cat >&2 <<EOF
Error: Use of '$1' is no longer supported. Please use '$2' instead.
EOF