[CRIU] [PATCH 1/2] test: Add unlink_dir test

Pavel Tikhomirov snorcht at gmail.com
Mon Feb 11 15:12:56 MSK 2019


Found another problem, if I patch your test with these diff just adding one
extra directory it does not restore again:

diff --git a/test/zdtm/static/unlink_dir.c b/test/zdtm/static/unlink_dir.c
index 1d9a19bc4..48015e9de 100644
--- a/test/zdtm/static/unlink_dir.c
+++ b/test/zdtm/static/unlink_dir.c
@@ -19,9 +19,10 @@ TEST_OPTION(dirname, string, "directory name", 1);

 int main(int argc, char ** argv)
 {
-       int fds[4], dirfd1, dirfd2, i, len;
+       int fds[4], dirfd1, dirfd3, i, len;
        char path_dir1[PATH_MAX];
        char path_dir2[PATH_MAX];
+       char path_dir3[PATH_MAX];
        char path[PATH_MAX];

        int lo = ARRAY_SIZE(fds) / 2;
@@ -48,6 +49,13 @@ int main(int argc, char ** argv)
                return 1;
        }

+       len = snprintf(path_dir3, sizeof(path_dir3), "%s/%s/%s/%s",
dirname, "gd1", "gd2", "gd3");
+       if (len == sizeof(path_dir3)) path_dir3[len-1] = '\0';
+       if (mkdir(path_dir3, 0700) < 0) {
+               pr_perror("Can't create directory %s", path_dir3);
+               return 1;
+       }
+
        for (i = 0; i < lo; i++) {
                len = snprintf(path, sizeof(path), "%s/%d", path_dir1, i);
                if (len == sizeof(path)) path[len-1] = '\0';
@@ -62,8 +70,8 @@ int main(int argc, char ** argv)
                }
        }

-       dirfd2 = open(path_dir2, O_RDONLY | O_DIRECTORY);
-       if (dirfd2 < 0) {
+       dirfd3 = open(path_dir3, O_RDONLY | O_DIRECTORY);
+       if (dirfd3 < 0) {
                pr_perror("Can't open %s", path_dir2);
                return 1;
        }
@@ -88,6 +96,11 @@ int main(int argc, char ** argv)
                return 1;
        }

+       if (rmdir(path_dir3)) {
+               pr_perror("Can't rmdir %s", path_dir3);
+               return 1;
+       }
+
        if (rmdir(path_dir2)) {
                pr_perror("Can't rmdir %s", path_dir2);
                return 1;

I get:

[root at snorch criu]# ./test/zdtm.py run -t zdtm/static/unlink_dir
=== Run 1/1 ================ zdtm/static/unlink_dir
======================= Run zdtm/static/unlink_dir in h
========================
Start test
./unlink_dir --pidfile=unlink_dir.pid --outfile=unlink_dir.out
--dirname=unlink_dir.test
Run criu dump
Run criu restore
=[log]=> dump/zdtm/static/unlink_dir/36/1/restore.log
------------------------ grep Error ------------------------
(00.004058) Unlink remap
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1/gd2/2.cr.4.ghost
(00.004073) Unlink remap
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1/gd2/3.cr.5.ghost
(00.004084) Unlink remap
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1/gd2/gd3
(00.004100) Unlink remap
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1
(00.004123) Error (criu/files-reg.c:792): Couldn't unlink remap /
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1: Directory not
empty
(00.004146) Unlink remap
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1
(00.004156) Error (criu/files-reg.c:792): Couldn't unlink remap /
home/snorch/devel/criu/test/zdtm/static/unlink_dir.test/gd1: Directory not
empty
(00.004162) Error (criu/cr-restore.c:2294): Restoring FAILED.
------------------------ ERROR OVER ------------------------
############### Test zdtm/static/unlink_dir FAIL at CRIU restore
###############
##################################### FAIL
#####################################

Best Regards, Tikhomirov Pavel.


пт, 8 февр. 2019 г. в 15:08, Cyrill Gorcunov <gorcunov at gmail.com>:

> On Fri, Feb 08, 2019 at 01:24:27PM +0300, Pavel Tikhomirov wrote:
> >      >    check error like: if (len >= sizeof(path_dir1)) return -1;
> >
> >      It is for warnings suppression nothing else. Strictly speaking we
> might
> >      need to check for negative value rather but since it is path-max
> limit
> >      i don't expect here any errors at all, just to placate gcc.
> >
> >    FMPOV actual overflow check is better here, it is what gcc really
> wants
> >    from us by these warnings.
> >    Except that, Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com
> >
>
> I don't mind. Will update.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20190211/175bf90d/attachment.html>


More information about the CRIU mailing list