Page MenuHomePhabricator

[libcxx] [test] [support] Use socket()+bind() to create unix sockets portably
ClosedPublic

Authored by mgorny on Dec 11 2018, 1:27 PM.

Details

Summary

Replace the mknod() call with socket() + bind() for creating unix
sockets. The mknod() method is not portable and does not work
on NetBSD while binding the socket should work on all systems supporting
unix sockets.

// NB: I think this should solve the issues w/ FreeBSD/Darwin too but I don't have those systems to test

Diff Detail

Repository
rCXX libc++

Event Timeline

mgorny created this revision.Dec 11 2018, 1:27 PM
krytarowski accepted this revision.Dec 11 2018, 7:16 PM
This revision is now accepted and ready to land.Dec 11 2018, 7:16 PM

@emaste, maybe you could take a look at this too. I think it would solve the problem for FreeBSD as well.

dim accepted this revision.Dec 16 2018, 7:10 AM

LGTM.

@dim, thanks for the review. Should I also try removing the following restriction?

#if !defined(__APPLE__) && !defined(__FreeBSD__) // No support for domain sockets
        {env.create_socket("socket"), file_type::socket},
#endif
This revision was automatically updated to reflect the committed changes.
dim added a comment.Dec 16 2018, 7:42 AM

@dim, thanks for the review. Should I also try removing the following restriction?

#if !defined(__APPLE__) && !defined(__FreeBSD__) // No support for domain sockets
        {env.create_socket("socket"), file_type::socket},
#endif

Well, test/support/filesystem_test_helper.hpp also has this comment:

  // OS X and FreeBSD doesn't support socket files so we shouldn't even
  // allow tests to call this unguarded.
#if !defined(__FreeBSD__) && !defined(__APPLE__)
    std::string create_socket(std::string file) {
        file = sanitize_path(std::move(file));
        fs_helper_run(fs_make_cmd("create_socket", file));
        return file;
    }
#endif

but it looks like you now fixed it with this change to filesystem_dynamic_test_helper.py. So I guess after this, it should be safe to remove the FreeBSD specific exception. I don't know about macOS, though.