From: Ondrej Kozina Date: Wed, 6 Feb 2013 14:27:46 +0000 (+0100) Subject: - add stub files for XA testing X-Git-Tag: v0.1.3~18^2~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd382723604bb082852e6fce5cbcef015a23b9a6;p=thirdparty%2Fsnapper.git - add stub files for XA testing --- diff --git a/testsuite-real/Makefile.am b/testsuite-real/Makefile.am index be44b3d0..1ec3da17 100644 --- a/testsuite-real/Makefile.am +++ b/testsuite-real/Makefile.am @@ -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 index 00000000..ed90a718 --- /dev/null +++ b/testsuite-real/xattrs1.cc @@ -0,0 +1,36 @@ +#include + +#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 index 00000000..c19d58a3 --- /dev/null +++ b/testsuite-real/xattrs_utils.cc @@ -0,0 +1,21 @@ +#include +#include + +#include +#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 index 00000000..350d9d51 --- /dev/null +++ b/testsuite-real/xattrs_utils.h @@ -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