Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338884
b: refs/heads/master
c: 3f3a206
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Ingo Molnar committed Oct 24, 2012
1 parent 545136e commit 685d477
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1d33d6dce11e2c900daeca8110d56b95f1174188
refs/heads/master: 3f3a20648797c3ff49c6ebfe10747ef0acd37c50
68 changes: 68 additions & 0 deletions trunk/tools/perf/util/parse-events-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,23 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist)
return 0;
}

static int test__checkevent_pmu_events(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;

evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong exclude_user",
!evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel",
evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);

return 0;
}

static int test__checkterms_simple(struct list_head *terms)
{
struct parse_events__term *term;
Expand Down Expand Up @@ -1024,6 +1041,51 @@ static int test_pmu(void)
return !ret;
}

static int test_pmu_events(void)
{
struct stat st;
char path[PATH_MAX];
struct dirent *ent;
DIR *dir;
int ret;

snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
sysfs_find_mountpoint());

ret = stat(path, &st);
if (ret) {
pr_debug("ommiting PMU cpu events tests\n");
return 0;
}

dir = opendir(path);
if (!dir) {
pr_debug("can't open pmu event dir");
return -1;
}

while (!ret && (ent = readdir(dir))) {
#define MAX_NAME 100
struct test__event_st e;
char name[MAX_NAME];

if (!strcmp(ent->d_name, ".") ||
!strcmp(ent->d_name, ".."))
continue;

snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);

e.name = name;
e.check = test__checkevent_pmu_events;

ret = test_event(&e);
#undef MAX_NAME
}

closedir(dir);
return ret;
}

int parse_events__test(void)
{
int ret1, ret2 = 0;
Expand All @@ -1040,6 +1102,12 @@ do { \
if (test_pmu())
TEST_EVENTS(test__events_pmu);

if (test_pmu()) {
int ret = test_pmu_events();
if (ret)
return ret;
}

ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));
if (!ret2)
ret2 = ret1;
Expand Down

0 comments on commit 685d477

Please sign in to comment.