Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/python3.4 |
| 2 | # |
| 3 | # Copyright 2017 - The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import string |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 18 | import time |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 19 | |
| 20 | from acts import asserts |
| 21 | from acts.test_utils.wifi.aware import aware_const as aconsts |
| 22 | from acts.test_utils.wifi.aware import aware_test_utils as autils |
| 23 | from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest |
| 24 | |
| 25 | |
| 26 | class DiscoveryTest(AwareBaseTest): |
| 27 | """Set of tests for Wi-Fi Aware discovery.""" |
| 28 | |
| 29 | # configuration parameters used by tests |
| 30 | PAYLOAD_SIZE_MIN = 0 |
| 31 | PAYLOAD_SIZE_TYPICAL = 1 |
| 32 | PAYLOAD_SIZE_MAX = 2 |
| 33 | |
| 34 | # message strings |
| 35 | query_msg = "How are you doing? 你好嗎?" |
| 36 | response_msg = "Doing ok - thanks! 做的不錯 - 謝謝!" |
| 37 | |
| 38 | # message re-transmit counter (increases reliability in open-environment) |
| 39 | # Note: reliability of message transmission is tested elsewhere |
| 40 | msg_retx_count = 5 # hard-coded max value, internal API |
| 41 | |
| 42 | def __init__(self, controllers): |
| 43 | AwareBaseTest.__init__(self, controllers) |
| 44 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 45 | def create_base_config(self, caps, is_publish, ptype, stype, payload_size, |
| 46 | ttl, term_ind_on, null_match): |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 47 | """Create a base configuration based on input parameters. |
| 48 | |
| 49 | Args: |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 50 | caps: device capability dictionary |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 51 | is_publish: True if a publish config, else False |
| 52 | ptype: unsolicited or solicited (used if is_publish is True) |
| 53 | stype: passive or active (used if is_publish is False) |
| 54 | payload_size: min, typical, max (PAYLOAD_SIZE_xx) |
| 55 | ttl: time-to-live configuration (0 - forever) |
| 56 | term_ind_on: is termination indication enabled |
| 57 | null_match: null-out the middle match filter |
| 58 | Returns: |
| 59 | publish discovery configuration object. |
| 60 | """ |
| 61 | config = {} |
| 62 | if is_publish: |
| 63 | config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = ptype |
| 64 | else: |
| 65 | config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = stype |
| 66 | config[aconsts.DISCOVERY_KEY_TTL] = ttl |
| 67 | config[aconsts.DISCOVERY_KEY_TERM_CB_ENABLED] = term_ind_on |
| 68 | if payload_size == self.PAYLOAD_SIZE_MIN: |
| 69 | config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "a" |
| 70 | config[aconsts.DISCOVERY_KEY_SSI] = None |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 71 | config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST] = [] |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 72 | elif payload_size == self.PAYLOAD_SIZE_TYPICAL: |
| 73 | config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceX" |
| 74 | if is_publish: |
| 75 | config[aconsts.DISCOVERY_KEY_SSI] = string.ascii_letters |
| 76 | else: |
| 77 | config[aconsts.DISCOVERY_KEY_SSI] = string.ascii_letters[:: |
| 78 | -1] # reverse |
| 79 | config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST] = autils.encode_list( |
| 80 | [(10).to_bytes(1, byteorder="big"), "hello there string" |
| 81 | if not null_match else None, |
| 82 | bytes(range(40))]) |
Etan Cohen | 5a629a6 | 2017-05-19 15:11:18 -0700 | [diff] [blame] | 83 | else: # PAYLOAD_SIZE_MAX |
| 84 | config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "VeryLong" + "X" * ( |
| 85 | caps[aconsts.CAP_MAX_SERVICE_NAME_LEN] - 8) |
| 86 | config[aconsts.DISCOVERY_KEY_SSI] = ("P" if is_publish else "S") * caps[ |
| 87 | aconsts.CAP_MAX_SERVICE_SPECIFIC_INFO_LEN] |
| 88 | mf = autils.construct_max_match_filter( |
| 89 | caps[aconsts.CAP_MAX_MATCH_FILTER_LEN]) |
| 90 | if null_match: |
| 91 | mf[2] = None |
| 92 | config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST] = autils.encode_list(mf) |
| 93 | |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 94 | return config |
| 95 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 96 | def create_publish_config(self, caps, ptype, payload_size, ttl, term_ind_on, |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 97 | null_match): |
| 98 | """Create a publish configuration based on input parameters. |
| 99 | |
| 100 | Args: |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 101 | caps: device capability dictionary |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 102 | ptype: unsolicited or solicited |
| 103 | payload_size: min, typical, max (PAYLOAD_SIZE_xx) |
| 104 | ttl: time-to-live configuration (0 - forever) |
| 105 | term_ind_on: is termination indication enabled |
| 106 | null_match: null-out the middle match filter |
| 107 | Returns: |
| 108 | publish discovery configuration object. |
| 109 | """ |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 110 | return self.create_base_config(caps, True, ptype, None, payload_size, ttl, |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 111 | term_ind_on, null_match) |
| 112 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 113 | def create_subscribe_config(self, caps, stype, payload_size, ttl, term_ind_on, |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 114 | null_match): |
| 115 | """Create a subscribe configuration based on input parameters. |
| 116 | |
| 117 | Args: |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 118 | caps: device capability dictionary |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 119 | stype: passive or active |
| 120 | payload_size: min, typical, max (PAYLOAD_SIZE_xx) |
| 121 | ttl: time-to-live configuration (0 - forever) |
| 122 | term_ind_on: is termination indication enabled |
| 123 | null_match: null-out the middle match filter |
| 124 | Returns: |
| 125 | subscribe discovery configuration object. |
| 126 | """ |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 127 | return self.create_base_config(caps, False, None, stype, payload_size, ttl, |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 128 | term_ind_on, null_match) |
| 129 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 130 | def positive_discovery_test_utility(self, ptype, stype, payload_size): |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 131 | """Utility which runs a positive discovery test: |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 132 | - Discovery (publish/subscribe) with TTL=0 (non-self-terminating) |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 133 | - Exchange messages |
| 134 | - Update publish/subscribe |
| 135 | - Terminate |
| 136 | |
| 137 | Args: |
| 138 | ptype: Publish discovery type |
| 139 | stype: Subscribe discovery type |
| 140 | payload_size: One of PAYLOAD_SIZE_* constants - MIN, TYPICAL, MAX |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 141 | """ |
| 142 | p_dut = self.android_devices[0] |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 143 | p_dut.pretty_name = "Publisher" |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 144 | s_dut = self.android_devices[1] |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 145 | s_dut.pretty_name = "Subscriber" |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 146 | |
| 147 | # Publisher+Subscriber: attach and wait for confirmation |
| 148 | p_id = p_dut.droid.wifiAwareAttach(False) |
| 149 | autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 150 | s_id = s_dut.droid.wifiAwareAttach(False) |
| 151 | autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 152 | |
| 153 | # Publisher: start publish and wait for confirmation |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 154 | p_config = self.create_publish_config( |
| 155 | p_dut.aware_capabilities, |
| 156 | ptype, |
| 157 | payload_size, |
| 158 | ttl=0, |
| 159 | term_ind_on=False, |
| 160 | null_match=False) |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 161 | p_disc_id = p_dut.droid.wifiAwarePublish(p_id, p_config) |
| 162 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 163 | |
| 164 | # Subscriber: start subscribe and wait for confirmation |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 165 | s_config = self.create_subscribe_config( |
| 166 | s_dut.aware_capabilities, |
| 167 | stype, |
| 168 | payload_size, |
| 169 | ttl=0, |
| 170 | term_ind_on=False, |
| 171 | null_match=True) |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 172 | s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, s_config) |
| 173 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
| 174 | |
| 175 | # Subscriber: wait for service discovery |
| 176 | discovery_event = autils.wait_for_event( |
| 177 | s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 178 | peer_id_on_sub = discovery_event["data"][aconsts.SESSION_CB_KEY_PEER_ID] |
| 179 | |
| 180 | # Subscriber: validate contents of discovery (specifically that getting the |
| 181 | # Publisher's SSI and MatchFilter!) |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 182 | autils.assert_equal_strings( |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 183 | bytes(discovery_event["data"][ |
| 184 | aconsts.SESSION_CB_KEY_SERVICE_SPECIFIC_INFO]).decode("utf-8"), |
| 185 | p_config[aconsts.DISCOVERY_KEY_SSI], |
| 186 | "Discovery mismatch: service specific info (SSI)") |
| 187 | asserts.assert_equal( |
| 188 | autils.decode_list( |
| 189 | discovery_event["data"][aconsts.SESSION_CB_KEY_MATCH_FILTER_LIST]), |
| 190 | autils.decode_list(p_config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST]), |
| 191 | "Discovery mismatch: match filter") |
| 192 | |
| 193 | # Subscriber: send message to peer (Publisher) |
| 194 | s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub, |
| 195 | self.get_next_msg_id(), self.query_msg, |
| 196 | self.msg_retx_count) |
| 197 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT) |
| 198 | |
| 199 | # Publisher: wait for received message |
| 200 | pub_rx_msg_event = autils.wait_for_event( |
| 201 | p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) |
| 202 | peer_id_on_pub = pub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_PEER_ID] |
| 203 | |
| 204 | # Publisher: validate contents of message |
| 205 | asserts.assert_equal( |
| 206 | pub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_MESSAGE_AS_STRING], |
| 207 | self.query_msg, "Subscriber -> Publisher message corrupted") |
| 208 | |
| 209 | # Publisher: send message to peer (Subscriber) |
| 210 | p_dut.droid.wifiAwareSendMessage(p_disc_id, peer_id_on_pub, |
| 211 | self.get_next_msg_id(), self.response_msg, |
| 212 | self.msg_retx_count) |
| 213 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT) |
| 214 | |
| 215 | # Subscriber: wait for received message |
| 216 | sub_rx_msg_event = autils.wait_for_event( |
| 217 | s_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED) |
| 218 | |
| 219 | # Subscriber: validate contents of message |
| 220 | asserts.assert_equal( |
| 221 | sub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_PEER_ID], |
| 222 | peer_id_on_sub, |
| 223 | "Subscriber received message from different peer ID then discovery!?") |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 224 | autils.assert_equal_strings( |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 225 | sub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_MESSAGE_AS_STRING], |
| 226 | self.response_msg, "Publisher -> Subscriber message corrupted") |
| 227 | |
| 228 | # Subscriber: validate that we're not getting another Service Discovery |
| 229 | autils.fail_on_event(s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 230 | |
| 231 | # Publisher: update publish and wait for confirmation |
| 232 | p_config[aconsts.DISCOVERY_KEY_SSI] = "something else" |
| 233 | p_dut.droid.wifiAwareUpdatePublish(p_disc_id, p_config) |
| 234 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_SESSION_CONFIG_UPDATED) |
| 235 | |
| 236 | # Subscriber: expect a new service discovery |
| 237 | discovery_event = autils.wait_for_event( |
| 238 | s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 239 | |
| 240 | # Subscriber: validate contents of discovery |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 241 | autils.assert_equal_strings( |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 242 | bytes(discovery_event["data"][ |
| 243 | aconsts.SESSION_CB_KEY_SERVICE_SPECIFIC_INFO]).decode("utf-8"), |
| 244 | p_config[aconsts.DISCOVERY_KEY_SSI], |
| 245 | "Discovery mismatch (after pub update): service specific info (SSI)") |
| 246 | asserts.assert_equal( |
| 247 | autils.decode_list( |
| 248 | discovery_event["data"][aconsts.SESSION_CB_KEY_MATCH_FILTER_LIST]), |
| 249 | autils.decode_list(p_config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST]), |
| 250 | "Discovery mismatch: match filter") |
| 251 | |
| 252 | # Subscribe: update subscribe and wait for confirmation |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 253 | s_config = self.create_subscribe_config( |
| 254 | s_dut.aware_capabilities, |
| 255 | stype, |
| 256 | payload_size, |
| 257 | ttl=0, |
| 258 | term_ind_on=False, |
| 259 | null_match=False) |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 260 | s_dut.droid.wifiAwareUpdateSubscribe(s_disc_id, s_config) |
| 261 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SESSION_CONFIG_UPDATED) |
| 262 | |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 263 | # Publisher+Subscriber: Terminate sessions |
| 264 | p_dut.droid.wifiAwareDestroyDiscoverySession(p_disc_id) |
| 265 | s_dut.droid.wifiAwareDestroyDiscoverySession(s_disc_id) |
| 266 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 267 | # sleep for timeout period and then verify all 'fail_on_event' together |
| 268 | time.sleep(autils.EVENT_TIMEOUT) |
| 269 | |
Etan Cohen | 2c8db55 | 2017-05-22 11:00:03 -0700 | [diff] [blame] | 270 | # verify that there were no other events |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 271 | autils.verify_no_more_events(p_dut, timeout=0) |
| 272 | autils.verify_no_more_events(s_dut, timeout=0) |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 273 | |
Etan Cohen | 2c8db55 | 2017-05-22 11:00:03 -0700 | [diff] [blame] | 274 | def verify_discovery_session_term(self, dut, disc_id, config, is_publish, |
| 275 | term_ind_on): |
| 276 | """Utility to verify that the specified discovery session has terminated (by |
| 277 | waiting for the TTL and then attempting to reconfigure). |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 278 | |
Etan Cohen | 2c8db55 | 2017-05-22 11:00:03 -0700 | [diff] [blame] | 279 | Args: |
| 280 | dut: device under test |
| 281 | disc_id: discovery id for the existing session |
| 282 | config: configuration of the existing session |
| 283 | is_publish: True if the configuration was publish, False if subscribe |
| 284 | term_ind_on: True if a termination indication is expected, False otherwise |
| 285 | """ |
| 286 | # Wait for session termination |
| 287 | if term_ind_on: |
| 288 | autils.wait_for_event( |
| 289 | dut, |
| 290 | autils.decorate_event(aconsts.SESSION_CB_ON_SESSION_TERMINATED, |
| 291 | disc_id)) |
| 292 | else: |
| 293 | # can't defer wait to end since in any case have to wait for session to |
| 294 | # expire |
| 295 | autils.fail_on_event( |
| 296 | dut, |
| 297 | autils.decorate_event(aconsts.SESSION_CB_ON_SESSION_TERMINATED, |
| 298 | disc_id)) |
| 299 | |
| 300 | # Validate that session expired by trying to configure it (expect failure) |
| 301 | config[aconsts.DISCOVERY_KEY_SSI] = "something else" |
| 302 | if is_publish: |
| 303 | dut.droid.wifiAwareUpdatePublish(disc_id, config) |
| 304 | else: |
| 305 | dut.droid.wifiAwareUpdateSubscribe(disc_id, config) |
| 306 | # failure expected - should verify that SESSION_CB_ON_SESSION_CONFIG_UPDATED |
| 307 | # not received but instead will verify_no_more_events at end of test |
| 308 | |
| 309 | def positive_ttl_test_utility(self, is_publish, ptype, stype, term_ind_on): |
| 310 | """Utility which runs a positive discovery session TTL configuration test |
| 311 | |
| 312 | Iteration 1: Verify session started with TTL |
| 313 | Iteration 2: Verify session started without TTL and reconfigured with TTL |
| 314 | Iteration 3: Verify session started with (long) TTL and reconfigured with |
| 315 | (short) TTL |
| 316 | |
| 317 | Args: |
| 318 | is_publish: True if testing publish, False if testing subscribe |
| 319 | ptype: Publish discovery type (used if is_publish is True) |
| 320 | stype: Subscribe discovery type (used if is_publish is False) |
| 321 | term_ind_on: Configuration of termination indication |
| 322 | """ |
| 323 | SHORT_TTL = 5 # 5 seconds |
| 324 | LONG_TTL = 100 # 100 seconds |
| 325 | dut = self.android_devices[0] |
| 326 | |
| 327 | # Attach and wait for confirmation |
| 328 | id = dut.droid.wifiAwareAttach(False) |
| 329 | autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 330 | |
| 331 | # Iteration 1: Start discovery session with TTL |
| 332 | config = self.create_base_config(dut.aware_capabilities, is_publish, ptype, |
| 333 | stype, self.PAYLOAD_SIZE_TYPICAL, |
| 334 | SHORT_TTL, term_ind_on, False) |
| 335 | if is_publish: |
| 336 | disc_id = dut.droid.wifiAwarePublish(id, config, True) |
| 337 | autils.wait_for_event(dut, |
| 338 | autils.decorate_event( |
| 339 | aconsts.SESSION_CB_ON_PUBLISH_STARTED, disc_id)) |
| 340 | else: |
| 341 | disc_id = dut.droid.wifiAwareSubscribe(id, config, True) |
| 342 | autils.wait_for_event( |
| 343 | dut, |
| 344 | autils.decorate_event(aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED, |
| 345 | disc_id)) |
| 346 | |
| 347 | # Wait for session termination & verify |
| 348 | self.verify_discovery_session_term(dut, disc_id, config, is_publish, |
| 349 | term_ind_on) |
| 350 | |
| 351 | # Iteration 2: Start a discovery session without TTL |
| 352 | config = self.create_base_config(dut.aware_capabilities, is_publish, ptype, |
| 353 | stype, self.PAYLOAD_SIZE_TYPICAL, 0, |
| 354 | term_ind_on, False) |
| 355 | if is_publish: |
| 356 | disc_id = dut.droid.wifiAwarePublish(id, config, True) |
| 357 | autils.wait_for_event(dut, |
| 358 | autils.decorate_event( |
| 359 | aconsts.SESSION_CB_ON_PUBLISH_STARTED, disc_id)) |
| 360 | else: |
| 361 | disc_id = dut.droid.wifiAwareSubscribe(id, config, True) |
| 362 | autils.wait_for_event( |
| 363 | dut, |
| 364 | autils.decorate_event(aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED, |
| 365 | disc_id)) |
| 366 | |
| 367 | # Update with a TTL |
| 368 | config = self.create_base_config(dut.aware_capabilities, is_publish, ptype, |
| 369 | stype, self.PAYLOAD_SIZE_TYPICAL, |
| 370 | SHORT_TTL, term_ind_on, False) |
| 371 | if is_publish: |
| 372 | dut.droid.wifiAwareUpdatePublish(disc_id, config) |
| 373 | else: |
| 374 | dut.droid.wifiAwareUpdateSubscribe(disc_id, config) |
| 375 | autils.wait_for_event( |
| 376 | dut, |
| 377 | autils.decorate_event(aconsts.SESSION_CB_ON_SESSION_CONFIG_UPDATED, |
| 378 | disc_id)) |
| 379 | |
| 380 | # Wait for session termination & verify |
| 381 | self.verify_discovery_session_term(dut, disc_id, config, is_publish, |
| 382 | term_ind_on) |
| 383 | |
| 384 | # Iteration 3: Start a discovery session with (long) TTL |
| 385 | config = self.create_base_config(dut.aware_capabilities, is_publish, ptype, |
| 386 | stype, self.PAYLOAD_SIZE_TYPICAL, LONG_TTL, |
| 387 | term_ind_on, False) |
| 388 | if is_publish: |
| 389 | disc_id = dut.droid.wifiAwarePublish(id, config, True) |
| 390 | autils.wait_for_event(dut, |
| 391 | autils.decorate_event( |
| 392 | aconsts.SESSION_CB_ON_PUBLISH_STARTED, disc_id)) |
| 393 | else: |
| 394 | disc_id = dut.droid.wifiAwareSubscribe(id, config, True) |
| 395 | autils.wait_for_event( |
| 396 | dut, |
| 397 | autils.decorate_event(aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED, |
| 398 | disc_id)) |
| 399 | |
| 400 | # Update with a TTL |
| 401 | config = self.create_base_config(dut.aware_capabilities, is_publish, ptype, |
| 402 | stype, self.PAYLOAD_SIZE_TYPICAL, |
| 403 | SHORT_TTL, term_ind_on, False) |
| 404 | if is_publish: |
| 405 | dut.droid.wifiAwareUpdatePublish(disc_id, config) |
| 406 | else: |
| 407 | dut.droid.wifiAwareUpdateSubscribe(disc_id, config) |
| 408 | autils.wait_for_event( |
| 409 | dut, |
| 410 | autils.decorate_event(aconsts.SESSION_CB_ON_SESSION_CONFIG_UPDATED, |
| 411 | disc_id)) |
| 412 | |
| 413 | # Wait for session termination & verify |
| 414 | self.verify_discovery_session_term(dut, disc_id, config, is_publish, |
| 415 | term_ind_on) |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 416 | |
| 417 | # verify that there were no other events |
Etan Cohen | 2c8db55 | 2017-05-22 11:00:03 -0700 | [diff] [blame] | 418 | autils.verify_no_more_events(dut) |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 419 | |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 420 | def negative_discovery_test_utility(self, p_dut, s_dut, p_config, s_config): |
| 421 | """Utility which runs a negative discovery test: |
| 422 | - Start discovery (publish/subscribe) with TTL=0 (non-self-terminating) |
| 423 | - Validate no service is discovered |
| 424 | - Terminate discovery sessions |
| 425 | |
| 426 | Uses typical payload size. |
| 427 | |
| 428 | Args: |
| 429 | p_dut: Publish device under test |
| 430 | s_dut: Subscribe device under test |
| 431 | p_config: Publish discovery configuration |
| 432 | s_config: Subscribe discovery configuration |
| 433 | """ |
| 434 | # Publisher+Subscriber: attach and wait for confirmation |
| 435 | p_id = p_dut.droid.wifiAwareAttach(False) |
| 436 | autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 437 | s_id = s_dut.droid.wifiAwareAttach(False) |
| 438 | autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED) |
| 439 | |
| 440 | # Publisher: start publish and wait for confirmation |
| 441 | p_disc_id = p_dut.droid.wifiAwarePublish(p_id, p_config) |
| 442 | autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED) |
| 443 | |
| 444 | # Subscriber: start subscribe and wait for confirmation |
| 445 | s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, s_config) |
| 446 | autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED) |
| 447 | |
| 448 | # Subscriber: fail on service discovery |
| 449 | autils.fail_on_event(s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED) |
| 450 | |
| 451 | # Publisher+Subscriber: Terminate sessions |
| 452 | p_dut.droid.wifiAwareDestroyDiscoverySession(p_disc_id) |
| 453 | s_dut.droid.wifiAwareDestroyDiscoverySession(s_disc_id) |
| 454 | |
| 455 | # verify that there were no other events (including terminations) |
| 456 | time.sleep(autils.EVENT_TIMEOUT) |
| 457 | autils.verify_no_more_events(p_dut, timeout=0) |
| 458 | autils.verify_no_more_events(s_dut, timeout=0) |
| 459 | |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 460 | def negative_discovery_mismatch_test_utility(self, |
| 461 | p_type, |
| 462 | s_type, |
| 463 | p_service_name=None, |
| 464 | s_service_name=None, |
| 465 | p_mf_1=None, |
| 466 | s_mf_1=None): |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 467 | """Utility which runs the negative discovery test for mismatched service |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 468 | configs. |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 469 | |
| 470 | Args: |
| 471 | p_type: Publish discovery type |
| 472 | s_type: Subscribe discovery type |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 473 | p_service_name: Publish service name (or None to leave unchanged) |
| 474 | s_service_name: Subscribe service name (or None to leave unchanged) |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 475 | p_mf_1: Publish match filter element [1] (or None to leave unchanged) |
| 476 | s_mf_1: Subscribe match filter element [1] (or None to leave unchanged) |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 477 | """ |
| 478 | p_dut = self.android_devices[0] |
| 479 | p_dut.pretty_name = "Publisher" |
| 480 | s_dut = self.android_devices[1] |
| 481 | s_dut.pretty_name = "Subscriber" |
| 482 | |
| 483 | # create configurations |
| 484 | p_config = self.create_publish_config( |
| 485 | p_dut.aware_capabilities, |
| 486 | p_type, |
| 487 | self.PAYLOAD_SIZE_TYPICAL, |
| 488 | ttl=0, |
| 489 | term_ind_on=False, |
| 490 | null_match=False) |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 491 | if p_service_name is not None: |
| 492 | p_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = p_service_name |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 493 | if p_mf_1 is not None: |
| 494 | p_config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST] = autils.encode_list( |
| 495 | [(10).to_bytes(1, byteorder="big"), |
| 496 | p_mf_1, |
| 497 | bytes(range(40))]) |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 498 | s_config = self.create_publish_config( |
| 499 | s_dut.aware_capabilities, |
| 500 | s_type, |
| 501 | self.PAYLOAD_SIZE_TYPICAL, |
| 502 | ttl=0, |
| 503 | term_ind_on=False, |
| 504 | null_match=False) |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 505 | if s_service_name is not None: |
| 506 | s_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = s_service_name |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 507 | if s_mf_1 is not None: |
| 508 | s_config[aconsts.DISCOVERY_KEY_MATCH_FILTER_LIST] = autils.encode_list( |
| 509 | [(10).to_bytes(1, byteorder="big"), |
| 510 | s_mf_1, |
| 511 | bytes(range(40))]) |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 512 | |
| 513 | self.negative_discovery_test_utility(p_dut, s_dut, p_config, s_config) |
| 514 | |
| 515 | |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 516 | ####################################### |
| 517 | # Positive tests key: |
| 518 | # |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 519 | # names is: test_<pub_type>_<sub_type>_<size> |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 520 | # where: |
| 521 | # |
| 522 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 523 | # sub_type: Type of subscribe discovery session: passive or active. |
| 524 | # size: Size of payload fields (service name, service specific info, and match |
| 525 | # filter: typical, max, or min. |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 526 | ####################################### |
| 527 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 528 | def test_positive_unsolicited_passive_typical(self): |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 529 | """Functional test case / Discovery test cases / positive test case: |
| 530 | - Solicited publish + passive subscribe |
| 531 | - Typical payload fields size |
Etan Cohen | 872a6be | 2017-05-16 08:08:15 -0700 | [diff] [blame] | 532 | |
| 533 | Verifies that discovery and message exchange succeeds. |
| 534 | """ |
| 535 | self.positive_discovery_test_utility( |
| 536 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 537 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 538 | payload_size=self.PAYLOAD_SIZE_TYPICAL) |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 539 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 540 | def test_positive_unsolicited_passive_min(self): |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 541 | """Functional test case / Discovery test cases / positive test case: |
| 542 | - Solicited publish + passive subscribe |
| 543 | - Minimal payload fields size |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 544 | |
| 545 | Verifies that discovery and message exchange succeeds. |
| 546 | """ |
| 547 | self.positive_discovery_test_utility( |
| 548 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 549 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 550 | payload_size=self.PAYLOAD_SIZE_MIN) |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 551 | |
Etan Cohen | 5a629a6 | 2017-05-19 15:11:18 -0700 | [diff] [blame] | 552 | def test_positive_unsolicited_passive_max(self): |
| 553 | """Functional test case / Discovery test cases / positive test case: |
| 554 | - Solicited publish + passive subscribe |
| 555 | - Maximal payload fields size |
| 556 | |
| 557 | Verifies that discovery and message exchange succeeds. |
| 558 | """ |
| 559 | self.positive_discovery_test_utility( |
| 560 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 561 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 562 | payload_size=self.PAYLOAD_SIZE_MAX) |
| 563 | |
| 564 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 565 | def test_positive_solicited_active_typical(self): |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 566 | """Functional test case / Discovery test cases / positive test case: |
| 567 | - Unsolicited publish + active subscribe |
| 568 | - Typical payload fields size |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 569 | |
| 570 | Verifies that discovery and message exchange succeeds. |
| 571 | """ |
| 572 | self.positive_discovery_test_utility( |
| 573 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 574 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 575 | payload_size=self.PAYLOAD_SIZE_TYPICAL) |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 576 | |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 577 | def test_positive_solicited_active_min(self): |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 578 | """Functional test case / Discovery test cases / positive test case: |
| 579 | - Unsolicited publish + active subscribe |
| 580 | - Minimal payload fields size |
Etan Cohen | 0bc1cab | 2017-05-18 15:30:41 -0700 | [diff] [blame] | 581 | |
| 582 | Verifies that discovery and message exchange succeeds. |
| 583 | """ |
| 584 | self.positive_discovery_test_utility( |
| 585 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 586 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
Etan Cohen | fb7f3b1 | 2017-05-19 06:54:03 -0700 | [diff] [blame] | 587 | payload_size=self.PAYLOAD_SIZE_MIN) |
Etan Cohen | 5a629a6 | 2017-05-19 15:11:18 -0700 | [diff] [blame] | 588 | |
| 589 | def test_positive_solicited_active_max(self): |
| 590 | """Functional test case / Discovery test cases / positive test case: |
| 591 | - Unsolicited publish + active subscribe |
| 592 | - Maximal payload fields size |
| 593 | |
| 594 | Verifies that discovery and message exchange succeeds. |
| 595 | """ |
| 596 | self.positive_discovery_test_utility( |
| 597 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 598 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 599 | payload_size=self.PAYLOAD_SIZE_MAX) |
Etan Cohen | 2c8db55 | 2017-05-22 11:00:03 -0700 | [diff] [blame] | 600 | |
| 601 | ####################################### |
| 602 | # TTL tests key: |
| 603 | # |
| 604 | # names is: test_ttl_<pub_type|sub_type>_<term_ind> |
| 605 | # where: |
| 606 | # |
| 607 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 608 | # sub_type: Type of subscribe discovery session: passive or active. |
| 609 | # term_ind: ind_on or ind_off |
| 610 | ####################################### |
| 611 | |
| 612 | def test_ttl_unsolicited_ind_on(self): |
| 613 | """Functional test case / Discovery test cases / TTL test case: |
| 614 | - Unsolicited publish |
| 615 | - Termination indication enabled |
| 616 | """ |
| 617 | self.positive_ttl_test_utility( |
| 618 | is_publish=True, |
| 619 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 620 | stype=None, |
| 621 | term_ind_on=True) |
Etan Cohen | 3010bc2 | 2017-05-22 12:47:17 -0700 | [diff] [blame] | 622 | |
| 623 | def test_ttl_unsolicited_ind_off(self): |
| 624 | """Functional test case / Discovery test cases / TTL test case: |
| 625 | - Unsolicited publish |
| 626 | - Termination indication disabled |
| 627 | """ |
| 628 | self.positive_ttl_test_utility( |
| 629 | is_publish=True, |
| 630 | ptype=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 631 | stype=None, |
| 632 | term_ind_on=False) |
| 633 | |
| 634 | def test_ttl_solicited_ind_on(self): |
| 635 | """Functional test case / Discovery test cases / TTL test case: |
| 636 | - Solicited publish |
| 637 | - Termination indication enabled |
| 638 | """ |
| 639 | self.positive_ttl_test_utility( |
| 640 | is_publish=True, |
| 641 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 642 | stype=None, |
| 643 | term_ind_on=True) |
| 644 | |
| 645 | def test_ttl_solicited_ind_off(self): |
| 646 | """Functional test case / Discovery test cases / TTL test case: |
| 647 | - Solicited publish |
| 648 | - Termination indication disabled |
| 649 | """ |
| 650 | self.positive_ttl_test_utility( |
| 651 | is_publish=True, |
| 652 | ptype=aconsts.PUBLISH_TYPE_SOLICITED, |
| 653 | stype=None, |
| 654 | term_ind_on=False) |
| 655 | |
| 656 | def test_ttl_passive_ind_on(self): |
| 657 | """Functional test case / Discovery test cases / TTL test case: |
| 658 | - Passive subscribe |
| 659 | - Termination indication enabled |
| 660 | """ |
| 661 | self.positive_ttl_test_utility( |
| 662 | is_publish=False, |
| 663 | ptype=None, |
| 664 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 665 | term_ind_on=True) |
| 666 | |
| 667 | def test_ttl_passive_ind_off(self): |
| 668 | """Functional test case / Discovery test cases / TTL test case: |
| 669 | - Passive subscribe |
| 670 | - Termination indication disabled |
| 671 | """ |
| 672 | self.positive_ttl_test_utility( |
| 673 | is_publish=False, |
| 674 | ptype=None, |
| 675 | stype=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 676 | term_ind_on=False) |
| 677 | |
| 678 | def test_ttl_active_ind_on(self): |
| 679 | """Functional test case / Discovery test cases / TTL test case: |
| 680 | - Active subscribe |
| 681 | - Termination indication enabled |
| 682 | """ |
| 683 | self.positive_ttl_test_utility( |
| 684 | is_publish=False, |
| 685 | ptype=None, |
| 686 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 687 | term_ind_on=True) |
| 688 | |
| 689 | def test_ttl_active_ind_off(self): |
| 690 | """Functional test case / Discovery test cases / TTL test case: |
| 691 | - Active subscribe |
| 692 | - Termination indication disabled |
| 693 | """ |
| 694 | self.positive_ttl_test_utility( |
| 695 | is_publish=False, |
| 696 | ptype=None, |
| 697 | stype=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 698 | term_ind_on=False) |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 699 | |
| 700 | ####################################### |
| 701 | # Mismatched service name tests key: |
| 702 | # |
| 703 | # names is: test_mismatch_service_name_<pub_type>_<sub_type> |
| 704 | # where: |
| 705 | # |
| 706 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 707 | # sub_type: Type of subscribe discovery session: passive or active. |
| 708 | ####################################### |
| 709 | |
| 710 | def test_mismatch_service_name_unsolicited_passive(self): |
| 711 | """Functional test case / Discovery test cases / Mismatch service name |
| 712 | - Unsolicited publish |
| 713 | - Passive subscribe |
| 714 | """ |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 715 | self.negative_discovery_mismatch_test_utility( |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 716 | p_type=aconsts.PUBLISH_TYPE_UNSOLICITED, |
| 717 | s_type=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
| 718 | p_service_name="GoogleTestServiceXXX", |
| 719 | s_service_name="GoogleTestServiceYYY") |
| 720 | |
| 721 | def test_mismatch_service_name_solicited_active(self): |
| 722 | """Functional test case / Discovery test cases / Mismatch service name |
| 723 | - Solicited publish |
| 724 | - Active subscribe |
| 725 | """ |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 726 | self.negative_discovery_mismatch_test_utility( |
Etan Cohen | 60a9b52 | 2017-05-22 14:10:01 -0700 | [diff] [blame] | 727 | p_type=aconsts.PUBLISH_TYPE_SOLICITED, |
| 728 | s_type=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 729 | p_service_name="GoogleTestServiceXXX", |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 730 | s_service_name="GoogleTestServiceYYY") |
| 731 | |
| 732 | ####################################### |
| 733 | # Mismatched discovery session type tests key: |
| 734 | # |
| 735 | # names is: test_mismatch_service_type_<pub_type>_<sub_type> |
| 736 | # where: |
| 737 | # |
| 738 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 739 | # sub_type: Type of subscribe discovery session: passive or active. |
| 740 | ####################################### |
| 741 | |
| 742 | def test_mismatch_service_type_unsolicited_active(self): |
| 743 | """Functional test case / Discovery test cases / Mismatch service name |
| 744 | - Unsolicited publish |
| 745 | - Active subscribe |
| 746 | """ |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 747 | self.negative_discovery_mismatch_test_utility( |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 748 | p_type=aconsts.PUBLISH_TYPE_UNSOLICITED, |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 749 | s_type=aconsts.SUBSCRIBE_TYPE_ACTIVE) |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 750 | |
| 751 | def test_mismatch_service_type_solicited_passive(self): |
| 752 | """Functional test case / Discovery test cases / Mismatch service name |
| 753 | - Unsolicited publish |
| 754 | - Active subscribe |
| 755 | """ |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 756 | self.negative_discovery_mismatch_test_utility( |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 757 | p_type=aconsts.PUBLISH_TYPE_SOLICITED, |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 758 | s_type=aconsts.SUBSCRIBE_TYPE_PASSIVE) |
| 759 | |
| 760 | ####################################### |
| 761 | # Mismatched discovery match filter tests key: |
| 762 | # |
| 763 | # names is: test_mismatch_match_filter_<pub_type>_<sub_type> |
| 764 | # where: |
| 765 | # |
| 766 | # pub_type: Type of publish discovery session: unsolicited or solicited. |
| 767 | # sub_type: Type of subscribe discovery session: passive or active. |
| 768 | ####################################### |
| 769 | |
| 770 | def test_mismatch_match_filter_unsolicited_passive(self): |
| 771 | """Functional test case / Discovery test cases / Mismatch match filter |
| 772 | - Unsolicited publish |
| 773 | - Passive subscribe |
| 774 | """ |
| 775 | self.negative_discovery_mismatch_test_utility( |
| 776 | p_type=aconsts.PUBLISH_TYPE_UNSOLICITED, |
Etan Cohen | 6677a2a | 2017-05-22 14:38:04 -0700 | [diff] [blame] | 777 | s_type=aconsts.SUBSCRIBE_TYPE_PASSIVE, |
Etan Cohen | d8d5808 | 2017-05-22 15:03:17 -0700 | [diff] [blame^] | 778 | p_mf_1="hello there string", |
| 779 | s_mf_1="goodbye there string") |
| 780 | |
| 781 | def test_mismatch_match_filter_solicited_active(self): |
| 782 | """Functional test case / Discovery test cases / Mismatch match filter |
| 783 | - Solicited publish |
| 784 | - Active subscribe |
| 785 | """ |
| 786 | self.negative_discovery_mismatch_test_utility( |
| 787 | p_type=aconsts.PUBLISH_TYPE_SOLICITED, |
| 788 | s_type=aconsts.SUBSCRIBE_TYPE_ACTIVE, |
| 789 | p_mf_1="hello there string", |
| 790 | s_mf_1="goodbye there string") |