Skip to content

Commit

Permalink
Update tests (#55)
Browse files Browse the repository at this point in the history
* Update tests

* Fix whitespace

* openat2 header is unsupported on Travis CI

* Ignore SOMAXCONN on Travis CI

* SOMAXCONN attempt II
  • Loading branch information
tmds authored Jun 3, 2020
1 parent c58d628 commit 7284998
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Sources/linux.common/socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static unsafe partial class LibC
public static int SOL_KCM => 281;
public static int SOL_TLS => 282;

public static int SOMAXCONN => 128;
public static int SOMAXCONN => 4096;

public static int MSG_OOB => 1;
public static int MSG_PEEK => 2;
Expand Down
7 changes: 5 additions & 2 deletions test/Tmds.LibC.Tests/ConstantsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public unsafe void Constants()
"linux/if_packet.h",
"sys/mman.h",
"linux/mman.h",
"sys/eventfd.h"
"sys/eventfd.h",
"linux/stat.h",
"linux/openat2.h"
})
{
if (TestEnvironment.Current.SupportsHeader(header) == false)
Expand All @@ -53,7 +55,8 @@ public unsafe void Constants()
if (name == "MS_NOUSER" || // glibc defines it as 1 << 31, while it should be 1U << 31.
name == "errno" ||
name == "SIGRTMAX" ||
name == "SIGRTMIN")
name == "SIGRTMIN" ||
(name == "SOMAXCONN" && TestEnvironment.Current.Rid == TestEnvironment.TravisRid)) // SOMAXCONN was increased in recent kernels
{
continue;
}
Expand Down
66 changes: 61 additions & 5 deletions test/Tmds.LibC.Tests/TestEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ namespace Tmds.Linux.Tests
{
class TestEnvironment
{
public const string TravisRid = "ubuntu-16.04";
public const string TmdsRid = "fedora-32";

private string[] _unsupportedStructs;
private string[] _unsupportedConstants;
private string[] _unsupportedFunctions;
private string[] _unsupportedHeaders;

public string Rid { get; set; }

private TestEnvironment(
string rid,
string[] unsupportedStructs = null,
string[] unsupportedConstants = null,
string[] unsupportedFunctions = null,
string[] unsupportedHeaders = null)
{
Rid = rid;
_unsupportedConstants = unsupportedConstants;
_unsupportedStructs = unsupportedStructs;
_unsupportedFunctions = unsupportedFunctions;
Expand Down Expand Up @@ -79,9 +86,10 @@ static TestEnvironment()
{
string rid = GetRid();
Console.WriteLine($"Test Environment: {rid}");
if (rid == "fedora-31")
if (rid == TmdsRid)
{
Current = new TestEnvironment(
rid,
unsupportedStructs: new string[]
{ },
unsupportedConstants: new string[]
Expand Down Expand Up @@ -148,22 +156,70 @@ static TestEnvironment()
"IORING_UNREGISTER_FILES",
"IORING_REGISTER_EVENTFD",
"IORING_UNREGISTER_EVENTFD",
"IOSQE_IO_HARDLINK",
"IOSQE_ASYNC",
"IOSQE_BUFFER_SELECT",
"IORING_SETUP_CQSIZE",
"IORING_SETUP_CLAMP",
"IORING_SETUP_ATTACH_WQ",
"IORING_OP_TIMEOUT",
"IORING_OP_TIMEOUT_REMOVE",
"IORING_OP_ACCEPT",
"IORING_OP_ASYNC_CANCEL",
"IORING_OP_LINK_TIMEOUT",
"IORING_OP_CONNECT",
"IORING_OP_FALLOCATE",
"IORING_OP_OPENAT",
"IORING_OP_CLOSE",
"IORING_OP_FILES_UPDATE",
"IORING_OP_STATX",
"IORING_OP_READ",
"IORING_OP_WRITE",
"IORING_OP_FADVISE",
"IORING_OP_MADVISE",
"IORING_OP_SEND",
"IORING_OP_RECV",
"IORING_OP_OPENAT2",
"IORING_OP_EPOLL_CTL",
"IORING_OP_SPLICE",
"IORING_OP_PROVIDE_BUFFERS",
"IORING_OP_REMOVE_BUFFERS",
"IORING_TIMEOUT_ABS",
"SPLICE_F_FD_IN_FIXED",
"IORING_CQE_F_BUFFER",
"IORING_CQE_BUFFER_SHIFT",
"IORING_FEAT_SINGLE_MMAP",
"IORING_FEAT_NODROP",
"IORING_FEAT_SUBMIT_STABLE",
"IORING_FEAT_RW_CUR_POS",
"IORING_FEAT_CUR_PERSONALITY",
"IORING_FEAT_FAST_POLL",
"IORING_REGISTER_FILES_UPDATE",
"IORING_REGISTER_EVENTFD_ASYNC",
"IORING_REGISTER_PROBE",
"IORING_REGISTER_PERSONALITY",
"IORING_UNREGISTER_PERSONALITY",
"IO_URING_OP_SUPPORTED",
},
unsupportedHeaders: new string[]
{ },
unsupportedFunctions: new string[]
{ });
}
else if (rid == "ubuntu-16.04") // Travis
else if (rid == TravisRid) // Travis
{
Current = new TestEnvironment(
unsupportedStructs: new string[]
rid,
unsupportedStructs: new string[]
{
"statx_timestamp",
"statx"
},
unsupportedConstants: null,
unsupportedHeaders: null,
unsupportedHeaders: new string[]
{
"linux/openat2.h"
},
unsupportedFunctions: new string[]
{
"mlock2",
Expand All @@ -173,7 +229,7 @@ static TestEnvironment()
}
else
{
Current = new TestEnvironment();
Current = new TestEnvironment(rid);
}
}

Expand Down

0 comments on commit 7284998

Please sign in to comment.