[CRIU] [PATCH v5 3/3] zdtm: Add unlink_regular00 test

Kirill Tkhai ktkhai at virtuozzo.com
Thu Feb 4 08:45:52 PST 2016


On 04.02.2016 19:33, Andrew Vagin wrote:
> On Thu, Feb 04, 2016 at 12:31:08PM +0300, Kirill Tkhai wrote:
>> Hi, Andrew,
>>
>> On 04.02.2016 01:54, Andrew Vagin wrote:
>>> Hi Kirill,
>>>
>>> [root at fc22-vm criu]# python test/zdtm.py run -t zdtm/live/static/unlink_regular00
>>> === Run 1/1 ================
>>>
>>> ================= Run zdtm/live/static/unlink_regular00 in ns ==================
>>> Start test
>>> Test is SUID
>>> ./unlink_regular00 --pidfile=unlink_regular00.pid --outfile=unlink_regular00.out --dirname=unlink_regular00.test
>>> Run criu dump
>>> =[log]=> dump/zdtm/live/static/unlink_regular00/66/1/dump.log
>>> ------------------------ grep Error ------------------------
>>> (00.006252) Error (files-reg.c:757): Can't create link remap for /zdtm/live/static/unlink_regular00.test/subdir/testfile (deleted). Use link-remap option.
>>> (00.006353) Error (cr-dump.c:1292): Dump files (pid: 69) failed with -1
>>> (00.010679) Error (cr-dump.c:1578): Dumping FAILED.
>>> ------------------------ ERROR OVER ------------------------
>>> ########### Test zdtm/live/static/unlink_regular00 FAIL at CRIU dump ###########
>>> Wait for zdtm/live/static/unlink_regular00 to die for 0.100000
>>> ##################################### FAIL #####################################
>>
>> I added link remap to this test by Pavel's suggestion. The patch set does not support that.
> 
> I don't understand. Could you elaborate? If something doesn't work, why
> did we commit this?

But we have tests for future functionality. The test for msg_names of messages in datagram sockets,
for example. So, this is one more.

The fact it's need additional support I wrote in message of 28.01.2016 14:28.
 
