|
|
be3800 |
From 4b54464394c7cddf7e8335d976632bae1240846a Mon Sep 17 00:00:00 2001
|
|
|
be3800 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
be3800 |
Date: Tue, 11 Sep 2018 09:18:33 +0900
|
|
|
be3800 |
Subject: [PATCH] test: make test-catalog relocatable
|
|
|
be3800 |
|
|
|
be3800 |
Fixes #10045.
|
|
|
be3800 |
|
|
|
be3800 |
(cherry picked from commit d9b6baa69968132d33e4ad8627c7fe0bd527c859)
|
|
|
be3800 |
(cherry picked from commit 444ad721dc163d4952bb35a0b061e57c91bfc9ff)
|
|
|
be3800 |
|
|
|
be3800 |
Resolves: #1836979
|
|
|
be3800 |
---
|
|
|
be3800 |
catalog/meson.build | 1 -
|
|
|
be3800 |
src/journal/test-catalog.c | 27 +++++++++++++++++++--------
|
|
|
be3800 |
src/test/meson.build | 2 +-
|
|
|
be3800 |
3 files changed, 20 insertions(+), 10 deletions(-)
|
|
|
be3800 |
|
|
|
be3800 |
diff --git a/catalog/meson.build b/catalog/meson.build
|
|
|
be3800 |
index 1b13150894..3db8e390f2 100644
|
|
|
be3800 |
--- a/catalog/meson.build
|
|
|
be3800 |
+++ b/catalog/meson.build
|
|
|
be3800 |
@@ -17,7 +17,6 @@ in_files = '''
|
|
|
be3800 |
|
|
|
be3800 |
support_url = get_option('support-url')
|
|
|
be3800 |
support_sed = 's~%SUPPORT_URL%~@0@~'.format(support_url)
|
|
|
be3800 |
-build_catalog_dir = meson.current_build_dir()
|
|
|
be3800 |
|
|
|
be3800 |
foreach file : in_files
|
|
|
be3800 |
custom_target(
|
|
|
be3800 |
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
|
|
|
be3800 |
index 8eae993780..0c4da29f31 100644
|
|
|
be3800 |
--- a/src/journal/test-catalog.c
|
|
|
be3800 |
+++ b/src/journal/test-catalog.c
|
|
|
be3800 |
@@ -14,14 +14,13 @@
|
|
|
be3800 |
#include "fileio.h"
|
|
|
be3800 |
#include "log.h"
|
|
|
be3800 |
#include "macro.h"
|
|
|
be3800 |
+#include "path-util.h"
|
|
|
be3800 |
#include "string-util.h"
|
|
|
be3800 |
+#include "strv.h"
|
|
|
be3800 |
+#include "tests.h"
|
|
|
be3800 |
#include "util.h"
|
|
|
be3800 |
|
|
|
be3800 |
-static const char *catalog_dirs[] = {
|
|
|
be3800 |
- CATALOG_DIR,
|
|
|
be3800 |
- NULL,
|
|
|
be3800 |
-};
|
|
|
be3800 |
-
|
|
|
be3800 |
+static char** catalog_dirs = NULL;
|
|
|
be3800 |
static const char *no_catalog_dirs[] = {
|
|
|
be3800 |
"/bin/hopefully/with/no/catalog",
|
|
|
be3800 |
NULL
|
|
|
be3800 |
@@ -167,8 +166,8 @@ static void test_catalog_update(const char *database) {
|
|
|
be3800 |
assert_se(r == 0);
|
|
|
be3800 |
|
|
|
be3800 |
/* Make sure that we at least have some files loaded or the
|
|
|
be3800 |
- catalog_list below will fail. */
|
|
|
be3800 |
- r = catalog_update(database, NULL, catalog_dirs);
|
|
|
be3800 |
+ * catalog_list below will fail. */
|
|
|
be3800 |
+ r = catalog_update(database, NULL, (const char * const *) catalog_dirs);
|
|
|
be3800 |
assert_se(r == 0);
|
|
|
be3800 |
}
|
|
|
be3800 |
|
|
|
be3800 |
@@ -202,14 +201,26 @@ static void test_catalog_file_lang(void) {
|
|
|
be3800 |
|
|
|
be3800 |
int main(int argc, char *argv[]) {
|
|
|
be3800 |
_cleanup_(unlink_tempfilep) char database[] = "/tmp/test-catalog.XXXXXX";
|
|
|
be3800 |
- _cleanup_free_ char *text = NULL;
|
|
|
be3800 |
+ _cleanup_free_ char *text = NULL, *catalog_dir = NULL;
|
|
|
be3800 |
int r;
|
|
|
be3800 |
|
|
|
be3800 |
setlocale(LC_ALL, "de_DE.UTF-8");
|
|
|
be3800 |
|
|
|
be3800 |
+ log_set_max_level(LOG_DEBUG);
|
|
|
be3800 |
log_parse_environment();
|
|
|
be3800 |
log_open();
|
|
|
be3800 |
|
|
|
be3800 |
+ /* If test-catalog is located at the build directory, then use catalogs in that.
|
|
|
be3800 |
+ * If it is not, e.g. installed by systemd-tests package, then use installed catalogs. */
|
|
|
be3800 |
+ if (test_is_running_from_builddir(NULL)) {
|
|
|
be3800 |
+ assert_se(catalog_dir = path_join(NULL, ABS_BUILD_DIR, "catalog"));
|
|
|
be3800 |
+ catalog_dirs = STRV_MAKE(catalog_dir);
|
|
|
be3800 |
+ } else
|
|
|
be3800 |
+ catalog_dirs = STRV_MAKE(CATALOG_DIR);
|
|
|
be3800 |
+
|
|
|
be3800 |
+ assert_se(access(catalog_dirs[0], F_OK) >= 0);
|
|
|
be3800 |
+ log_notice("Using catalog directory '%s'", catalog_dirs[0]);
|
|
|
be3800 |
+
|
|
|
be3800 |
test_catalog_file_lang();
|
|
|
be3800 |
|
|
|
be3800 |
test_catalog_import_invalid();
|
|
|
be3800 |
diff --git a/src/test/meson.build b/src/test/meson.build
|
|
|
be3800 |
index 4259421f98..ead000e30c 100644
|
|
|
be3800 |
--- a/src/test/meson.build
|
|
|
be3800 |
+++ b/src/test/meson.build
|
|
|
be3800 |
@@ -766,7 +766,7 @@ tests += [
|
|
|
be3800 |
[threads,
|
|
|
be3800 |
libxz,
|
|
|
be3800 |
liblz4],
|
|
|
be3800 |
- '', '', '-DCATALOG_DIR="@0@"'.format(build_catalog_dir)],
|
|
|
be3800 |
+ '', '', '-DCATALOG_DIR="@0@"'.format(catalogdir)],
|
|
|
be3800 |
|
|
|
be3800 |
[['src/journal/test-compress.c'],
|
|
|
be3800 |
[libjournal_core,
|