test_fastboot.py 25.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (C) 2015 Linaro Limited
#
# Author: Senthil Kumaran S <senthil.kumaran@linaro.org>
#
# This file is part of LAVA Dispatcher.
#
# LAVA Dispatcher is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LAVA Dispatcher is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along
# with this program; if not, see <http://www.gnu.org/licenses>.

import os
import glob
import unittest
24
from unittest.mock import patch, ANY, MagicMock, PropertyMock
25
from lava_common.exceptions import JobError, InfrastructureError
Rémi Duraffort's avatar
Rémi Duraffort committed
26
from lava_dispatcher.protocols.lxc import LxcProtocol
27
from tests.lava_dispatcher.test_basic import Factory, StdoutTestCase
28
from tests.utils import infrastructure_error, infrastructure_error_multi_paths
Rémi Duraffort's avatar
Rémi Duraffort committed
29
from lava_dispatcher.actions.deploy import DeployAction
30
from lava_dispatcher.actions.deploy.fastboot import FastbootFlashOrderAction
Rémi Duraffort's avatar
Rémi Duraffort committed
31
from lava_dispatcher.actions.boot.fastboot import BootAction
32
from lava_dispatcher.utils.fastboot import BaseAction
33
from lava_dispatcher.utils.fastboot import NullDriver, LxcDriver, DockerDriver
34
from lava_dispatcher.utils.lxc import is_lxc_requested, lxc_cmd_prefix
35
36


37
class FastBootFactory(Factory):
38
39
40
41
42
    """
    Not Model based, this is not a Django factory.
    Factory objects are dispatcher based classes, independent
    of any database objects.
    """
43

44
    def create_fastboot_job(self, filename):
45
        return self.create_job("nexus4-01.jinja2", filename)
46
47

    def create_db410c_job(self, filename):
48
        return self.create_job("db410c-01.jinja2", filename)
49
50

    def create_x15_job(self, filename):
51
        return self.create_job("x15-01.jinja2", filename)
52
53

    def create_hikey_job(self, filename):
54
        return self.create_job("hi6220-hikey-r2-01.jinja2", filename)
55
56

    def create_hikey960_job(self, filename):
57
        return self.create_job("hi960-hikey-01.jinja2", filename)
58
59

    def create_nexus5x_job(self, filename):
60
        return self.create_job("nexus5x-01.jinja2", filename)
61
62

    def create_pixel_job(self, filename):
63
        return self.create_job("pixel-01.jinja2", filename)
64

65

66
67
68
69
70
71
72
73
74
75
76
77
78
79
class TestFastbootBaseAction(unittest.TestCase):
    def setUp(self):
        self.factory = FastBootFactory()

    def test_null_driver(self):
        job = self.factory.create_fastboot_job("sample_jobs/nexus4-minus-lxc.yaml")
        action = job.pipeline.actions[0]
        self.assertIsInstance(action.driver, NullDriver)

    def test_lxc_driver(self):
        job = self.factory.create_fastboot_job("sample_jobs/fastboot.yaml")
        action = job.pipeline.actions[2]
        self.assertIsInstance(action.driver, LxcDriver)

80
81
82
83
84
    def test_docker_driver(self):
        job = self.factory.create_fastboot_job("sample_jobs/fastboot-docker.yaml")
        action = job.pipeline.actions[0]
        self.assertIsInstance(action.driver, DockerDriver)

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

