|
8 | 8 |
|
9 | 9 | # Constants
|
10 | 10 | image_dir = f'{aboot.IMAGE_DIR_PREFIX}expeliarmus-{aboot.IMAGE_DIR_PREFIX}abcde'
|
| 11 | +image_chainloader = f'{image_dir}/.sonic-boot.swi' |
11 | 12 | exp_image = f'{aboot.IMAGE_PREFIX}expeliarmus-{aboot.IMAGE_DIR_PREFIX}abcde'
|
12 | 13 | image_dirs = [image_dir]
|
13 | 14 |
|
@@ -45,15 +46,27 @@ def test_get_installed_images():
|
45 | 46 | assert bootloader.get_installed_images() == [exp_image]
|
46 | 47 |
|
47 | 48 |
|
48 |
| -@patch("sonic_installer.bootloader.aboot.re.search") |
49 |
| -def test_get_next_image(re_search_patch): |
| 49 | +def test_get_next_image(): |
50 | 50 | bootloader = aboot.AbootBootloader()
|
51 |
| - bootloader._boot_config_read = Mock(return_value={'SWI': None}) |
| 51 | + |
| 52 | + # Test missing boot-config |
| 53 | + bootloader._boot_config_read() |
| 54 | + |
| 55 | + # Test missing SWI value |
| 56 | + bootloader._boot_config_read = Mock(return_value={}) |
| 57 | + assert bootloader.get_next_image() == '' |
52 | 58 |
|
53 | 59 | # Test convertion image dir to image name
|
54 |
| - re_search_patch().group = Mock(return_value=image_dir) |
| 60 | + swi = f'flash:{image_chainloader}' |
| 61 | + bootloader._boot_config_read = Mock(return_value={'SWI': swi}) |
55 | 62 | assert bootloader.get_next_image() == exp_image
|
56 | 63 |
|
| 64 | + # Test some other image |
| 65 | + next_image = 'EOS.swi' |
| 66 | + bootloader._boot_config_read = Mock(return_value={'SWI': f'flash:{next_image}'}) |
| 67 | + assert bootloader.get_next_image() == next_image |
| 68 | + |
| 69 | + |
57 | 70 | def test_install_image():
|
58 | 71 | image_path = 'sonic'
|
59 | 72 | env = os.environ.copy()
|
|
0 commit comments