]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/test/test-umount.c
core/umount: use _cleanup_
[thirdparty/systemd.git] / src / test / test-umount.c
CommitLineData
6fa392bf
ZJS
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include "log.h"
4#include "string-util.h"
5#include "tests.h"
6#include "umount.h"
7#include "util.h"
8
9static void test_mount_points_list(const char *fname) {
a6dcd229 10 _cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);
6fa392bf
ZJS
11 MountPoint *m;
12
13 log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/self/mountinfo");
14
15 LIST_HEAD_INIT(mp_list_head);
16 assert_se(mount_points_list_get(fname, &mp_list_head) >= 0);
17
18 LIST_FOREACH(mount_point, m, mp_list_head)
19 log_debug("path=%s o=%s f=0x%lx try-ro=%s dev=%u:%u",
20 m->path,
21 strempty(m->remount_options),
22 m->remount_flags,
23 yes_no(m->try_remount_ro),
24 major(m->devnum), minor(m->devnum));
6fa392bf
ZJS
25}
26
27int main(int argc, char **argv) {
28 log_set_max_level(LOG_DEBUG);
29 log_parse_environment();
30 log_open();
31
32 test_mount_points_list(NULL);
33 test_mount_points_list(get_testdata_dir("/test-umount/empty.mountinfo"));
34 test_mount_points_list(get_testdata_dir("/test-umount/garbled.mountinfo"));
35 test_mount_points_list(get_testdata_dir("/test-umount/rhbug-1554943.mountinfo"));
36}