| 57 | } |
| 58 | |
| 59 | void loop(void) |
| 60 | { |
| 61 | static uint32_t count; |
| 62 | uint8_t type = get_random() % 4; |
| 63 | const StorageAccess &storage = all_storage[type]; |
| 64 | uint16_t offset = get_random() % storage.size(); |
| 65 | uint8_t length = (get_random() & 31); |
| 66 | if (offset + length > storage.size()) { |
| 67 | length = storage.size() - offset; |
| 68 | } |
| 69 | if (length == 0) { |
| 70 | return; |
| 71 | } |
| 72 | uint8_t b[length]; |
| 73 | for (uint8_t i=0; i<length; i++) { |
| 74 | b[i] = pvalue(offset+i); |
| 75 | } |
| 76 | |
| 77 | if (get_random() % 2 == 1) { |
| 78 | if (!storage.write_block(offset, b, length)) { |
| 79 | hal.console->printf("write failed at offset %u length %u\n", |
| 80 | (unsigned)offset, (unsigned)length); |
| 81 | } |
| 82 | } else { |
| 83 | uint8_t b2[length]; |
| 84 | if (!storage.read_block(b2, offset, length)) { |
| 85 | hal.console->printf("read failed at offset %u length %u\n", |
| 86 | (unsigned)offset, (unsigned)length); |
| 87 | } |
| 88 | if (memcmp(b, b2, length) != 0) { |
| 89 | hal.console->printf("bad data at offset %u length %u\n", |
| 90 | (unsigned)offset, (unsigned)length); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | count++; |
| 95 | if (count % 10000 == 0) { |
| 96 | hal.console->printf("%u ops\n", (unsigned)count); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | |
| 101 |
nothing calls this directly
no test coverage detected