import UBI systemd-252-51.el9_6.2
This commit is contained in:
parent
9442ce4fe5
commit
ce6dba91ac
63
SOURCES/1112-Add-a-set-of-assertion-macros-to-tests.h.patch
Normal file
63
SOURCES/1112-Add-a-set-of-assertion-macros-to-tests.h.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From 91a2b272197bad53fc192e72dc8fdd87f4b7989a Mon Sep 17 00:00:00 2001
|
||||
From: Unique-Usman <usmanakinyemi202@gmail.com>
|
||||
Date: Sat, 16 Mar 2024 04:04:11 +0530
|
||||
Subject: [PATCH] Add a set of assertion macros to tests.h (ASSERT_OK(),
|
||||
ASSERT_EQ(), ASSERT_GE(), ASSERT_LE()) that log the failed condition before
|
||||
crashing and convert test-gpt.c test file to use them
|
||||
|
||||
[dtardon: Only the macro definitions have been backported.]
|
||||
|
||||
(cherry picked from commit e19186359a25ec56d1dd0a68def06aff1bbb19bb)
|
||||
|
||||
Related: RHEL-108481
|
||||
---
|
||||
src/shared/tests.h | 39 +++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 39 insertions(+)
|
||||
|
||||
diff --git a/src/shared/tests.h b/src/shared/tests.h
|
||||
index 3cf34d9bcc..97c83ce434 100644
|
||||
--- a/src/shared/tests.h
|
||||
+++ b/src/shared/tests.h
|
||||
@@ -143,3 +143,42 @@ static inline int run_test_table(void) {
|
||||
DEFINE_TEST_MAIN_FULL(log_level, intro, NULL)
|
||||
#define DEFINE_TEST_MAIN(log_level) \
|
||||
DEFINE_TEST_MAIN_FULL(log_level, NULL, NULL)
|
||||
+
|
||||
+#define ASSERT_OK(expr) \
|
||||
+ ({ \
|
||||
+ int _result = (expr); \
|
||||
+ if (_result < 0) { \
|
||||
+ log_error_errno("Assertion failed: %s (result: %d, error: %m)", #expr, _result); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_EQ(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ int _expr1 = (expr1); \
|
||||
+ int _expr2 = (expr2); \
|
||||
+ if (_expr1 != _expr2) { \
|
||||
+ log_error("Assertion failed: expected %s == %s, but %d != %d", #expr1, #expr2, _expr1, _expr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_GE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ int _expr1 = (expr1); \
|
||||
+ int _expr2 = (expr2); \
|
||||
+ if (_expr1 < _expr2) { \
|
||||
+ log_error("Assertion failed: expected %s >= %s, but %d < %d", #expr1, #expr2, _expr1, _expr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_LE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ int _expr1 = (expr1); \
|
||||
+ int _expr2 = (expr2); \
|
||||
+ if (_expr1 > _expr2) { \
|
||||
+ log_error("Assertion failed: expected %s <= %s, but %d > %d", #expr1, #expr2, _expr1, _expr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
133
SOURCES/1113-Follow-up-with-the-PR-31819.patch
Normal file
133
SOURCES/1113-Follow-up-with-the-PR-31819.patch
Normal file
@ -0,0 +1,133 @@
|
||||
From db3e52ff1f2d911699e9ede04264455548ad39c9 Mon Sep 17 00:00:00 2001
|
||||
From: Unique-Usman <usmanakinyemi202@gmail.com>
|
||||
Date: Tue, 19 Mar 2024 18:20:29 +0530
|
||||
Subject: [PATCH] Follow up with the PR #31819
|
||||
|
||||
(cherry picked from commit c0cd99eee69fd9c0a66e7167784d01a49f93b13f)
|
||||
|
||||
Related: RHEL-108481
|
||||
---
|
||||
src/basic/macro.h | 13 +++++++
|
||||
src/shared/tests.h | 85 ++++++++++++++++++++++++++++------------------
|
||||
2 files changed, 65 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/src/basic/macro.h b/src/basic/macro.h
|
||||
index c2934f9951..8ed4270a14 100644
|
||||
--- a/src/basic/macro.h
|
||||
+++ b/src/basic/macro.h
|
||||
@@ -466,4 +466,17 @@ assert_cc(sizeof(dummy_t) == 0);
|
||||
((long)(_current_ - _entries_) < (long)ELEMENTSOF(_entries_)) && ({ entry = *_current_; true; }); \
|
||||
_current_++)
|
||||
|
||||
+#define DECIMAL_STR_FMT(x) _Generic((x), \
|
||||
+ char: "%c", \
|
||||
+ bool: "%d", \
|
||||
+ unsigned char: "%d", \
|
||||
+ short: "%hd", \
|
||||
+ unsigned short: "%hu", \
|
||||
+ int: "%d", \
|
||||
+ unsigned: "%u", \
|
||||
+ long: "%ld", \
|
||||
+ unsigned long: "%lu", \
|
||||
+ long long: "%lld", \
|
||||
+ unsigned long long: "%llu")
|
||||
+
|
||||
#include "log.h"
|
||||
diff --git a/src/shared/tests.h b/src/shared/tests.h
|
||||
index 97c83ce434..89248d171a 100644
|
||||
--- a/src/shared/tests.h
|
||||
+++ b/src/shared/tests.h
|
||||
@@ -144,41 +144,60 @@ static inline int run_test_table(void) {
|
||||
#define DEFINE_TEST_MAIN(log_level) \
|
||||
DEFINE_TEST_MAIN_FULL(log_level, NULL, NULL)
|
||||
|
||||
-#define ASSERT_OK(expr) \
|
||||
- ({ \
|
||||
- int _result = (expr); \
|
||||
- if (_result < 0) { \
|
||||
- log_error_errno("Assertion failed: %s (result: %d, error: %m)", #expr, _result); \
|
||||
- abort(); \
|
||||
- } \
|
||||
+#define ASSERT_OK(expr) \
|
||||
+ ({ \
|
||||
+ typeof(expr) _result = (expr); \
|
||||
+ if (_result < 0) { \
|
||||
+ log_error_errno(_result, "%s:%i: Assertion failed: %s: %m", \
|
||||
+ PROJECT_FILE, __LINE__, #expr); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+/* DECIMAL_STR_FMT() uses _Generic which cannot be used in string concatenation so we have to format the
|
||||
+ * input into strings first and then format those into the final assertion message. */
|
||||
+
|
||||
+#define ASSERT_EQ(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 != _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s == %s\", but \"%s != %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
})
|
||||
|
||||
-#define ASSERT_EQ(expr1, expr2) \
|
||||
- ({ \
|
||||
- int _expr1 = (expr1); \
|
||||
- int _expr2 = (expr2); \
|
||||
- if (_expr1 != _expr2) { \
|
||||
- log_error("Assertion failed: expected %s == %s, but %d != %d", #expr1, #expr2, _expr1, _expr2); \
|
||||
- abort(); \
|
||||
- } \
|
||||
+#define ASSERT_GE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 < _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s >= %s\", but \"%s < %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
})
|
||||
|
||||
-#define ASSERT_GE(expr1, expr2) \
|
||||
- ({ \
|
||||
- int _expr1 = (expr1); \
|
||||
- int _expr2 = (expr2); \
|
||||
- if (_expr1 < _expr2) { \
|
||||
- log_error("Assertion failed: expected %s >= %s, but %d < %d", #expr1, #expr2, _expr1, _expr2); \
|
||||
- abort(); \
|
||||
- } \
|
||||
- })
|
||||
-
|
||||
-#define ASSERT_LE(expr1, expr2) \
|
||||
- ({ \
|
||||
- int _expr1 = (expr1); \
|
||||
- int _expr2 = (expr2); \
|
||||
- if (_expr1 > _expr2) { \
|
||||
- log_error("Assertion failed: expected %s <= %s, but %d > %d", #expr1, #expr2, _expr1, _expr2); \
|
||||
- abort(); \
|
||||
- } \
|
||||
+#define ASSERT_LE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 > _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s <= %s\", but \"%s > %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
})
|
@ -0,0 +1,201 @@
|
||||
From c6d8c9e1d90a26789aefcfa66903b48f859a7d76 Mon Sep 17 00:00:00 2001
|
||||
From: Unique-Usman <usmanakinyemi202@gmail.com>
|
||||
Date: Wed, 20 Mar 2024 23:05:55 +0530
|
||||
Subject: [PATCH] Added more ASSERT macro and also make some test file to use
|
||||
them
|
||||
|
||||
[dtardon: Only the macro definitions have been backported.]
|
||||
|
||||
(cherry picked from commit 5f0e4d2fb4188b58dd24c749a732faf6fef1f75b)
|
||||
|
||||
Related: RHEL-108481
|
||||
---
|
||||
src/shared/tests.h | 170 ++++++++++++++++++++++++++++++++++-----------
|
||||
1 file changed, 131 insertions(+), 39 deletions(-)
|
||||
|
||||
diff --git a/src/shared/tests.h b/src/shared/tests.h
|
||||
index 89248d171a..8a3b928dfd 100644
|
||||
--- a/src/shared/tests.h
|
||||
+++ b/src/shared/tests.h
|
||||
@@ -154,50 +154,142 @@ static inline int run_test_table(void) {
|
||||
} \
|
||||
})
|
||||
|
||||
+#define ASSERT_TRUE(expr) \
|
||||
+ ({ \
|
||||
+ if (!(expr)) { \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s\" to be true", \
|
||||
+ PROJECT_FILE, __LINE__, #expr); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_FALSE(expr) \
|
||||
+ ({ \
|
||||
+ if ((expr)) { \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s\" to be false", \
|
||||
+ PROJECT_FILE, __LINE__, #expr); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_NULL(expr) \
|
||||
+ ({ \
|
||||
+ if ((expr) != NULL) { \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s\" to be NULL", \
|
||||
+ PROJECT_FILE, __LINE__, #expr); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_NOT_NULL(expr) \
|
||||
+ ({ \
|
||||
+ if ((expr) == NULL) { \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s\" to be not NULL", \
|
||||
+ PROJECT_FILE, __LINE__, #expr); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_STREQ(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ const char* _expr1 = (expr1); \
|
||||
+ const char* _expr2 = (expr2); \
|
||||
+ if (strcmp(_expr1, _expr2) != 0) { \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s == %s\", but \"%s != %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _expr1, _expr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
/* DECIMAL_STR_FMT() uses _Generic which cannot be used in string concatenation so we have to format the
|
||||
* input into strings first and then format those into the final assertion message. */
|
||||
|
||||
-#define ASSERT_EQ(expr1, expr2) \
|
||||
- ({ \
|
||||
- typeof(expr1) _expr1 = (expr1); \
|
||||
- typeof(expr2) _expr2 = (expr2); \
|
||||
- if (_expr1 != _expr2) { \
|
||||
- char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
- char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
- xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
- xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
- log_error("%s:%i: Assertion failed: expected \"%s == %s\", but \"%s != %s\"", \
|
||||
- PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
- abort(); \
|
||||
- } \
|
||||
+#define ASSERT_EQ(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 != _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s == %s\", but \"%s != %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_GE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 < _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s >= %s\", but \"%s < %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_LE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 > _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s <= %s\", but \"%s > %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
+ })
|
||||
+
|
||||
+#define ASSERT_NE(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (_expr1 == _expr2) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s != %s\", but \"%s == %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
})
|
||||
|
||||
-#define ASSERT_GE(expr1, expr2) \
|
||||
- ({ \
|
||||
- typeof(expr1) _expr1 = (expr1); \
|
||||
- typeof(expr2) _expr2 = (expr2); \
|
||||
- if (_expr1 < _expr2) { \
|
||||
- char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
- char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
- xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
- xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
- log_error("%s:%i: Assertion failed: expected \"%s >= %s\", but \"%s < %s\"", \
|
||||
- PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
- abort(); \
|
||||
- } \
|
||||
+#define ASSERT_GT(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (!(_expr1 > _expr2)) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s > %s\", but \"%s <= %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
})
|
||||
|
||||
-#define ASSERT_LE(expr1, expr2) \
|
||||
- ({ \
|
||||
- typeof(expr1) _expr1 = (expr1); \
|
||||
- typeof(expr2) _expr2 = (expr2); \
|
||||
- if (_expr1 > _expr2) { \
|
||||
- char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
- char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
- xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
- xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
- log_error("%s:%i: Assertion failed: expected \"%s <= %s\", but \"%s > %s\"", \
|
||||
- PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
- abort(); \
|
||||
- } \
|
||||
+#define ASSERT_LT(expr1, expr2) \
|
||||
+ ({ \
|
||||
+ typeof(expr1) _expr1 = (expr1); \
|
||||
+ typeof(expr2) _expr2 = (expr2); \
|
||||
+ if (!(_expr1 < _expr2)) { \
|
||||
+ char _sexpr1[DECIMAL_STR_MAX(typeof(expr1))]; \
|
||||
+ char _sexpr2[DECIMAL_STR_MAX(typeof(expr2))]; \
|
||||
+ xsprintf(_sexpr1, DECIMAL_STR_FMT(_expr1), _expr1); \
|
||||
+ xsprintf(_sexpr2, DECIMAL_STR_FMT(_expr2), _expr2); \
|
||||
+ log_error("%s:%i: Assertion failed: expected \"%s < %s\", but \"%s >= %s\"", \
|
||||
+ PROJECT_FILE, __LINE__, #expr1, #expr2, _sexpr1, _sexpr2); \
|
||||
+ abort(); \
|
||||
+ } \
|
||||
})
|
@ -0,0 +1,37 @@
|
||||
From 9182df9ad2cc9e426fe1873cdcb25cc4390c0443 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 20 Jul 2025 02:12:00 +0900
|
||||
Subject: [PATCH] sd-event: drop inotify event from buffer when no event source
|
||||
is triggered
|
||||
|
||||
Even when we receive an inotify event, there is no relevant event source
|
||||
exists. In that case, we need to drop the event from the buffer,
|
||||
otherwise we cannot escape from the loop.
|
||||
|
||||
Fixes #38265.
|
||||
|
||||
(cherry picked from commit 064b9b2bb3544707171662f548677259c3d6aa7f)
|
||||
|
||||
Resolves: RHEL-108481
|
||||
---
|
||||
src/libsystemd/sd-event/sd-event.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||||
index f15115c57f..79b2fa6789 100644
|
||||
--- a/src/libsystemd/sd-event/sd-event.c
|
||||
+++ b/src/libsystemd/sd-event/sd-event.c
|
||||
@@ -3579,9 +3579,12 @@ static int event_inotify_data_process(sd_event *e, struct inotify_data *d) {
|
||||
}
|
||||
}
|
||||
|
||||
- /* Something pending now? If so, let's finish, otherwise let's read more. */
|
||||
+ /* Something pending now? If so, let's finish. */
|
||||
if (d->n_pending > 0)
|
||||
return 1;
|
||||
+
|
||||
+ /* otherwise, drop the event and let's read more */
|
||||
+ event_inotify_data_drop(e, d, sz);
|
||||
}
|
||||
|
||||
return 0;
|
63
SOURCES/1116-test-add-test-case-for-issue-38265.patch
Normal file
63
SOURCES/1116-test-add-test-case-for-issue-38265.patch
Normal file
@ -0,0 +1,63 @@
|
||||
From b998f7aa0752b8fd35ea873af37887e26ba9384a Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 20 Jul 2025 01:27:10 +0900
|
||||
Subject: [PATCH] test: add test case for issue #38265
|
||||
|
||||
(cherry picked from commit b92258eb229f84680b91e744e98d72429710770e)
|
||||
|
||||
Related: RHEL-108481
|
||||
---
|
||||
src/libsystemd/sd-event/test-event.c | 35 ++++++++++++++++++++++++++++
|
||||
1 file changed, 35 insertions(+)
|
||||
|
||||
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
|
||||
index 246658d024..daf2ed3ec1 100644
|
||||
--- a/src/libsystemd/sd-event/test-event.c
|
||||
+++ b/src/libsystemd/sd-event/test-event.c
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "alloc-util.h"
|
||||
#include "exec-util.h"
|
||||
#include "fd-util.h"
|
||||
+#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "log.h"
|
||||
#include "macro.h"
|
||||
@@ -809,4 +810,38 @@ TEST(inotify_process_buffered_data) {
|
||||
assert_se(sd_event_wait(e, 0) == 0);
|
||||
}
|
||||
|
||||
+static int inotify_handler_issue_38265(sd_event_source *s, const struct inotify_event *event, void *userdata) {
|
||||
+ log_debug("Inotify event: mask=0x%x name=%s", event->mask, event->name);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+TEST(inotify_issue_38265) {
|
||||
+ _cleanup_(rm_rf_physical_and_freep) char *t = NULL;
|
||||
+ _cleanup_(sd_event_source_unrefp) sd_event_source *a = NULL, *b = NULL;
|
||||
+ _cleanup_(sd_event_unrefp) sd_event *e = NULL;
|
||||
+ _cleanup_free_ char *p = NULL;
|
||||
+
|
||||
+ /* For issue #38265. */
|
||||
+
|
||||
+ ASSERT_OK(mkdtemp_malloc("/tmp/test-inotify-XXXXXX", &t));
|
||||
+
|
||||
+ ASSERT_OK(sd_event_default(&e));
|
||||
+
|
||||
+ /* Create inode data that watches IN_MODIFY */
|
||||
+ ASSERT_OK(sd_event_add_inotify(e, &a, t, IN_CREATE | IN_MODIFY, inotify_handler_issue_38265, NULL));
|
||||
+ ASSERT_OK(sd_event_add_inotify(e, &b, t, IN_CREATE, inotify_handler_issue_38265, NULL));
|
||||
+
|
||||
+ /* Then drop the event source that is interested in IN_MODIFY */
|
||||
+ ASSERT_NULL(a = sd_event_source_unref(a));
|
||||
+
|
||||
+ /* Trigger IN_MODIFY (of course with IN_CREATE) */
|
||||
+ ASSERT_NOT_NULL(p = path_join(t, "hoge"));
|
||||
+ ASSERT_OK(write_string_file(p, "aaa", WRITE_STRING_FILE_CREATE));
|
||||
+
|
||||
+ for (unsigned i = 1; i < 5; i++) {
|
||||
+ log_debug("Running event loop cycle %u to process inotify events...", i);
|
||||
+ ASSERT_OK(sd_event_run(e, USEC_PER_MSEC));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
DEFINE_TEST_MAIN(LOG_DEBUG);
|
@ -21,7 +21,7 @@
|
||||
Name: systemd
|
||||
Url: https://systemd.io
|
||||
Version: 252
|
||||
Release: 51%{?dist}.1
|
||||
Release: 51%{?dist}.2
|
||||
# For a breakdown of the licensing, see README
|
||||
License: LGPLv2+ and MIT and GPLv2+
|
||||
Summary: System and Service Manager
|
||||
@ -1194,6 +1194,11 @@ Patch1108: 1108-Fix-failing-test.patch
|
||||
Patch1109: 1109-unit-don-t-gc-unit-in-oom-queue.patch
|
||||
Patch1110: 1110-core-do-not-GC-units-jobs-that-are-in-the-D-Bus-queu.patch
|
||||
Patch1111: 1111-unit-always-return-1-in-log_kill.patch
|
||||
Patch1112: 1112-Add-a-set-of-assertion-macros-to-tests.h.patch
|
||||
Patch1113: 1113-Follow-up-with-the-PR-31819.patch
|
||||
Patch1114: 1114-Added-more-ASSERT-macro-and-also-make-some-test-file.patch
|
||||
Patch1115: 1115-sd-event-drop-inotify-event-from-buffer-when-no-even.patch
|
||||
Patch1116: 1116-test-add-test-case-for-issue-38265.patch
|
||||
|
||||
# Downstream-only patches (9000–9999)
|
||||
|
||||
@ -2071,6 +2076,13 @@ systemd-hwdb update &>/dev/null || :
|
||||
%{_prefix}/lib/dracut/modules.d/70rhel-net-naming-sysattrs/*
|
||||
|
||||
%changelog
|
||||
* Mon Aug 11 2025 systemd maintenance team <systemd-maint@redhat.com> - 252-51.2
|
||||
- Add a set of assertion macros to tests.h (ASSERT_OK(), ASSERT_EQ(), ASSERT_GE(), ASSERT_LE()) that log the failed condition before crashing and convert test-gpt.c test file to use them (RHEL-108481)
|
||||
- Follow up with the PR #31819 (RHEL-108481)
|
||||
- Added more ASSERT macro and also make some test file to use them (RHEL-108481)
|
||||
- sd-event: drop inotify event from buffer when no event source is triggered (RHEL-108481)
|
||||
- test: add test case for issue #38265 (RHEL-108481)
|
||||
|
||||
* Tue Apr 08 2025 systemd maintenance team <systemd-maint@redhat.com> - 252-51.1
|
||||
- unit: always return 1 in log_kill (RHEL-86239)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user