[CRIU] [PATCH 7/7] zdtm: emulate situation invalid files in irmap cache
Andrey Vagin
avagin at openvz.org
Tue Mar 8 10:44:05 PST 2016
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
test/jenkins/criu-fault.sh | 1 +
test/zdtm/static/inotify_irmap.c | 50 +++++++++++++++++++++----------------
test/zdtm/static/inotify_irmap.desc | 2 +-
test/zdtm/static/inotify_irmap.hook | 18 +++++++++++++
4 files changed, 49 insertions(+), 22 deletions(-)
create mode 100755 test/zdtm/static/inotify_irmap.hook
diff --git a/test/jenkins/criu-fault.sh b/test/jenkins/criu-fault.sh
index 82f8f73..61a6bf1 100755
--- a/test/jenkins/criu-fault.sh
+++ b/test/jenkins/criu-fault.sh
@@ -4,3 +4,4 @@ source `dirname $0`/criu-lib.sh
prep
./test/zdtm.py run -t zdtm/static/env00 --fault 1 --report report -f h || fail
./test/zdtm.py run -t zdtm/static/unlink_fstat00 --fault 2 --report report -f h || fail
+./test/zdtm.py run -t zdtm/static/inotify_irmap --fault 3 --pre 2 -f uns || fail
diff --git a/test/zdtm/static/inotify_irmap.c b/test/zdtm/static/inotify_irmap.c
index e16a418..8722010 100644
--- a/test/zdtm/static/inotify_irmap.c
+++ b/test/zdtm/static/inotify_irmap.c
@@ -19,51 +19,59 @@ const char *test_doc = "Check for irmap";
const char *test_author = "Pavel Emelyanov <xemul at parallels.com>";
#define TDIR "/etc"
-#define TFIL TDIR"/zdtm-test"
+char test_files[2][128] = {TDIR"/zdtm-test", TDIR"/zdtm-test1"};
#define BUFF_SIZE ((sizeof(struct inotify_event) + PATH_MAX))
int main (int argc, char *argv[])
{
char buf[BUFF_SIZE];
- int fd, wd;
+ int fd, wd, i;
test_init(argc, argv);
- unlink(TFIL);
- if (creat(TFIL, 0600) < 0) {
- pr_perror("Can't make test file");
- exit(1);
+ for (i = 0; i < 2; i++) {
+ unlink(test_files[i]);
+ if (creat(test_files[i], 0600) < 0) {
+ pr_perror("Can't make test file");
+ exit(1);
+ }
}
fd = inotify_init1(IN_NONBLOCK);
if (fd < 0) {
- fail("inotify_init failed");
- unlink(TFIL);
- exit(1);
+ pr_perror("inotify_init failed");
+ goto err;
}
- wd = inotify_add_watch(fd, TFIL, IN_OPEN);
- if (wd < 0) {
- fail("inotify_add_watch failed");
- unlink(TFIL);
- exit(1);
+ for (i = 0; i < 2; i++) {
+ wd = inotify_add_watch(fd, test_files[i], IN_OPEN);
+ if (wd < 0) {
+ pr_perror("inotify_add_watch failed");
+ goto err;
+ }
}
test_daemon();
test_waitsig();
- memset(buf, 0, sizeof(buf));
- wd = open(TFIL, O_RDONLY);
- if (read(fd, buf, sizeof(buf)) <= 0) {
- unlink(TFIL);
- fail("No events in queue");
- exit(1);
+ for (i = 0; i < 2; i++) {
+ memset(buf, 0, sizeof(buf));
+ wd = open(test_files[i], O_RDONLY);
+ if (read(fd, buf, sizeof(buf)) <= 0) {
+ fail("No events in queue");
+ goto err;
+ }
}
close(wd);
close(fd);
- unlink(TFIL);
+ for (i = 0; i < 2; i++)
+ unlink(test_files[i]);
pass();
return 0;
+err:
+ for (i = 0; i < 2; i++)
+ unlink(test_files[i]);
+ return 1;
}
diff --git a/test/zdtm/static/inotify_irmap.desc b/test/zdtm/static/inotify_irmap.desc
index 9c5994e..525a4a6 100644
--- a/test/zdtm/static/inotify_irmap.desc
+++ b/test/zdtm/static/inotify_irmap.desc
@@ -1 +1 @@
-{'flags': 'suid', 'opts' : '--force-irmap'}
+{'flags': 'suid', 'opts' : '--force-irmap --irmap-scan-path /zdtm/static'}
diff --git a/test/zdtm/static/inotify_irmap.hook b/test/zdtm/static/inotify_irmap.hook
new file mode 100755
index 0000000..eca6bfa
--- /dev/null
+++ b/test/zdtm/static/inotify_irmap.hook
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+umask 0000
+
+[ "$1" == "--pre-restore" ] && {
+ # emulate rsync
+ rm -rf etc/zdtm-test
+ touch etc/zdtm-test
+}
+
+[ "$1" == "--post-pre-dump" ] && {
+ echo 'invalidate the irmap cache'
+ mv etc/zdtm-test etc/zdtm-test2
+ mv etc/zdtm-test1 etc/zdtm-test
+ mv etc/zdtm-test2 etc/zdtm-test1
+}
+
+exit 0
--
2.5.0
More information about the CRIU
mailing list