mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
autotest: check the lossy FTP listing test lists every entry
The test set 50% receive loss and then waited only for "Total size", which a listing that gave up part-way through would still print. Wait for the total the files actually add up to instead. Give every file a different size while doing so: with all of them the same the total is just a count, so a listing which lost one page and repeated another still reached it.
This commit is contained in:
committed by
Andrew Tridgell
parent
13b6dc0887
commit
06559fb9df
@@ -16956,12 +16956,20 @@ switch value'''
|
||||
|
||||
def create_ftp_listing_pages(self, dirname, file_count):
|
||||
'''create a directory whose listing needs many packets, so that it is
|
||||
still paging while the next command runs'''
|
||||
still paging while the next command runs. returns the total size of
|
||||
the files created'''
|
||||
if os.path.exists(dirname):
|
||||
shutil.rmtree(dirname)
|
||||
os.mkdir(dirname)
|
||||
# every file a different size, so the total the client reports only
|
||||
# comes out right if it saw each entry exactly once - equal sizes
|
||||
# would let a lost page and a repeated one cancel out
|
||||
total = 0
|
||||
for i in range(file_count):
|
||||
self.write_content_to_filepath(b"x", os.path.join(dirname, "entry_%03u.txt" % i))
|
||||
content = b"x" * (i + 1)
|
||||
self.write_content_to_filepath(content, os.path.join(dirname, "entry_%03u.txt" % i))
|
||||
total += len(content)
|
||||
return total
|
||||
|
||||
def wait_for_path(self, path, present=True, timeout=20):
|
||||
'''wait for a path to appear or disappear. the autopilot's filesystem
|
||||
@@ -17321,7 +17329,7 @@ switch value'''
|
||||
dirname = "ftp_lossy_listing_test"
|
||||
file_count = 200
|
||||
|
||||
self.create_ftp_listing_pages(dirname, file_count)
|
||||
total_size = self.create_ftp_listing_pages(dirname, file_count)
|
||||
|
||||
mavproxy = self.start_mavproxy()
|
||||
ex = None
|
||||
@@ -17342,7 +17350,12 @@ switch value'''
|
||||
mavproxy.send("ftp set loss_seed 2\n")
|
||||
mavproxy.send("ftp set pkt_loss_rx 50\n")
|
||||
mavproxy.send("ftp list %s\n" % dirname)
|
||||
mavproxy.expect("Total size", timeout=120)
|
||||
# MAVProxy sums the sizes of the entries it listed, so the total
|
||||
# only comes out right if every page arrived; expecting a bare
|
||||
# "Total size" would pass on a listing which stopped early
|
||||
mavproxy.expect(
|
||||
re.escape("Total size %.2f kByte" % (total_size / 1024.0)),
|
||||
timeout=120)
|
||||
mavproxy.send("ftp set pkt_loss_rx 0\n")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self.print_exception_caught(e)
|
||||
|
||||
Reference in New Issue
Block a user