class TestFastbootBaseActionDriverUsage(unittest.TestCase):
    def setUp(self):
        action = BaseAction()
        action.job = MagicMock()
        action.job.device = {
            "adb_serial_number": "01234556789",
            "fastboot_serial_number": "01234556789",
            "fastboot_options": [],
        }

        driver_patcher = patch(
            "lava_dispatcher.actions.deploy.fastboot.BaseAction.driver",
            new_callable=PropertyMock,
        )
        action.driver = driver_patcher.start()
        self.addCleanup(driver_patcher.stop)

        self.action = action

        run_cmd_patcher = patch(
            "lava_dispatcher.actions.deploy.fastboot.BaseAction.run_cmd"
        )
        self.run_cmd = run_cmd_patcher.start()
        self.addCleanup(run_cmd_patcher.stop)

        parsed_command_patcher = patch(
            "lava_dispatcher.actions.deploy.fastboot.BaseAction.parsed_command"
        )
        self.parsed_command = parsed_command_patcher.start()
        self.addCleanup(parsed_command_patcher.stop)

    def test_run_fastboot(self):
        self.action.driver.get_command_prefix.return_value = ["foo", "bar"]
        self.action.run_fastboot(["xyz"])
        self.run_cmd.assert_called_with(
            ["foo", "bar", "fastboot", "-s", "01234556789", "xyz"]
        )

    def test_get_fastboot_output(self):
        self.action.driver.get_command_prefix.return_value = ["abc"]
        self.parsed_command.return_value = "HELLO"
        output = self.action.get_fastboot_output(["devices"])
        self.assertEqual("HELLO", output)

    def test_get_fastboot_output_kwards(self):
        self.action.driver.get_command_prefix.return_value = []
        self.action.get_fastboot_output(["devices"], foo="bar")
        self.parsed_command.assert_called_with(ANY, foo="bar")

    def test_run_adb(self):
        self.action.driver.get_command_prefix.return_value = ["foo", "bar"]
        self.action.run_adb(["devices"])
        self.run_cmd.assert_called_with(
            ["foo", "bar", "adb", "-s", "01234556789", "devices"]
        )

    def test_get_adb_output(self):
        self.action.driver.get_command_prefix.return_value = ["abc"]
        self.parsed_command.return_value = "HELLO"
        output = self.action.get_adb_output(["devices"])
        self.assertEqual("HELLO", output)

    def test_get_adb_output_kwards(self):
        self.action.driver.get_command_prefix.return_value = []
        self.action.get_adb_output(["devices"], foo="bar")
        self.parsed_command.assert_called_with(ANY, foo="bar")


class TestNullDriver(unittest.TestCase):
    def setUp(self):
        self.factory = FastBootFactory()
        job = self.factory.create_fastboot_job("sample_jobs/nexus4-minus-lxc.yaml")
        self.action = job.pipeline.actions[0]

    @patch("lava_dispatcher.actions.deploy.fastboot.BaseAction.run_cmd")
    def test_run_fastboot(self, run_cmd):
        self.action.run_fastboot(["wait-for-devices"])
        run_cmd.assert_called_with(["fastboot", "-s", ANY, "wait-for-devices"])

    def test_maybe_copy_to_container(self):
        src = "/path/to/file.img"
        self.assertEqual(src, self.action.maybe_copy_to_container(src))


class TestLxcDriver(unittest.TestCase):
    def setUp(self):
        self.factory = FastBootFactory()
        job = self.factory.create_fastboot_job("sample_jobs/fastboot.yaml")
        self.action = job.pipeline.actions[2]
        self.lxc_name = "lxc-nexus4-test-" + str(self.action.job.job_id)

    @patch("lava_dispatcher.actions.deploy.fastboot.BaseAction.run_cmd")
    def test_run_fastboot(self, run_cmd):
        self.action.run_fastboot(["wait-for-devices"])
        run_cmd.assert_called_with(
            [
                "lxc-attach",
                "-n",
                self.lxc_name,
                "--",
                "fastboot",
                "-s",
                ANY,
                "wait-for-devices",
            ]
        )

    @patch(
        "lava_dispatcher.utils.fastboot.copy_to_lxc",
        return_value="/path/inside/container/to/file.img",
    )
    def test_maybe_copy_to_container(self, copy_to_lxc):
        src = "/path/to/file.img"
        dest = self.action.maybe_copy_to_container(src)
        copy_to_lxc.assert_called_with(self.lxc_name, src, ANY)
        self.assertEqual(dest, "/path/inside/container/to/file.img")


