Commit Graph

11 Commits

Author SHA1 Message Date
Vishvananda Abrams
1e35ba25dc test: Improve test reliability with proper cleanup and isolation
Refactors test setup and teardown logic to use `t.Cleanup` instead
of `defer`. This ensures that cleanup functions are correctly scoped
to each subtest's lifecycle, improving test isolation and reliability.

The `setUpNetlinkTest` helper function is also improved to correctly
save and restore the original network namespace, ensuring that tests
do not leak state.

To support this, a `Close()` method that returns an error is added to
the `Handle` struct, allowing for proper cleanup of underlying netlink
sockets. The test helpers are updated to use this new method,
preventing resource leaks between tests.

Additionally, a bug in the `netns` tests is fixed where a large
namespace ID could overflow a 32-bit integer, causing spurious
failures on some systems.
2025-08-27 09:24:17 -07:00
Tobias Klauser
20a4b9a571 Clean logging up socket tests
Remove a stray fmt.Println in TestUnixSocketDiagInfo and convert any
log.Fatal lines to testing.(*T).Fatal to properly fail tests.
2025-07-22 09:50:59 -07:00
Asutorufa
d237ee16c3 SocketGet support udp and ipv6
Signed-off-by: Asutorufa <16442314+Asutorufa@users.noreply.github.com>
2024-03-29 09:33:44 -07:00
frei-0xff
3e28e6db88 Added SocketDestroy function. 2024-03-28 11:51:11 -07:00
Sven Rebhan
ec7bcb248e Implement unix socket diagnostics 2024-02-21 09:21:27 -08:00
Sven Rebhan
06219cde3e Implement UDP socket diagnostics
Signed-off-by: Sven Rebhan <srebhan@influxdata.com>
2024-01-26 09:08:48 -08:00
Oleg Senin
e499154279 Add SocketDiagTCPInfo with some constants and structs to get tcp_info via sock_diag
Add simple test for SocketDiagTCPInfo
2020-09-24 21:34:23 -04:00
Alessandro Boch
6e7bb56ca4 Run TestSocketGet in dedicated netns
Signed-off-by: Alessandro Boch <aboch@tetrationanalytics.com>
2017-11-27 17:51:57 -08:00
Vishvananda Ishaya Abrams
b7148c6755 skip inconsistent test 2017-04-12 10:28:41 -07:00
Aithal
dedc638a06 Fix compilation errors for non linux platforms.
The go get command and make both fail when executed on
non-linux platforms. Modified it so that there are no
compilation errors when developing in such an
environment.
2017-02-20 12:00:54 -08:00
Sebastien Boving
a3f0be6352 Add support for tcp diags. 2017-02-04 16:48:17 -08:00