diff options
author | Karel Zak | 2010-07-26 16:27:45 +0200 |
---|---|---|
committer | Karel Zak | 2011-01-03 12:28:40 +0100 |
commit | 6d94f2dc2564d869f11de7d3dc637c51f7970a22 (patch) | |
tree | 20f91bc8d295be90b8f5474d552b7066d5edf1be /shlibs/mount/src/tab.c | |
parent | libmount: add utils to get FS root/mountpoint (diff) | |
download | kernel-qcow2-util-linux-6d94f2dc2564d869f11de7d3dc637c51f7970a22.tar.gz kernel-qcow2-util-linux-6d94f2dc2564d869f11de7d3dc637c51f7970a22.tar.xz kernel-qcow2-util-linux-6d94f2dc2564d869f11de7d3dc637c51f7970a22.zip |
libmount: add unit test for mnt_copy_fs()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/tab.c')
-rw-r--r-- | shlibs/mount/src/tab.c | 29 |
1 files changed, 29 insertions, 0 deletions
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, "<file> parse and print tab" }, { "--find-forward", test_find_fw, "<file> <source|target> <string>" }, { "--find-backward", test_find_bw, "<file> <source|target> <string>" }, + { "--copy-fs", test_copy_fs, "<file> copy root FS from the file" }, { NULL } }; |