Skip to content

🧪 [testing improvement] Add test for OggFLACPassthroughCodec exception handling#272

Open
segin wants to merge 1 commit intomasterfrom
fix/test-ogg-flac-passthrough-3976644242601386341
Open

🧪 [testing improvement] Add test for OggFLACPassthroughCodec exception handling#272
segin wants to merge 1 commit intomasterfrom
fix/test-ogg-flac-passthrough-3976644242601386341

Conversation

@segin
Copy link
Copy Markdown
Owner

@segin segin commented Apr 8, 2026

🎯 What: Improved test coverage for OggFLACPassthroughCodec::initialize in src/codecs/OggCodecs.cpp by validating the behavior when the underlying codec throws an exception or fails initialization due to malformed data.
📊 Coverage: Added testOggFLACExceptionHandling to tests/test_ogg_error_handling.cpp which simulates an invalid sample rate for FLAC initialization, verifying the outer codec correctly returns false and handles the failure gracefully. Updated tests/Makefile.am to link necessary dependencies (FULL_CODEC_LIBS and COMMON_CODEC_LIBS) for proper test compilation.
Result: Enhanced error handling test coverage for Ogg demuxing.


PR created automatically by Jules for task 3976644242601386341 started by @segin

Co-authored-by: segin <480709+segin@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings April 8, 2026 04:06
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new regression test to validate that OggFLACPassthroughCodec::initialize() fails gracefully when FLAC initialization fails, and updates test link dependencies to ensure the new test builds.

Changes:

  • Added testOggFLACExceptionHandling() to exercise FLAC passthrough initialization failure behavior.
  • Updated tests/Makefile.am LDADD entries to include broader codec/common codec link sets for Ogg-related tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/test_ogg_error_handling.cpp Adds a new test case that expects OggFLACPassthroughCodec::initialize() to return false under invalid FLAC stream parameters.
tests/Makefile.am Adjusts test link dependencies (notably adding FULL_CODEC_LIBS for test_ogg_error_handling and simplifying test_ogg_fuzzing linkage).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +106 to +122
bool testOggFLACExceptionHandling() {
std::cout << "Testing OggFLACPassthroughCodec exception handling..." << std::endl;

StreamInfo info;
info.codec_name = "flac";
// Provide an invalid sample rate to force initialization to fail.
// The maximum sample rate permitted by RFC 9639 is 1048575 Hz.
info.sample_rate = 2000000;
info.codec_data = {0x00, 0x01, 0x02};

OggFLACPassthroughCodec codec(info);
bool result = codec.initialize();

// Depending on the NativeFLACCodec implementation, it might throw an exception
// that OggFLACPassthroughCodec catches, or it might just return false.
// In either case, the passthrough codec should return false and not crash.
ASSERT(!result, "Should return false when underlying FLACCodec initialization fails");
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is named/worded as “exception handling”, but with info.sample_rate = 2000000 the native FLAC codec fails via explicit parameter validation and returns false (e.g., src/codecs/flac/NativeFLACCodec.cpp:272-279) rather than throwing. Also, the comment about “NativeFLACCodec … might throw an exception” is misleading because FLACCodec::initialize() already catches std::exception and returns false (src/codecs/flac/NativeFLACCodec.cpp:115-122). If the intent is to cover OggFLACPassthroughCodec’s catch (...) path (src/codecs/OggCodecs.cpp:67-72), consider adjusting the test to actually trigger an exception (or rename/reword it to focus on initialization failure handling rather than exception handling).

Copilot uses AI. Check for mistakes.
Comment thread tests/Makefile.am
Comment on lines 1113 to +1114
test_ogg_error_handling_LDADD = libtest_utilities.a \
$(FULL_CODEC_LIBS) \
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_ogg_error_handling_LDADD now adds $(FULL_CODEC_LIBS) but still keeps libtest_utilities.a at the front. Since FULL_CODEC_LIBS already includes libtest_utilities.a (tests/Makefile.am:188-191), this is redundant and makes the link line significantly heavier than needed. Consider either removing the standalone libtest_utilities.a here, or (preferably) linking only the minimal codec archive(s) required for OggFLACPassthroughCodec instead of pulling in the full codec test dependency set.

Suggested change
test_ogg_error_handling_LDADD = libtest_utilities.a \
$(FULL_CODEC_LIBS) \
test_ogg_error_handling_LDADD = $(FULL_CODEC_LIBS) \

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants