bluetooth: do not ignore the first chunk failure

This patch fixed the bug that A2DP test did not raise
a failure if there is only one chunk in the test.

BUG=b:169039281
TEST=Conduct both the A2DP test and A2DP long test on DUTs
in the lab.

Change-Id: I17c8a459f2db32dc86787bb713249b0ad187b685
Previous-Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2461188
Previous-Reviewed-on: https://chromium-review.googlesource.com/2461188
(cherry picked from commit cde871778c06648a2703e988b2ea7ff8d90167f5)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2531693
Reviewed-by: Michael Sun <michaelfsun@google.com>
Tested-by: Shyh-In Hwang <josephsih@chromium.org>
Commit-Queue: Shyh-In Hwang <josephsih@chromium.org>
diff --git a/server/cros/bluetooth/bluetooth_adapter_audio_tests.py b/server/cros/bluetooth/bluetooth_adapter_audio_tests.py
index b3c3311..745cfa8 100644
--- a/server/cros/bluetooth/bluetooth_adapter_audio_tests.py
+++ b/server/cros/bluetooth/bluetooth_adapter_audio_tests.py
@@ -637,7 +637,8 @@
             # Check if the audio frames in the recorded file are legitimate.
             if not self._check_audio_frames_legitimacy(
                     test_data, 'recorded_by_peer', recorded_file=recorded_file):
-                if i >= nchunks - self.IGNORE_LAST_FEW_CHUNKS:
+                if (i > self.IGNORE_LAST_FEW_CHUNKS and
+                        i >= nchunks - self.IGNORE_LAST_FEW_CHUNKS):
                     logging.info('empty chunk %d ignored for last %d chunks',
                                  i, self.IGNORE_LAST_FEW_CHUNKS)
                 else:
@@ -649,7 +650,8 @@
             if not self._check_primary_frequencies(A2DP, test_data,
                                                    'recorded_by_peer',
                                                    recorded_file=recorded_file):
-                if i >= nchunks - self.IGNORE_LAST_FEW_CHUNKS:
+                if (i > self.IGNORE_LAST_FEW_CHUNKS and
+                        i >= nchunks - self.IGNORE_LAST_FEW_CHUNKS):
                     msg = 'partially filled chunk %d ignored for last %d chunks'
                     logging.info(msg, i, self.IGNORE_LAST_FEW_CHUNKS)
                 else: