Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Tests for mbr command |
| 4 | * |
| 5 | * Copyright 2023 Matrox Video |
| 6 | * Written by Alex Gendin <agendin@matrox.com> |
| 7 | */ |
| 8 | |
| 9 | #include <dm.h> |
| 10 | #include <console.h> |
| 11 | #include <dm/test.h> |
| 12 | #include <mapmem.h> |
| 13 | #include <part.h> |
| 14 | #include <asm/global_data.h> |
| 15 | #include <dm/device-internal.h> |
| 16 | #include <dm/lists.h> |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 17 | #include <linux/sizes.h> |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 18 | #include <test/suites.h> |
| 19 | #include <test/ut.h> |
| 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 22 | |
| 23 | #define BLKSZ SZ_512 /* block size */ |
| 24 | |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 25 | /* |
| 26 | * Requirements for running test manually: |
| 27 | * mmc6.img - File size needs to be at least 12 MiB |
| 28 | * |
| 29 | * Command to create mmc6.img: |
| 30 | * $ dd if=/dev/zero of=mmc6.img bs=12M count=1 |
| 31 | * |
| 32 | * To run this test manually, place mmc6.img into the same directory as u-boot, |
| 33 | * then run: |
| 34 | * $ ./u-boot -Tc 'ut mbr' |
| 35 | * |
| 36 | * To run this test as part of U-Boot test: |
| 37 | * $ ./test/py/test.py --bd sandbox --build -k ut_dm -v |
| 38 | * Note: mmc6.img will be created by the test suit. |
| 39 | */ |
| 40 | |
| 41 | static char * mbr_parts_header = "setenv mbr_parts '"; |
| 42 | static char * mbr_parts_p1 = "uuid_disk=0x12345678;name=p1,start=8M,bootable,size=1M,id=0x0e"; |
| 43 | static char * mbr_parts_p2 = ";name=p2,size=1M,id=0x0e"; |
| 44 | static char * mbr_parts_p3 = ";name=p3,size=1M,id=0x0e"; |
| 45 | static char * mbr_parts_p4 = ";name=p4,size=1M,id=0x0e"; |
| 46 | static char * mbr_parts_p5 = ";name=[ext],size=2M,id=0x05;name=p5,size=1M,id=0x0e"; |
| 47 | static char * mbr_parts_tail = "'"; |
| 48 | |
| 49 | /* |
| 50 | * One MBR partition |
| 51 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 52 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 00 |...%$..@........| |
| 53 | 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 54 | 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 55 | 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 56 | */ |
Simon Glass | 40d2a6e | 2024-09-01 16:26:21 -0600 | [diff] [blame] | 57 | static unsigned int mbr_cmp_start = 0x1b8; |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 58 | static unsigned mbr_cmp_size = 0x48; |
| 59 | static unsigned char mbr_parts_ref_p1[] = { |
| 60 | 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05, |
| 61 | 0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa |
| 65 | }; |
| 66 | |
| 67 | /* |
| 68 | * Two MBR partitions |
| 69 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 70 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 71 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 00 |%..F...H........| |
| 72 | 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 73 | 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 74 | */ |
| 75 | static unsigned char mbr_parts_ref_p2[] = { |
| 76 | 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05, |
| 77 | 0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25, |
| 78 | 0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa |
| 81 | }; |
| 82 | |
| 83 | /* |
| 84 | * Three MBR partitions |
| 85 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 86 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 87 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F| |
| 88 | 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 00 |...f%..P........| |
| 89 | 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 90 | */ |
| 91 | static unsigned char mbr_parts_ref_p3[] = { |
| 92 | 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05, |
| 93 | 0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25, |
| 94 | 0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, |
| 95 | 0x06, 0x01, 0x0e, 0x66, 0x25, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa |
| 97 | }; |
| 98 | |
| 99 | /* |
| 100 | * Four MBR partitions |
| 101 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 102 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 103 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F| |
| 104 | 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f| |
| 105 | 000001f0 26 01 0e 87 06 01 00 58 00 00 00 08 00 00 55 aa |&......X......U.| |
| 106 | */ |
| 107 | static unsigned char mbr_parts_ref_p4[] = { |
| 108 | 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05, |
| 109 | 0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25, |
| 110 | 0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, |
| 111 | 0x06, 0x01, 0x0e, 0x66, 0x25, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, |
| 112 | 0x26, 0x01, 0x0e, 0x87, 0x06, 0x01, 0x00, 0x58, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x55, 0xaa |
| 113 | }; |
| 114 | |
| 115 | /* |
| 116 | * Five MBR partitions |
| 117 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 118 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 119 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F| |
| 120 | 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f| |
| 121 | 000001f0 26 01 05 a7 26 01 00 58 00 00 00 10 00 00 55 aa |&...&..X......U.| |
| 122 | */ |
| 123 | static unsigned char mbr_parts_ref_p5[] = { |
| 124 | 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05, |
| 125 | 0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25, |
| 126 | 0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, |
| 127 | 0x06, 0x01, 0x0e, 0x66, 0x25, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66, |
| 128 | 0x26, 0x01, 0x05, 0xa7, 0x26, 0x01, 0x00, 0x58, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x55, 0xaa |
| 129 | }; |
| 130 | static unsigned ebr_cmp_start = 0x1B8; |
| 131 | static unsigned ebr_cmp_size = 0x48; |
| 132 | /* |
| 133 | * EBR |
| 134 | 00b001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 87 |................| |
| 135 | 00b001c0 07 01 0e a7 26 01 00 08 00 00 00 08 00 00 00 00 |....&...........| |
| 136 | 00b001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 137 | 00b001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 138 | 00b001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 139 | */ |
| 140 | static unsigned char ebr_parts_ref_p5[] = { |
| 141 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, |
| 142 | 0x07, 0x01, 0x0e, 0xa7, 0x26, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, |
| 143 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 145 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa |
| 146 | }; |
| 147 | |
| 148 | /* Fill write buffers with pseudo-random data */ |
| 149 | static void init_write_buffers(char *mbr_wb, size_t mbr_wb_size, |
| 150 | char *ebr_wb, size_t ebr_wb_size, unsigned seed) |
| 151 | { |
| 152 | while (mbr_wb_size--) { |
| 153 | *mbr_wb++ = seed; |
| 154 | seed *= 43; |
| 155 | seed += 17 + mbr_wb_size/4; |
| 156 | } |
| 157 | while (ebr_wb_size--) { |
| 158 | *ebr_wb++ = seed; |
| 159 | seed *= 43; |
| 160 | seed += 17 + ebr_wb_size/4; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | /* Build string with MBR partition(s) layout */ |
| 165 | static unsigned build_mbr_parts(char *buf, size_t buf_size, unsigned num_parts) |
| 166 | { |
| 167 | size_t bytes_remaining, cur_str_size; |
| 168 | char * cur_buf; |
| 169 | |
| 170 | if (!num_parts || num_parts > 5 || !buf) |
| 171 | return 1; |
| 172 | |
| 173 | cur_buf = buf; |
| 174 | *cur_buf = '\0'; |
| 175 | bytes_remaining = buf_size; |
| 176 | |
| 177 | cur_str_size = sizeof(mbr_parts_header); |
| 178 | if (cur_str_size + 1 > bytes_remaining) |
| 179 | return 1; |
| 180 | strcat(cur_buf, mbr_parts_header); |
| 181 | bytes_remaining -= cur_str_size; |
| 182 | |
| 183 | if (num_parts >= 1) { |
| 184 | cur_str_size = sizeof(mbr_parts_p1); |
| 185 | if (cur_str_size + 1 > bytes_remaining) |
| 186 | return 1; |
| 187 | strcat(cur_buf, mbr_parts_p1); |
| 188 | bytes_remaining -= cur_str_size; |
| 189 | |
| 190 | if (num_parts >= 2) { |
| 191 | cur_str_size = sizeof(mbr_parts_p2); |
| 192 | if (cur_str_size + 1 > bytes_remaining) |
| 193 | return 1; |
| 194 | strcat(cur_buf, mbr_parts_p2); |
| 195 | bytes_remaining -= cur_str_size; |
| 196 | |
| 197 | if (num_parts >= 3) { |
| 198 | cur_str_size = sizeof(mbr_parts_p3); |
| 199 | if (cur_str_size + 1 > bytes_remaining) |
| 200 | return 1; |
| 201 | strcat(cur_buf, mbr_parts_p3); |
| 202 | bytes_remaining -= cur_str_size; |
| 203 | |
| 204 | if (num_parts == 4) { |
| 205 | cur_str_size = sizeof(mbr_parts_p4); |
| 206 | if (cur_str_size + 1 > bytes_remaining) |
| 207 | return 1; |
| 208 | strcat(cur_buf, mbr_parts_p4); |
| 209 | bytes_remaining -= cur_str_size; |
| 210 | |
| 211 | } |
Alexander Gendin | 207fc53 | 2023-11-08 03:05:19 +0000 | [diff] [blame] | 212 | else if (num_parts == 5) { |
| 213 | cur_str_size = sizeof(mbr_parts_p5); |
| 214 | if (cur_str_size + 1 > bytes_remaining) |
| 215 | return 1; |
| 216 | strcat(cur_buf, mbr_parts_p5); |
| 217 | bytes_remaining -= cur_str_size; |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 218 | |
Alexander Gendin | 207fc53 | 2023-11-08 03:05:19 +0000 | [diff] [blame] | 219 | } |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | cur_str_size = sizeof(mbr_parts_tail); |
| 225 | if (cur_str_size + 1 > bytes_remaining) |
| 226 | return 1; |
| 227 | strcat(cur_buf, mbr_parts_tail); |
| 228 | |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | static int mbr_test_run(struct unit_test_state *uts) |
| 233 | { |
| 234 | struct blk_desc *mmc_dev_desc; |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 235 | unsigned char *mbr_wbuf, *ebr_wbuf, *rbuf; |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 236 | char mbr_parts_buf[256]; |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 237 | ulong addr = 0x1000; /* start address for buffers */ |
| 238 | ulong mbr_wa = addr, ebr_wa = addr + BLKSZ, ra = addr + BLKSZ * 2; |
| 239 | ulong ebr_blk, mbr_parts_max; |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 240 | struct udevice *dev; |
| 241 | ofnode root, node; |
| 242 | |
| 243 | /* Enable the mmc6 node for this test */ |
| 244 | root = oftree_root(oftree_default()); |
| 245 | node = ofnode_find_subnode(root, "mmc6"); |
| 246 | ut_assert(ofnode_valid(node)); |
| 247 | ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false)); |
| 248 | |
Alexander Gendin | 2036ad1 | 2024-02-03 02:56:19 +0000 | [diff] [blame] | 249 | /* |
| 250 | * 1 byte for null character |
| 251 | * 2 reserved bytes |
| 252 | */ |
| 253 | mbr_parts_max = 1 + 2 + |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 254 | strlen(mbr_parts_header) + |
| 255 | strlen(mbr_parts_p1) + |
| 256 | strlen(mbr_parts_p2) + |
| 257 | strlen(mbr_parts_p3) + |
| 258 | max(strlen(mbr_parts_p4), strlen(mbr_parts_p5)) + |
| 259 | strlen(mbr_parts_tail); |
| 260 | ut_assertf(sizeof(mbr_parts_buf) >= mbr_parts_max, "Buffer avail: %ld; buffer req: %ld\n", |
| 261 | sizeof(mbr_parts_buf), mbr_parts_max); |
| 262 | |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 263 | mbr_wbuf = map_sysmem(mbr_wa, BLKSZ); |
| 264 | ebr_wbuf = map_sysmem(ebr_wa, BLKSZ); |
| 265 | rbuf = map_sysmem(ra, BLKSZ); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 266 | ebr_blk = (ulong)0xb00000 / BLKSZ; |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 267 | |
| 268 | /* Make sure mmc6 exists */ |
| 269 | ut_asserteq(6, blk_get_device_by_str("mmc", "6", &mmc_dev_desc)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 270 | ut_assertok(run_commandf("mmc dev 6")); |
| 271 | ut_assert_nextline("switch to partitions #0, OK"); |
| 272 | ut_assert_nextline("mmc6 is current device"); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 273 | ut_assert_console_end(); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 274 | |
| 275 | /* Make sure mmc6 is 12+ MiB in size */ |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 276 | ut_assertok(run_commandf("mmc read %lx %lx 1", ra, |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 277 | (ulong)0xbffe00 / BLKSZ)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 278 | |
| 279 | /* Test one MBR partition */ |
| 280 | init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); |
| 281 | ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 1)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 282 | ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 283 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 284 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 285 | ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 286 | ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 287 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 288 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 289 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 290 | ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); |
| 291 | ut_assertok(run_commandf("mbr write mmc 6")); |
Simon Glass | 5622825 | 2024-08-22 07:57:58 -0600 | [diff] [blame] | 292 | ut_assert_nextlinen("MMC read: dev # 6"); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 293 | ut_assert_nextline("MBR: write success!"); |
| 294 | ut_assertok(run_commandf("mbr verify mmc 6")); |
| 295 | ut_assert_nextline("MBR: verify success!"); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 296 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 297 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 298 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 299 | ut_assert_console_end(); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 300 | /* |
| 301 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 302 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 00 |...%$..@........| |
| 303 | 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 304 | 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 305 | 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 306 | */ |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 307 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 308 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 309 | for (unsigned i = 0; i < mbr_cmp_size; i++) { |
| 310 | ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p1[i], |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 311 | "1P MBR+0x%04X: expected %#02X, actual: %#02X\n", |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 312 | mbr_cmp_start + i, mbr_parts_ref_p1[i], rbuf[mbr_cmp_start + i]); |
| 313 | } |
| 314 | |
| 315 | /* Test two MBR partitions */ |
| 316 | init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); |
| 317 | ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 2)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 318 | ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 319 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 320 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 321 | ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 322 | ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 323 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 324 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 325 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 326 | ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); |
| 327 | ut_assertok(run_commandf("mbr write mmc 6")); |
| 328 | ut_assert_nextline("MBR: write success!"); |
| 329 | ut_assertok(run_commandf("mbr verify mmc 6")); |
| 330 | ut_assert_nextline("MBR: verify success!"); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 331 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 332 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 333 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 334 | ut_assert_console_end(); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 335 | /* |
| 336 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 337 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 338 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 00 |%..F...H........| |
| 339 | 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 340 | 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 341 | */ |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 342 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 343 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 344 | for (unsigned i = 0; i < mbr_cmp_size; i++) { |
| 345 | ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p2[i], |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 346 | "2P MBR+0x%04X: expected %#02X, actual: %#02X\n", |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 347 | mbr_cmp_start + i, mbr_parts_ref_p2[i], rbuf[mbr_cmp_start + i]); |
| 348 | } |
| 349 | |
| 350 | /* Test three MBR partitions */ |
| 351 | init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); |
| 352 | ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 3)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 353 | ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 354 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 355 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 356 | ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 357 | ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 358 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 359 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 360 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 361 | ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); |
| 362 | ut_assertok(run_commandf("mbr write mmc 6")); |
| 363 | ut_assert_nextline("MBR: write success!"); |
| 364 | ut_assertok(run_commandf("mbr verify mmc 6")); |
| 365 | ut_assert_nextline("MBR: verify success!"); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 366 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 367 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 368 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 369 | ut_assert_console_end(); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 370 | /* |
| 371 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 372 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 373 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F| |
| 374 | 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 00 |...f%..P........| |
| 375 | 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 376 | */ |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 377 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 378 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 379 | for (unsigned i = 0; i < mbr_cmp_size; i++) { |
| 380 | ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p3[i], |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 381 | "3P MBR+0x%04X: expected %#02X, actual: %#02X\n", |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 382 | mbr_cmp_start + i, mbr_parts_ref_p3[i], rbuf[mbr_cmp_start + i]); |
| 383 | } |
| 384 | |
| 385 | /* Test four MBR partitions */ |
| 386 | init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); |
| 387 | ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 4)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 388 | ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 389 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 390 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 391 | ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 392 | ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 393 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 394 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 395 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 396 | ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); |
| 397 | ut_assertok(run_commandf("mbr write mmc 6")); |
| 398 | ut_assert_nextline("MBR: write success!"); |
| 399 | ut_assertok(run_commandf("mbr verify mmc 6")); |
| 400 | ut_assert_nextline("MBR: verify success!"); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 401 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 402 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 403 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 404 | ut_assert_console_end(); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 405 | /* |
| 406 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 407 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 408 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F| |
| 409 | 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f| |
| 410 | 000001f0 26 01 0e 87 06 01 00 58 00 00 00 08 00 00 55 aa |&......X......U.| |
| 411 | */ |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 412 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 413 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 414 | for (unsigned i = 0; i < mbr_cmp_size; i++) { |
| 415 | ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p4[i], |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 416 | "4P MBR+0x%04X: expected %#02X, actual: %#02X\n", |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 417 | mbr_cmp_start + i, mbr_parts_ref_p4[i], rbuf[mbr_cmp_start + i]); |
| 418 | } |
| 419 | |
| 420 | /* Test five MBR partitions */ |
| 421 | init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__); |
| 422 | ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 5)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 423 | ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 424 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 425 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 426 | ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ)); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 427 | ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk)); |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 428 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 429 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Simon Glass | a8c1252 | 2024-09-01 16:26:32 -0600 | [diff] [blame] | 430 | ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 431 | ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf); |
| 432 | ut_assertf(0 == run_commandf("mbr write mmc 6"), "Invalid partitions string: %s\n", mbr_parts_buf); |
| 433 | ut_assert_nextline("MBR: write success!"); |
| 434 | ut_assertok(run_commandf("mbr verify mmc 6")); |
| 435 | ut_assert_nextline("MBR: verify success!"); |
Simon Glass | c579bd4 | 2024-08-22 07:58:03 -0600 | [diff] [blame] | 436 | ut_assert_console_end(); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 437 | /* |
| 438 | 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....| |
| 439 | 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%| |
| 440 | 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F| |
| 441 | 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f| |
| 442 | 000001f0 26 01 05 a7 26 01 00 58 00 00 00 10 00 00 55 aa |&...&..X......U.| |
| 443 | */ |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 444 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 445 | ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 446 | for (unsigned i = 0; i < mbr_cmp_size; i++) { |
| 447 | ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p5[i], |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 448 | "5P MBR+0x%04X: expected %#02X, actual: %#02X\n", |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 449 | mbr_cmp_start + i, mbr_parts_ref_p5[i], rbuf[mbr_cmp_start + i]); |
| 450 | } |
| 451 | /* |
| 452 | 00b001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 87 |................| |
| 453 | 00b001c0 07 01 0e a7 26 01 00 08 00 00 00 08 00 00 00 00 |....&...........| |
| 454 | 00b001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 455 | 00b001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
| 456 | 00b001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.| |
| 457 | */ |
Simon Glass | 2ca519b | 2024-09-01 16:26:33 -0600 | [diff] [blame] | 458 | memset(rbuf, '\0', BLKSZ); |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 459 | ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk)); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 460 | for (unsigned i = 0; i < ebr_cmp_size; i++) { |
| 461 | ut_assertf(rbuf[ebr_cmp_start + i] == ebr_parts_ref_p5[i], |
Simon Glass | 345567c | 2024-09-01 16:26:22 -0600 | [diff] [blame] | 462 | "5P EBR+0x%04X: expected %#02X, actual: %#02X\n", |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 463 | ebr_cmp_start + i, ebr_parts_ref_p5[i], rbuf[ebr_cmp_start + i]); |
| 464 | } |
Simon Glass | 2a1f169 | 2024-09-01 16:26:31 -0600 | [diff] [blame] | 465 | unmap_sysmem(mbr_wbuf); |
| 466 | unmap_sysmem(ebr_wbuf); |
| 467 | unmap_sysmem(rbuf); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 468 | |
| 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | /* Declare mbr test */ |
Simon Glass | 11fcfa3 | 2024-08-22 07:57:50 -0600 | [diff] [blame] | 473 | UNIT_TEST(mbr_test_run, UTF_CONSOLE, mbr_test); |
Alexander Gendin | 038cb02 | 2023-10-09 01:24:36 +0000 | [diff] [blame] | 474 | |
| 475 | int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
| 476 | { |
| 477 | struct unit_test *tests = UNIT_TEST_SUITE_START(mbr_test); |
| 478 | const int n_ents = UNIT_TEST_SUITE_COUNT(mbr_test); |
| 479 | |
| 480 | return cmd_ut_category("mbr", "mbr_test_", tests, n_ents, argc, argv); |
| 481 | } |