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 <ar...@mojatatu.com> 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