diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/build/check-links.sh | 28 | ||||
-rw-r--r-- | tools/regression/posixsem2/semtest.c | 35 |
2 files changed, 61 insertions, 2 deletions
diff --git a/tools/build/check-links.sh b/tools/build/check-links.sh index 57c9437c0259..06aa8d31d28e 100755 --- a/tools/build/check-links.sh +++ b/tools/build/check-links.sh @@ -18,17 +18,34 @@ libkey() { return 0 } +usage() { + cat <<-EOF + usage: $0 [-Uv] [-L LD_LIBRARY_PATH] file + -L: Specify an alternative LD_LIBRARY_PATH for the library resolution. + -U: Skip looking for unresolved symbols. + -v: Show which library each symbol is resolved to. + EOF + exit 0 +} + ret=0 CHECK_UNRESOLVED=1 VERBOSE_RESOLVED=0 -while getopts "Uv" flag; do +while getopts "L:Uv" flag; do case "${flag}" in + L) LIB_PATH="${OPTARG}" ;; U) CHECK_UNRESOLVED=0 ;; v) VERBOSE_RESOLVED=1 ;; + *) usage ;; esac done shift $((OPTIND-1)) +if ! [ -f "$1" ]; then + echo "No such file or directory: $1" >&2 + exit 1 +fi + mime=$(file -L --mime-type $1) isbin=0 case $mime in @@ -40,7 +57,14 @@ esac # Gather all symbols from the target unresolved_symbols=$(nm -u -D --format=posix "$1" | awk '$2 == "U" {print $1}' | tr '\n' ' ') [ ${isbin} -eq 1 ] && bss_symbols=$(nm -D --format=posix "$1" | awk '$2 == "B" && $4 != "" {print $1}' | tr '\n' ' ') -ldd_libs=$(ldd $(realpath $1) | awk '{print $1 ":" $3}') +if [ -n "${LIB_PATH}" ]; then + for libc in /lib/libc.so.*; do + LDD_ENV="LD_PRELOAD=${libc}" + done + LDD_ENV="${LDD_ENV} LD_LIBRARY_PATH=${LIB_PATH}" +fi + +ldd_libs=$(env ${LDD_ENV} ldd $(realpath $1) | awk '{print $1 ":" $3}') # Check for useful libs list_libs= diff --git a/tools/regression/posixsem2/semtest.c b/tools/regression/posixsem2/semtest.c index b1255db83724..0879ff9fda78 100644 --- a/tools/regression/posixsem2/semtest.c +++ b/tools/regression/posixsem2/semtest.c @@ -7,6 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <err.h> +#include <errno.h> #include <fcntl.h> #include <unistd.h> @@ -14,6 +15,7 @@ int test_unnamed(void); int test_named(void); +int test_named2(void); int test_unnamed(void) @@ -94,9 +96,42 @@ test_named(void) } int +test_named2(void) +{ + sem_t *s, *s2, *s3; + + printf("testing named process-shared semaphore, O_EXCL cases\n"); + sem_unlink(SEM_NAME); + s = sem_open(SEM_NAME, O_CREAT | O_EXCL, 0777, 0); + if (s == SEM_FAILED) + err(1, "sem_open failed"); + s2 = sem_open(SEM_NAME, O_CREAT | O_EXCL, 0777, 0); + if (s2 != SEM_FAILED) + errx(2, "second sem_open call wrongly succeeded"); + if (errno != EEXIST) + err(3, "second sem_open call failed with wrong errno"); + + s3 = sem_open(SEM_NAME, 0); + if (s3 == SEM_FAILED) + err(4, "third sem_open call failed"); + if (s != s3) + errx(5, +"two sem_open calls for same semaphore do not return same address"); + if (sem_close(s3)) + err(6, "sem_close failed"); + + if (sem_close(s)) + err(7, "sem_close failed"); + + printf("OK.\n"); + return (0); +} + +int main(void) { test_unnamed(); test_named(); + test_named2(); return (0); } |