Commit 7f6024b
authored
Fix sockopt tests (#1534)
* Fix cfgs in sockopt tests
`rustix::time` and the txtime socket options are only available with the `time`
feature, but they are unconditionally used in sockopt tests. Mark them with
`cfg(feature = "time")` to enable compiling sockopt tests with just the `net`
feature enabled. Otherwise `cargo test --features net` would end up with a
compile error.
Fixes: 65b04ae ("Add support for SO_TXTIME / SCM_TXTIME (#1409)")
* Test `socket_passcred` only for Unix domain sockets
Since Linux 6.16, `SO_PASSCRED` is allowed only for `AF_UNIX`, `AF_NETLINK` and
`AF_BLUETOOTH` sockets. The tests used to get/set this option for IP sockets,
which doesn't work with new kernels, so make the tests use a Unix domain socket
instead.
On new kernels, the tests fail with:
```
---- sockopt::test_sockopts_ipv6 stdout ----
thread 'sockopt::test_sockopts_ipv6' panicked at tests/net/sockopt.rs:44:42:
called `Result::unwrap()` on an `Err` value: Os { code: 95, kind: Unsupported, message: "Operation not supported" }
---- sockopt::test_sockopts_ipv4 stdout ----
thread 'sockopt::test_sockopts_ipv4' panicked at tests/net/sockopt.rs:44:42:
called `Result::unwrap()` on an `Err` value: Os { code: 95, kind: Unsupported, message: "Operation not supported" }
```
The restriction was introduced to Linux in this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7d8d93fdde50b86bbbf46a203c368ed320e729ab1 parent 8a2472a commit 7f6024b
1 file changed
+15
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
119 | 117 | | |
120 | 118 | | |
121 | 119 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | 120 | | |
132 | 121 | | |
133 | 122 | | |
| |||
527 | 516 | | |
528 | 517 | | |
529 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
| |||
668 | 669 | | |
669 | 670 | | |
670 | 671 | | |
671 | | - | |
| 672 | + | |
672 | 673 | | |
673 | 674 | | |
674 | 675 | | |
| |||
0 commit comments