test/bpf: skip test if libpcap is unavailable

Message ID 1647868407-4467-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series test/bpf: skip test if libpcap is unavailable |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-broadcom-Functional fail Functional Testing issues

Commit Message

Tyler Retzlaff March 21, 2022, 1:13 p.m. UTC
  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(-)
  

Comments

Ananyev, Konstantin March 21, 2022, 2:42 p.m. UTC | #1
> 
> 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..de1fa87 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 not supported, skipping test\n");

One nit: the message above seems a bit misleading...
Probably "LIBPCAP is not supported" or so?
With that fixed:
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>


> +	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
  
Stephen Hemminger March 21, 2022, 4:15 p.m. UTC | #2
On Mon, 21 Mar 2022 06:13:27 -0700
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:

> 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>

LGTM
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  
Tyler Retzlaff March 22, 2022, 6:11 a.m. UTC | #3
On Mon, Mar 21, 2022 at 02:42:39PM +0000, Ananyev, Konstantin wrote:
> 
> > 
> > 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..de1fa87 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 not supported, skipping test\n");
> 
> One nit: the message above seems a bit misleading...
> Probably "LIBPCAP is not supported" or so?
> With that fixed:
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

yeah, i cut and paste the other skip function. i agree i'll tweak the
message to talk about libpcap.

> 
> 
> > +	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
  

Patch

diff --git a/app/test/test_bpf.c b/app/test/test_bpf.c
index 805cce6..de1fa87 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 not supported, 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);