Skip to content
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

test for issue 76 #78

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

test for issue 76 #78

wants to merge 1 commit into from

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

Merging #78 into develop will decrease coverage by 4.31%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #78      +/-   ##
===========================================
- Coverage    69.04%   64.73%   -4.32%     
===========================================
  Files           80       81       +1     
  Lines         3437     3547     +110     
  Branches      1025      950      -75     
===========================================
- Hits          2373     2296      -77     
- Misses         451      461      +10     
- Partials       613      790     +177
Impacted Files Coverage Δ
include/boost/iostreams/detail/access_control.hpp 50% <0%> (-50%) ⬇️
include/boost/iostreams/device/file_descriptor.hpp 62.5% <0%> (-37.5%) ⬇️
include/boost/iostreams/detail/double_object.hpp 70% <0%> (-30%) ⬇️
include/boost/iostreams/detail/execute.hpp 73.33% <0%> (-20%) ⬇️
include/boost/iostreams/invert.hpp 41.46% <0%> (-16.44%) ⬇️
include/boost/iostreams/detail/restrict_impl.hpp 57.62% <0%> (-15.53%) ⬇️
.../boost/iostreams/detail/adapter/filter_adapter.hpp 66.66% <0%> (-13.34%) ⬇️
.../iostreams/detail/streambuf/indirect_streambuf.hpp 65% <0%> (-12.78%) ⬇️
include/boost/iostreams/stream.hpp 61.53% <0%> (-11.19%) ⬇️
include/boost/iostreams/read.hpp 78.43% <0%> (-10.25%) ⬇️
... and 52 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50b4f00...c006eeb. Read the comment docs.

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