From: Arvin Schnell Date: Fri, 1 Apr 2016 09:05:21 +0000 (+0200) Subject: - added test program for functions in BtrfsUtils X-Git-Tag: v0.3.3~13^2^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5237a74ff18a27ddc75c5ac45aea9b7182a491af;p=thirdparty%2Fsnapper.git - added test program for functions in BtrfsUtils --- diff --git a/testsuite-real/.gitignore b/testsuite-real/.gitignore index 318a56f8..74cae1b1 100644 --- a/testsuite-real/.gitignore +++ b/testsuite-real/.gitignore @@ -16,3 +16,4 @@ xattrs1 xattrs2 xattrs3 xattrs4 +test-btrfsutils diff --git a/testsuite-real/Makefile.am b/testsuite-real/Makefile.am index cb37a6a3..31d4e926 100644 --- a/testsuite-real/Makefile.am +++ b/testsuite-real/Makefile.am @@ -16,7 +16,7 @@ noinst_SCRIPTS = run-all noinst_PROGRAMS = simple1 permissions1 permissions2 permissions3 owner1 owner2 \ owner3 directory1 missing-directory1 error1 error2 error4 \ - $(TMP_XATST) + $(TMP_XATST) test-btrfsutils simple1_SOURCES = simple1.cc common.h common.cc @@ -41,5 +41,7 @@ xattrs2_SOURCES = xattrs2.cc xattrs_utils.cc xattrs_utils.h common.h common.cc xattrs3_SOURCES = xattrs3.cc xattrs_utils.cc xattrs_utils.h common.h common.cc xattrs4_SOURCES = xattrs4.cc xattrs_utils.cc xattrs_utils.h common.h common.cc +test_btrfsutils_SOURCES = test-btrfsutils.cc + EXTRA_DIST = $(noinst_SCRIPTS) diff --git a/testsuite-real/test-btrfsutils.cc b/testsuite-real/test-btrfsutils.cc new file mode 100644 index 00000000..a3701d70 --- /dev/null +++ b/testsuite-real/test-btrfsutils.cc @@ -0,0 +1,106 @@ + + +#include +#include +#include +#include +#include +#include + +#include + +#include "snapper/BtrfsUtils.h" + + +using namespace std; +using namespace snapper; +using namespace BtrfsUtils; + + +int +main() +{ + int fd = open("/btrfs", O_NOATIME); + if (fd < 0) + { + cerr << "open failed (" << strerror(errno) << ")" << endl; + return EXIT_FAILURE; + } + + + if (false) + { + quota_enable(fd); + } + + + if (false) + { + quota_disable(fd); + } + + + if (false) + { + quota_rescan(fd); + } + + + if (false) + { + qgroup_create(fd, parse_qgroup("1/0")); + } + + + if (false) + { + qgroup_destroy(fd, parse_qgroup("1/0")); + } + + + if (false) + { + qgroup_assign(fd, parse_qgroup("0/123"), parse_qgroup("1/0")); + } + + + if (false) + { + qgroup_remove(fd, parse_qgroup("0/123"), parse_qgroup("1/0")); + } + + + if (false) + { + cout << "qgroup_query_usage" << endl; + + qgroup_t qgroup = parse_qgroup("1/0"); + QGroupUsage qgroup_usage = qgroup_query_usage(fd, qgroup); + cout << "referenced:" << qgroup_usage.referenced << endl; + cout << "referenced_compressed:" << qgroup_usage.referenced_compressed << endl; + cout << "exclusive:" << qgroup_usage.exclusive << endl; + cout << "exclusive_compressed:" << qgroup_usage.exclusive_compressed << endl; + } + + + if (false) + { + cout << "qgroup_find_free" << endl; + + qgroup_t qgroup = qgroup_find_free(fd, 1); + cout << format_qgroup(qgroup) << endl; + } + + + if (false) + { + cout << "qgroup_query_children" << endl; + + vector children = qgroup_query_children(fd, parse_qgroup("1/0")); + for (qgroup_t child : children) + cout << format_qgroup(child) << " "; + cout << endl; + } + + close(fd); +}