|
|
984f77 |
From 33305c6801c10b741b11a3f329dc339d2e8c5514 Mon Sep 17 00:00:00 2001
|
|
|
984f77 |
From: Lukas Nykryn <lnykryn@redhat.com>
|
|
|
984f77 |
Date: Thu, 18 Aug 2022 16:35:23 +0200
|
|
|
984f77 |
Subject: [PATCH] test-procfs-util: skip test on certain errors
|
|
|
984f77 |
|
|
|
984f77 |
Inspired by upstream bf47f71c1c
|
|
|
984f77 |
|
|
|
984f77 |
RHEL-only
|
|
|
984f77 |
Related: #2087152
|
|
|
984f77 |
---
|
|
|
984f77 |
src/shared/tests.c | 12 ++++++++++++
|
|
|
984f77 |
src/shared/tests.h | 2 ++
|
|
|
984f77 |
src/test/test-procfs-util.c | 6 ++++--
|
|
|
984f77 |
3 files changed, 18 insertions(+), 2 deletions(-)
|
|
|
984f77 |
|
|
|
984f77 |
diff --git a/src/shared/tests.c b/src/shared/tests.c
|
|
|
984f77 |
index 1da80d653f..b1c71b992f 100644
|
|
|
984f77 |
--- a/src/shared/tests.c
|
|
|
984f77 |
+++ b/src/shared/tests.c
|
|
|
984f77 |
@@ -78,6 +78,18 @@ void test_setup_logging(int level) {
|
|
|
984f77 |
log_open();
|
|
|
984f77 |
}
|
|
|
984f77 |
|
|
|
984f77 |
+int log_tests_skipped(const char *message) {
|
|
|
984f77 |
+ log_notice("%s: %s, skipping tests.",
|
|
|
984f77 |
+ program_invocation_short_name, message);
|
|
|
984f77 |
+ return EXIT_TEST_SKIP;
|
|
|
984f77 |
+}
|
|
|
984f77 |
+
|
|
|
984f77 |
+int log_tests_skipped_errno(int r, const char *message) {
|
|
|
984f77 |
+ log_notice_errno(r, "%s: %s, skipping tests: %m",
|
|
|
984f77 |
+ program_invocation_short_name, message);
|
|
|
984f77 |
+ return EXIT_TEST_SKIP;
|
|
|
984f77 |
+}
|
|
|
984f77 |
+
|
|
|
984f77 |
const char *ci_environment(void) {
|
|
|
984f77 |
/* We return a string because we might want to provide multiple bits of information later on: not
|
|
|
984f77 |
* just the general CI environment type, but also whether we're sanitizing or not, etc. The caller is
|
|
|
984f77 |
diff --git a/src/shared/tests.h b/src/shared/tests.h
|
|
|
984f77 |
index 4f8f349097..d50711338c 100644
|
|
|
984f77 |
--- a/src/shared/tests.h
|
|
|
984f77 |
+++ b/src/shared/tests.h
|
|
|
984f77 |
@@ -5,6 +5,8 @@ char* setup_fake_runtime_dir(void);
|
|
|
984f77 |
bool test_is_running_from_builddir(char **exedir);
|
|
|
984f77 |
const char* get_testdata_dir(void);
|
|
|
984f77 |
void test_setup_logging(int level);
|
|
|
984f77 |
+int log_tests_skipped(const char *message);
|
|
|
984f77 |
+int log_tests_skipped_errno(int r, const char *message);
|
|
|
984f77 |
|
|
|
984f77 |
/* Provide a convenient way to check if we're running in CI. */
|
|
|
984f77 |
const char *ci_environment(void);
|
|
|
984f77 |
diff --git a/src/test/test-procfs-util.c b/src/test/test-procfs-util.c
|
|
|
984f77 |
index d656c4df4f..aba5692e54 100644
|
|
|
984f77 |
--- a/src/test/test-procfs-util.c
|
|
|
984f77 |
+++ b/src/test/test-procfs-util.c
|
|
|
984f77 |
@@ -7,6 +7,7 @@
|
|
|
984f77 |
#include "procfs-util.h"
|
|
|
984f77 |
#include "process-util.h"
|
|
|
984f77 |
#include "util.h"
|
|
|
984f77 |
+#include "tests.h"
|
|
|
984f77 |
|
|
|
984f77 |
int main(int argc, char *argv[]) {
|
|
|
984f77 |
char buf[CONST_MAX(FORMAT_TIMESPAN_MAX, FORMAT_BYTES_MAX)];
|
|
|
984f77 |
@@ -52,8 +53,9 @@ int main(int argc, char *argv[]) {
|
|
|
984f77 |
log_info("Reducing limit by one to %"PRIu64"…", v-1);
|
|
|
984f77 |
|
|
|
984f77 |
r = procfs_tasks_set_limit(v-1);
|
|
|
984f77 |
- log_info_errno(r, "procfs_tasks_set_limit: %m");
|
|
|
984f77 |
- assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);
|
|
|
984f77 |
+ if (IN_SET(r, -ENOENT, -EROFS) || ERRNO_IS_PRIVILEGE(r))
|
|
|
984f77 |
+ return log_tests_skipped_errno(r, "can't set tasks limit");
|
|
|
984f77 |
+ assert_se(r >= 0);
|
|
|
984f77 |
|
|
|
984f77 |
assert_se(procfs_get_threads_max(&w) >= 0);
|
|
|
984f77 |
assert_se(r >= 0 ? w == v - 1 : w == v);
|