Why my AT_CHECK() can't work?

classic Classic list List threaded Threaded
10 messages Options
Sam
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why my AT_CHECK() can't work?

Sam
Hi all,

I'm using autotest to test ovs, and I write a new *.at file using only one
AT_CHECK sentence like this:

AT_CHECK([ovs-appctl dpdk/bond-show dpdkb2], [0], [stdout])
> AT_CHECK([[sed '/ACTIVE/p' stdout | head -4]], [0], [[LACP actor_state
> ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING]])


but this *.at file failed, log is:

789. netdev-dpdk.at:23: testing netdev-dpdk - dpdk/bond-show ...

> ./netdev-dpdk.at:27: ovs-appctl dpdk/bond-show dpdkb2
> stdout:
> ---- dpdkb2 ----
> bond_mode: 4
> slave 0:
> active
> mac address ec:f4:bb:e1:1a:40
> Link Up - speed 10000 Mbps - full-duplex
> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>  rx pkts=268449, bytes=16502449, mcasts=0, drop=0, errs=0, nombufs=0
>  tx pkts=261, bytes=32020, errs=0
> slave 1:
> active
> mac address ec:f4:bb:e1:1a:42
> Link Up - speed 10000 Mbps - full-duplex
> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>  rx pkts=296190, bytes=17934647, mcasts=0, drop=0, errs=0, nombufs=0
>  tx pkts=254, bytes=31496, errs=0
> ./netdev-dpdk.at:28: sed '/ACTIVE/p' stdout | head -4
> --- -   2017-08-09 16:59:18.802810195 +0800
> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>  2017-08-09 16:59:18.801176471 +0800
> @@ -1,4 +1,5 @@
> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> +---- dpdkb2 ----
> +bond_mode: 4
> +
> +slave 0:
> +
> 789. netdev-dpdk.at:23: 789. netdev-dpdk - dpdk/bond-show (
> netdev-dpdk.at:23): FAILED (netdev-dpdk.at:28)


1. I don't know what "+" "-" means, and why there are "+" and "-"?
2. I run `ovs-appctl dpdk/bond-show dpdkb2 | sed -n '/ACTIVE/p' | head -4`,
result is:

> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING

That's exactly what I matched in AT_CHECK, why it fails?

Autotest is really hard to use...
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Sam
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Sam
Then I change commd into `awk '/ACTIVE/' stdout | head -4`, it failed
again, log is :

./netdev-dpdk.at:28: awk '/ACTIVE/' stdout | head -4

> --- -   2017-08-09 17:41:24.809066088 +0800
> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>  2017-08-09 17:41:24.807150522 +0800
> @@ -1,5 +1,5 @@
> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> 789. netdev-dpdk.at:23: 789. netdev-dpdk - dpdk/bond-show (
> netdev-dpdk.at:23): FAILED (netdev-dpdk.at:28)


I don't know where is the difference....

2017-08-09 17:15 GMT+08:00 Sam <[hidden email]>:

