Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1568097ybl; Mon, 2 Dec 2019 05:22:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwroTVT+Rplpv5dOvz+mp03FXFtcoNENIR8rxVJD4L7zLe1uS4kjlKzEezBaW70LkzINNlX X-Received: by 2002:aa7:c2c7:: with SMTP id m7mr64146945edp.295.1575292931152; Mon, 02 Dec 2019 05:22:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575292931; cv=none; d=google.com; s=arc-20160816; b=tJaHkfFwtLuX8DViqoRPP380Fm42BsbHNyRiViG402Kb2RgxCQvHWiR6wLkk0itD3s AI1W3KtE/V+SrbVnWexuCDHhK3FLF2d40KyTfUL8y8IVJnEUuF0MnkMcnYHUlz56fsoY KdhEEzisrfWJDdwsyD2lrDRd7HaXgo5LxLs7k/WDw0QHmYzVVM9+Ue79N0fyAyKs2Exr Rpf/sbKaU4fKze3wnoelygZ9B+Jm4MXT73AeCTuhSRpVcOmznC3Z4JTRvwqA3O5Ks2Yj 5XNhzgtaxByyFKytl9rZDsEhtoWMLLAvbQxMmKYN4+23HArUQF2/n/IzsTG4ZeRGRg91 YJDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1bsJJ6BqCi7omZoO35rgu9b66kBJTT4L5Bh05+P2Qm0=; b=IaKNsPRlWH0QIdMWx7X/xcg3JGrjNpShPSjXY1BfkMo1rhvRQ2rgvDspsTsHKuUDK2 W5yNxlEd40y5iu2an5+blSUy927ynch/SuVnfdi6GC1qEb6qIgd8mIfsmdaUwPPj8Zn6 R4JNI3W27vuD7PIO1U/ipdFPB/adupH9adwuxhtacZ3rbUQH4hiReL8Cm/DA6+YIC76Z xKQGWpFXqStcNMkNdF6ZiTwJXjOwsQhDJlfbqoA50drHNvViavJYJpIbC5FYISzZmibk I40RqP0TwNBKieLiZ66FbMu8PQHejBmaP7jF1IW8NcdoTZF2tXmjdrb6YPXLcLv1P9hf QT8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id om20si6861523ejb.120.2019.12.02.05.21.42; Mon, 02 Dec 2019 05:22:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbfLBNTb convert rfc822-to-8bit (ORCPT + 99 others); Mon, 2 Dec 2019 08:19:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25776 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727641AbfLBNT3 (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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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