Skip to content

Commit c8e7fdb

Browse files
authored
Merge pull request #3324 from eseiler/fix/zlib-ng
[FIX,TEST] Do not check zlib output for alternative implementations
2 parents 787d724 + 04913ed commit c8e7fdb

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2+
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
/*!\file
6+
* \brief Provides macros for skipping tests that rely on the binary compressed output of zlib.
7+
* \author Enrico Seiler <enrico.seiler AT fu-berlin.de>
8+
*/
9+
10+
#pragma once
11+
12+
#include <gtest/gtest.h>
13+
14+
#include <seqan3/core/platform.hpp>
15+
16+
#if defined(SEQAN3_HAS_ZLIB)
17+
# include <zlib.h>
18+
#endif
19+
20+
// Some of our tests check the binary compressed output of zlib. This is not guaranteed to be the same for all zlib
21+
// implementations.
22+
// This macro should be set to 1 if the zlib implementation is not the standard zlib, for example, zlib-ng.
23+
// zlib-ng is automatically detected if `zlib.h` resolves to zlib-ng's header.
24+
#ifndef SEQAN3_TEST_SKIP_ZLIB_DEFLATE
25+
# ifdef ZLIBNG_VERSION
26+
# define SEQAN3_TEST_SKIP_ZLIB_DEFLATE 1
27+
# else
28+
# define SEQAN3_TEST_SKIP_ZLIB_DEFLATE 0
29+
# endif
30+
#endif
31+
32+
// Defines a GTEST_SKIP macro if the zlib implementation is not the standard zlib.
33+
// Otherwise, it does nothing.
34+
#ifndef SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE
35+
# if SEQAN3_TEST_SKIP_ZLIB_DEFLATE
36+
# define SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE \
37+
GTEST_SKIP() << "Not testing binary compressed output for alternative zlib implementations."
38+
# else
39+
# define SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE
40+
# endif
41+
#endif

test/unit/io/sam_file/sam_file_output_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <seqan3/io/sam_file/input.hpp>
1313
#include <seqan3/io/sam_file/output.hpp>
1414
#include <seqan3/test/tmp_directory.hpp>
15+
#include <seqan3/test/zlib_skip.hpp>
1516

1617
using seqan3::operator""_dna4;
1718
using seqan3::operator""_dna5;
@@ -702,6 +703,7 @@ TEST(compression, by_filename_gz)
702703

703704
std::string buffer = compression_by_filename_impl(filename);
704705
buffer[9] = '\x00'; // zero out OS byte.
706+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
705707
EXPECT_EQ(buffer, expected_gz);
706708
}
707709

@@ -715,6 +717,7 @@ TEST(compression, by_stream_gz)
715717
}
716718
std::string buffer = out.str();
717719
buffer[9] = '\x00'; // zero out OS byte.
720+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
718721
EXPECT_EQ(buffer, expected_gz);
719722
}
720723

@@ -725,6 +728,7 @@ TEST(compression, by_filename_bgzf)
725728

726729
std::string buffer = compression_by_filename_impl(filename);
727730
buffer[9] = '\x00'; // zero out OS byte.
731+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
728732
EXPECT_EQ(buffer, expected_bgzf);
729733
}
730734

@@ -738,6 +742,7 @@ TEST(compression, by_stream_bgzf)
738742
}
739743
std::string buffer = out.str();
740744
buffer[9] = '\x00'; // zero out OS byte.
745+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
741746
EXPECT_EQ(buffer, expected_bgzf);
742747
}
743748
#endif

test/unit/io/sequence_file/sequence_file_output_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <seqan3/alphabet/quality/phred42.hpp>
1111
#include <seqan3/io/sequence_file/output.hpp>
1212
#include <seqan3/test/tmp_directory.hpp>
13+
#include <seqan3/test/zlib_skip.hpp>
1314
#include <seqan3/utility/views/zip.hpp>
1415

1516
using seqan3::operator""_dna5;
@@ -483,6 +484,7 @@ TEST(compression, by_filename_gz)
483484

484485
std::string buffer = compression_by_filename_impl(filename);
485486
buffer[9] = '\x00'; // zero out OS byte
487+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
486488
EXPECT_EQ(buffer, expected_gz);
487489
}
488490

