[CRIU] [PATCH 18/18] zdtm: Add fanotify00 test

Cyrill Gorcunov gorcunov at openvz.org
Fri Jan 11 15:58:09 EST 2013


On Sat, Jan 12, 2013 at 12:52:29AM +0400, Andrew Vagin wrote:
> > +int main (int argc, char *argv[])
> > +{
> > +	char buf[BUFF_SIZE];
> > +	int fa_fd, fd, del_after;
> > +
> > +	test_init(argc, argv);
> > +
> > +	fa_fd = fanotify_init(FAN_NONBLOCK | O_RDONLY | O_LARGEFILE |
> > +			      FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE,
> > +			      0);
> > +	if (fa_fd < 0) {
> > +		fail("fanotify_init failed\n");
> fail() can't be used before checkpoint/restore (test_waitsig).
> err() should be used here.
> > +		exit(1);
> > +	}

Why?

#define fail(format, arg...)	\
	test_msg("FAIL: %s:%d: " format " (errno = %d (%m))\n", \
		 __FILE__, __LINE__, ## arg, errno)

void test_msg(const char *format, ...)
{
	va_list arg;
	int off = 0;
	char buf[PAGE_SIZE];
	struct timeval tv;
	struct tm *tm;

	gettimeofday(&tv, NULL);
	tm = localtime(&tv.tv_sec);
	if (tm == NULL) {
		err("localtime() failed");
	} else {
		off += strftime(buf, sizeof(buf), "%H:%M:%S", tm);
	}

	off += sprintf(buf + off, ".%.3ld: ", tv.tv_usec / 1000);
	off += sprintf(buf + off, "%5d: ", getpid());
	va_start(arg, format);
	off += vsnprintf(buf + off, sizeof(buf) - off, format, arg);
	va_end(arg);

	fprintf(stderr, "%s", buf);
}

and what's wrong wirtting to stderr then?

	Cyrill


More information about the CRIU mailing list