From patchwork Mon Dec 2 13:18:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 1203153 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47RQgl2DdHz9sPc for ; Tue, 3 Dec 2019 00:19:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbfLBNTa convert rfc822-to-8bit (ORCPT ); Mon, 2 Dec 2019 08:19:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46189 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727640AbfLBNT3 (ORCPT ); Mon, 2 Dec 2019 08:19:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-77-Df7Z5Rv0PtOJKGMFN-1dpg-1; Mon, 02 Dec 2019 08:19:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E750E1005502; Mon, 2 Dec 2019 13:19:22 +0000 (UTC) Received: from krava.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B063600C8; Mon, 2 Dec 2019 13:19:19 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , netdev@vger.kernel.org, bpf@vger.kernel.org, Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , =?utf-8?q?Toke_H=C3=B8ila?= =?utf-8?q?nd-J=C3=B8rgensen?= , Jesper Dangaard Brouer , Daniel Borkmann , Alexei Starovoitov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Quentin Monnet Subject: [PATCH 6/6] selftests, bpftool: Add build test for libbpf dynamic linking Date: Mon, 2 Dec 2019 14:18:46 +0100 Message-Id: <20191202131847.30837-7-jolsa@kernel.org> In-Reply-To: <20191202131847.30837-1-jolsa@kernel.org> References: <20191202131847.30837-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: Df7Z5Rv0PtOJKGMFN-1dpg-1 X-Mimecast-Spam-Score: 0 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Adding new test to test_bpftool_build.sh script to test the dynamic linkage of libbpf for bpftool: $ ./test_bpftool_build.sh [SNIP] ... with dynamic libbpf $PWD: /home/jolsa/kernel/linux-perf/tools/bpf/bpftool command: make -s -C ../../build/feature clean >/dev/null command: make -s -C ../../lib/bpf clean >/dev/null command: make -s -C ../../lib/bpf prefix=/tmp/tmp.fG8O2Ps8ER install_lib install_headers >/dev/null Parsed description of 117 helper function(s) command: make -s clean >/dev/null command: make -s LIBBPF_DYNAMIC=1 LIBBPF_DIR=/tmp/tmp.fG8O2Ps8ER >/dev/null binary: /home/jolsa/kernel/linux-perf/tools/bpf/bpftool/bpftool binary: linked with libbpf The test installs libbpf into temp directory and links bpftool dynamically with it. Signed-off-by: Jiri Olsa --- .../selftests/bpf/test_bpftool_build.sh | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/testing/selftests/bpf/test_bpftool_build.sh b/tools/testing/selftests/bpf/test_bpftool_build.sh index ac349a5cea7e..e4a6a0520f8e 100755 --- a/tools/testing/selftests/bpf/test_bpftool_build.sh +++ b/tools/testing/selftests/bpf/test_bpftool_build.sh @@ -85,6 +85,55 @@ make_with_tmpdir() { echo } +# Assumes current directory is tools/bpf/bpftool +make_with_dynamic_libbpf() { + TMPDIR=$(mktemp -d) + echo -e "\$PWD: $PWD" + + # It might be needed to clean build tree first because features + # framework does not detect the change properly + echo -e "command: make -s -C ../../build/feature clean >/dev/null" + make $J -s -C ../../build/feature clean >/dev/null + if [ $? -ne 0 ] ; then + ERROR=1 + fi + echo -e "command: make -s -C ../../lib/bpf clean >/dev/null" + make $J -s -C ../../lib/bpf clean >/dev/null + if [ $? -ne 0 ] ; then + ERROR=1 + fi + + # Now install libbpf into TMPDIR + echo -e "command: make -s -C ../../lib/bpf prefix=$TMPDIR install_lib install_headers >/dev/null" + make $J -s -C ../../lib/bpf prefix=$TMPDIR install_lib install_headers >/dev/null + if [ $? -ne 0 ] ; then + ERROR=1 + fi + + # And final bpftool build (with clean first) with libbpf dynamic link + echo -e "command: make -s clean >/dev/null" + if [ $? -ne 0 ] ; then + ERROR=1 + fi + echo -e "command: make -s LIBBPF_DYNAMIC=1 LIBBPF_DIR=$TMPDIR >/dev/null" + make $J -s LIBBPF_DYNAMIC=1 LIBBPF_DIR=$TMPDIR >/dev/null + if [ $? -ne 0 ] ; then + ERROR=1 + fi + + check . + ldd bpftool | grep -q libbpf.so + if [ $? -ne 0 ] ; then + printf "FAILURE: Did not find libbpf linked\n" + else + echo "binary: linked with libbpf" + fi + make -s -C ../../lib/bpf clean + make -s clean + rm -rf -- $TMPDIR + echo +} + echo "Trying to build bpftool" echo -e "... through kbuild\n" @@ -145,3 +194,7 @@ make_and_clean make_with_tmpdir OUTPUT make_with_tmpdir O + +echo -e "... with dynamic libbpf\n" + +make_with_dynamic_libbpf