Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 1 | # Copyright (C) 2024 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 15 | from mobly import asserts |
| 16 | from net_tests_utils.host.python import adb_utils, apf_test_base, apf_utils, assert_utils, tether_utils |
Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 17 | from net_tests_utils.host.python.tether_utils import UpstreamType |
| 18 | |
| 19 | COUNTER_DROPPED_ETHERTYPE_NOT_ALLOWED = "DROPPED_ETHERTYPE_NOT_ALLOWED" |
| 20 | |
| 21 | |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 22 | class ApfV4Test(apf_test_base.ApfTestBase): |
Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 23 | |
| 24 | def test_apf_drop_ethercat(self): |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 25 | count_before_test = apf_utils.get_apf_counter( |
| 26 | self.clientDevice, |
| 27 | self.client_iface_name, |
| 28 | COUNTER_DROPPED_ETHERTYPE_NOT_ALLOWED, |
Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 29 | ) |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 30 | apf_utils.send_broadcast_empty_ethercat_packet( |
| 31 | self.serverDevice, self.server_iface_name |
| 32 | ) |
Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 33 | |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 34 | assert_utils.expect_with_retry( |
| 35 | lambda: apf_utils.get_apf_counter( |
| 36 | self.clientDevice, |
| 37 | self.client_iface_name, |
| 38 | COUNTER_DROPPED_ETHERTYPE_NOT_ALLOWED, |
Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 39 | ) |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 40 | > count_before_test |
| 41 | ) |
Junyu Lai | 32a2d15 | 2024-07-03 16:05:41 +0800 | [diff] [blame] | 42 | |
Junyu Lai | cf65586 | 2024-07-04 11:09:52 +0800 | [diff] [blame^] | 43 | # TODO: Verify the packet is not actually received. |