204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
class TestDockerDriver(unittest.TestCase):
    def setUp(self):
        self.factory = FastBootFactory()
        job = self.factory.create_fastboot_job("sample_jobs/fastboot-docker.yaml")
        self.action = job.pipeline.actions[0]
        self.image = self.action.parameters["docker"]["image"]

    def test_maybe_copy_to_container(self):
        src = "/path/to/image.img"
        dest = self.action.maybe_copy_to_container(src)
        self.assertEqual(src, dest)

    @patch("lava_dispatcher.utils.fastboot.BaseAction.run_cmd")
    @patch(
        "lava_dispatcher.utils.fastboot.get_udev_devices", return_value=["/dev/foo/bar"]
    )
    def test_run_fastboot(self, get_udev_devices, run_cmd):
        self.action.job.device["device_info"] = {"board_id": "01234556789"}
        self.action.maybe_copy_to_container("/path/to/image.img")
        self.action.run_fastboot(["wait-for-devices"])
        run_cmd.assert_called_with(
            [
                "docker",
                "run",
228
                "--rm",
229
                "--device=/dev/foo/bar",
230
                "--mount=type=bind,source=/path/to/image.img,destination=/path/to/image.img",
231
232
233
234
235
236
237
238
239
                self.image,
                "fastboot",
                "-s",
                ANY,
                "wait-for-devices",
            ]
        )


240
class TestFastbootDeploy(StdoutTestCase):
241
    def setUp(self):
Rémi Duraffort's avatar
Rémi Duraffort committed
242
        super().setUp()
243
        self.factory = FastBootFactory()
244
        self.job = self.factory.create_fastboot_job("sample_jobs/fastboot.yaml")
245
246
247

    def test_deploy_job(self):
        self.assertEqual(self.job.pipeline.job, self.job)
248
        self.assertIsInstance(self.job.device["device_info"], list)
249
250
251
252
253
        for action in self.job.pipeline.actions:
            if isinstance(action, DeployAction):
                self.assertEqual(action.job, self.job)

    def test_pipeline(self):
254
        description_ref = self.pipeline_reference("fastboot.yaml", job=self.job)
255
256
        self.assertEqual(description_ref, self.job.pipeline.describe(False))

257
258
259
260
    @unittest.skipIf(
        infrastructure_error_multi_paths(["lxc-info", "img2simg", "simg2img"]),
        "lxc or img2simg or simg2img not installed",
    )
261
    def test_lxc_api(self):
262
263
        job = self.factory.create_hikey_job("sample_jobs/hikey-oe.yaml")
        description_ref = self.pipeline_reference("hikey-oe.yaml", job=job)
264
265
266
267
        job.validate()
        self.assertEqual(description_ref, job.pipeline.describe(False))
        self.assertIn(LxcProtocol.name, [protocol.name for protocol in job.protocols])
        self.assertEqual(len(job.protocols), 1)
Neil Williams's avatar
Neil Williams committed
268
        self.assertIsNotNone(job.device.pre_os_command)
269
270
271
272
273
        select = [
            action
            for action in job.pipeline.actions
            if action.name == "grub-sequence-action"
        ][0]
274
        self.assertIn(LxcProtocol.name, select.parameters.keys())
275
276
277
278
279
280
281
282
283
284
        self.assertIn("protocols", select.parameters.keys())
        self.assertIn(LxcProtocol.name, select.parameters["protocols"].keys())
        self.assertEqual(len(select.parameters["protocols"][LxcProtocol.name]), 1)
        lxc_active = any(
            [
                protocol
                for protocol in job.protocols
                if protocol.name == LxcProtocol.name
            ]
        )
285
        self.assertTrue(lxc_active)
286
287
288
289
290
291
292
293
        for calling in select.parameters["protocols"][LxcProtocol.name]:
            self.assertEqual(calling["action"], select.name)
            self.assertEqual(calling["request"], "pre-os-command")
        deploy = [
            action
            for action in job.pipeline.actions
            if action.name == "fastboot-deploy"
        ][0]
