Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion perf tests: Add framework for automated perf_event_attr tests

Received: by 10.68.138.14 with SMTP id qm14mr4857354pbb.5.1352484629996;
        Fri, 09 Nov 2012 10:10:29 -0800 (PST)
From: Jiri Olsa <jo...@redhat.com>
Newsgroups: fa.linux.kernel
Subject: Re: [PATCHv2 03/25] perf tests: Add framework for automated
 perf_event_attr tests
Date: Fri, 02 Nov 2012 10:41:15 UTC
Organization: Internet mailing list
Lines: 97
Sender: linux-kernel-ow...@vger.kernel.org
Message-ID: <fa.uu3YUnNh4hyd7KYgx+l5LuNDkRg@ifi.uio.no>
References: <fa.lKpIMLW4rk9nZoQk2+FwqnT3dTs@ifi.uio.no> <fa.Sc+Sao+TDVUw+LFwtu3z7cIVgI4@ifi.uio.no> <fa.y0+sI8hXYVBa9A7az7GVLGMqBaI@ifi.uio.no> <fa.qq9GRi3SEHYhYVEYIMm7lixD/Gg@ifi.uio.no> <fa.FMRQjjDtJCjWNQd5tX5NsEYjERM@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1351852875 23855 129.240.7.9 (2 Nov 2012 10:41:15 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Fri, 2 Nov 2012 10:41:15 +0000 (UTC)
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: Arnaldo Carvalho de Melo <a...@ghostprotocols.net>,
	linux-ker...@vger.kernel.org,
	Peter Zijlstra <a.p.zijls...@chello.nl>,
	Ingo Molnar <mi...@elte.hu>, Paul Mackerras <pau...@samba.org>,
	Corey Ashford <cjash...@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweis...@gmail.com>
To: Namhyung Kim <namhy...@kernel.org>
In-Reply-To: <87fw4s4ui7.fsf@sejong.aot.lge.com>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org
Original-Date: Fri, 2 Nov 2012 11:40:52 +0100
Original-Message-Id: <20121102104052.GC1157@krava.brq.redhat.com>
Original-References: <1351634526-1516-1-git-send-email-jo...@redhat.com>
 <1351634526-1516-4-git-send-email-jo...@redhat.com>
 <20121030230120.GA1...@krava.redhat.com>
 <20121031142600.GB28...@ghostprotocols.net>
 <20121031145247.GB1...@krava.brq.redhat.com>
 <87fw4s4ui7....@sejong.aot.lge.com>
Path: s9ni1878pbb.0!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.mccarragher.com!news.grnet.gr!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
Bytes: 4949
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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/