Skip to content

cpr_session_tests fails when built against curl 8.13 #1216

@ZLima12

Description

@ZLima12

Description

When built against curl 8.13, two tests in test/session_tests.cpp fail:

[ RUN      ] LocalPortTests.SetLocalPortTest
/usr/src/debug/cpr/cpr-1.11.2/test/session_tests.cpp:1143: Failure
Expected equality of these values:
  (*__errno_location ())
    Which is: 11
  0

[  FAILED  ] LocalPortTests.SetLocalPortTest (0 ms)
[ RUN      ] LocalPortTests.SetOptionTest
/usr/src/debug/cpr/cpr-1.11.2/test/session_tests.cpp:1178: Failure
Expected equality of these values:
  (*__errno_location ())
    Which is: 11
  0
[  FAILED  ] LocalPortTests.SetOptionTest (0 ms)

On my system, 11 means: EAGAIN 11 Resource temporarily unavailable

Example/How to Reproduce

Build cpr against curl 8.13 with tests enabled.

Possible Fix

I'd have to dig deeper than my available time permits to figure out the exact issue, but the two failed tests have this block in common (with one main minor difference):

    // Try up to 10 times to get a free local port
    for (size_t i = 0; i < 10; i++) {
        session.SetUrl(url);
        local_port = 40252 + (i * 100); // beware of HttpServer::GetPort when changing
        local_port_range = 7000;
        session.SetLocalPort(local_port);
        session.SetLocalPortRange(local_port_range);
        // expected response: body contains port number in specified range
        // NOTE: even when trying up to 7000 ports there is the chance that all of them are occupied.
        // It would be possible to also check here for ErrorCode::UNKNOWN_ERROR but that somehow seems
        // wrong as then this test would pass in case SetLocalPort does not work at all
        // or in other words: we have to assume that at least one port in the specified range is free.
        response = session.Get();

        if (response.error.code != ErrorCode::UNKNOWN_ERROR) {
            break;
        }
    }

I am not sure what difference introduced in curl 8.13 causes this to fail, but the issue is completely resolved by switching back to curl 8.12.1.

Where did you get it from?

Other (specify in "Additional Context/Your Environment")

Additional Context/Your Environment

  • OS: Arch Linux
  • Version: Latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions