diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-10 18:01:13 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-30 14:01:46 +0200 |
commit | 91e0ee5f16321656ed6f827742ecbeb2b36027f2 (patch) | |
tree | 41f3b5b389f8e6353b5e8bfb34272add25b10385 /src/test | |
parent | analyze: add "unit-files" to dump the unit fragment map (diff) | |
download | systemd-91e0ee5f16321656ed6f827742ecbeb2b36027f2.tar.xz systemd-91e0ee5f16321656ed6f827742ecbeb2b36027f2.zip |
pid1: drop unit caches only based on mtime
v2:
- do not watch mtime of transient and generated dirs
We'd reload the map after every transient unit we created, which we don't
need to do, since we create those units ourselves and know their fragment
path.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-unit-file.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index c5144a1b7e..0c0371375a 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -31,10 +31,12 @@ static void test_unit_file_build_name_map(void) { Iterator i; const char *k, *dst; char **v; + usec_t mtime = 0; + int r; assert_se(lookup_paths_init(&lp, UNIT_FILE_SYSTEM, 0, NULL) >= 0); - assert_se(unit_file_build_name_map(&lp, &unit_ids, &unit_names, NULL) == 0); + assert_se(unit_file_build_name_map(&lp, &mtime, &unit_ids, &unit_names, NULL) == 1); HASHMAP_FOREACH_KEY(dst, k, unit_ids, i) log_info("ids: %s → %s", k, dst); @@ -43,6 +45,14 @@ static void test_unit_file_build_name_map(void) { _cleanup_free_ char *j = strv_join(v, ", "); log_info("aliases: %s ← %s", k, j); } + + char buf[FORMAT_TIMESTAMP_MAX]; + log_debug("Last modification time: %s", format_timestamp(buf, sizeof buf, mtime)); + + r = unit_file_build_name_map(&lp, &mtime, &unit_ids, &unit_names, NULL); + assert_se(IN_SET(r, 0, 1)); + if (r == 0) + log_debug("Cache rebuild skipped based on mtime."); } int main(int argc, char **argv) { |