On Fri, Nov 02, 2012 at 11:18:56AM +0900, Namhyung Kim wrote:
> On Wed, 31 Oct 2012 15:52:47 +0100, Jiri Olsa wrote:
> > Adding automated test to check event's perf_event_attr values.
> > +#define WRITE_ASS(str, fmt, data)                                  \
> > +do {                                                                       
> > \
> > +   char buf[BUFSIZE];                                              \
> > +   size_t size;                                                    \
> > +                                                                   \
> > +   size = snprintf(buf, BUFSIZE, #str "=%"fmt "\n", data);         \
> > +   if (1 != fwrite(buf, size, 1, file)) {                          \
> > +           perror("test attr - failed to write event file");       \
> > +           fclose(file);                                           \
> > +           return -1;                                              \
> > +   }                                                               \
> > +                                                                   \
> > +} while (0)
> 
> What is ASS?

short for assignment

> 
> > +
> > +static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,
> > +                  int fd, int group_fd, unsigned long flags)
> > +{
> > +   FILE *file;
> > +   char path[PATH_MAX];
> > +

SNIP

> > +   WRITE_ASS(sample_regs_user,   "llu", attr->sample_regs_user);
> > +   WRITE_ASS(sample_stack_user,  PRIu32, attr->sample_stack_user);
> > +   WRITE_ASS(optional, "d", 0);
> 
> How about rename current WRITE_ASS to __WRITE_ASS and create a wrapper
> WRITE_ASS like this:
> 
>   #define WRITE_ASS(field, fmt)  __WRITE_ASS(field, fmt, attr->field)
> 
> and use __WRITE_ASS for 'optional'.

looks ok

> 
> > +
> > +   fclose(file);
> > +   return 0;
> > +}
> [snip]
> > +    def compare_data(self, a, b):
> > +        a_list = a.split('|')
> > +        b_list = b.split('|')
> > +
> > +        for a_item in a_list:
> > +            for b_item in b_list:
> > +                if (a_item == b_item):
> > +                    return True
> > +                elif (a_item == '*') or (b_item == '*'):
> > +                    return True
> > +
> > +        return False
> 
> I think it needs some comments about how it works.
> 
> > +
> [snip]
> > +    def load_events(self, path, events):
> > +        parser_event = ConfigParser.SafeConfigParser()
> > +        parser_event.read(path)
> > +
> > +        for section in filter(self.is_event, parser_event.sections()):
> > +
> > +            parser_items = parser_event.items(section);
> > +            base_items   = {}
> > +
> > +            if (':' in section):
> > +                base = section[section.index(':') + 1:]
> > +                parser_base = ConfigParser.SafeConfigParser()
> > +                parser_base.read(self.test_dir + '/' + base)
> > +                base_items = parser_base.items('event')
> > +
> > +            e = Event(section, parser_items, base_items)
> > +            events[section] = e
> 
> And this too. :)

ok, will try ;)

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

Reply via email to