1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#!/bin/sh
#
# Check seccomp filter performance.
#
# Copyright (c) 2019 Paul Chaignon <paul.chaignon@gmail.com>
# Copyright (c) 2018-2021 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
. "${srcdir=.}/init.sh"
. "${srcdir=.}/filter_seccomp.sh"
args="-f -qq -e signal=none -e trace=fchdir ../$NAME"
num_regular="$(run_strace $args)"
mv "$LOG" "$LOG.regular"
num_seccomp="$(run_strace --seccomp-bpf $args)"
mv "$LOG" "$LOG.seccomp"
match_diff "$LOG.regular" "$LOG.seccomp"
min_ratio=5
# With seccomp filter enabled, we should be able to complete
# at least $min_ratio times more chdir system calls.
ratio="$((num_seccomp / num_regular))"
if [ "$ratio" -lt "$min_ratio" ]; then
fail_ "Only $ratio times more syscalls performed with seccomp filter enabled, expected at least $min_ratio times speedup"
fi
|