diff --git a/Tools/autotest/vehicle_test_suite.py b/Tools/autotest/vehicle_test_suite.py index 3b170efa191..9302641b606 100644 --- a/Tools/autotest/vehicle_test_suite.py +++ b/Tools/autotest/vehicle_test_suite.py @@ -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)