#!/usr/bin/env python3

# stdlib imports
import atexit
import sys
import subprocess

# stdlib "from" imports
from pathlib import Path

assert __name__ == "__main__", "Can't determine script dir"
_SCRIPT_DIR = Path(sys.argv[0]).parent.resolve()

subprocess.check_call([_SCRIPT_DIR.joinpath("setup")])

# Try to ensure we tear down the network on exit, including failure, ctrl-c, etc.
atexit.register(lambda: subprocess.check_call([_SCRIPT_DIR.joinpath("teardown")]))

# bootstrap the network
subprocess.check_call([_SCRIPT_DIR.joinpath("bootstrap")])

# test the network
subprocess.check_call([_SCRIPT_DIR.joinpath("test"), "-v"])
