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