Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 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 | # SPDX-License-Identifier: GPL-2.0+ # Copyright 2022 Google LLC # # Test addition of VBE import os import pytest import fit_util # Define a base ITS which we can adjust using % and a dictionary base_its = ''' /dts-v1/; / { description = "Example kernel"; images { kernel-1 { data = /incbin/("%(kernel)s"); type = "kernel"; arch = "sandbox"; os = "linux"; load = <0x40000>; entry = <0x8>; compression = "%(compression)s"; random { compatible = "vbe,random-rand"; vbe,size = <0x40>; vbe,required; }; aslr1 { compatible = "vbe,aslr-move"; vbe,align = <0x100000>; }; aslr2 { compatible = "vbe,aslr-rand"; }; efi-runtime { compatible = "vbe,efi-runtime-rand"; }; wibble { compatible = "vbe,wibble"; }; }; fdt-1 { description = "snow"; data = /incbin/("%(fdt)s"); type = "flat_dt"; arch = "sandbox"; load = <%(fdt_addr)#x>; compression = "%(compression)s"; }; }; configurations { default = "conf-1"; conf-1 { kernel = "kernel-1"; fdt = "fdt-1"; }; }; }; ''' # Define a base FDT - currently we don't use anything in this base_fdt = ''' /dts-v1/; / { chosen { }; }; ''' # This is the U-Boot script that is run for each test. First load the FIT, # then run the 'bootm' command, then run the unit test which checks that the # working tree has the required things filled in according to the OS requests # above (random, aslr2, etc.) base_script = ''' host load hostfs 0 %(fit_addr)x %(fit)s fdt addr %(fit_addr)x bootm start %(fit_addr)x bootm loados bootm prep fdt addr fdt print ''' @pytest.mark.boardspec('sandbox') @pytest.mark.requiredtool('dtc') def test_vbe_os_request(ubman): """Test loading an OS and dealing with requests""" kernel = fit_util.make_kernel(ubman, 'vbe-kernel.bin', 'kernel') fdt = fit_util.make_dtb(ubman, base_fdt, 'vbe-fdt') fdt_out = fit_util.make_fname(ubman, 'fdt-out.dtb') params = { 'fit_addr' : 0x1000, 'kernel' : kernel, 'fdt' : fdt, 'fdt_out' : fdt_out, 'fdt_addr' : 0x80000, 'fdt_size' : 0x1000, 'compression' : 'none', } mkimage = ubman.config.build_dir + '/tools/mkimage' fit = fit_util.make_fit(ubman, mkimage, base_its, params, 'test-vbe.fit', base_fdt) params['fit'] = fit cmd = base_script % params with ubman.log.section('Kernel load'): ubman.run_command_list(cmd.splitlines()) ubman.run_ut('bootstd', 'vbe_test_fixup') @pytest.mark.boardspec('sandbox') def test_vbe_extlinux_fit_no_oem(ubman): """Test reading a FIT from an extlinux.conf file""" fname = os.path.join(ubman.config.persistent_data_dir, 'vbe0.img') ubman.run_command(f'host bind 0 {fname}') ubman.run_ut('bootstd', 'vbe_test_abrec_no_oem') @pytest.mark.boardspec('sandbox') def test_vbe_extlinux_fit_oem(ubman): """Test reading an OEM FIT, then an OS FIT from an extlinux.conf file""" fname = os.path.join(ubman.config.persistent_data_dir, 'vbe1.img') ubman.run_command(f'host bind 0 {fname}') ubman.run_ut('bootstd', 'vbe_test_abrec_oem') |