-
Notifications
You must be signed in to change notification settings - Fork 746
Fix #2081: Apply zstd compression level reliably across the documente… #2113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a957091
322eeca
6543a42
48dc05a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1314,6 +1314,41 @@ PTF_TEST_CASE(TestPcapNgFileReadWrite) | |
|
|
||
| } // TestPcapNgFileReadWrite | ||
|
|
||
| PTF_TEST_CASE(TestPcapNgZstdCompressionLevels) | ||
| { | ||
| #ifdef USE_Z_STD | ||
| // If the compression level is silently ignored, low and high levels | ||
| // produce identical output sizes. PcapPlusPlus exposes levels 0-10, | ||
| // which the zstd wrapper maps to zstd's native 1-22 range. Test three | ||
| // points to verify the level scales monotonically, not just that the | ||
| // endpoints differ. | ||
| std::array<int, 3> sizes = { 0, 0, 0 }; | ||
| const std::array<int, 3> levels = { 1, 5, 10 }; | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| pcpp::PcapNgFileReaderDevice readerDev(EXAMPLE2_PCAPNG_PATH); | ||
| PTF_ASSERT_TRUE(readerDev.open()); | ||
|
|
||
| pcpp::PcapNgFileWriterDevice writerDev(EXAMPLE_PCAPNG_ZSTD_LEVELS_WRITE_PATH, levels[i]); | ||
| PTF_ASSERT_TRUE(writerDev.open()); | ||
|
|
||
| pcpp::RawPacket rawPacket; | ||
| while (readerDev.getNextPacket(rawPacket)) | ||
| { | ||
| PTF_ASSERT_TRUE(writerDev.writePacket(rawPacket)); | ||
| } | ||
| readerDev.close(); | ||
| writerDev.close(); | ||
|
|
||
| sizes[i] = getFileLength(EXAMPLE_PCAPNG_ZSTD_LEVELS_WRITE_PATH); | ||
| } | ||
| PTF_ASSERT_GREATER_THAN(sizes[0], sizes[1]); | ||
| PTF_ASSERT_GREATER_THAN(sizes[1], sizes[2]); | ||
|
Comment on lines
+1345
to
+1346
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI is failing for almost all platforms, maybe this is not always true? 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took a look at
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That appears to be because the compression context in LightPcapNG is I suppose we could catch that in the constructor or open call of the PcapNg writer. PR #1962 does add some methods to detect if zst is detected at compile time, tho that one is still open.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the test can use the PTF_TEST_CASE(TestPcapNgZstdCompressionLevels)
{
#ifdef USE_Z_STD
// The test...
#else
PTF_SKIP_TEST("Zstd is not configured");
#endif
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing now 😄 |
||
| #else | ||
| PTF_SKIP_TEST("Zstd is not configured"); | ||
| #endif | ||
| } // TestPcapNgZstdCompressionLevels | ||
|
|
||
| PTF_TEST_CASE(TestPcapNgFileReadWriteAdv) | ||
| { | ||
| pcpp::PcapNgFileReaderDevice readerDev(EXAMPLE2_PCAPNG_PATH); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.