From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 4B8EBA04FF;
	Tue, 22 Mar 2022 08:12:40 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id DDC0A427ED;
	Tue, 22 Mar 2022 08:12:39 +0100 (CET)
Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182])
 by mails.dpdk.org (Postfix) with ESMTP id 88B45410E5;
 Tue, 22 Mar 2022 08:12:38 +0100 (CET)
Received: by linux.microsoft.com (Postfix, from userid 1086)
 id 9A63F20D5913; Tue, 22 Mar 2022 00:12:37 -0700 (PDT)
DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9A63F20D5913
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;
 s=default; t=1647933157;
 bh=xmbVCBtYABRU8DGFyCtZIzIfCwfeycHX6CFinUJYn+U=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
 b=COSK8rBSj85nUVr0rkY8UTPHUjiLqp6FB/2qL56iC41ebILaHrDwnOlOxSNH7UJ51
 Q4I4G2cTWGqMaFPC0fhatoRHSSita/V8MZvtrCBm2buGYQyEH2jHZWhbdtgHojMXEy
 qjY3x3K8EUL0Do0zBydMBfYWO6LFSZBTCFaKrk0g=
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: Tyler Retzlaff <roretzla@linux.microsoft.com>, stephen@networkplumber.org,
 anatoly.burakov@intel.com, stable@dpdk.org
Subject: [PATCH v2] test/bpf: skip test if libpcap is unavailable
Date: Tue, 22 Mar 2022 00:12:35 -0700
Message-Id: <1647933155-30745-1-git-send-email-roretzla@linux.microsoft.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1647868407-4467-1-git-send-email-roretzla@linux.microsoft.com>
References: <1647868407-4467-1-git-send-email-roretzla@linux.microsoft.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

test_bpf_convert is being conditionally registered depending on the
presence of RTE_HAS_LIBPCAP except the UT unconditionally lists it as a
test to run.

when the UT runs test_bpf_convert test-dpdk can't find the registration
and assumes the DPDK_TEST environment variable hasn't been defined
resulting in test-dpdk dropping to interactive mode and subsequently
waiting for the remainder of the UT fast-test timeout period before
reporting the test as having timed out.

* unconditionally register test_bpf_convert
* if ! RTE_HAS_LIBPCAP provide a stub test_bpf_convert that reports the
  test is skipped similar to that done with the test_bpf test.

Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")
Cc: stephen@networkplumber.org
Cc: anatoly.burakov@intel.com
Cc: stable@dpdk.org

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/test/test_bpf.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index 805cce6..97f5008 100644
--- a/app/test/test_bpf.c
+++ b/app/test/test_bpf.c
@@ -3264,7 +3264,16 @@ struct bpf_test {
 
 REGISTER_TEST_COMMAND(bpf_autotest, test_bpf);
 
-#ifdef RTE_HAS_LIBPCAP
+#ifndef RTE_HAS_LIBPCAP
+
+static int
+test_bpf_convert(void)
+{
+	printf("BPF convert RTE_HAS_LIBPCAP is undefined, skipping test\n");
+	return TEST_SKIPPED;
+}
+
+#else
 #include <pcap/pcap.h>
 
 static void
@@ -3462,5 +3471,6 @@ struct bpf_test {
 	return rc;
 }
 
-REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);
 #endif /* RTE_HAS_LIBPCAP */
+
+REGISTER_TEST_COMMAND(bpf_convert_autotest, test_bpf_convert);
-- 
1.8.3.1