From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93995C43215 for ; Mon, 2 Dec 2019 13:19:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6904320674 for ; Mon, 2 Dec 2019 13:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575292770; bh=ta352u00Y9Sh/vXn7+ZQhT6z5MmNgcaRNDiZYABzNgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FiGZFMqDtyyVsIxnx22RFiU8HI76RWGYWaYjRYy4fe4J+sxa8kG4nx4ZeRBNAK0im bdsoxILpD5uYgQXwzRTad+wscBKLrsnvsdARh+LkDNSd7B3325Goplr/2RzMYjuD5Z 2MYr0UHcObDH056EE1XY+BC9n8G9fyrLQqE7jsgk= 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=20H=C3=B8iland-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 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT 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 -- 2.21.0