Skip to content

Commit

Permalink
tests:conacc: Add a test for a connection failure
Browse files Browse the repository at this point in the history
This was recently found, there was no test for a situation where a
connection failed and then was retries, which was a pretty big miss
in the tests.

Signed-off-by: Corey Minyard <[email protected]>
  • Loading branch information
cminyard committed May 7, 2024
1 parent e00bd34 commit 2572ca9
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/test_conacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self, o, accstr, acc2str, acc3str, tester):
self.io1 = None
self.io2 = None
self.waiter = gensio.waiter(o)
gensios_enabled.check_iostr_gensios(accstr)
gensios_enabled.check_iostr_gensios(accstr + "0")

self.acc = gensio.gensio_accepter(o, accstr, self);
self.acc = gensio.gensio_accepter(o, accstr + "0", self);
self.acc.startup()

port = self.acc.control(gensio.GENSIO_CONTROL_DEPTH_FIRST,
Expand Down Expand Up @@ -83,6 +83,23 @@ def __init__(self, o, accstr, acc2str, acc3str, tester):
self.expect_connects = True
self.wait()

print(" Test retry failure then restart");
# Now disable the connection so it fails.
self.acc.shutdown_s();
self.acc = None;
self.close()

self.expect_connects = False
if self.waiter.wait_timeout(1, 1200) != 0:
raise Exception("Got wakeup when nothing should happen");

# Re-enable it, we should get a connection.
self.expect_connects = True
self.acc = gensio.gensio_accepter(o, accstr + port, self);
self.acc.startup();

self.wait()

self.acc.shutdown_s()
self.acc2.shutdown_s()
self.acc3.shutdown_s()
Expand Down Expand Up @@ -128,7 +145,7 @@ def wait(self):
raise Exception("test_conacc: Timed out");

print("Test conacc")
TestAcceptConAcc(o, "tcp,localhost,0", "conacc,tcp,localhost,",
TestAcceptConAcc(o, "tcp,localhost,", "conacc,tcp,localhost,",
"conacc(retry-time=1000),tcp,localhost,", do_small_test)
del o
test_shutdown()

0 comments on commit 2572ca9

Please sign in to comment.