zgrab2/integration_tests/test.sh
Andrew Sardone f45ab312bb
Move all test scripts into integration_tests/ directory
This is just a very minor directory organization change, but it has the
advantage of keeping a bunch of files out of the root directory and
packaging them together since they are related to each other.

Now, our `integration_tests/` directory has a nice pattern of
setup/cleanup/test.sh scripts at the top global level and at each module
level:

```
❯ tree --dirsfirst integration_tests
integration_tests
├── mysql
│   ├── util
│   │   ├── launch_mysql_container.sh
│   │   └── wait_for_mysqld.sh
│   ├── cleanup.sh
│   ├── setup.sh
│   ├── single_run.sh
│   └── test.sh
├── ssh
│   ├── cleanup.sh
│   ├── setup.sh
│   └── test.sh
├── cleanup.sh
├── setup.sh
└── test.sh

3 directories, 12 files
```

The scripts are runnable via:

```
./integration_tests/setup.sh && ./integration_tests/test.sh && ./integration_tests/cleanup.sh
```
2017-12-18 00:44:06 -05:00

42 lines
1.1 KiB
Bash
Executable File

#!/bin/bash -e
# Do all integration tests for all protocols
# To add tests for a new protocol, create a directory integration_tests/<new_protocol>, and drop its setup.sh, test.sh, and cleanup.sh there.
# Run from root of project
TEST_DIR=$(dirname "$0")
cd "$TEST_DIR/.."
# <protocol>_integration_tests.sh should drop its output into $ZGRAB_OUTPUT/<protocol>/* so that it can be validated
if [ -z $ZGRAB_OUTPUT ]; then
ZGRAB_OUTPUT="$(pwd)/zgrab-output"
fi
export ZGRAB_OUTPUT=$ZGRAB_OUTPUT
export ZGRAB_ROOT=$(pwd)
pushd integration_tests
for mod in $(ls); do
if [ -d "$mod" ]; then
pushd $mod
for test in $(ls test*.sh); do
echo "Running integration_tests/$mod/$test"
./$test
done
popd
fi
done
popd
echo "Doing schema validation..."
for protocol in $(ls $ZGRAB_OUTPUT); do
for outfile in $(ls $ZGRAB_OUTPUT/$protocol); do
target="$ZGRAB_OUTPUT/$protocol/$outfile"
echo "Validating $target [{("
cat $target
echo ")}]:"
python -m zschema validate schemas/__init__.py:zgrab2 $target
echo "validation of $target succeeded."
done
done