1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-26 04:35:39 +03:00
aports/testing/libosmium/fix-bzip2-test.patch
2022-08-10 12:37:43 +00:00

55 lines
1.9 KiB
Diff

Make bzip2 unit tests pass on musl-based systems
https://github.com/osmcode/libosmium/issues/353
https://github.com/osmcode/libosmium/commit/dcb34b53e34d449edb5578f070a3da9975d7534b
Committed to upstream main branch, but not yet in any release.
In future releases after libosmum 2.18.0, this patch can be removed.
--- libosmium-2.18.0/test/t/io/test_bzip2.cpp.orig
+++ libosmium-2.18.0/test/t/io/test_bzip2.cpp
@@ -7,13 +7,19 @@
#include <string>
+static void read_from_decompressor(int fd) {
+ osmium::io::Bzip2Decompressor decomp{fd};
+ decomp.read();
+ decomp.close();
+}
+
TEST_CASE("Invalid file descriptor of bzip2-compressed file") {
- REQUIRE_THROWS_AS(osmium::io::Bzip2Decompressor{-1}, std::system_error);
+ REQUIRE_THROWS(read_from_decompressor(-1));
}
TEST_CASE("Non-open file descriptor of bzip2-compressed file") {
// 12345 is just a random file descriptor that should not be open
- REQUIRE_THROWS_AS(osmium::io::Bzip2Decompressor{12345}, std::system_error);
+ REQUIRE_THROWS(read_from_decompressor(12345));
}
TEST_CASE("Empty bzip2-compressed file") {
@@ -93,13 +99,19 @@
REQUIRE(count == count_fds());
}
+static void write_to_compressor(int fd) {
+ osmium::io::Bzip2Compressor comp{fd, osmium::io::fsync::yes};
+ comp.write("foo");
+ comp.close();
+}
+
TEST_CASE("Compressor: Invalid file descriptor for bzip2-compressed file") {
- REQUIRE_THROWS_AS(osmium::io::Bzip2Compressor(-1, osmium::io::fsync::yes), std::system_error);
+ REQUIRE_THROWS(write_to_compressor(-1));
}
TEST_CASE("Compressor: Non-open file descriptor for bzip2-compressed file") {
// 12345 is just a random file descriptor that should not be open
- REQUIRE_THROWS_AS(osmium::io::Bzip2Compressor(12345, osmium::io::fsync::yes), std::system_error);
+ REQUIRE_THROWS(write_to_compressor(12345));
}
TEST_CASE("Write bzip2-compressed file with explicit close") {