From 6d94f2dc2564d869f11de7d3dc637c51f7970a22 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 26 Jul 2010 16:27:45 +0200 Subject: libmount: add unit test for mnt_copy_fs() Signed-off-by: Karel Zak --- shlibs/mount/src/tab.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'shlibs/mount/src/tab.c') diff --git a/shlibs/mount/src/tab.c b/shlibs/mount/src/tab.c index c61571d1c..c0a954264 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 } }; -- cgit v1.2.3-55-g7522