glibc/sysdeps/unix/sysv/linux/tst-syscall-list.sh

100 lines
2.9 KiB
Bash
Raw Normal View History

#!/bin/bash
# Consistency checks for the system call list
# Copyright (C) 2017-2023 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
#
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
Prefer https to http for gnu.org and fsf.org URLs Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
# <https://www.gnu.org/licenses/>.
export LC_ALL=C
set -e
set -o pipefail
if test $# != 4; then
echo "error: wrong number of arguments: $#"
exit 1
fi
macros="$1"
list_nr="$2"
list_sys="$3"
GAWK="$4"
linux_version="$("$GAWK" \
'/#define LINUX_VERSION_CODE / {print $3}' < "$macros")"
glibc_linux_version="$("$GAWK" \
'/#define __GLIBC_LINUX_VERSION_CODE / {print $3}' < "$macros")"
echo "info: LINUX_VERSION_CODE: $linux_version"
echo "info: __GLIBC_LINUX_VERSION_CODE: $glibc_linux_version"
# Ignore the subrelease in the comparison.
if test $(expr "$glibc_linux_version" / 256) \
-lt $(expr "$linux_version" / 256); then
echo "info: The kernel major/minor version is newer than the glibc version"
kernel_newer=true
else
kernel_newer=false
fi
echo
errors=0
# Use getpid as a system call which is expected to be always defined.
# alpha uses getxpid instead, so it is permitted as an alternative.
if ! grep -E -q '^getx?pid$' -- "$list_nr"; then
echo "error: __NR_getpid not defined"
errors=1
fi
if ! grep -E -q '^getx?pid$' -- "$list_sys"; then
echo "error: SYS_getpid not defined"
errors=1
fi
comm_1="$(mktemp)"
comm_2="$(mktemp)"
comm_result="$(mktemp)"
cleanup () {
rm -f -- "$comm_1" "$comm_2" "$comm_result"
}
trap cleanup 0
sort -o "$comm_1" -- "$list_nr"
sort -o "$comm_2" -- "$list_sys"
# Check for missing SYS_* macros.
comm --check-order -2 -3 -- "$comm_1" "$comm_2" > "$comm_result"
if test -s "$comm_result"; then
echo "error: These system calls need to be added to syscall-names.list:"
cat -- "$comm_result"
# This is only an error if our version is older than the kernel
# version because we cannot predict future kernel development.
if $kernel_newer; then
echo
echo "warning: This error has been ignored because the glibc"
echo "warning: system call list is older than the kernel version."
else
errors=1
fi
fi
# Check for additional SYS_* macros.
comm --check-order -1 -3 -- "$comm_1" "$comm_2" > "$comm_result"
if test -s "$comm_result"; then
echo "error: The following system calls have unexpected SYS_* macros:"
cat -- "$comm_result"
errors=1
fi
exit "$errors"