xref: /aosp_15_r20/external/autotest/client/cros/cellular/labconfig_data.py (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1# Lint as: python2, python3
2# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Configuration for cell emulator tests."""
7from __future__ import absolute_import
8from __future__ import division
9from __future__ import print_function
10
11import copy, unittest
12import six
13
14CELLS = {}
15
16# TODO(rochberg):  Need some way to subset this list for long/short tests
17
18LTE_TECHNOLOGIES = ['LTE']
19GENERIC_GSM_TECHNOLOGIES = ['GPRS', 'EGPRS', 'WCDMA', 'HSDPA', 'HSUPA',
20                            'HSDUPA', 'HSPA_PLUS']
21
22ICERA_TECHNOLOGIES = GENERIC_GSM_TECHNOLOGIES[:]
23ICERA_TECHNOLOGIES.remove('HSPA_PLUS')
24
25GOBI_3000_TECHNOLOGIES = GENERIC_GSM_TECHNOLOGIES + ['CDMA_2000', 'EVDO_1X']
26
27GOBI_2000_TECHNOLOGIES = GOBI_3000_TECHNOLOGIES[:]
28GOBI_2000_TECHNOLOGIES.remove('HSPA_PLUS')
29
30# TODO(thieule): Make HSPA_PLUS work with autotest (crosbug.com/32621).
31GENERIC_GSM_TECHNOLOGIES.remove('HSPA_PLUS')
32GOBI_3000_TECHNOLOGIES.remove('HSPA_PLUS')
33
34def combine_trees(a_original, b):
35    """Combines two dict-of-dict trees, favoring the second."""
36    try:
37        a = copy.copy(a_original)
38        for (key_b, value_b) in six.iteritems(b):
39            a[key_b] = combine_trees(a.get(key_b, None), value_b)
40    except AttributeError:  # one argument wasn't a dict.  B wins.
41        return b
42    return a
43
44
45def MakeDefaultCallBoxConfig(specifics):
46    base = {
47            "type": "8960-prologix",
48            # IP addresses and netmask for the air-side of the
49            # basestation network.
50            "bs_addresses": [
51                "192.168.2.2",
52                "192.168.2.3"
53                ],
54            "bs_netmask": "255.255.0.0",
55
56            "gpib_adapter": {
57                "gpib_address": 14,
58                "ip_port": 1234
59                },
60            # DNS addresses for the UE.  You do not need a
61            # working DNS server at this address, but you must
62            # have a machine there to send ICMP Port
63            # Unreachable messages, so the DNS lookups will
64            # fail quickly)
65            "ue_dns_addresses": [
66                "192.168.2.254",
67                "192.168.2.254"
68                ],
69            "ue_rf_addresses": [
70                "192.168.2.4",
71                "192.168.2.5"
72                ]
73            }
74    return combine_trees(base, specifics)
75
76def MakeDefaultPerfServer(specifics):
77    rf_address = "192.168.2.254"
78    base = {
79        "rf_address": rf_address,
80        "upload_url": "http://%s/upload" % (rf_address),
81        "download_url_format_string": ("http://%s/download?size=%%(size)s" %
82                                       rf_address),
83        }
84    return combine_trees(base, specifics)
85
86
87CELLS['cam'] = {
88    "basestations": [
89        MakeDefaultCallBoxConfig({
90            "gpib_adapter": {
91                "address": "172.31.206.171",
92                },
93            })
94        ],
95    "duts": [
96        {
97            "address": "172.31.206.145",
98            "name": "ad-hoc-usb",
99            "technologies": GOBI_2000_TECHNOLOGIES,
100            "rf_switch_port": 3,
101            },
102        {
103            "address": "172.31.206.146",
104            "name": "y3300",
105            "technologies": GENERIC_GSM_TECHNOLOGIES,
106            "rf_switch_port": 0,
107            }
108        ],
109
110    "perfserver": MakeDefaultPerfServer({
111        "name": "perfserver-cam",
112        "address": "172.31.206.153",
113        "ethernet_mac": "e8:11:32:cb:bb:95 ",
114        }),
115
116    "http_connectivity": {
117        # "url" should point to a URL that fetches a page small enough
118        # to be comfortably kept in memory.  If
119        # "url_required_contents" is present, it points to a string
120        # that must be present in the the fetched data.
121
122        "url": "http://192.168.2.254/connectivity/index.html",
123        "url_required_contents": "Chromium",
124        },
125    "rf_switch": {
126        "type": "ether_io",
127        "address":  "172.31.206.172",
128        "ethernet_mac": "00:11:ba:02:12:83",
129        }
130    }
131
132CELLS['mtv'] = {
133    "basestations": [
134        MakeDefaultCallBoxConfig({
135            "gpib_adapter": {
136              "type":'8960',
137              "address": "172.22.50.118",
138              "ethernet_mac": "00:21:69:01:06:46",
139              }
140            }),
141        MakeDefaultCallBoxConfig({
142          "type":'pxt',
143          "gpib_adapter": {
144              "address": "172.22.50.244",
145              "ethernet_mac": "00:21:69:01:0a:11",
146              # ddns-hostname "chromeos1-rack1-pxt-gpib";
147            }
148        })
149        ],
150
151
152#chromeos1-rack1-pxt / 172.22.50.243
153#chromeos1-rack2-rfswitch2 / 172.22.50.229
154#pixel 172.22.50.86 chromeos1-rack2-host6
155
156    "duts": [
157         {
158             "address": "172.22.50.86",
159             "ethernet_mac": "00:0e:c6:89:9d:18",
160             "name": "link-lte",
161             "technologies": LTE_TECHNOLOGIES,
162             "location": "rack2-host6",
163             "rf_switch_port": 1,
164             },
165        {
166            "address": "172.22.50.187",
167            "ethernet_mac": "00:00:00:00:08:4b",
168            "name": "alex-gobi-2000",
169            "technologies": GOBI_2000_TECHNOLOGIES,
170            "location": "rack2-host0",
171            "rf_switch_port": 0,
172            },
173        {
174            "address": "172.22.50.85",
175            "ethernet_mac": "00:00:00:00:00:c8",
176            "name": "alex-gobi-3000",
177            "technologies": GOBI_3000_TECHNOLOGIES,
178            "location": "rack2-host4",
179            "rf_switch_port": 1,
180            },
181        {
182            "address": "172.22.50.191",
183            "ethernet_mac": "c0:c1:c0:4b:d7:4f",
184            "name": "alex-y3300",
185            "technologies": ICERA_TECHNOLOGIES,
186            "location": "rack2-host1",
187            "rf_switch_port": 3,
188            },
189        {
190            "address": "172.22.50.89",
191            "ethernet_mac": "58:6d:8f:50:ae:55",
192            "name": "alex-y3400",
193            "technologies": ICERA_TECHNOLOGIES,
194            "location": "rack2-host5",
195            "rf_switch_port": 2,
196            },
197        ],
198
199    "perfserver": MakeDefaultPerfServer({
200        "name": "perfserver-mtv",
201        "address": "172.22.50.246",
202        "ethernet_mac": "c4:54:44:2a:1a:8b",
203        }),
204
205    # Used for tests that check web connectivity
206    "http_connectivity": {
207        "url": "http://192.168.2.254/connectivity/index.html",
208        "url_required_contents": "Chromium",
209        },
210    "rf_switch": {
211        "type": "ether_io",
212        "name": "rf-switch-1-mtv",
213        "ethernet_mac": "00:11:BA:02:12:82",
214        "address":  "172.22.50.88",
215        }
216    }
217
218
219class TestCombineTrees(unittest.TestCase):
220    def test_simple(self):
221        self.assertEqual({1:2, 3:4, 5:6},
222                         combine_trees({1:2, 3:4}, {5:6}))
223
224    def test_override_simple(self):
225        self.assertEqual({1:3},
226                         combine_trees({1:2},{1:3}))
227
228    def test_join_nested(self):
229        self.assertEqual({1:{2:3, 3:4}},
230                         combine_trees({1:{2:3}},{1:{3:4}}))
231
232    def test_override_in_nested(self):
233        self.assertEqual({1:{2:4}},
234                         combine_trees({1:{2:3}},{1:{2:4}}))
235
236    def test_override_different_types(self):
237        self.assertEqual({1:{2:4}},
238                         combine_trees({1:'rhinoceros'},{1:{2:4}}))
239        self.assertEqual({1:'rhinoceros'},
240                         combine_trees({1:{2:4}},{1:'rhinoceros'}))
241
242    def test_two_level(self):
243        self.assertEqual({1:{2:{3:4, 5:6}}},
244                         combine_trees({1:{2:{3:4}}},{1:{2:{5:6}}}))
245
246    def test_none(self):
247        self.assertEqual({1:None},
248                         combine_trees({1:2}, {1:None}))
249        self.assertEqual({1:None},
250                         combine_trees({1:None}, {}))
251        self.assertEqual({1:2},
252                         combine_trees({1:None}, {1:2}))
253
254
255if __name__ == '__main__':
256    unittest.main()
257