From 8b02ade2818d86f29965dae61918456330f38d55 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 30 Nov 2020 13:35:46 -0700 Subject: [PATCH] LU-13855 tests: remove the need for libiberty The statx.c test program uses a bunch of GNU-specific xstr* functions that have very little, if any, benefit to the code. They allocate copies of static format strings, but those strings are not modified, and are never freed. Since the use of xstr* drags in libiberty and associated build issues on a variety of platforms, instead avoid those functions. Remove the use of this library completely from the statx.c test tool, with minimal replacements to keep the build happy. Remove the corresponding configure checks. Fixes: 3f7853b31ef6 ("LU-10934 llite: integrate statx() API with Lustre") Test-Parameters: trivial testlist=sanityn env=ONLY=106 clientdistro=ubuntu2004 Signed-off-by: Andreas Dilger Change-Id: I2c11bac8e2a4b4754ee78caabfa9cbdba98bffff Reviewed-on: https://review.whamcloud.com/40802 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yingjin Qian Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- config/lustre-build.m4 | 1 - debian/control | 2 +- debian/control.main | 2 +- lustre/tests/Makefile.am | 5 +---- lustre/tests/statx.c | 16 +++++++++++++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index ad23218..a4abb21 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -440,7 +440,6 @@ AM_CONDITIONAL([RHEL], [test -f /etc/redhat-release]) AM_CONDITIONAL([SUSE], [test -f /etc/SUSE-brand -o -f /etc/SuSE-release]) AM_CONDITIONAL([UBUNTU], [test x$UBUNTU_KERNEL = xyes]) AM_CONDITIONAL([BUILD_LUTF], [test x$enable_lutf = xyes]) -AM_CONDITIONAL([LIBIBERTY_SUBDIR], [test -d /usr/include/libiberty]) LN_CONDITIONALS LC_CONDITIONALS diff --git a/debian/control b/debian/control index 7bfa5b7..ead0fdd 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: Brian J. Murrell Uploaders: Brian J. Murrell Standards-Version: 3.8.3 -Build-Depends: module-assistant, libreadline-dev, debhelper (>=9.0.0), dpatch, automake (>=1.7) | automake1.7 | automake1.8 | automake1.9, pkg-config, libtool, libyaml-dev, libselinux-dev, libsnmp-dev, mpi-default-dev, bzip2, quilt, linux-headers-generic | linux-headers | linux-headers-amd64, rsync, libssl-dev, libiberty-dev +Build-Depends: module-assistant, libreadline-dev, debhelper (>=9.0.0), dpatch, automake (>=1.7) | automake1.7 | automake1.8 | automake1.9, pkg-config, libtool, libyaml-dev, libselinux-dev, libsnmp-dev, mpi-default-dev, bzip2, quilt, linux-headers-generic | linux-headers | linux-headers-amd64, rsync, libssl-dev Homepage: https://wiki.whamcloud.com/ Vcs-Git: git://git.whamcloud.com/fs/lustre-release.git diff --git a/debian/control.main b/debian/control.main index 7bfa5b7..ead0fdd 100644 --- a/debian/control.main +++ b/debian/control.main @@ -4,7 +4,7 @@ Priority: optional Maintainer: Brian J. Murrell Uploaders: Brian J. Murrell Standards-Version: 3.8.3 -Build-Depends: module-assistant, libreadline-dev, debhelper (>=9.0.0), dpatch, automake (>=1.7) | automake1.7 | automake1.8 | automake1.9, pkg-config, libtool, libyaml-dev, libselinux-dev, libsnmp-dev, mpi-default-dev, bzip2, quilt, linux-headers-generic | linux-headers | linux-headers-amd64, rsync, libssl-dev, libiberty-dev +Build-Depends: module-assistant, libreadline-dev, debhelper (>=9.0.0), dpatch, automake (>=1.7) | automake1.7 | automake1.8 | automake1.9, pkg-config, libtool, libyaml-dev, libselinux-dev, libsnmp-dev, mpi-default-dev, bzip2, quilt, linux-headers-generic | linux-headers | linux-headers-amd64, rsync, libssl-dev Homepage: https://wiki.whamcloud.com/ Vcs-Git: git://git.whamcloud.com/fs/lustre-release.git diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index 4890031..f736fca 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -117,8 +117,5 @@ check_fallocate_LDADD = $(LIBLUSTREAPI) if LIBAIO aiocp_LDADD= -laio endif -if LIBIBERTY_SUBDIR -statx_CPPFLAGS := -I/usr/include/libiberty -endif -statx_LDADD = $(SELINUX) -liberty +statx_LDADD = $(SELINUX) endif # TESTS diff --git a/lustre/tests/statx.c b/lustre/tests/statx.c index a3fbbeb..d5c2e88 100644 --- a/lustre/tests/statx.c +++ b/lustre/tests/statx.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #ifdef HAVE_SELINUX @@ -86,6 +85,21 @@ ssize_t statx(int dfd, const char *filename, int flags, } #endif /* HAVE_STATX */ +#define xstrdup(str) strdup(str) +static inline +char *xasprintf(const char *fmt, const char *old_fmt, const char *str) +{ + char *tmp = NULL; + + if (asprintf(&tmp, fmt, old_fmt, str) < 0) { + fprintf(stderr, "asprintf allocation failed\n"); + exit(1); + } + + return tmp; +} + + /* coreutils/lib/intprops.h */ #define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED(__typeof__(t)) -- 1.8.3.1