]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added test program for functions in BtrfsUtils
authorArvin Schnell <aschnell@suse.de>
Fri, 1 Apr 2016 09:05:21 +0000 (11:05 +0200)
committerArvin Schnell <aschnell@suse.de>
Fri, 1 Apr 2016 09:05:21 +0000 (11:05 +0200)
testsuite-real/.gitignore
testsuite-real/Makefile.am
testsuite-real/test-btrfsutils.cc [new file with mode: 0644]

index 318a56f86f74bee7b98f6bd707ca98d80a72324b..74cae1b10b09c5441ea90ac098c1991e244e0fac 100644 (file)
@@ -16,3 +16,4 @@ xattrs1
 xattrs2
 xattrs3
 xattrs4
+test-btrfsutils
index cb37a6a3a85483b1cac0b3ffc3278a359228dfa6..31d4e926fb64fb50bdd7508748b3a9f7a8dd1e4b 100644 (file)
@@ -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 (file)
index 0000000..a3701d7
--- /dev/null
@@ -0,0 +1,106 @@
+
+
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <iostream>
+
+#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<qgroup_t> children = qgroup_query_children(fd, parse_qgroup("1/0"));
+       for (qgroup_t child : children)
+           cout << format_qgroup(child) << " ";
+       cout << endl;
+    }
+
+    close(fd);
+}