diff --git a/xapian-core/tests/unittest.cc b/xapian-core/tests/unittest.cc
index 36ab22c3e3cb..f371723c8ac0 100644
|
a
|
b
|
|
| 30 | 30 | #include <cstring> |
| 31 | 31 | #include <iostream> |
| 32 | 32 | #include <limits> |
| | 33 | #include <random> |
| 33 | 34 | #include <utility> |
| 34 | 35 | |
| 35 | 36 | #include "safeunistd.h" |
| … |
… |
try {
|
| 912 | 913 | int fd = io_open_block_wr(tmp_file, true); |
| 913 | 914 | TEST_REL(fd, >=, 0); |
| 914 | 915 | |
| 915 | | string buf(BLOCK_SIZE, 'x'); |
| | 916 | mt19937 gen; |
| | 917 | gen.seed(42); |
| | 918 | uniform_int_distribution<> distribution(0, 255); |
| | 919 | string buf(BLOCK_SIZE, '\0'); |
| | 920 | for (int i = 0; i != BLOCK_SIZE; ++i) { |
| | 921 | buf[i] = static_cast<char>(distribution(gen)); |
| | 922 | } |
| 916 | 923 | string out; |
| 917 | 924 | |
| 918 | 925 | io_write_block(fd, buf.data(), BLOCK_SIZE, 1); |
| … |
… |
try {
|
| 924 | 931 | // any effect is much harder to do. |
| 925 | 932 | TEST(io_sync(fd)); |
| 926 | 933 | |
| | 934 | for (int i = 0; i != BLOCK_SIZE; ++i) { |
| | 935 | buf[i] = static_cast<char>(distribution(gen)); |
| | 936 | } |
| 927 | 937 | io_write_block(fd, buf.data(), BLOCK_SIZE, 12); |
| 928 | 938 | out.resize(BLOCK_SIZE); |
| 929 | 939 | io_read_block(fd, &out[0], BLOCK_SIZE, 12); |
| … |
… |
try {
|
| 954 | 964 | // which truncate the offset used. |
| 955 | 965 | constexpr off_t high_offset = (off_t{1} << 32) + BLOCK_SIZE; |
| 956 | 966 | constexpr off_t high_block = high_offset / BLOCK_SIZE; |
| | 967 | for (int i = 0; i != BLOCK_SIZE; ++i) { |
| | 968 | buf[i] = static_cast<char>(distribution(gen)); |
| | 969 | } |
| 957 | 970 | try { |
| 958 | 971 | io_write_block(fd, buf.data(), BLOCK_SIZE, high_block); |
| 959 | 972 | } catch (const Xapian::DatabaseError& e) { |
| … |
… |
try {
|
| 982 | 995 | #else |
| 983 | 996 | close(fd); |
| 984 | 997 | io_unlink(tmp_file); |
| 985 | | SKIP_TEST("Skipping rest of testcase - FS doesn't support holes"); |
| | 998 | SKIP_TEST("Skipping rest of testcase - FS doesn't support holes or compressed blocks"); |
| 986 | 999 | #endif |
| 987 | 1000 | } catch (const Xapian::Error& e) { |
| 988 | 1001 | // Translate Xapian::Error exceptions to std::string exceptions which |