summaryrefslogtreecommitdiffstats
path: root/tests/load-functions
diff options
context:
space:
mode:
Diffstat (limited to 'tests/load-functions')
-rw-r--r--tests/load-functions60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/load-functions b/tests/load-functions
new file mode 100644
index 0000000..f0c5311
--- /dev/null
+++ b/tests/load-functions
@@ -0,0 +1,60 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+stderr () {
+ ("$@") 2>&1 >/dev/null
+}
+
+getlist () {
+ getlist_list="$1"
+ shift 1
+ if test $# = 0; then set cat; fi
+ "$@" < libsyscalls.h \
+ | tr , '\n' \
+ | sed -n 's/^\s*LIBSYSCALLS_'"${getlist_list}"'_\([A-Z0-9_]\+\(\s*=\s*[ 0-9A-Fa-fxXULul()^&|!*/<>~+-]\+\)\?\)\b.*$/\1/p' \
+ | tr = ' ' \
+ | (i=0; while read name value; do
+ if test -n "$value"; then
+ i=$(( $(printf '%s\n' "$value" | tr -d 'ULul') ))
+ i=$(printf '%s\n' "$i" | cut -d . -f 1)
+ fi
+ printf '%i %s\n' $(( i++ )) $name;
+ done)
+}
+
+getnamelist () {
+ getlist "$@" | cut -d ' ' -f 2
+}
+
+getnumlist () {
+ getlist "$@" | cut -d ' ' -f 1
+}
+
+getname () {
+ (getlist "$1" | grep "^$2 " | cut -d ' ' -f 2 | tee /dev/stderr | grep . >/dev/null) 2>&1
+}
+
+getnum () {
+ (getlist "$1" | grep " $2"\$ | cut -d ' ' -f 1 | tee /dev/stderr | grep . >/dev/null) 2>&1
+}
+
+lookupname () {
+ (printf '%s\n' "$1" | grep "^$2 " | cut -d ' ' -f 2 | tee /dev/stderr | grep . >/dev/null) 2>&1
+}
+
+lookupnum () {
+ (printf '%s\n' "$1" | grep " $2"\$ | cut -d ' ' -f 1 | tee /dev/stderr | grep . >/dev/null) 2>&1
+}
+
+issupported () {
+ if test $# = 1; then
+ printf '%s\n' ${SUPPORTED_OSES} | grep -i "^$1"\$ > /dev/null
+ else
+ printf '%s\n' ${SUPPORTED_OSES} | grep -i "^$1"\$ > /dev/null &&
+ env | sed -n 's/^SUPPORTED_'"$1"'_ARCHES=//p' | xargs printf '%s\n' | grep -i "^$2"\$ > /dev/null
+ fi
+}
+
+cpp_enum_clean () {
+ $CPP < libsyscalls.h 2>/dev/null | grep -v '#' | tr '\n,{}' ' \n\n\n'
+}