> Hi all,
>
> I'm using autotest to test ovs, and I write a new *.at file using only one
> AT_CHECK sentence like this:
>
> AT_CHECK([ovs-appctl dpdk/bond-show dpdkb2], [0], [stdout])
>> AT_CHECK([[sed '/ACTIVE/p' stdout | head -4]], [0], [[LACP actor_state
>> ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING]])
>
>
> but this *.at file failed, log is:
>
> 789. netdev-dpdk.at:23: testing netdev-dpdk - dpdk/bond-show ...
>> ./netdev-dpdk.at:27: ovs-appctl dpdk/bond-show dpdkb2
>> stdout:
>> ---- dpdkb2 ----
>> bond_mode: 4
>> slave 0:
>> active
>> mac address ec:f4:bb:e1:1a:40
>> Link Up - speed 10000 Mbps - full-duplex
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>  rx pkts=268449, bytes=16502449, mcasts=0, drop=0, errs=0, nombufs=0
>>  tx pkts=261, bytes=32020, errs=0
>> slave 1:
>> active
>> mac address ec:f4:bb:e1:1a:42
>> Link Up - speed 10000 Mbps - full-duplex
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>  rx pkts=296190, bytes=17934647, mcasts=0, drop=0, errs=0, nombufs=0
>>  tx pkts=254, bytes=31496, errs=0
>> ./netdev-dpdk.at:28: sed '/ACTIVE/p' stdout | head -4
>> --- -   2017-08-09 16:59:18.802810195 +0800
>> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>>  2017-08-09 16:59:18.801176471 +0800
>> @@ -1,4 +1,5 @@
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> +---- dpdkb2 ----
>> +bond_mode: 4
>> +
>> +slave 0:
>> +
>> 789. netdev-dpdk.at:23: 789. netdev-dpdk - dpdk/bond-show (
>> netdev-dpdk.at:23): FAILED (netdev-dpdk.at:28)
>
>
> 1. I don't know what "+" "-" means, and why there are "+" and "-"?
> 2. I run `ovs-appctl dpdk/bond-show dpdkb2 | sed -n '/ACTIVE/p' | head
> -4`, result is:
>
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>
> That's exactly what I matched in AT_CHECK, why it fails?
>
> Autotest is really hard to use...
>
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Eric Blake-3
In reply to this post by Sam
On 08/09/2017 04:15 AM, Sam wrote:
> Hi all,
>
> I'm using autotest to test ovs, and I write a new *.at file using only one
> AT_CHECK sentence like this:
>
> AT_CHECK([ovs-appctl dpdk/bond-show dpdkb2], [0], [stdout])
>> AT_CHECK([[sed '/ACTIVE/p' stdout | head -4]], [0], [[LACP actor_state

Note - this invocation of sed will print EVERY line, as well as printing
the lines that contain ACTIVE a second time.

Also, 'head -4' is obsolete syntax that is not portable to all machines;
'sed -n4' is newer (and given your use of ovs-appctl, probably works on
all machines that you care about).

You probably meant to use [[sed -n '/ACTIVE/p' stdout | head -n4]] or
even [[grep ACTIVE stdout | head -n4]]

>> ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING]])
>

>> ./netdev-dpdk.at:28: sed '/ACTIVE/p' stdout | head -4
>> --- -   2017-08-09 16:59:18.802810195 +0800
>> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>>  2017-08-09 16:59:18.801176471 +0800
>> @@ -1,4 +1,5 @@
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> +---- dpdkb2 ----
>> +bond_mode: 4
>> +
>> +slave 0:
>> +
>> 789. netdev-dpdk.at:23: 789. netdev-dpdk - dpdk/bond-show (
>> netdev-dpdk.at:23): FAILED (netdev-dpdk.at:28)
>
>
> 1. I don't know what "+" "-" means, and why there are "+" and "-"?
That is the output of 'diff'.  '-' lines are what you EXPECTED the
output to contain, '+' lines are what the output ACTUALLY contained.

> 2. I run `ovs-appctl dpdk/bond-show dpdkb2 | sed -n '/ACTIVE/p' | head -4`,
> result is:

Notice that what you ran by hand limited the sed output to just the
interesting lines, rather than the first four lines where lines
containing ACTIVE were doubled.

> That's exactly what I matched in AT_CHECK, why it fails?

