From: Karel Zak Date: Mon, 26 Jul 2010 14:27:45 +0000 (+0200) Subject: libmount: add unit test for mnt_copy_fs() X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d94f2dc2564d869f11de7d3dc637c51f7970a22;p=util-linux libmount: add unit test for mnt_copy_fs() Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/tab.c b/shlibs/mount/src/tab.c index c61571d1..c0a95426 100644 --- a/shlibs/mount/src/tab.c +++ b/shlibs/mount/src/tab.c @@ -680,6 +680,34 @@ err: return NULL; } +int test_copy_fs(struct mtest *ts, int argc, char *argv[]) +{ + mnt_tab *tb; + mnt_fs *fs; + + tb = create_tab(argv[1]); + if (!tb) + return -1; + + fs = mnt_tab_find_target(tb, "/", MNT_ITER_FORWARD); + if (!fs) + goto err; + + printf("ORIGINAL:\n"); + mnt_fs_print_debug(fs, stdout); + + fs = mnt_copy_fs(fs); + if (!fs) + goto err; + + printf("COPY:\n"); + mnt_fs_print_debug(fs, stdout); + mnt_free_fs(fs); +err: + mnt_free_tab(tb); + return 0; +} + int test_parse(struct mtest *ts, int argc, char *argv[]) { mnt_tab *tb; @@ -768,6 +796,7 @@ int main(int argc, char *argv[]) { "--parse", test_parse, " parse and print tab" }, { "--find-forward", test_find_fw, " " }, { "--find-backward", test_find_bw, " " }, + { "--copy-fs", test_copy_fs, " copy root FS from the file" }, { NULL } };