Update pool_block verify test for Salvium
- Add 200-block test data extracted from live cache
This commit is contained in:
40
tests/extract_cache.cpp
Normal file
40
tests/extract_cache.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
static constexpr uint32_t BLOCK_SIZE = 96 * 1024;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 4) {
|
||||
std::cerr << "Usage: " << argv[0] << " <cache_file> <output> <num_blocks>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::ifstream in(argv[1], std::ios::binary);
|
||||
std::ofstream out(argv[2], std::ios::binary);
|
||||
int max_blocks = std::stoi(argv[3]);
|
||||
|
||||
std::vector<uint8_t> slot(BLOCK_SIZE);
|
||||
int blocks_written = 0;
|
||||
|
||||
while (in && blocks_written < max_blocks) {
|
||||
// Read 96KB slot
|
||||
in.read(reinterpret_cast<char*>(slot.data()), BLOCK_SIZE);
|
||||
if (!in) break;
|
||||
|
||||
// Read size from first 4 bytes
|
||||
uint32_t size = *reinterpret_cast<uint32_t*>(slot.data());
|
||||
|
||||
// Skip empty slots
|
||||
if (size == 0 || size > BLOCK_SIZE - 4) continue;
|
||||
|
||||
// Write: size + data
|
||||
out.write(reinterpret_cast<char*>(&size), sizeof(size));
|
||||
out.write(reinterpret_cast<char*>(slot.data() + 4), size);
|
||||
blocks_written++;
|
||||
}
|
||||
|
||||
std::cout << "Extracted " << blocks_written << " blocks\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user