294
        self.assertIn(LxcProtocol.name, deploy.parameters.keys())
295
296
297
298
299
300
301
302
303
        self.assertIn("protocols", deploy.parameters.keys())
        self.assertIn(LxcProtocol.name, deploy.parameters["protocols"].keys())
        self.assertEqual(len(deploy.parameters["protocols"][LxcProtocol.name]), 1)
        for calling in deploy.parameters["protocols"][LxcProtocol.name]:
            self.assertEqual(calling["action"], deploy.name)
            self.assertEqual(calling["request"], "pre-power-command")
        pair = ["pre-os-command", "pre-power-command"]
        action_list = {list(jaction.keys())[0] for jaction in job.parameters["actions"]}
        block = job.parameters["actions"]
304
305
306
        for action in action_list:
            for item in block:
                if action in item:
307
308
                    if "protocols" in item[action]:
                        caller = item[action]["protocols"][LxcProtocol.name]
309
                        for call in caller:
310
                            self.assertIn(call["request"], pair)
311

312
    @unittest.skipIf(infrastructure_error("lxc-info"), "lxc-info not installed")
313
    def test_fastboot_lxc(self):
314
        job = self.factory.create_hikey_job("sample_jobs/hi6220-hikey.yaml")
315

316
        description_ref = self.pipeline_reference("hi6220-hikey.yaml", job=job)
317
        self.assertEqual(description_ref, job.pipeline.describe(False))
318
319
        self.assertEqual(
            job.device.pre_power_command,
320
321
322
323
324
325
326
            "/home/neil/lava-lab/shared/lab-scripts/usb_hub_control -u 12 -p 4000 -m sync",
        )
        lxc_deploy = [
            action for action in job.pipeline.actions if action.name == "lxc-deploy"
        ][0]
        overlay = [
            action
327
            for action in lxc_deploy.pipeline.actions
328
329
330
331
            if action.name == "lava-overlay"
        ][0]
        testdef = [
            action
332
            for action in overlay.pipeline.actions
333
334
            if action.name == "test-definition"
        ][0]
335
336
337
        job.validate()
        self.assertEqual(
            {
338
339
340
341
342
343
344
345
346
347
348
349
                "1.8.4.20": "4_android-optee",
                "1.8.4.4": "0_get-adb-serial",
                "1.8.4.12": "2_android-busybox",
                "1.8.4.8": "1_android-meminfo",
                "1.8.4.16": "3_android-ping-dns",
            },
            testdef.get_namespace_data(
                action="test-runscript-overlay",
                label="test-runscript-overlay",
                key="testdef_levels",
            ),
        )
350
        for testdef in testdef.test_list[0]:
351
            self.assertEqual("git", testdef["from"])
352

353
    @unittest.skipIf(infrastructure_error("lxc-create"), "lxc-create not installed")
354
355
356
357
358
359
360
361
362
363
364
365
366
    def test_validate(self):
        try:
            self.job.pipeline.validate_actions()
        except JobError as exc:
            self.fail(exc)
        for action in self.job.pipeline.actions:
            self.assertEqual([], action.errors)

    def test_overlay(self):
        overlay = None
        for action in self.job.pipeline.actions:
            self.assertIsNotNone(action.name)
            if isinstance(action, DeployAction):
367
368
369
370
371
372
                if action.parameters["namespace"] == "tlxc":
                    overlay = [
                        action
                        for action in action.pipeline.actions
                        if action.name == "lava-overlay"
                    ][0]
373
374
375
        self.assertIsNotNone(overlay)
        # these tests require that lava-dispatcher itself is installed, not just running tests from a git clone
        self.assertTrue(os.path.exists(overlay.lava_test_dir))
