From 95d88436eaa840b93fc3eda4737d3aa6a04ea3fe Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 21 Dec 2021 20:34:23 +0900 Subject: [PATCH 1/2] errno-name: drop aliases defined for specific arch In kernel's arch/parisc/include/uapi/asm/errno.h, ECANCELLED and EREFUSED are defined as aliases of ECANCELED and ECONNREFUSED, respectively. Let's drop them. Fixes #21844. --- src/basic/generate-errno-list.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/basic/generate-errno-list.sh b/src/basic/generate-errno-list.sh index d2ce51e981..f756b2e020 100755 --- a/src/basic/generate-errno-list.sh +++ b/src/basic/generate-errno-list.sh @@ -3,5 +3,9 @@ set -eu set -o pipefail +# In kernel's arch/parisc/include/uapi/asm/errno.h, ECANCELLED and EREFUSED are defined as aliases of +# ECANCELED and ECONNREFUSED, respectively. Let's drop them. + ${1:?} -dM -include errno.h - Date: Wed, 22 Dec 2021 08:51:41 +0900 Subject: [PATCH 2/2] test: add test for errno-list.[ch] --- src/test/meson.build | 3 +++ src/test/test-errno-list.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/test-errno-list.c diff --git a/src/test/meson.build b/src/test/meson.build index 71d2422caf..9a1c481f22 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -574,6 +574,9 @@ tests += [ [['src/test/test-arphrd-util.c', generated_gperf_headers]], + [['src/test/test-errno-list.c', + generated_gperf_headers]], + [['src/test/test-ip-protocol-list.c', shared_generated_gperf_headers]], diff --git a/src/test/test-errno-list.c b/src/test/test-errno-list.c new file mode 100644 index 0000000000..6c8f384cab --- /dev/null +++ b/src/test/test-errno-list.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include + +#include "errno-list.h" +#include "errno-to-name.h" +#include "macro.h" +#include "string-util.h" +#include "tests.h" +#include "util.h" + +TEST(errno_list) { + for (size_t i = 0; i < ELEMENTSOF(errno_names); i++) { + if (errno_names[i]) { + assert_se(streq(errno_to_name(i), errno_names[i])); + assert_se(errno_from_name(errno_names[i]) == (int) i); + } + } + +#ifdef ECANCELLED + /* ECANCELLED is an alias of ECANCELED. */ + assert_se(streq(errno_to_name(ECANCELLED), "ECANCELED")); +#endif + assert_se(streq(errno_to_name(ECANCELED), "ECANCELED")); + +#ifdef EREFUSED + /* EREFUSED is an alias of ECONNREFUSED. */ + assert_se(streq(errno_to_name(EREFUSED), "ECONNREFUSED")); +#endif + assert_se(streq(errno_to_name(ECONNREFUSED), "ECONNREFUSED")); +} + +DEFINE_TEST_MAIN(LOG_INFO);