@@ -497,6 +499,7 @@ TEST(compression, by_stream_gz)
497499

498500
std::string buffer = out.str();
499501
buffer[9] = '\x00'; // zero out OS byte
502+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
500503
EXPECT_EQ(buffer, expected_gz);
501504
}
502505

@@ -507,6 +510,7 @@ TEST(compression, by_filename_bgzf)
507510

508511
std::string buffer = compression_by_filename_impl(filename);
509512
buffer[9] = '\x00'; // zero out OS byte
513+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
510514
EXPECT_EQ(buffer, expected_bgzf);
511515
}
512516

@@ -521,6 +525,7 @@ TEST(compression, by_stream_bgzf)
521525

522526
std::string buffer = out.str();
523527
buffer[9] = '\x00'; // zero out OS byte
528+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
524529
EXPECT_EQ(buffer, expected_bgzf);
525530
}
526531

test/unit/io/stream/ostream_test_template.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <seqan3/io/stream/concept.hpp>
1313
#include <seqan3/test/tmp_directory.hpp>
14+
#include <seqan3/test/zlib_skip.hpp>
1415

1516
template <typename T>
1617
class ostream : public ::testing::Test
@@ -41,7 +42,10 @@ TYPED_TEST_P(ostream, output)
4142
std::string buffer{std::istreambuf_iterator<char>{fi}, std::istreambuf_iterator<char>{}};
4243

4344
if constexpr (TestFixture::zero_out_os_byte)
45+
{
4446
buffer[9] = '\x00'; // zero-out the OS byte.
47+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
48+
}
4549

4650
EXPECT_EQ(buffer, TestFixture::compressed);
4751
}
@@ -63,7 +67,10 @@ TYPED_TEST_P(ostream, output_type_erased)
6367
std::string buffer{std::istreambuf_iterator<char>{fi}, std::istreambuf_iterator<char>{}};
6468

6569
if constexpr (TestFixture::zero_out_os_byte)
70+
{
6671
buffer[9] = '\x00'; // zero-out the OS byte.
72+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
73+
}
6774

6875
EXPECT_EQ(buffer, TestFixture::compressed);
6976
}

test/unit/io/structure_file/structure_file_output_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <seqan3/io/structure_file/input.hpp>
1414
#include <seqan3/io/structure_file/output.hpp>
1515
#include <seqan3/test/tmp_directory.hpp>
16+
#include <seqan3/test/zlib_skip.hpp>
1617

1718
using seqan3::operator""_rna5;
1819
using seqan3::operator""_wuss51;
@@ -474,6 +475,7 @@ TEST_F(structure_file_output_compression, by_filename_gz)
474475

475476
std::string buffer = compression_by_filename_impl(filename);
476477
buffer[9] = '\x00'; // zero out OS byte
478+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
477479
EXPECT_EQ(buffer, expected_gz);
478480
}
479481

@@ -486,6 +488,7 @@ TEST_F(structure_file_output_compression, by_stream_gz)
486488
}
487489
std::string buffer = out.str();
488490
buffer[9] = '\x00'; // zero out OS byte
491+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
489492
EXPECT_EQ(buffer, expected_gz);
490493
}
491494

@@ -495,6 +498,7 @@ TEST_F(structure_file_output_compression, by_filename_bgzf)
495498
auto filename = tmp.path() / "structure_file_output_test.dbn.bgzf";
496499
std::string buffer = compression_by_filename_impl(filename);
497500
buffer[9] = '\x00'; // zero out OS byte
501+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
498502
EXPECT_EQ(buffer, expected_bgzf);
499503
}
500504

@@ -507,6 +511,7 @@ TEST_F(structure_file_output_compression, by_stream_bgzf)
507511
}
508512
std::string buffer = out.str();
509513
buffer[9] = '\x00'; // zero out OS byte
514+
SEQAN3_TEST_GTEST_SKIP_ZLIB_DEFLATE;
510515
EXPECT_EQ(buffer, expected_bgzf);
511516
}
512517
#endif

0 commit comments

Comments
 (0)