376
377
378
379
380
381
382
383
384
385
386
387
388
389
        self.assertIsNot(overlay.lava_test_dir, "/")
        self.assertNotIn("lava_multi_node_test_dir", dir(overlay))
        self.assertNotIn("lava_multi_node_cache_file", dir(overlay))
        self.assertNotIn("lava_lmp_test_dir", dir(overlay))
        self.assertNotIn("lava_lmp_cache_file", dir(overlay))
        self.assertIsNotNone(
            overlay.parameters["deployment_data"]["lava_test_results_dir"]
        )
        self.assertIsNotNone(overlay.parameters["deployment_data"]["lava_test_sh_cmd"])
        self.assertEqual(overlay.parameters["deployment_data"]["distro"], "debian")
        self.assertIsNotNone(
            overlay.parameters["deployment_data"]["lava_test_results_part_attr"]
        )
        self.assertIsNotNone(glob.glob(os.path.join(overlay.lava_test_dir, "lava-*")))
390

391
    @unittest.skipIf(infrastructure_error("lxc-attach"), "lxc-attach not installed")
392
393
394
395
    def test_boot(self):
        for action in self.job.pipeline.actions:
            if isinstance(action, BootAction):
                # get the action & populate it
396
397
398
399
400
401
                if action.parameters.get("namespace") == "tlxc":
                    self.assertIn(action.parameters["method"], ["lxc", "fastboot"])
                    self.assertEqual(action.parameters["prompts"], ["root@(.*):/#"])
                if action.parameters.get("namespace") == "droid":
                    self.assertIn(action.parameters["method"], ["lxc", "fastboot"])
                    self.assertEqual(action.parameters.get("prompts"), None)
402
403
404

    def test_testdefinitions(self):
        for action in self.job.pipeline.actions:
405
            if action.name == "test":
406
                # get the action & populate it
407
                self.assertEqual(len(action.parameters["definitions"]), 2)
408
409
410

    def test_udev_actions(self):
        self.factory = FastBootFactory()
411
412
413
        job = self.factory.create_db410c_job("sample_jobs/db410c.yaml")
        self.assertTrue(job.device.get("fastboot_via_uboot", True))
        description_ref = self.pipeline_reference("db410c.yaml", job=job)
414
        self.assertEqual(description_ref, job.pipeline.describe(False))
415
416
417
        boot = [
            action for action in job.pipeline.actions if action.name == "fastboot-boot"
        ][0]
418

419
    @unittest.skipIf(infrastructure_error("lxc-start"), "lxc-start not installed")
420
421
    def test_x15_job(self):
        self.factory = FastBootFactory()
422
        job = self.factory.create_x15_job("sample_jobs/x15.yaml")
Neil Williams's avatar
Neil Williams committed
423
        job.validate()
424
        description_ref = self.pipeline_reference("x15.yaml", job=job)
425
        self.assertEqual(description_ref, job.pipeline.describe(False))
426
427
428
429
430
431
432
        deploy = [
            action
            for action in job.pipeline.actions
            if action.name == "fastboot-deploy"
        ][0]
        enter = [
            action
433
            for action in deploy.pipeline.actions
434
435
436
437
            if action.name == "uboot-enter-fastboot"
        ][0]
        interrupt = [
            action
438
            for action in enter.pipeline.actions
439
440
            if action.name == "bootloader-interrupt"
        ][0]
Neil Williams's avatar
Neil Williams committed
441
442
443
        self.assertTrue(interrupt.needs_interrupt)
        self.assertIsInstance(interrupt.params, dict)
        self.assertNotEqual(interrupt.params, {})
444
445
446
447
448
449
450
        self.assertIn("mkimage_arch", interrupt.params)
        self.assertIn("interrupt_prompt", interrupt.params)
        boot = [
            action for action in job.pipeline.actions if action.name == "fastboot-boot"
        ][0]
        enter = [
            action
451
            for action in boot.pipeline.actions
452
453
454
455
            if action.name == "uboot-enter-fastboot"
        ][0]
        interrupt = [
            action
456
            for action in enter.pipeline.actions
457
458
            if action.name == "bootloader-interrupt"
        ][0]
