diff --git a/.travis-functions.sh b/.travis-functions.sh index bef459756..3315a9159 100755 --- a/.travis-functions.sh +++ b/.travis-functions.sh @@ -11,23 +11,14 @@ if [ ! -f "configure.ac" ]; then return 1 || exit 1 fi -# some config settings -MAKE="make -j4" +## some config settings +# travis docs say we get 1.5 CPUs +MAKE="make -j2" DUMP_CONFIG_LOG="short" -# We could test (exotic) out-of-tree build dirs using relative or abs paths. -# After sourcing this script we are living in build dir. Tasks for source dir -# have to use $SOURCE_DIR. -SOURCE_DIR="." -BUILD_DIR="." -CONFIGURE="$SOURCE_DIR/configure" - -mkdir -p "$BUILD_DIR" -cd "$BUILD_DIR" || return 1 || exit 1 - -function configure_travis +function xconfigure { - "$CONFIGURE" "$@" + ./configure "$@" err=$? if [ "$DUMP_CONFIG_LOG" = "short" ]; then grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE=" @@ -41,7 +32,7 @@ function check_nonroot { local opts="$MAKE_CHECK_OPTS" - configure_travis \ + xconfigure \ --disable-use-tty-group \ --with-python \ --enable-all-programs \ @@ -56,7 +47,7 @@ function check_root { local opts="$MAKE_CHECK_OPTS --parallel=1" - configure_travis \ + xconfigure \ --with-python \ --enable-all-programs \ || return @@ -68,7 +59,7 @@ function check_root function check_dist { - configure_travis \ + xconfigure \ || return $MAKE distcheck || return } @@ -98,14 +89,12 @@ function travis_install_script function travis_before_script { - pushd "$SOURCE_DIR" || return set -o xtrace ./autogen.sh ret=$? set +o xtrace - popd return $ret } @@ -142,10 +131,10 @@ function travis_after_script local tmp # find diff dir from check as well as from distcheck - diff_dir=$(find -type d -a -name "diff" | grep "tests/diff" | head -n 1) + diff_dir=$(find . -type d -name "diff" | grep "tests/diff" | head -n 1) if [ -d "$diff_dir" ]; then tmp=$(find "$diff_dir" -type f | sort) echo -en "dump test diffs:\n${tmp}\n" - echo "$tmp" | xargs -r cat + echo "$tmp" | xargs cat fi } diff --git a/.travis.yml b/.travis.yml index 85a753d39..e27adc4d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,8 @@ branches: - /^travis.*/ before_install: + # print some host info + - env | grep -v "encrypted" | LC_ALL=C sort - $CC --version - which $CC # workaround clang not system wide, fail on sudo make install diff --git a/autogen.sh b/autogen.sh index bfa46fec3..116885bc7 100755 --- a/autogen.sh +++ b/autogen.sh @@ -75,7 +75,7 @@ if ! ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1; then echo DIE=1 else - ltver=$($LIBTOOLIZE --version | awk '/^libtoolize/ { print $4 }') + ltver=$($LIBTOOLIZE --version | awk '/^[g]*libtoolize/ { print $4 }') ltver=${ltver:-"none"} test ${ltver##2.} = "$ltver" && { echo diff --git a/configure.ac b/configure.ac index 455957396..227ba253f 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,9 @@ AC_SUBST([BSD_WARN_CFLAGS]) dnl libtool-2 LT_INIT +dnl check supported linker flags +AX_CHECK_VSCRIPT + m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([Could not locate the pkg-config autoconf macros. These are usually located in /usr/share/aclocal/pkg.m4. @@ -155,11 +158,17 @@ bsd_os=no AS_CASE([${host_os}], [*linux*], [linux_os=yes], + [*darwin*], + [darwin_os=yes], [*bsd*], [bsd_os=yes]) AM_CONDITIONAL([LINUX], [test "x$linux_os" = xyes]) +AM_CONDITIONAL([DARWIN], [test "x$darwin_os" = xyes]) AM_CONDITIONAL([BSD], [test "x$bsd_os" = xyes]) +AS_IF([test "x$darwin_os" = xyes], [ + AC_DEFINE([_DARWIN_C_SOURCE], [1], [Enable MAP_ANON in sys/mman.h on Mac OS X]) +]) dnl define ARCH_ conditionals UL_SET_ARCH([I86], [i?86-*]) @@ -228,6 +237,7 @@ AC_CHECK_HEADERS([ \ sys/ioccom.h \ sys/ioctl.h \ sys/mkdev.h \ + sys/mount.h \ sys/param.h \ sys/prctl.h \ sys/queue.h \ @@ -235,12 +245,14 @@ AC_CHECK_HEADERS([ \ sys/socket.h \ sys/sockio.h \ sys/stat.h \ + sys/sysmacros.h \ sys/swap.h \ sys/syscall.h \ sys/time.h \ sys/timex.h \ sys/ttydefaults.h \ sys/types.h \ + sys/ucred.h \ sys/un.h \ unistd.h \ ]) diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index d5d379086..d3088a5ab 100644 --- a/disk-utils/fsck.cramfs.c +++ b/disk-utils/fsck.cramfs.c @@ -49,7 +49,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSMACROS_H #include /* for major, minor */ +#endif #include "cramfs.h" #include "nls.h" diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index 3d73d49e9..2058a9798 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -87,7 +87,6 @@ #include #include #include -#include #include #include #include diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 471277290..b472242ed 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -64,7 +64,6 @@ #include #include #include -#include #include #include diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 22999dafb..ae02de569 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/disk-utils/raw.c b/disk-utils/raw.c index d29ff1ba3..6c4b6de8e 100644 --- a/disk-utils/raw.c +++ b/disk-utils/raw.c @@ -20,7 +20,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSMACROS_H #include +#endif #include #include "c.h" diff --git a/include/c.h b/include/c.h index ca028baee..aec34394d 100644 --- a/include/c.h +++ b/include/c.h @@ -355,4 +355,12 @@ static inline int xusleep(useconds_t usec) */ #define UL_GETPW_BUFSIZ (16 * 1024) +/* + * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must + * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h. + */ +#if !defined MAP_ANONYMOUS && defined MAP_ANON +# define MAP_ANONYMOUS (MAP_ANON) +#endif + #endif /* UTIL_LINUX_C_H */ diff --git a/include/strutils.h b/include/strutils.h index ec2a8acd6..4bb3b2dc3 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -78,7 +78,7 @@ static inline char *strdup_to_offset(void *stru, size_t offset, const char *str) #define strdup_to_struct_member(_s, _m, _str) \ strdup_to_offset((void *) _s, offsetof(__typeof__(*(_s)), _m), _str) -extern void strmode(mode_t mode, char *str); +extern void xstrmode(mode_t mode, char *str); /* Options for size_to_human_string() */ enum diff --git a/lib/blkdev.c b/lib/blkdev.c index f6df92d4f..403e9e48a 100644 --- a/lib/blkdev.c +++ b/lib/blkdev.c @@ -150,7 +150,6 @@ blkdev_get_size(int fd, unsigned long long *bytes) int part = -1; struct disklabel lab; struct partition *pp; - char ch; struct stat st; if ((fstat(fd, &st) >= 0) && diff --git a/lib/idcache.c b/lib/idcache.c index 4cb20fd2d..3c358b8a8 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -7,6 +7,10 @@ #include "c.h" #include "idcache.h" +#ifndef LOGIN_NAME_MAX +#define LOGIN_NAME_MAX 256 +#endif + struct identry *get_id(struct idcache *ic, unsigned long int id) { struct identry *ent; diff --git a/lib/ismounted.c b/lib/ismounted.c index 90952905d..f83be65e0 100644 --- a/lib/ismounted.c +++ b/lib/ismounted.c @@ -18,9 +18,14 @@ #include #include #include -#ifdef __APPLE__ -#include -#include + +#ifndef __linux__ +# ifdef HAVE_SYS_UCRED_H +# include +# endif +# ifdef HAVE_SYS_MOUNT_H +# include +# endif #endif #include "pathnames.h" diff --git a/lib/monotonic.c b/lib/monotonic.c index 372cc9c5a..bb58e15d7 100644 --- a/lib/monotonic.c +++ b/lib/monotonic.c @@ -4,7 +4,9 @@ */ #include #include +#ifdef HAVE_SYSINFO #include +#endif #include #include "c.h" diff --git a/lib/strutils.c b/lib/strutils.c index ac59de8ee..ef81ebd74 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -425,7 +425,7 @@ void strtotimeval_or_err(const char *str, struct timeval *tv, const char *errmes * Converts stat->st_mode to ls(1)-like mode string. The size of "str" must * be 11 bytes. */ -void strmode(mode_t mode, char *str) +void xstrmode(mode_t mode, char *str) { unsigned short i = 0; diff --git a/lib/timer.c b/lib/timer.c index 0ad0cad78..62656932a 100644 --- a/lib/timer.c +++ b/lib/timer.c @@ -5,7 +5,6 @@ */ #include #include -#include #include #include "c.h" diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am index 52d0b0a7b..1d03d92d6 100644 --- a/libblkid/src/Makemodule.am +++ b/libblkid/src/Makemodule.am @@ -129,7 +129,9 @@ endif libblkid_la_LDFLAGS = \ $(SOLIB_LDFLAGS) \ - -Wl,--version-script=$(top_srcdir)/libblkid/src/libblkid.sym \ +if HAVE_VSCRIPT + $(VSCRIPT_LDFLAGS),$(top_srcdir)/libblkid/src/libblkid.sym \ +endif -version-info $(LIBBLKID_VERSION_INFO) EXTRA_DIST += \ diff --git a/libblkid/src/superblocks/drbdmanage.c b/libblkid/src/superblocks/drbdmanage.c index d7384dff3..e84efa343 100644 --- a/libblkid/src/superblocks/drbdmanage.c +++ b/libblkid/src/superblocks/drbdmanage.c @@ -11,7 +11,6 @@ * (a DRBDmanage "cluster"); this file detects its control volume, * which is replicated (via DRBD 9) on some of the nodes. */ -#include #include #include #include @@ -21,6 +20,7 @@ #include #include +#include "bitops.h" #include "superblocks.h" struct drbdmanage_hdr { diff --git a/libfdisk/src/Makemodule.am b/libfdisk/src/Makemodule.am index 00c3d9f0c..69a3f3e34 100644 --- a/libfdisk/src/Makemodule.am +++ b/libfdisk/src/Makemodule.am @@ -48,7 +48,9 @@ libfdisk_la_DEPENDENCIES = \ libfdisk_la_LDFLAGS = \ $(SOLIB_LDFLAGS) \ - -Wl,--version-script=$(top_srcdir)/libfdisk/src/libfdisk.sym \ +if HAVE_VSCRIPT + $(VSCRIPT_LDFLAGS),$(top_srcdir)/libfdisk/src/libfdisk.sym \ +endif -version-info $(LIBFDISK_VERSION_INFO) if BUILD_LIBBLKID diff --git a/libmount/src/Makemodule.am b/libmount/src/Makemodule.am index 3a89d0de4..36bb00c56 100644 --- a/libmount/src/Makemodule.am +++ b/libmount/src/Makemodule.am @@ -61,7 +61,9 @@ libmount_la_DEPENDENCIES = \ libmount_la_LDFLAGS = \ $(SOLIB_LDFLAGS) \ - -Wl,--version-script=$(top_srcdir)/libmount/src/libmount.sym \ +if HAVE_VSCRIPT + $(VSCRIPT_LDFLAGS),$(top_srcdir)/libmount/src/libmount.sym \ +endif -version-info $(LIBMOUNT_VERSION_INFO) EXTRA_DIST += \ diff --git a/libsmartcols/samples/tree.c b/libsmartcols/samples/tree.c index 7f41f9eb4..52be7fbd5 100644 --- a/libsmartcols/samples/tree.c +++ b/libsmartcols/samples/tree.c @@ -59,7 +59,7 @@ static int add_line_from_stat(struct libscols_table *tb, err(EXIT_FAILURE, "failed to create output line"); /* MODE; local buffer, use scols_line_set_data() that calls strdup() */ - strmode(mode, modbuf); + xstrmode(mode, modbuf); if (scols_line_set_data(ln, COL_MODE, modbuf)) goto fail; diff --git a/libsmartcols/src/Makemodule.am b/libsmartcols/src/Makemodule.am index c2ec515d4..257d46dcb 100644 --- a/libsmartcols/src/Makemodule.am +++ b/libsmartcols/src/Makemodule.am @@ -36,7 +36,9 @@ libsmartcols_la_DEPENDENCIES = \ libsmartcols_la_LDFLAGS = \ $(SOLIB_LDFLAGS) \ - -Wl,--version-script=$(top_srcdir)/libsmartcols/src/libsmartcols.sym \ +if HAVE_VSCRIPT + $(VSCRIPT_LDFLAGS),$(top_srcdir)/libsmartcols/src/libsmartcols.sym \ +endif -version-info $(LIBSMARTCOLS_VERSION_INFO) EXTRA_DIST += \ diff --git a/libuuid/src/Makemodule.am b/libuuid/src/Makemodule.am index 180ac01c0..dc8d8672a 100644 --- a/libuuid/src/Makemodule.am +++ b/libuuid/src/Makemodule.am @@ -37,7 +37,9 @@ libuuid_la_CFLAGS = \ libuuid_la_LDFLAGS = \ $(SOLIB_LDFLAGS) \ - -Wl,--version-script=$(top_srcdir)/libuuid/src/libuuid.sym \ +if HAVE_VSCRIPT + libuuid_la_LDFLAGS += $(VSCRIPT_LDFLAGS),$(top_srcdir)/libuuid/src/libuuid.sym \ +endif -version-info $(LIBUUID_VERSION_INFO) EXTRA_DIST += libuuid/src/libuuid.sym diff --git a/login-utils/login.c b/login-utils/login.c index 6f5103909..e1f11eb9e 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -48,7 +48,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSMACROS_H #include +#endif #ifdef HAVE_LINUX_MAJOR_H # include #endif diff --git a/m4/ax_check_vscript.m4 b/m4/ax_check_vscript.m4 new file mode 100644 index 000000000..219ad2260 --- /dev/null +++ b/m4/ax_check_vscript.m4 @@ -0,0 +1,142 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_vscript.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_VSCRIPT +# +# DESCRIPTION +# +# Check whether the linker supports version scripts. Version scripts are +# used when building shared libraries to bind symbols to version nodes +# (helping to detect incompatibilities) or to limit the visibility of +# non-public symbols. +# +# Output: +# +# If version scripts are supported, VSCRIPT_LDFLAGS will contain the +# appropriate flag to pass to the linker. On GNU systems this would +# typically be "-Wl,--version-script", and on Solaris it would typically +# be "-Wl,-M". +# +# Two Automake conditionals are also set: +# +# HAVE_VSCRIPT is true if the linker supports version scripts with +# entries that use simple wildcards, like "local: *". +# +# HAVE_VSCRIPT_COMPLEX is true if the linker supports version scripts with +# pattern matching wildcards, like "global: Java_*". +# +# On systems that do not support symbol versioning, such as Mac OS X, both +# conditionals will be false. They will also be false if the user passes +# "--disable-symvers" on the configure command line. +# +# Example: +# +# configure.ac: +# +# AX_CHECK_VSCRIPT +# +# Makefile.am: +# +# if HAVE_VSCRIPT +# libfoo_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libfoo.map +# endif +# +# if HAVE_VSCRIPT_COMPLEX +# libbar_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libbar.map +# endif +# +# LICENSE +# +# Copyright (c) 2014 Kevin Cernekee +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +# _AX_CHECK_VSCRIPT(flag, global-sym, action-if-link-succeeds, [junk-file=no]) +AC_DEFUN([_AX_CHECK_VSCRIPT], [ + AC_LANG_PUSH([C]) + ax_check_vscript_save_flags="$LDFLAGS" + echo "V1 { global: $2; local: *; };" > conftest.map + AS_IF([test x$4 = xyes], [ + echo "{" >> conftest.map + ]) + LDFLAGS="$LDFLAGS -Wl,$1,conftest.map" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[int show, hide;]], [])], [$3]) + LDFLAGS="$ax_check_vscript_save_flags" + rm -f conftest.map + AC_LANG_POP([C]) +]) dnl _AX_CHECK_VSCRIPT + +AC_DEFUN([AX_CHECK_VSCRIPT], [ + + AC_ARG_ENABLE([symvers], + AS_HELP_STRING([--disable-symvers], + [disable library symbol versioning [default=auto]]), + [want_symvers=$enableval], + [want_symvers=yes] + ) + + AS_IF([test x$want_symvers = xyes], [ + + dnl First test --version-script and -M with a simple wildcard. + + AC_CACHE_CHECK([linker version script flag], ax_cv_check_vscript_flag, [ + ax_cv_check_vscript_flag=unsupported + _AX_CHECK_VSCRIPT([--version-script], [show], [ + ax_cv_check_vscript_flag=--version-script + ]) + AS_IF([test x$ax_cv_check_vscript_flag = xunsupported], [ + _AX_CHECK_VSCRIPT([-M], [show], [ax_cv_check_vscript_flag=-M]) + ]) + + dnl The linker may interpret -M (no argument) as "produce a load map." + dnl If "-M conftest.map" doesn't fail when conftest.map contains + dnl obvious syntax errors, assume this is the case. + + AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [ + _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [show], + [ax_cv_check_vscript_flag=unsupported], [yes]) + ]) + ]) + + dnl If the simple wildcard worked, retest with a complex wildcard. + + AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [ + ax_check_vscript_flag=$ax_cv_check_vscript_flag + AC_CACHE_CHECK([if version scripts can use complex wildcards], + ax_cv_check_vscript_complex_wildcards, [ + ax_cv_check_vscript_complex_wildcards=no + _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [sh*], [ + ax_cv_check_vscript_complex_wildcards=yes]) + ]) + ax_check_vscript_complex_wildcards="$ax_cv_check_vscript_complex_wildcards" + ], [ + ax_check_vscript_flag= + ax_check_vscript_complex_wildcards=no + ]) + ], [ + AC_MSG_CHECKING([linker version script flag]) + AC_MSG_RESULT([disabled]) + + ax_check_vscript_flag= + ax_check_vscript_complex_wildcards=no + ]) + + AS_IF([test x$ax_check_vscript_flag != x], [ + VSCRIPT_LDFLAGS="-Wl,$ax_check_vscript_flag" + AC_SUBST([VSCRIPT_LDFLAGS]) + ]) + + AM_CONDITIONAL([HAVE_VSCRIPT], + [test x$ax_check_vscript_flag != x]) + AM_CONDITIONAL([HAVE_VSCRIPT_COMPLEX], + [test x$ax_check_vscript_complex_wildcards = xyes]) + +]) dnl AX_CHECK_VSCRIPT diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 1162d0778..5c065a903 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -911,7 +911,7 @@ static void set_scols_data(struct blkdev_cxt *cxt, int col, int id, struct libsc char md[11]; if (!st_rc) { - strmode(cxt->st.st_mode, md); + xstrmode(cxt->st.st_mode, md); str = xstrdup(md); } break; diff --git a/misc-utils/namei.c b/misc-utils/namei.c index 41557cac3..df678e003 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -44,10 +44,6 @@ #define MAXSYMLINKS 256 #endif -#ifndef LOGIN_NAME_MAX -#define LOGIN_NAME_MAX 256 -#endif - #define NAMEI_NOLINKS (1 << 1) #define NAMEI_MODES (1 << 2) #define NAMEI_MNTS (1 << 3) @@ -288,7 +284,7 @@ print_namei(struct namei *nm, char *path) return -1; } - strmode(nm->st.st_mode, md); + xstrmode(nm->st.st_mode, md); if (nm->mountpoint) md[0] = 'D'; diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c index 523859c6d..9e34e6b59 100644 --- a/sys-utils/lsipc.c +++ b/sys-utils/lsipc.c @@ -579,7 +579,7 @@ static void do_sem(int id, struct lsipc_control *ctl, struct libscols_table *tb) xasprintf(&arg, "%#o", semdsp->sem_perm.mode & 0777); else { arg = xmalloc(11); - strmode(semdsp->sem_perm.mode & 0777, arg); + xstrmode(semdsp->sem_perm.mode & 0777, arg); } rc = scols_line_refer_data(ln, n, arg); break; @@ -776,7 +776,7 @@ static void do_msg(int id, struct lsipc_control *ctl, struct libscols_table *tb) xasprintf(&arg, "%#o", msgdsp->msg_perm.mode & 0777); else { arg = xmalloc(11); - strmode(msgdsp->msg_perm.mode & 0777, arg); + xstrmode(msgdsp->msg_perm.mode & 0777, arg); rc = scols_line_refer_data(ln, n, arg); } break; @@ -928,7 +928,7 @@ static void do_shm(int id, struct lsipc_control *ctl, struct libscols_table *tb) xasprintf(&arg, "%#o", shmdsp->shm_perm.mode & 0777); else { arg = xmalloc(11); - strmode(shmdsp->shm_perm.mode & 0777, arg); + xstrmode(shmdsp->shm_perm.mode & 0777, arg); } rc = scols_line_refer_data(ln, n, arg); break; diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 7b8f17d55..71ae3f99e 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -233,7 +233,7 @@ static int read_process(struct lsns *ls, pid_t pid) if (!dir) return -errno; - p = calloc(1, sizeof(*p)); + p = xcalloc(1, sizeof(*p)); if (!p) { rc = -ENOMEM; goto done; @@ -338,7 +338,7 @@ static int namespace_has_process(struct lsns_namespace *ns, pid_t pid) static struct lsns_namespace *add_namespace(struct lsns *ls, int type, ino_t ino) { - struct lsns_namespace *ns = calloc(1, sizeof(*ns)); + struct lsns_namespace *ns = xcalloc(1, sizeof(*ns)); if (!ns) return NULL; diff --git a/tests/functions.sh b/tests/functions.sh index d3367e1a5..e639e7362 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -158,13 +158,15 @@ function ts_has_option { fi # or just check the global command line options - echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }' + if [[ $ALL =~ ([$' \t\n']|^)--$NAME([$'= \t\n']|$) ]]; then echo yes; fi } function ts_option_argument { NAME="$1" ALL="$2" - echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /'$NAME'=/ { print $2 }' + + # last option wins! + echo "$ALL" | sed -n "s/.*[ \t\n]--$NAME=\([^ \t\n]*\).*/\1/p" | tail -n 1 } function ts_init_core_env { diff --git a/tests/run.sh b/tests/run.sh index dca9c6c54..03cd9f5c2 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -34,6 +34,13 @@ function num_cpus() fi } +function find_test_scripts() +{ + local searchdir="$1" + find "$searchdir" -type f -regex ".*/[^\.~]*" \ + \( -perm -u=x -o -perm -g=x -o -perm -o=x \) +} + while [ -n "$1" ]; do case "$1" in --force) @@ -117,7 +124,7 @@ if [ -n "$SUBTESTS" ]; then # selected tests only for s in $SUBTESTS; do if [ -d "$top_srcdir/tests/ts/$s" ]; then - comps+=( $(find $top_srcdir/tests/ts/$s -type f -perm /a+x -regex ".*/[^\.~]*") ) + comps+=( $(find_test_scripts "$top_srcdir/tests/ts/$s") ) || exit 1 else echo "Unknown test component '$s'" exit 1 @@ -129,7 +136,7 @@ else exit 1 fi - comps=( $(find $top_srcdir/tests/ts/ -type f -perm /a+x -regex ".*/[^\.~]*") ) + comps=( $(find_test_scripts "$top_srcdir/tests/ts") ) || exit 1 fi if [ -n "$EXCLUDETESTS" ]; then diff --git a/tests/ts/build-sys/config b/tests/ts/build-sys/config index 15b355103..bc48c509d 100755 --- a/tests/ts/build-sys/config +++ b/tests/ts/build-sys/config @@ -32,7 +32,7 @@ for conf in $config_gen_dir/config-gen.d/*.conf; do ./configure $opts &> /dev/null make -j &> /dev/null - bins=$(find . -type f -perm /a+x | sort) + bins=$(find . -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | sort) for b in $bins; do libs=$(readelf --dynamic $b 2> /dev/null | \ awk '/NEEDED/ { print $5 }' | \ diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs index 78e5c1764..07f703f67 100755 --- a/tests/ts/cramfs/mkfs +++ b/tests/ts/cramfs/mkfs @@ -66,7 +66,7 @@ fi ts_cd "$IMAGE_SRC" ts_log "list checksums from original data" -find -type f -exec md5sum {} \; | sort >> $TS_OUTPUT +find . -type f -exec md5sum {} \; | sort >> $TS_OUTPUT echo >> $TS_OUTPUT ts_log "create cramfs image" diff --git a/text-utils/ul.c b/text-utils/ul.c index 7765b571e..115b88232 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -81,7 +81,7 @@ static void fwd(void); static void reverse(void); static void initinfo(void); static void outc(wint_t c, int width); -static void setmode(int newmode); +static void xsetmode(int newmode); static void setcol(int newcol); static void needcol(int col); static void sig_handler(int signo); @@ -368,7 +368,7 @@ static void flushln(void) for (i = 0; i < maxcol; i++) { if (obuf[i].c_mode != lastmode) { hadmodes++; - setmode(obuf[i].c_mode); + xsetmode(obuf[i].c_mode); lastmode = obuf[i].c_mode; } if (obuf[i].c_char == '\0') { @@ -382,7 +382,7 @@ static void flushln(void) i += obuf[i].c_width - 1; } if (lastmode != NORMAL) { - setmode(0); + xsetmode(0); } if (must_overstrike && hadmodes) overstrike(); @@ -560,11 +560,11 @@ static void outc(wint_t c, int width) { } } -static void setmode(int newmode) +static void xsetmode(int newmode) { if (!iflag) { if (curmode != NORMAL && newmode != NORMAL) - setmode(NORMAL); + xsetmode(NORMAL); switch (newmode) { case NORMAL: switch (curmode) { diff --git a/tools/checkmans.sh b/tools/checkmans.sh index 9a137780c..63da3d73e 100755 --- a/tools/checkmans.sh +++ b/tools/checkmans.sh @@ -70,7 +70,7 @@ remove_repeats() cd $(git rev-parse --show-toplevel) for I in $( - find -path './autom4te.cache' -prune -o -path './.libs' -prune -o -name '*[[:alpha:]].[1-8]' -print + find . -type f -name '*[[:alpha:]].[1-8]' |grep -v "autom4te.cache\|\.libs/" ); do MAN_FILE=${I##*/} MAN_LIST[${MAN_FILE%%.[0-9]}]=1