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=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 29492C606C2 for ; Mon, 8 Jul 2019 17:25:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0E56216C4 for ; Mon, 8 Jul 2019 17:25:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="VCBfnJPX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388979AbfGHRZC (ORCPT ); Mon, 8 Jul 2019 13:25:02 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:42511 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728744AbfGHRZB (ORCPT ); Mon, 8 Jul 2019 13:25:01 -0400 Received: by mail-io1-f65.google.com with SMTP id u19so37010136ior.9 for ; Mon, 08 Jul 2019 10:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aErlu6fvYbW7WJ9LzWOWg2BZGtOQx1pF2GQfzMk3Y/8=; b=VCBfnJPXV9syPat1kOEmvhib+2y3XP+4I0d7KywQrjJK826YVQSQ0s+LuNsImrvn7b 8Kt4ZrBdf9irHKHIhcOfyzDdDPQ9KmQ3syDTUC9m8Hrzag67kXSDFF0OpfH4EzvMmeAi y3l+uz3jPkzLyDlU5qr0SirGbWvNsXDt0vSZ391CMP7xfWbMKNnQMXL2TVU/uPh49965 foTtStDx8zVQ5TmsAPLcijGC5lLscwJbLEtQdKqQ5KP9QaMCWJKz8VjDL8PbAOiKqxvu ehOfmz1IG8nw38KZSlcBAoDfwqUXUtBK+ZNlSMRnsaSTT1tCo1WBUYE+KOYBfhW9uKGW elyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aErlu6fvYbW7WJ9LzWOWg2BZGtOQx1pF2GQfzMk3Y/8=; b=rRIeqrBGPUPkL8aJeTkPetTupysorDrylVvmQtsY0v1ZjlME5I5Rv2BggopFWSM1Xi AjEoJzMZuBzTRijDfwBm6NXmm82kb17ME3Q7CasrHxFwJOQSixAxezhEyxUHKL8jEcx7 JqwjgYZt9ZdMKe7kPDSZbPihYemOCrbcubVMtqAQjHgL6CuOeoWRNmvk9e9cwECAUNte F52S0E4qskWy29yl6lgJdgHWPgQmfmdErnshQ7DT5H7uJ5uQtlaz9lSijkPKAzMH1HTl X+5XXg32U4A9fKX88WdSI6cwEOO1M9/D8dYhYV8s9HtdVGsle64sYcNxOc/OZ19b51u+ /rQw== X-Gm-Message-State: APjAAAX14CKmUVljtoSI+6iRpYRK4hY/gKc77ZLDV9Fu+pC+f4cm2Ef3 yMP2c1ku+ON1VL4ulBw45JBHH2ouo3w= X-Google-Smtp-Source: APXvYqyMmY7+V0915DbqfY3XR7MKKomjkgbNlHvFF8mGQoP8L00oFD2ZeAVcPparY+bnJBfoSEvlYw== X-Received: by 2002:a02:c6b8:: with SMTP id o24mr23731592jan.80.1562606701181; Mon, 08 Jul 2019 10:25:01 -0700 (PDT) Received: from x220t ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id e22sm16459241iob.66.2019.07.08.10.25.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 10:25:00 -0700 (PDT) Date: Mon, 8 Jul 2019 13:24:58 -0400 From: Alexander Aring To: Lucas Bates Cc: David Miller , Linux Kernel Network Developers , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Marcelo Ricardo Leitner , Vlad Buslov , Davide Caratti , kernel@mojatatu.com Subject: Re: [PATCH v2 net-next 1/3] tc-testing: Add JSON verification to tdc Message-ID: <20190708172458.syopc3bvvkjb3sxv@x220t> References: <1562201102-4332-1-git-send-email-lucasb@mojatatu.com> <1562201102-4332-2-git-send-email-lucasb@mojatatu.com> <20190704202130.tv2ivy5tjj7pjasj@x220t> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi, On Mon, Jul 08, 2019 at 12:48:12PM -0400, Lucas Bates wrote: > On Thu, Jul 4, 2019 at 4:21 PM Alexander Aring wrote: > > > why you just use eval() as pattern matching operation and let the user > > define how to declare a matching mechanism instead you introduce another > > static matching scheme based on a json description? > > > > Whereas in eval() you could directly use the python bool expression > > parser to make whatever you want. > > > > I don't know, I see at some points you will hit limitations what you can > > express with this matchFOO and we need to introduce another matchBAR, > > whereas in providing the code it should be no problem expression > > anything. If you want smaller shortcuts writing matching patterns you > > can implement them and using in your eval() operation. > > Regarding hitting limitations: quite possibly, yes. > > Using eval() to provide code for matching is going to put more of a > dependency on the test writer knowing Python. I know it's not a > terribly difficult language to pick up, but it's still setting a > higher barrier to entry. This is the primary reason I scrapped the > work I had presented at Netdev 1.2 in Tokyo, where all the tests were > coded using Python's unittest framework - I want to be sure it's as > easy as possible for people to use tdc and write tests for it. > > Unless I'm off-base here? yes you need to know some python, complex code can be hidden by some helper functionality I guess. I have no problem to let this patch in, it will not harm anything... Maybe I work on a matchEval and show some examples... in a human readable way you can even concatenate bool expressions in combinations with helpers. I just was curious, so I might add the matchEval or something to show this approach. add the and it shows like: "x == 5 or x == '5'" Whereas you could introduce helpers to do: "str_or_num(x, 5)" even "str_or_num_any_base(x, 5)" to also catch if somebody change the base. In this case "or" could be also concatenate with python bool expression... depends on how lowlvl your helpers be. Pretty sure the x as inputstring to match can also be hidden by user or transformed with split, regex, etc before. At the end it will work like TC with actions just provide the code to run... or is it more like "act_bpf"?, where act is the hook and bpf the eval(). :-) - Alex