All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Wang Nan <wangnan0@huawei.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Brendan Gregg <brendan.d.gregg@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	He Kuang <hekuang@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
	Li Zefan <lizefan@huawei.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will.deacon@arm.com>,
	pi3orama@163.com, Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 08/16] perf test: Check environment before start real BPF test
Date: Fri, 29 Jan 2016 18:17:45 -0300	[thread overview]
Message-ID: <1454102273-16431-9-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1454102273-16431-1-git-send-email-acme@kernel.org>

See http://www.infradead.org/rpr.html

From: Wang Nan <wangnan0@huawei.com>

Copying perf to old kernel system results:

  # perf test bpf
  37: Test BPF filter                                          :
  37.1: Test basic BPF filtering                               : FAILED!
  37.2: Test BPF prologue generation                           : Skip

However, in case when kernel doesn't support a test case it should
return 'Skip', 'FAILED!' should be reserved for kernel tests for when
the kernel supports a feature that then fails to work as advertised.

This patch checks environment before real testcase.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1453715801-7732-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/bpf.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 952ca99aba6b..4aed5cb4ac2d 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -1,7 +1,11 @@
 #include <stdio.h>
 #include <sys/epoll.h>
+#include <util/util.h>
 #include <util/bpf-loader.h>
 #include <util/evlist.h>
+#include <linux/bpf.h>
+#include <linux/filter.h>
+#include <bpf/bpf.h>
 #include "tests.h"
 #include "llvm.h"
 #include "debug.h"
@@ -243,6 +247,36 @@ const char *test__bpf_subtest_get_desc(int i)
 	return bpf_testcase_table[i].desc;
 }
 
+static int check_env(void)
+{
+	int err;
+	unsigned int kver_int;
+	char license[] = "GPL";
+
+	struct bpf_insn insns[] = {
+		BPF_MOV64_IMM(BPF_REG_0, 1),
+		BPF_EXIT_INSN(),
+	};
+
+	err = fetch_kernel_version(&kver_int, NULL, 0);
+	if (err) {
+		pr_debug("Unable to get kernel version\n");
+		return err;
+	}
+
+	err = bpf_load_program(BPF_PROG_TYPE_KPROBE, insns,
+			       sizeof(insns) / sizeof(insns[0]),
+			       license, kver_int, NULL, 0);
+	if (err < 0) {
+		pr_err("Missing basic BPF support, skip this test: %s\n",
+		       strerror(errno));
+		return err;
+	}
+	close(err);
+
+	return 0;
+}
+
 int test__bpf(int i)
 {
 	int err;
@@ -255,6 +289,9 @@ int test__bpf(int i)
 		return TEST_SKIP;
 	}
 
+	if (check_env())
+		return TEST_SKIP;
+
 	err = __test__bpf(i);
 	return err;
 }
-- 
2.5.0

  parent reply	other threads:[~2016-01-29 21:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29 21:17 [GIT PULL 00/16] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-01-29 21:17 ` Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 01/16] tools build: Check basic headers for test-compile feature checker Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 02/16] perf build: Fix feature-dump checks, we need to test all features Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 03/16] perf build: Remove all condition feature check {C,LD}FLAGS Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 04/16] perf build: Use feature dump file for build-test Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 05/16] perf tools: Speed up build-tests by reducing the number of builds tested Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 06/16] perf auxtrace: Add perf_evlist pointer to *info_priv_size() Arnaldo Carvalho de Melo
2016-01-29 21:17   ` Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 07/16] perf buildid: Fix cpumode of buildid event Arnaldo Carvalho de Melo
2016-01-29 21:17 ` Arnaldo Carvalho de Melo [this message]
2016-01-29 21:17 ` [PATCH 09/16] perf test: Improve bp_signal Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 10/16] perf tools: Move timestamp creation to util Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 11/16] perf record: Use OPT_BOOLEAN_SET for buildid cache related options Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 12/16] perf kvm/{x86, s390}: Remove dependency on uapi/kvm_perf.h Arnaldo Carvalho de Melo
2016-01-29 21:17   ` [PATCH 12/16] perf kvm/{x86,s390}: " Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 13/16] perf kvm/{x86,s390}: Remove const from kvm_events_tp Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 14/16] perf kvm/powerpc: Port perf kvm stat to powerpc Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 15/16] perf kvm/powerpc: Add support for HCALL reasons Arnaldo Carvalho de Melo
2016-01-29 21:17 ` [PATCH 16/16] perf build: Align the names of the build tests: Arnaldo Carvalho de Melo
2016-02-03 10:02 ` [GIT PULL 00/16] perf/core improvements and fixes Ingo Molnar
2016-02-03 10:02   ` Ingo Molnar

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=1454102273-16431-9-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ast@kernel.org \
    --cc=brendan.d.gregg@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    --cc=will.deacon@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.