echo "$*" >&2
}
-die() {
- err "$*"
- exit 1
-}
-
if [ "$(id -u)" != "0" ] ; then
- die "this requires root!"
+ err "this requires root!"
+ exit 77
fi
testdir=$(mktemp -d)
if [ ! -d $testdir ]; then
- die "Failed to create test directory"
+ err "Failed to create test directory"
+ exit 99
fi
trap 'rm -rf $testdir; $nft flush ruleset' EXIT
if os.getuid() != 0:
print("You need to be root to run this, sorry")
- return
+ return 77
if not args.no_netns and not spawn_netns():
print_warning("cannot run in own namespace, connectivity might break")
if check_lib_path and not os.path.exists(args.library):
print("The nftables library at '%s' does not exist. "
"You need to build the project." % args.library)
- return
+ return 99
if args.enable_schema and not args.enable_json:
print_error("Option --schema requires option --json")
- return
+ return 99
global nftables
nftables = Nftables(sofile = args.library)
print_info("Log will be available at %s" % LOGFILE)
except IOError:
print_error("Cannot open log file %s" % LOGFILE)
- return
+ return 99
file_list = []
if args.filenames:
print("%d test files, %d files passed, %d unit tests, " % (test_files, files_ok, tests))
print("%d error, %d warning" % (errors, warnings))
+ return errors != 0
+
if __name__ == '__main__':
- main()
+ sys.exit(main())