zdtm/bridge: wait when the tentative flas is disappeared

Submitted by Andrey Vagin on April 30, 2018, 7:47 a.m.

Details

Message ID 20180430074707.9468-1-avagin@virtuozzo.com
State New
Series "zdtm/bridge: wait when the tentative flas is disappeared"
Headers show

Commit Message

Andrey Vagin April 30, 2018, 7:47 a.m.
From: Andrei Vagin <avagin@openvz.org>

Test output: ================================
3c3
<     inet6 fe80::34d1:2cff:fe9b:a54e/64 scope link

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 test/zdtm/static/bridge.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/bridge.c b/test/zdtm/static/bridge.c
index 983c262af..0c26c0b0f 100644
--- a/test/zdtm/static/bridge.c
+++ b/test/zdtm/static/bridge.c
@@ -84,6 +84,10 @@  int main(int argc, char **argv)
 	 * (I got this race with zdtm.py, but not with zdtm.sh; not quite sure
 	 * what the environment difference is/was.)
 	 */
+	while (1) {
+		if (system("ip addr list dev " BRIDGE_NAME " | grep tentative"))
+			break;
+	}
 	if (system("ip addr list dev " BRIDGE_NAME " | grep inet | sort > bridge.dump.test")) {
 		pr_perror("can't save net config");
 		fail("Can't save net config");
@@ -93,12 +97,16 @@  int main(int argc, char **argv)
 	test_daemon();
 	test_waitsig();
 
+	while (1) {
+		if (system("ip addr list dev " BRIDGE_NAME " | grep tentative"))
+			break;
+	}
 	if (system("ip addr list dev " BRIDGE_NAME " | grep inet | sort > bridge.rst.test")) {
 		fail("Can't get net config");
 		goto out;
 	}
 
-	if (system("diff bridge.rst.test bridge.dump.test")) {
+	if (system("diff -up bridge.rst.test bridge.dump.test")) {
 		fail("Net config differs after restore");
 		goto out;
 	}

Comments

Dmitry Safonov April 30, 2018, 11:30 a.m.
> diff --git a/test/zdtm/static/bridge.c b/test/zdtm/static/bridge.c
> index 983c262af..0c26c0b0f 100644
> --- a/test/zdtm/static/bridge.c
> +++ b/test/zdtm/static/bridge.c
> @@ -84,6 +84,10 @@ int main(int argc, char **argv)
>          * (I got this race with zdtm.py, but not with zdtm.sh; not quite sure
>          * what the environment difference is/was.)
>          */
> +       while (1) {
> +               if (system("ip addr list dev " BRIDGE_NAME " | grep tentative"))
> +                       break;
> +       }

`grep -v tentative`, I guess.

As travis failed anyway, maybe it makes sense for v2 to add nanosleep() here?
Just not to busyloop the system pointlessly with fork()s and all that.
Maybe it doesn't make sense, not sure.
But say the dad is slow by some reason - this version will punch the
test system.
A perfect solution would be to read netlink messages for intf.. But
that's a zdtm
test, not sure if it's worth to bother so much.
Andrey Vagin April 30, 2018, 4:37 p.m.
On Mon, Apr 30, 2018 at 12:30:40PM +0100, Dmitry Safonov wrote:
> > diff --git a/test/zdtm/static/bridge.c b/test/zdtm/static/bridge.c
> > index 983c262af..0c26c0b0f 100644
> > --- a/test/zdtm/static/bridge.c
> > +++ b/test/zdtm/static/bridge.c
> > @@ -84,6 +84,10 @@ int main(int argc, char **argv)
> >          * (I got this race with zdtm.py, but not with zdtm.sh; not quite sure
> >          * what the environment difference is/was.)
> >          */
> > +       while (1) {
> > +               if (system("ip addr list dev " BRIDGE_NAME " | grep tentative"))
> > +                       break;
> > +       }
> 
> `grep -v tentative`, I guess.

No. We are waiting when tentative is disappeared. Travis failed because
criu has a bug. Who wants to fix it?:)

[root@fc24 criu]# python2 ./test/zdtm.py run  -t zdtm/static/bridge
--iter 0 -f ns
=== Run 1/1 ================ zdtm/static/bridge

========================= Run zdtm/static/bridge in ns
Start test
Test is SUID
./bridge --pidfile=bridge.pid --outfile=bridge.out
Send the 15 signal to  85
Wait for zdtm/static/bridge(85) to die for 0.100000
Removing dump/zdtm/static/bridge/85
========================= Test zdtm/static/bridge PASS

> 
> As travis failed anyway, maybe it makes sense for v2 to add nanosleep() here?
> Just not to busyloop the system pointlessly with fork()s and all that.
> Maybe it doesn't make sense, not sure.
> But say the dad is slow by some reason - this version will punch the
> test system.
> A perfect solution would be to read netlink messages for intf.. But
> that's a zdtm
> test, not sure if it's worth to bother so much.
> 
> -- 
>              Dmitry
Dmitry Safonov April 30, 2018, 4:44 p.m.
2018-04-30 17:37 GMT+01:00 Andrei Vagin <avagin@virtuozzo.com>:
> On Mon, Apr 30, 2018 at 12:30:40PM +0100, Dmitry Safonov wrote:
>> > diff --git a/test/zdtm/static/bridge.c b/test/zdtm/static/bridge.c
>> > index 983c262af..0c26c0b0f 100644
>> > --- a/test/zdtm/static/bridge.c
>> > +++ b/test/zdtm/static/bridge.c
>> > @@ -84,6 +84,10 @@ int main(int argc, char **argv)
>> >          * (I got this race with zdtm.py, but not with zdtm.sh; not quite sure
>> >          * what the environment difference is/was.)
>> >          */
>> > +       while (1) {
>> > +               if (system("ip addr list dev " BRIDGE_NAME " | grep tentative"))
>> > +                       break;
>> > +       }
>>
>> `grep -v tentative`, I guess.
>
> No. We are waiting when tentative is disappeared. Travis failed because
> criu has a bug.

Oh, yeah, it's me stupid - system() will return non-zero when grep fails,
makes sense.  For a second unconsciously I thought it will return the number
of characters printed, lol.

> Who wants to fix it?:)
>
> [root@fc24 criu]# python2 ./test/zdtm.py run  -t zdtm/static/bridge
> --iter 0 -f ns
> === Run 1/1 ================ zdtm/static/bridge
>
> ========================= Run zdtm/static/bridge in ns
> Start test
> Test is SUID
> ./bridge --pidfile=bridge.pid --outfile=bridge.out
> Send the 15 signal to  85
> Wait for zdtm/static/bridge(85) to die for 0.100000
> Removing dump/zdtm/static/bridge/85
> ========================= Test zdtm/static/bridge PASS
>
>>
>> As travis failed anyway, maybe it makes sense for v2 to add nanosleep() here?
>> Just not to busyloop the system pointlessly with fork()s and all that.
>> Maybe it doesn't make sense, not sure.
>> But say the dad is slow by some reason - this version will punch the
>> test system.
>> A perfect solution would be to read netlink messages for intf.. But
>> that's a zdtm
>> test, not sure if it's worth to bother so much.