>>  
>>> On Thu, Jan 28, 2016 at 02:39:51PM +0300, Kirill Tkhai wrote:
>>>> Test checks that a deleted file content in a deleted parent directory
>>>> restores right. Initially directory is created in a separate mount,
>>>> to check the ghost file is created in right mount and link() in
>>>> rfi_remap() is working.
>>>>
>>>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>>>> ---
>>>>  test/zdtm/live/static/Makefile              |    1 
>>>>  test/zdtm/live/static/unlink_regular00.c    |  109 +++++++++++++++++++++++++++
>>>>  test/zdtm/live/static/unlink_regular00.desc |    1 
>>>>  3 files changed, 111 insertions(+)
>>>>  create mode 100644 test/zdtm/live/static/unlink_regular00.c
>>>>  create mode 100644 test/zdtm/live/static/unlink_regular00.desc
>>>>
>>>> diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
>>>> index c4c0df7..444b6bb 100644
>>>> --- a/test/zdtm/live/static/Makefile
>>>> +++ b/test/zdtm/live/static/Makefile
>>>> @@ -225,6 +225,7 @@ TST_DIR		=				\
>>>>  		mnt_ext_master			\
>>>>  		mntns_deleted			\
>>>>  		binfmt_misc			\
>>>> +		unlink_regular00		\
>>>>  
>>>>  TST_DIR_FILE	=				\
>>>>  		chroot				\
>>>> diff --git a/test/zdtm/live/static/unlink_regular00.c b/test/zdtm/live/static/unlink_regular00.c
>>>> new file mode 100644
>>>> index 0000000..6e97df2
>>>> --- /dev/null
>>>> +++ b/test/zdtm/live/static/unlink_regular00.c
>>>> @@ -0,0 +1,109 @@
>>>> +#include <errno.h>
>>>> +#include <fcntl.h>
>>>> +#include <stdlib.h>
>>>> +#include <sys/types.h>
>>>> +#include <sys/stat.h>
>>>> +#include <sys/mount.h>
>>>> +#include <unistd.h>
>>>> +#include <string.h>
>>>> +#include <limits.h>
>>>> +
>>>> +#include "zdtmtst.h"
>>>> +
>>>> +const char *test_doc = "Checkpointing/restore of unlinked file inside unlinked directory";
>>>> +const char *test_author	= "Kirill Tkhai <ktkhai at virtuozzo.com>";
>>>> +
>>>> +char *dirname;
>>>> +TEST_OPTION(dirname, string, "directory name", 1);
>>>> +
>>>> +#define SUBDIR "subdir"
>>>> +#define FNAME "testfile"
>>>> +#define MSG "Hello!!!111"
>>>> +
>>>> +int main(int argc, char ** argv)
>>>> +{
>>>> +	char subdir[PATH_MAX], fname[PATH_MAX], lname[PATH_MAX];
>>>> +	char buf[sizeof(MSG) + 1];
>>>> +	int fd, ret = -1;
>>>> +
>>>> +	test_init(argc, argv);
>>>> +
>>>> +	memset(buf, 0, sizeof(buf));
>>>> +
>>>> +	if (mkdir(dirname, 0777)) {
>>>> +		fail("can't create %s", dirname);
>>>> +		exit(1);
>>>> +	}
>>>> +
>>>> +	if (mount("none", dirname, "tmpfs", 0, "") < 0) {
>>>> +		fail("can't mount tmpfs to %s", dirname);
>>>> +		goto rm_topdir;
>>>> +	}
>>>> +
>>>> +	sprintf(subdir, "%s/" SUBDIR, dirname);
>>>> +
>>>> +	if (mkdir(subdir, 0777)) {
>>>> +		fail("can't create %s", subdir);
>>>> +		goto umount;
>>>> +	}
>>>> +
>>>> +	sprintf(fname, "%s/" SUBDIR "/" FNAME, dirname);
>>>> +	sprintf(lname, "%s/" FNAME, dirname);
>>>> +
>>>> +	fd = open(fname, O_RDWR | O_CREAT, 0644);
>>>> +	if (fd < 0) {
>>>> +		fail("can't open %s", fname);
>>>> +		rmdir(subdir);
>>>> +		goto umount;
>>>> +	}
>>>> +
>>>> +	if (link(fname, lname) < 0) {
>>>> +		fail("can't link %s to %s", fname, lname);
>>>> +		unlink(fname);
>>>> +		rmdir(subdir);
>>>> +		goto umount;
>>>> +	}
>>>> +
>>>> +	if (unlink(fname) || rmdir(subdir)) {
>>>> +		fail("can't unlink %s or %s", fname, subdir);
>>>> +		goto close_file;
>>>> +	}
>>>> +
>>>> +	if (write(fd, MSG, sizeof(MSG)) != sizeof(MSG)) {
>>>> +		fail("can't write %s", fname);
>>>> +		goto close_file;
>>>> +	}
>>>> +
>>>> +	test_daemon();
>>>> +	test_waitsig();
>>>> +
>>>> +	if (lseek(fd, 0, SEEK_SET) != 0) {
>>>> +		fail("can't lseek %s", fname);
>>>> +		goto close_file;
>>>> +	}
>>>> +
>>>> +	if (read(fd, buf, sizeof(MSG)) != sizeof(MSG)) {
>>>> +		fail("can't read %s", fname);
>>>> +		goto close_file;
>>>> +	}
>>>> +
>>>> +	if (strcmp(buf, MSG)) {
>>>> +		fail("content differs: %s, %s, sizeof=%d", buf, MSG, sizeof(MSG));
>>>> +		goto close_file;
>>>> +	}
>>>> +
>>>> +	ret = 0;
>>>> +	pass();
>>>> +
>>>> +close_file:
>>>> +	close(fd);
>>>> +	unlink(lname);
>>>> +umount:
>>>> +	if (umount(dirname) < 0)
>>>> +		pr_err("Can't umount\n");
>>>> +rm_topdir:
>>>> +	if (rmdir(dirname) < 0)
>>>> +		pr_err("Can't rmdir()\n");
>>>> +
>>>> +	return ret;
>>>> +}
>>>> diff --git a/test/zdtm/live/static/unlink_regular00.desc b/test/zdtm/live/static/unlink_regular00.desc
>>>> new file mode 100644
>>>> index 0000000..dfe829b
>>>> --- /dev/null
>>>> +++ b/test/zdtm/live/static/unlink_regular00.desc
>>>> @@ -0,0 +1 @@
>>>> +{'flavor': 'ns', 'flags': 'suid'}
>>>>


More information about the CRIU mailing list