1 Star 0 Fork 49

YYNA/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0366-test-make-test-catalog-relocatable.patch 3.37 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From ac476ab0ce970e4a269fee34a15e24f6b20962b7 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Tue, 11 Sep 2018 09:18:33 +0900
Subject: [PATCH] test: make test-catalog relocatable
Fixes #10045.
(cherry picked from commit d9b6baa69968132d33e4ad8627c7fe0bd527c859)
Resolves: #1823767
---
catalog/meson.build | 1 -
src/journal/test-catalog.c | 27 +++++++++++++++++++--------
src/test/meson.build | 2 +-
3 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/catalog/meson.build b/catalog/meson.build
index 1b13150894..3db8e390f2 100644
--- a/catalog/meson.build
+++ b/catalog/meson.build
@@ -17,7 +17,6 @@ in_files = '''
support_url = get_option('support-url')
support_sed = 's~%SUPPORT_URL%~@0@~'.format(support_url)
-build_catalog_dir = meson.current_build_dir()
foreach file : in_files
custom_target(
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 8eae993780..0c4da29f31 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -14,14 +14,13 @@
#include "fileio.h"
#include "log.h"
#include "macro.h"
+#include "path-util.h"
#include "string-util.h"
+#include "strv.h"
+#include "tests.h"
#include "util.h"
-static const char *catalog_dirs[] = {
- CATALOG_DIR,
- NULL,
-};
-
+static char** catalog_dirs = NULL;
static const char *no_catalog_dirs[] = {
"/bin/hopefully/with/no/catalog",
NULL
@@ -167,8 +166,8 @@ static void test_catalog_update(const char *database) {
assert_se(r == 0);
/* Make sure that we at least have some files loaded or the
- catalog_list below will fail. */
- r = catalog_update(database, NULL, catalog_dirs);
+ * catalog_list below will fail. */
+ r = catalog_update(database, NULL, (const char * const *) catalog_dirs);
assert_se(r == 0);
}
@@ -202,14 +201,26 @@ static void test_catalog_file_lang(void) {
int main(int argc, char *argv[]) {
_cleanup_(unlink_tempfilep) char database[] = "/tmp/test-catalog.XXXXXX";
- _cleanup_free_ char *text = NULL;
+ _cleanup_free_ char *text = NULL, *catalog_dir = NULL;
int r;
setlocale(LC_ALL, "de_DE.UTF-8");
+ log_set_max_level(LOG_DEBUG);
log_parse_environment();
log_open();
+ /* If test-catalog is located at the build directory, then use catalogs in that.
+ * If it is not, e.g. installed by systemd-tests package, then use installed catalogs. */
+ if (test_is_running_from_builddir(NULL)) {
+ assert_se(catalog_dir = path_join(NULL, ABS_BUILD_DIR, "catalog"));
+ catalog_dirs = STRV_MAKE(catalog_dir);
+ } else
+ catalog_dirs = STRV_MAKE(CATALOG_DIR);
+
+ assert_se(access(catalog_dirs[0], F_OK) >= 0);
+ log_notice("Using catalog directory '%s'", catalog_dirs[0]);
+
test_catalog_file_lang();
test_catalog_import_invalid();
diff --git a/src/test/meson.build b/src/test/meson.build
index 4259421f98..ead000e30c 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -766,7 +766,7 @@ tests += [
[threads,
libxz,
liblz4],
- '', '', '-DCATALOG_DIR="@0@"'.format(build_catalog_dir)],
+ '', '', '-DCATALOG_DIR="@0@"'.format(catalogdir)],
[['src/journal/test-compress.c'],
[libjournal_core,
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ful9/systemd.git
git@gitee.com:ful9/systemd.git
ful9
systemd
systemd
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385