Neil Williams's avatar
Neil Williams committed
459
460
        self.assertIsInstance(interrupt.params, dict)
        self.assertNotEqual(interrupt.params, {})
461
462
        self.assertIn("mkimage_arch", interrupt.params)
        self.assertIn("interrupt_prompt", interrupt.params)
Neil Williams's avatar
Neil Williams committed
463
        self.assertTrue(interrupt.needs_interrupt)
464
465
        autologin = [
            action
466
            for action in boot.pipeline.actions
467
468
            if action.name == "auto-login-action"
        ][0]
Neil Williams's avatar
Neil Williams committed
469
        self.assertTrue(autologin.booting)
470
471
472
473
474
        self.assertEqual(
            set(autologin.parameters.get("prompts")),
            set(["root@(.*):/#", "shell@am57xevm:/"]),
        )
        self.assertIsNone(autologin.parameters.get("boot_message"))
475

476
477
478
    def test_sdm845_qcs(self):
        self.factory = FastBootFactory()
        job = self.factory.create_job(
479
            "qcs404-evb-1k-01.jinja2", "sample_jobs/qcs404-evb-1k.yaml"
480
481
482
483
484
485
486
487
488
489
490
        )
        # do not run job.validate() - power urls do not exist.
        description_ref = self.pipeline_reference("qcs404-evb-1k.yaml", job=job)
        self.assertEqual(description_ref, job.pipeline.describe(False))
        job = self.factory.create_job(
            "qcs404-evb-4k-01.jinja2", "sample_jobs/qcs404-evb-4k.yaml"
        )
        # do not run job.validate() - power urls do not exist.
        description_ref = self.pipeline_reference("qcs404-evb-4k.yaml", job=job)
        self.assertEqual(description_ref, job.pipeline.describe(False))

491
492
    def test_nexus5x_job(self):
        self.factory = FastBootFactory()
493
        job = self.factory.create_nexus5x_job("sample_jobs/nexus5x.yaml")
494
        # do not run job.validate() - urls no longer exist.
495
        description_ref = self.pipeline_reference("nexus5x.yaml", job=job)
496
        self.assertEqual(description_ref, job.pipeline.describe(False))
497
498
499

    def test_pixel_job(self):
        self.factory = FastBootFactory()
500
        job = self.factory.create_pixel_job("sample_jobs/pixel.yaml")
501
        # do not run job.validate() - urls no longer exist.
502
        description_ref = self.pipeline_reference("pixel.yaml", job=job)
503
        self.assertEqual(description_ref, job.pipeline.describe(False))
504
505
506

    def test_flash_cmds_order(self):
        self.factory = FastBootFactory()
507
        job = self.factory.create_db410c_job("sample_jobs/db410c.yaml")
508
509
510
511
512
513
        # The expected_flash_cmds list ensures the following:
        # 1. Order of flash commands.
        # 2. Number / Count of flash commands.
        # 3. 'cdt' flash command is not part of draganboard-410c's device
        #    dictionary, but ensure that it gets added in the final flash
        #    commands list.
514
515
516
517
518
519
520
521
522
523
524
        expected_flash_cmds = [
            "partition",
            "hyp",
            "rpm",
            "sbl1",
            "tz",
            "aboot",
            "cdt",
            "boot",
            "rootfs",
        ]
525
526
527
528
        flash_order = None
        for action in job.pipeline.actions:
            self.assertIsNotNone(action.name)
            if isinstance(action, DeployAction):
529
530
531
532
533
534
                if action.name == "fastboot-deploy":
                    flash_order = [
                        action
                        for action in action.pipeline.actions
                        if action.name == "fastboot-flash-order-action"
                    ][0]
535
                    flash_action = [
536
537
538
539
540
541
542
543
544
                        action
                        for action in flash_order.pipeline.actions
                        if action.name == "fastboot-flash-action"
                    ][0]
                    flash_cmds = [
                        action.command
                        for action in flash_order.pipeline.actions
                        if action.name == "fastboot-flash-action"
                    ]
