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

Andrew Vagin avagin at parallels.com
Fri Jan 11 16:11:43 EST 2013


On Sat, Jan 12, 2013 at 12:58:09AM +0400, Cyrill Gorcunov wrote:
> 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?

Sorry, I want to say that fail() should not be used here.
It is not about code, it is about philosophy.

Just because a test stage starts after test_daemon().

If we talk about C/R, a test should report fail only after restore
(test_waitsig()).

> 
> #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