lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 2 Nov 2012 11:40:52 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	Namhyung Kim <namhyung@...nel.org>
Cc:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	linux-kernel@...r.kernel.org,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>
Subject: Re: [PATCHv2 03/25] perf tests: Add framework for automated
 perf_event_attr tests

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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