545
        self.assertIsNotNone(flash_order)
546
547
        self.assertIsNotNone(flash_action)
        self.assertEqual(flash_action.timeout_exception, InfrastructureError)
548
549
550
        self.assertIsInstance(flash_order, FastbootFlashOrderAction)
        self.assertEqual(expected_flash_cmds, flash_cmds)

551
    @unittest.skipIf(infrastructure_error("lxc-start"), "lxc-start not installed")
552
    def test_hikey960_fastboot(self):
553
        job = self.factory.create_hikey960_job("sample_jobs/hikey960-aosp.yaml")
554
555
        self.assertIsNotNone(job)
        job.validate()
556
        description_ref = self.pipeline_reference("hi960-aosp-efi.yaml", job=job)
557
558
        self.assertEqual(description_ref, job.pipeline.describe(False))
        flash_order = None
559
        expected_flash_cmds = ["boot", "system", "userdata", "cache"]
560
561
562
        for action in job.pipeline.actions:
            self.assertIsNotNone(action.name)
            if isinstance(action, DeployAction):
563
564
565
566
567
568
569
570
571
572
573
                if action.name == "fastboot-deploy":
                    flash_order = [
                        action
                        for action in action.pipeline.actions
                        if action.name == "fastboot-flash-order-action"
                    ][0]
                    flash_cmds = [
                        action.command
                        for action in flash_order.pipeline.actions
                        if action.name == "fastboot-flash-action"
                    ]
574
575
        self.assertIsNotNone(flash_order)
        self.assertIsInstance(flash_order, FastbootFlashOrderAction)
576
        self.assertEqual(expected_flash_cmds, flash_cmds)
577
578

    def test_fastboot_minus_lxc(self):
579
580
        # Do not run job.validate() since it will require some android tools
        # such as fastboot, adb, etc. to be installed.
581
582
        job = self.factory.create_fastboot_job("sample_jobs/nexus4-minus-lxc.yaml")
        description_ref = self.pipeline_reference("nexus4-minus-lxc.yaml", job=job)
583
584
585
586
        self.assertEqual(description_ref, job.pipeline.describe(False))
        # There shouldn't be any lxc defined
        lxc_name = is_lxc_requested(job)
        self.assertEqual(lxc_name, False)
587
588
589
590
591
        deploy = [
            action
            for action in job.pipeline.actions
            if action.name == "fastboot-deploy"
        ][0]
592
        # No lxc requested, hence lxc_cmd_prefix is an empty list
593
        self.assertEqual([], lxc_cmd_prefix(job))
594
595
596
597

    def test_db410c_minus_lxc(self):
        # Do not run job.validate() since it will require some android tools
        # such as fastboot, adb, etc. to be installed.
598
599
        job = self.factory.create_db410c_job("sample_jobs/db410c-minus-lxc.yaml")
        description_ref = self.pipeline_reference("db410c-minus-lxc.yaml", job=job)
600
601
602
603
        self.assertEqual(description_ref, job.pipeline.describe(False))
        # There shouldn't be any lxc defined
        lxc_name = is_lxc_requested(job)
        self.assertEqual(lxc_name, False)
604
605
606
607
608
        deploy = [
            action
            for action in job.pipeline.actions
            if action.name == "fastboot-deploy"
        ][0]
609
        # No lxc requested, hence lxc_cmd_prefix is an empty list
610
        self.assertEqual([], lxc_cmd_prefix(job))
611
612

    def test_fastboot_boot_commands(self):
613
614
615
        job = self.factory.create_job(
            "imx8mq-evk-01.jinja2", "sample_jobs/imx8mq-evk.yaml"
        )
616
617
618
619
        boot = [
            action for action in job.pipeline.actions if action.name == "fastboot-boot"
        ][0]
        self.assertIn("commands", boot.parameters)
620
        self.assertEqual("191c51d6f060954b", job.device["fastboot_serial_number"])
621
        self.assertIsInstance(boot.parameters["commands"], list)