mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Kan Liang <kan.liang@intel.com>
Cc: acme@kernel.org, jolsa@kernel.org, ak@linux.intel.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V5 1/1] perf,test: test cpu topology
Date: Fri, 4 Sep 2015 09:40:20 +0200	[thread overview]
Message-ID: <20150904074020.GE24774@krava.redhat.com> (raw)
In-Reply-To: <1441174982-25090-1-git-send-email-kan.liang@intel.com>

On Wed, Sep 02, 2015 at 02:23:02AM -0400, Kan Liang wrote:

SNIP

> +
> +int test_session_topology(void)
> +{
> +	struct perf_session *session;
> +	char path[PATH_MAX];
> +	struct cpu_map *map;
> +	struct perf_data_file file = {
> +		.path = path,
> +		.mode = PERF_DATA_MODE_WRITE,
> +	};
> +	int i;
> +
> +	TEST_ASSERT_VAL("can't get templ file", !get_temp(path));
> +
> +	pr_debug("krava %s\n", path);

it's not that I'd have monopoly on that, but this probably
needs some better wording ;-)

> +
> +	session = perf_session__new(&file, false, NULL);
> +	TEST_ASSERT_VAL("can't get session", session);

hum, any failed TEST_ASSERT_VAL will leave the temp file

> +
> +	session->evlist = perf_evlist__new_default();
> +	TEST_ASSERT_VAL("can't get evlist", session->evlist);
> +
> +	perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
> +	perf_header__set_feat(&session->header, HEADER_NRCPUS);
> +
> +	session->header.data_size += DATA_SIZE;
> +
> +	TEST_ASSERT_VAL("failed to write header",
> +			!perf_session__write_header(session, session->evlist, file.fd, true));
> +
> +	perf_session__delete(session);
> +
> +	map = cpu_map__new(NULL);

also map, but the file is bigger issue, because someone might notice ;-)

jirka

> +	TEST_ASSERT_VAL("failed to get system cpumap", !(map == NULL));
> +
> +	file.mode = PERF_DATA_MODE_READ;
> +	session = perf_session__new(&file, false, NULL);
> +	TEST_ASSERT_VAL("can't get session", session);
> +
> +	for (i = 0; i < session->header.env.nr_cpus_online; i++) {
> +		pr_debug("CPU %d, core %d, socket %d\n", i,
> +			 session->header.env.cpu[i].core_id,
> +			 session->header.env.cpu[i].socket_id);
> +	}
> +
> +	for (i = 0; i < map->nr; i++) {
> +		TEST_ASSERT_VAL("Core ID doesn't match",
> +			(session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core(map, i) & 0xffff)));
> +
> +		TEST_ASSERT_VAL("Socket ID doesn't match",
> +			(session->header.env.cpu[map->map[i]].socket_id == cpu_map__get_socket(map, i)));
> +	}
> +
> +	perf_session__delete(session);
> +	cpu_map__put(map);
> +	unlink(path);
> +
> +	return 0;
> +}
> -- 
> 1.8.3.1
> 

      reply	other threads:[~2015-09-04  7:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02  6:23 Kan Liang
2015-09-04  7:40 ` Jiri Olsa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150904074020.GE24774@krava.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®