Re: [PATCH 05/23] perf tests: Add simple session read/write test

From: Jiri Olsa
Date: Thu Jul 18 2013 - 10:27:34 EST


On Wed, Jul 17, 2013 at 04:33:13PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

> > +
> > +static union perf_event *get_event_MMAP(void)
> > +{
> > + static union perf_event event;
> > + size_t size;
> > +
> > + size = snprintf(event.mmap.filename, sizeof(event.mmap.filename),
> > + "krava") + 1;
> > + size = PERF_ALIGN(size, sizeof(u64));
> > +
> > + event.header.type = PERF_RECORD_MMAP;
> > + event.header.misc = PERF_RECORD_MISC_KERNEL;
> > + event.header.size = sizeof(event.mmap) -
> > + (sizeof(event.mmap.filename) - size);
> > +
> > + event.mmap.pgoff = 10;
> > + event.mmap.start = 0;
> > + event.mmap.len = 10;
> > + event.mmap.pid = 123;
> > +
> > + return &event;
> > +}
>
> Don't use statics, here perhaps we can have another general purpose
> helper:
>
> void perf_event__init_mmap(union perf_event *event)

well, the thing is that it makes the test simple, I can use it like:

TEST_ASSERT_VAL("failed to store MMAP event",
!store_event(fd, get_event_MMAP(), &size));

no need to call extra functions, just get the single event

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/