]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- add stub files for XA testing
authorOndrej Kozina <okozina@redhat.com>
Wed, 6 Feb 2013 14:27:46 +0000 (15:27 +0100)
committerOndrej Kozina <okozina@redhat.com>
Wed, 27 Feb 2013 16:30:10 +0000 (17:30 +0100)
testsuite-real/Makefile.am
testsuite-real/xattrs1.cc [new file with mode: 0644]
testsuite-real/xattrs_utils.cc [new file with mode: 0644]
testsuite-real/xattrs_utils.h [new file with mode: 0644]

index be44b3d08c35a1666d133dc043c747fea38dccaf..1ec3da1715928242e5787a8e8c2bf3c7a0dafa7d 100644 (file)
@@ -11,7 +11,7 @@ LDADD = ../snapper/libsnapper.la
 noinst_SCRIPTS = run-all
 
 noinst_PROGRAMS = simple1 permissions1 permissions2 owner1 owner2 owner3       \
-       directory1 missing-directory1 error1 error2 error4
+       directory1 missing-directory1 error1 error2 error4 xattrs1
 
 simple1_SOURCES = simple1.cc common.h common.cc
 
@@ -30,5 +30,7 @@ error1_SOURCES = error1.cc common.h common.cc
 error2_SOURCES = error2.cc common.h common.cc
 error4_SOURCES = error4.cc common.h common.cc
 
+xattrs1_SOURCES = xattrs1.cc xattrs_utils.cc xattrs_utils.h common.h common.cc
+
 EXTRA_DIST = $(noinst_SCRIPTS)
 
diff --git a/testsuite-real/xattrs1.cc b/testsuite-real/xattrs1.cc
new file mode 100644 (file)
index 0000000..ed90a71
--- /dev/null
@@ -0,0 +1,36 @@
+#include <iostream>
+
+#include "common.h"
+#include "xattrs_utils.h"
+
+using namespace std;
+
+int
+main()
+{
+    setup();
+
+    run_command("touch file1");
+    run_command("setfacl -b file1");
+    run_command("setfacl -m u:nobody:rw file1");
+    xattr_create("user.aaa", "aaa-value", "/testsuite/file1");
+    xattr_create("user.bbb", "bbb-value", "/testsuite/file1");
+
+    first_snapshot();
+
+    run_command("setfacl -b file1");
+    xattr_remove("user.aaa","/testsuite/file1");
+    xattr_replace("user.bbb", "bbb-new-value", "/testsuite/file1");
+
+    second_snapshot();
+
+    check_undo_statistics(0, 1, 0);
+
+    undo();
+
+    check_undo_errors(0, 0, 0);
+
+    check_first();
+
+    exit(EXIT_SUCCESS);
+}
diff --git a/testsuite-real/xattrs_utils.cc b/testsuite-real/xattrs_utils.cc
new file mode 100644 (file)
index 0000000..c19d58a
--- /dev/null
@@ -0,0 +1,21 @@
+#include <string.h>
+#include <sys/xattr.h>
+
+#include <snapper/XAttributes.h>
+#include "xattrs_utils.h"
+#include "common.h"
+
+void xattr_create(const char *name, const char *value, const char *path)
+{
+    check_zero(setxattr(path, name, (void *) value, strlen(value), XATTR_CREATE));
+}
+
+void xattr_remove(const char *name, const char *path)
+{
+    check_zero(removexattr(path, name));
+}
+
+void xattr_replace(const char *name, const char *value, const char *path)
+{
+    check_zero(setxattr(path, name, (void *) value, strlen(value), XATTR_REPLACE));
+}
\ No newline at end of file
diff --git a/testsuite-real/xattrs_utils.h b/testsuite-real/xattrs_utils.h
new file mode 100644 (file)
index 0000000..350d9d5
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+void xattr_create(const char *, const char *, const char *);
+
+void xattr_remove(const char *, const char *);
+
+void xattr_replace(const char *, const char *, const char *);
\ No newline at end of file