Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / pigweed-app / mobly_tests / echo_test.py
1 # Copyright (c) 2021 Project CHIP Authors
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
15 from chip_mobly import pigweed_device
16 from mobly import asserts
17 from mobly import base_test
18 from mobly import test_runner
19 import time
20
21
22 class PigweedEchoTest(base_test.BaseTestClass):
23     def setup_class(self):
24         ''' Registering pigweed_device controller module declares the test's
25         dependency on CHIP/Pigweed device hardware. By default, we expect at least one
26         object is created from this.'''
27         self.ads = self.register_controller(pigweed_device)
28         self.dut = self.ads[0]
29         self.dut.platform.flash() # Flashes the image passed in the configuration yml.
30         time.sleep(1) # give the device time to boot and register rpcs
31
32     def test_hello(self):
33         ''' Tests EchoService.Echo '''
34         expected = "hello!"
35         status, payload = self.dut.rpcs().EchoService.Echo(msg=expected)
36         asserts.assert_true(status.ok(), "Status is %s" % status)
37         asserts.assert_equal(
38             payload.msg,
39             expected,
40             'Returned payload is "%s" expected "%s"' % (payload.msg, expected),
41         )
42
43
44 if __name__ == "__main__":
45     test_runner.main()