elogind: import upstream musl fixes for test-hexdecot and test-parse-util.

Closes: #11109 [via git-merge-pr]
This commit is contained in:
maxice8 2018-01-26 22:30:26 -02:00 committed by Jürgen Buchmüller
parent 41d26fff83
commit 86553e7d0a
4 changed files with 52 additions and 19 deletions

View file

@ -1,18 +0,0 @@
--- src/test/meson.build
+++ src/test/meson.build
@@ -198,10 +198,11 @@ tests += [
[],
[]],
- [['src/test/test-hexdecoct.c'],
- [],
- []],
-
+#if 0 /// FAILS TO COMPILE ON MUSL LIBC SYSTEMS
+# [['src/test/test-hexdecoct.c'],
+# [],
+# []],
+#endif //0
[['src/test/test-alloc-util.c'],
[],
[]],

View file

@ -0,0 +1,37 @@
--- src/shared/musl_missing.h
+++ src/shared/musl_missing.h
@@ -55,13 +55,14 @@ extern char *program_invocation_short_name;
/* strndupa may already be defined in another compatibility header */
#if !defined(strndupa)
-#define strndupa(src, n) \
- (__extension__ ({const char *in = (src); \
- size_t len = strnlen(in, (n)) + 1; \
- char *out = (char *) alloca(len); \
- out[len-1] = '\0'; \
- (char *) memcpy(out, in, len-1);}) \
- )
+#define strndupa(x_src, x_n) \
+ (__extension__ ( { \
+ const char* x_in = (x_src); \
+ size_t x_len = strnlen(x_in, (x_n)) + 1; \
+ char* x_out = (char *) alloca(x_len); \
+ x_out[x_len-1] = '\0'; \
+ (char *) memcpy(x_out, x_in, x_len-1); \
+ } ) )
#endif
/* See http://man7.org/linux/man-pages/man3/canonicalize_file_name.3.html */
--- src/test/test-hexdecoct.c
+++ src/test/test-hexdecoct.c
@@ -22,6 +22,9 @@
#include "macro.h"
#include "string-util.h"
+/// Additional includes needed by elogind
+#include "musl_missing.h"
+
static void test_hexchar(void) {
assert_se(hexchar(0xa) == 'a');
assert_se(hexchar(0x0) == '0');

View file

@ -0,0 +1,14 @@
--- src/test/test-parse-util.c
+++ src/test/test-parse-util.c
@@ -526,7 +526,10 @@ static void test_safe_atod(void) {
assert_se(r == -EINVAL);
errno = 0;
+/// elogind supports musl_libc, and their strtod doesn't seem to use the set locale.
+#if defined(__GLIBC__)
assert_se(fabs(strtod("0,5", &e) - 0.5) < 0.00001);
+#endif // __GLIBC__
}
/* And check again, reset */

View file

@ -1,7 +1,7 @@
# Template file for 'elogind'
pkgname=elogind
version=235.2
revision=2
revision=3
build_style=meson
hostmakedepends="intltool pkg-config gperf docbook-xsl gettext-devel shadow m4 libxslt git"
makedepends="libcap-devel libmount-devel libseccomp-devel libblkid-devel pam-devel gettext-devel eudev-libudev-devel acl-devel glib-devel"