No, it's not exactly what you passed to AT_CHECK ;)

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (632 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Eric Blake-3
In reply to this post by Sam
On 08/09/2017 04:45 AM, Sam wrote:

> Then I change commd into `awk '/ACTIVE/' stdout | head -4`, it failed
> again, log is :
>
> ./netdev-dpdk.at:28: awk '/ACTIVE/' stdout | head -4
>> --- -   2017-08-09 17:41:24.809066088 +0800
>> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>>  2017-08-09 17:41:24.807150522 +0800
>> @@ -1,5 +1,5 @@
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
Could this be a difference in line endings between what your .at file
used and what stdout contains (which in turn is what line endings
ovs-appctl outputs)?

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (632 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Zack Weinberg-2
On Wed, Aug 9, 2017 at 10:34 AM, Eric Blake <[hidden email]> wrote:

> On 08/09/2017 04:45 AM, Sam wrote:
>> Then I change commd into `awk '/ACTIVE/' stdout | head -4`, it failed
>> again, log is :
>>
>> ./netdev-dpdk.at:28: awk '/ACTIVE/' stdout | head -4
>>> --- -   2017-08-09 17:41:24.809066088 +0800
>>> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>>>  2017-08-09 17:41:24.807150522 +0800
>>> @@ -1,5 +1,5 @@
>>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>
> Could this be a difference in line endings between what your .at file
> used and what stdout contains (which in turn is what line endings
> ovs-appctl outputs)?

It could also be a difference between spaces and tabs.

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Sam
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Sam
In reply to this post by Eric Blake-3
Yes, it's because a space at the end of line:

--- -^I2017-08-10 10:51:06.097868811 +0800$

> +++
> /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout^I2017-08-10
> 10:51:06.096038720 +0800$
> @@ -1,5 +1,5 @@$
> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $


but in my match, I add a space, I don't know why it doesn't work.

AT_CHECK([[awk '/ACTIVE/' stdout | head -4]], [0], [LACP actor_state ACTIVE
> AGGREGATION SYNC COLLECTING DISTRIBUTING $
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> ])$


2017-08-09 22:34 GMT+08:00 Eric Blake <[hidden email]>:

> On 08/09/2017 04:45 AM, Sam wrote:
> > Then I change commd into `awk '/ACTIVE/' stdout | head -4`, it failed
> > again, log is :
> >
> > ./netdev-dpdk.at:28: awk '/ACTIVE/' stdout | head -4
> >> --- -   2017-08-09 17:41:24.809066088 +0800
> >> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
> >>  2017-08-09 17:41:24.807150522 +0800
> >> @@ -1,5 +1,5 @@
> >> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
> >> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>
> Could this be a difference in line endings between what your .at file
> used and what stdout contains (which in turn is what line endings
> ovs-appctl outputs)?
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
>
>
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Sam
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Sam
At last, I trim end line space, then it works. I have to say, compare to
python, shell is really hard, autotest is harder...

2017-08-10 10:56 GMT+08:00 Sam <[hidden email]>:

> Yes, it's because a space at the end of line:
>
> --- -^I2017-08-10 10:51:06.097868811 +0800$
>> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout^I2017-08-10
>> 10:51:06.096038720 +0800$
>> @@ -1,5 +1,5 @@$
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
>> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
>> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING$
>> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>
>
> but in my match, I add a space, I don't know why it doesn't work.
>
> AT_CHECK([[awk '/ACTIVE/' stdout | head -4]], [0], [LACP actor_state
>> ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> ])$
>
>
> 2017-08-09 22:34 GMT+08:00 Eric Blake <[hidden email]>:
>
>> On 08/09/2017 04:45 AM, Sam wrote:
>> > Then I change commd into `awk '/ACTIVE/' stdout | head -4`, it failed
>> > again, log is :
>> >
>> > ./netdev-dpdk.at:28: awk '/ACTIVE/' stdout | head -4
>> >> --- -   2017-08-09 17:41:24.809066088 +0800
>> >> +++ /home/gangyewei-3/mvs/mvs/tests/testsuite.dir/at-groups/789/stdout
>> >>  2017-08-09 17:41:24.807150522 +0800
>> >> @@ -1,5 +1,5 @@
>> >> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> -LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> -     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> +LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>> >> +     partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING
>>
>> Could this be a difference in line endings between what your .at file
>> used and what stdout contains (which in turn is what line endings
>> ovs-appctl outputs)?
>>
>> --
>> Eric Blake, Principal Software Engineer
>> Red Hat, Inc.           +1-919-301-3266
>> Virtualization:  qemu.org | libvirt.org
>>
>>
>
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Eric Blake-3
In reply to this post by Sam
On 08/09/2017 09:56 PM, Sam wrote:
> Yes, it's because a space at the end of line:
>
> --- -^I2017-08-10 10:51:06.097868811 +0800$
>> +++

> but in my match, I add a space, I don't know why it doesn't work.
>
> AT_CHECK([[awk '/ACTIVE/' stdout | head -4]], [0], [LACP actor_state ACTIVE
>> AGGREGATION SYNC COLLECTING DISTRIBUTING $
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
>> ])$

Because autoconf eats trailing spaces by default (it's a feature).  You
can work around it by TELLING autoconf that you intend for there to be
trailing space:

AT_CHECK(..., [[trailing space preserved here: @&t@
but not here
more text]])

The @&t@ quadrigraph (mnemonic 'and-t' sounds similar to 'empty')
expands to nothing, but is converted after the point when trailing
whitespace is eaten.

The manual documents this:
https://www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (632 bytes) Download Attachment
Sam
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Sam
Could I use regular match in AT_CHECK? Like this:

m4_define([OVS_VSWITCHD_STOP],
>   [AT_CHECK([/etc/init.d/openvswitch stop], [0], [stdout], [])
>   AT_CHECK([[awk '/Killing ovsdb-server/' stdout | sed  -e 's/[ ]*$//g']],
> [0], [Killing ovsdb-server ([0-9]*)
> ])
> ])


2017-08-10 21:40 GMT+08:00 Eric Blake <[hidden email]>:

> On 08/09/2017 09:56 PM, Sam wrote:
> > Yes, it's because a space at the end of line:
> >
> > --- -^I2017-08-10 10:51:06.097868811 +0800$
> >> +++
>
> > but in my match, I add a space, I don't know why it doesn't work.
> >
> > AT_CHECK([[awk '/ACTIVE/' stdout | head -4]], [0], [LACP actor_state
> ACTIVE
> >> AGGREGATION SYNC COLLECTING DISTRIBUTING $
> >>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> >> LACP actor_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> >>      partner_state ACTIVE AGGREGATION SYNC COLLECTING DISTRIBUTING $
> >> ])$
>
> Because autoconf eats trailing spaces by default (it's a feature).  You
> can work around it by TELLING autoconf that you intend for there to be
> trailing space:
>
> AT_CHECK(..., [[trailing space preserved here: @&t@
> but not here
> more text]])
>
> The @&t@ quadrigraph (mnemonic 'and-t' sounds similar to 'empty')
> expands to nothing, but is converted after the point when trailing
> whitespace is eaten.
>
> The manual documents this:
> https://www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
>
>
_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why my AT_CHECK() can't work?

Eric Blake-3
On 08/17/2017 10:54 PM, Sam wrote:
> Could I use regular match in AT_CHECK? Like this:

Please don't top-post on technical lists; it makes it harder to follow
the conversation.

>
> m4_define([OVS_VSWITCHD_STOP],
>>   [AT_CHECK([/etc/init.d/openvswitch stop], [0], [stdout], [])
>>   AT_CHECK([[awk '/Killing ovsdb-server/' stdout | sed  -e 's/[ ]*$//g']],

That's a lot of typing and a waste of a process.  Why not just use the
shorter:

AT_CHECK([sed -n '/Killing ovsdb-server/ s/ *$//p' stdout],

(that is, using 'awk' as a longhand for 'grep' followed immediately by
piping through 'sed' is pointless, when you can do it all in 'sed'; and
using 'g' on a substitution anchored at the end of a line is pointless).

>> [0], [Killing ovsdb-server ([0-9]*)

AT_CHECK only does direct textual matches.  But never fear - you can do
filtering as part of your command to pre-process the actual text into
something that will match your expected text - similar to how you are
eating trailing space, you can also convert random pids into a stable
placeholder, as in this example:

AT_CHECK([sed -n '/Killing ovsdb-server/ { s/ *$//; s/[0-9]*/PID/; p }'
stdout],
         [0], [Killing ovsdb-server (PID)

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (632 bytes) Download Attachment
Loading...