Ticket #823: xapian-1.4-ioblock-SEEK_HOLE-fix.patch

File xapian-1.4-ioblock-SEEK_HOLE-fix.patch, 1.1 KB (added by Olly Betts, 10 months ago)

Use SEEK_HOLE

  • xapian-core/tests/unittest.cc

    diff --git a/xapian-core/tests/unittest.cc b/xapian-core/tests/unittest.cc
    index 36ab22c3e3cb..8d5e2bbc9679 100644
    a b try {  
    939939        SKIP_TEST("Skipping rest of testcase - no Large File Support");
    940940    }
    941941
    942 #ifndef __WIN32__
     942#ifdef SEEK_HOLE
    943943    struct stat statbuf;
    944944    TEST(fstat(fd, &statbuf) == 0);
    945     TEST_REL(statbuf.st_blocks, >=, BLOCK_SIZE / 512 * 2);
    946     if (statbuf.st_blocks >= BLOCK_SIZE / 512 * (12 + 1)) {
     945
     946    off_t hole = lseek(fd, 0, SEEK_HOLE);
     947    if (hole < 0) {
     948        close(fd);
     949        io_unlink(tmp_file);
     950        SKIP_TEST("Skipping rest of testcase - SEEK_HOLE failed");
     951    }
     952    if (hole >= statbuf.st_size) {
    947953        close(fd);
    948954        io_unlink(tmp_file);
    949955        SKIP_TEST("Skipping rest of testcase - sparse files not supported");
    try {  
    982988#else
    983989    close(fd);
    984990    io_unlink(tmp_file);
    985     SKIP_TEST("Skipping rest of testcase - FS doesn't support holes");
     991    SKIP_TEST("Skipping rest of testcase - SEEK_HOLE not supported");
    986992#endif
    987993} catch (const Xapian::Error& e) {
    988994    // Translate Xapian::Error exceptions to std::string exceptions which