Skip to content

Conversation

@lvoege
Copy link

@lvoege lvoege commented Jan 15, 2019

on a theoretical 64bit Windows machine where allocating 4+GB fails the test would presumably exception out with a bad_alloc. that would make sense as such a theoretical Windows machine would be unable to properly run this test or verify that a fix fixed it.

@mclow
Copy link
Contributor

mclow commented Jan 15, 2019

So what happens when the call to new (allocating 4+GB) fails?

@mclow
Copy link
Contributor

mclow commented Jan 15, 2019

Also, do you have to handle the case when the disk fills up from the write?

@lvoege
Copy link
Author

lvoege commented Jan 25, 2019

I would say not. when I try the test with a full disk I get an exception and the test fails. as with not enough memory I think it's good that a test that can't usefully verify a fix on some machine fails.

I tried eating those exceptions and at least BOOST_WARN_MESSAGE()ing about it, but I don't actually see those warnings show up anywhere then, so then the test just silently passes when not enough memory or disk. that seems bad.

    {
        temp_file             temp;
        file_descriptor_sink  file(temp.name(), BOOST_IOS::trunc);
        std::streamsize len = static_cast<std::streamsize>(4ULL * 1024 * 1024 * 1024 + 1);
        try {
            std::unique_ptr<char[]> buf(new char[len]);
            memset(&buf[0], 0, len);
            try {
                std::streamsize written = file.write(&buf[0], len);
                std::streamsize pos = file.seek(0, BOOST_IOS::cur);
                BOOST_CHECK_MESSAGE(
                    pos == written,
                    "silent short write"
                );
            } catch (...) {
                if (GetLastError() != ERROR_DISK_FULL)
                    throw;
                BOOST_WARN_MESSAGE(false, "Disk full");
            }
        } catch (std::bad_alloc &) {
            BOOST_WARN_MESSAGE(false, "Not enough memory to run test");
        }
        file.close();
        BOOST_CHECK(!file.is_open());
    }

Copy link
Contributor

@jeking3 jeking3 left a comment

Choose a reason for hiding this comment

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

Okay, we identified something with a test. Now we need to fix it. :)

@codecov
Copy link

codecov bot commented May 13, 2019

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.04%. Comparing base (50b4f00) to head (c006eeb).
⚠️ Report is 84 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #78   +/-   ##
========================================
  Coverage    69.04%   69.04%           
========================================
  Files           80       80           
  Lines         3437     3437           
  Branches      1025     1025           
========================================
  Hits          2373     2373           
  Misses         451      451           
  Partials       613      613           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants