代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From b69552ccc0e33f713ae3a2baf1b0173cf221507d Mon Sep 17 00:00:00 2001
From: Yu Watanabe <[email protected]>
Date: Tue, 11 Sep 2018 09:17:22 +0900
Subject: [PATCH] test: introduce test_is_running_from_builddir()
(cherry picked from commit 8cb10a4f4dabc508a04f76ea55f23ef517881b61)
Resolves: #1823767
---
src/shared/tests.c | 23 ++++++++++++++++++++---
src/shared/tests.h | 1 +
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/shared/tests.c b/src/shared/tests.c
index b10343650f..c77eb00924 100644
--- a/src/shared/tests.c
+++ b/src/shared/tests.c
@@ -19,6 +19,24 @@ char* setup_fake_runtime_dir(void) {
return p;
}
+bool test_is_running_from_builddir(char **exedir) {
+ _cleanup_free_ char *s = NULL;
+ bool r;
+
+ /* Check if we're running from the builddir. Optionally, this returns
+ * the path to the directory where the binary is located. */
+
+ assert_se(readlink_and_make_absolute("/proc/self/exe", &s) >= 0);
+ r = path_startswith(s, ABS_BUILD_DIR);
+
+ if (exedir) {
+ dirname(s);
+ *exedir = TAKE_PTR(s);
+ }
+
+ return r;
+}
+
const char* get_testdata_dir(const char *suffix) {
const char *env;
/* convenience: caller does not need to free result */
@@ -35,14 +53,13 @@ const char* get_testdata_dir(const char *suffix) {
strncpy(testdir, env, sizeof(testdir) - 1);
} else {
_cleanup_free_ char *exedir = NULL;
- assert_se(readlink_and_make_absolute("/proc/self/exe", &exedir) >= 0);
/* Check if we're running from the builddir. If so, use the compiled in path. */
- if (path_startswith(exedir, ABS_BUILD_DIR))
+ if (test_is_running_from_builddir(&exedir))
assert_se(snprintf(testdir, sizeof(testdir), "%s/test", ABS_SRC_DIR) > 0);
else
/* Try relative path, according to the install-test layout */
- assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", dirname(exedir)) > 0);
+ assert_se(snprintf(testdir, sizeof(testdir), "%s/testdata", exedir) > 0);
/* test this without the suffix, as it may contain a glob */
if (access(testdir, F_OK) < 0) {
diff --git a/src/shared/tests.h b/src/shared/tests.h
index cad21169f8..7f45c32d32 100644
--- a/src/shared/tests.h
+++ b/src/shared/tests.h
@@ -2,5 +2,6 @@
#pragma once
char* setup_fake_runtime_dir(void);
+bool test_is_running_from_builddir(char **exedir);
const char* get_testdata_dir(const char *suffix);
void test_setup_logging(int level);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。