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 28D12A0093;
	Thu,  9 Dec 2021 17:40:35 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id A36064014F;
	Thu,  9 Dec 2021 17:40:34 +0100 (CET)
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by mails.dpdk.org (Postfix) with ESMTP id 5971240041
 for <dev@dpdk.org>; Thu,  9 Dec 2021 17:40:31 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1639068032; x=1670604032;
 h=date:from:to:cc:subject:message-id:references:
 mime-version:in-reply-to;
 bh=JPZvy7uB727Ji+yu5B0IeCcPBAzf/EUUHXnpu/h52JI=;
 b=Fs+TE5PRy4flkK5JelmMiTYTeujgho+rqm+vf5NFrzcUXbbU2iE7qcWb
 qKItQu5aylOHG4Cx+zKzQZD8IL6+tzCjOt80DEBz8tMgMJ24uGm0Hpj3u
 uzvJP0CnkW7rnkbIgKfK8kSLSggIu/zFns8jf/gApqzwq7pN60T7O0bLG
 n/a2MGXdYeHyDyK9X4APla1SrH+TYuaAcz0zM857c0pugwrRiNcYvCXH/
 1e6vk3R+eo3Wg3fM0/o20IsCd6FWqcqLn8Jn2MlYzVYGPOB6xRL0EaCMR
 lKDBXKxw6M2Lss/6UPiyEeYBWl5/z8PEUhvfaHI1idZgVq2kKdjFRkmFj g==;
X-IronPort-AV: E=McAfee;i="6200,9189,10193"; a="225414027"
X-IronPort-AV: E=Sophos;i="5.88,193,1635231600"; d="scan'208";a="225414027"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 09 Dec 2021 08:39:09 -0800
X-IronPort-AV: E=Sophos;i="5.88,193,1635231600"; d="scan'208";a="516373097"
Received: from bricha3-mobl.ger.corp.intel.com ([10.252.18.131])
 by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA;
 09 Dec 2021 08:39:05 -0800
Date: Thu, 9 Dec 2021 16:39:02 +0000
From: Bruce Richardson <bruce.richardson@intel.com>
To: Aaron Conole <aconole@redhat.com>
Cc: Jerin Jacob <jerinjacobk@gmail.com>,
 Jie Zhou <jizh@linux.microsoft.com>, dpdk-dev <dev@dpdk.org>,
 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>, roretzla@microsoft.com,
 Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
 "Dmitry Malloy (MESHCHANINOV)" <dmitrym@microsoft.com>,
 Pallavi Kadam <pallavi.kadam@intel.com>, talshn@nvidia.com,
 Thomas Monjalon <thomas@monjalon.net>
Subject: Re: [PATCH v14 04/11] app/test: skip interrupt tests on Windows
Message-ID: <YbIxJg6mvyohnBBf@bricha3-MOBL.ger.corp.intel.com>
References: <1638928262-13177-1-git-send-email-jizh@linux.microsoft.com>
 <1638990000-3228-1-git-send-email-jizh@linux.microsoft.com>
 <1638990000-3228-5-git-send-email-jizh@linux.microsoft.com>
 <CALBAE1Np=N-QxUrR_7ETjrrXyK-o-NiCwkqFdtTe+n+Mg0HbBw@mail.gmail.com>
 <f7t1r2lsywa.fsf@redhat.com>
 <YbIsBNq+nWaGvT/C@bricha3-MOBL.ger.corp.intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <YbIsBNq+nWaGvT/C@bricha3-MOBL.ger.corp.intel.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

On Thu, Dec 09, 2021 at 04:17:08PM +0000, Bruce Richardson wrote:
> On Thu, Dec 09, 2021 at 08:15:01AM -0500, Aaron Conole wrote:
> > Jerin Jacob <jerinjacobk@gmail.com> writes:
> > 
> > > On Thu, Dec 9, 2021 at 12:30 AM Jie Zhou <jizh@linux.microsoft.com> wrote:
> > >>
> > >> Even though test_interrupts.c can compile on Windows, skip interrupt
> > >> tests for now since majority of eal_interrupt on Windows are stubs.
> > >> Will remove the skip after interrupt being fully enabled on Windows.
> > >>
> > >> Signed-off-by: Jie Zhou <jizh@linux.microsoft.com>
> > >> Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> > >>
> > >> ---
> > >>  app/test/test_interrupts.c | 10 ++++++++++
> > >>  1 file changed, 10 insertions(+)
> > >>
> > >> diff --git a/app/test/test_interrupts.c b/app/test/test_interrupts.c
> > >> index 2a05399f96..eec9b2805b 100644
> > >> --- a/app/test/test_interrupts.c
> > >> +++ b/app/test/test_interrupts.c
> > >> @@ -12,6 +12,15 @@
> > >>
> > >>  #include "test.h"
> > >>
> > >> +#ifdef RTE_EXEC_ENV_WINDOWS
> > >
> > > Across the series,
> > > Instead of adding conditional compilation everywhere, Why not disable
> > > specific file
> > > for compilation for windows?
> > > Purpose of EAL to abstract the differences in execution environment
> > > and application
> > > should not know that.
> > 
> > I think this was done because there would be two test lists in the meson
> > unit test file.  But this is the second comment about these ifdef's, and
> > maybe we should revisit that discussion.  Is there a different way to
> > accomplish not running the tests which are not appropriate for windows
> > builds, while not having two overlapping lists of unit tests in the
> > meson build file?
> > 
> I'm wondering if a reasonable compromise solution might be to have the
> build system expose a usable RTE_EXEC_ENV symbol that can be used in C-code
> if statements rather than just in ifdefs. That would allow us to easily add
> e.g.
> 
> if (RTE_EXEC_ENV == rte_env_linux)
>     return TEST_SKIPPED;
> 
> into each test function needing it. Two lines of C-code is a lot easier to
> add and manage than #ifdefs covering the whole file, or alternative lists
> in meson.
> 
Quick patch to allow C-code comparisons:

diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 1722924f67..b5b9fa14b4 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -10,6 +10,12 @@ if not is_windows
     subdir('unix')
 endif
 
+exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
+foreach env, id:exec_envs
+    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
+endforeach
+dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
+
 dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env)

A slightly simpler patch would just expose the environment as a string as
e.g. "linux", but I think numeric ids just make the code better rather than
having string comparisons. Alternatively, this could also be done via
C-code with ifdefs in EAL, but as it stands this meson change allows:

  if (RTE_EXEC_ENV == RTE_ENV_WINDOWS)
     ...

or:

  switch (RTE_EXEC_ENV) {
    case RTE_ENV_LINUX: ... ; break;
    case RTE_ENV_FREEBSD: ... ; break;
    case RTE_ENV_WINDOWS: ... ; break;
  }

Thoughts?

/Bruce