On 03/01/2023 15.46, Laurent Vivier wrote:
On 1/3/23 15:08, Thomas Huth wrote:
On 03/01/2023 12.00, Laurent Vivier wrote:
Signed-off-by: Laurent Vivier <lviv...@redhat.com>
Acked-by: Michael S. Tsirkin <m...@redhat.com>
---
Notes:
v4:
- rework EXPECT_STATE()
- use g_dir_make_tmp()
v3:
- Add "-M none" to avoid error:
"No machine specified, and there is no default"
v2:
- Fix ipv6 free port allocation
- Check for IPv4, IPv6, AF_UNIX
- Use g_mkdtemp() rather than g_file_open_tmp()
- Use socketpair() in test_stream_fd()
v1: compared to v14 of "qapi: net: add unix socket type support to
netdev backend":
- use IP addresses 127.0.0.1 and ::1 rather than localhost
tests/qtest/meson.build | 2 +
tests/qtest/netdev-socket.c | 434 ++++++++++++++++++++++++++++++++++++
2 files changed, 436 insertions(+)
create mode 100644 tests/qtest/netdev-socket.c
[...]
+int main(int argc, char **argv)
+{
+ int ret;
+ bool has_ipv4, has_ipv6, has_afunix;
+ g_autoptr(GError) err = NULL;
+
+ g_test_init(&argc, &argv, NULL);
+
+ if (socket_check_protocol_support(&has_ipv4, &has_ipv6) < 0) {
+ g_printerr("socket_check_protocol_support() failed\n");
+ goto end;
+ }
+
+ tmpdir = g_dir_make_tmp("netdev-socket.XXXXXX", &err);
+ if (tmpdir == NULL) {
+ g_error("Can't create temporary directory in %s: %s",
+ g_get_tmp_dir(), err->message);
Should there also be a "goto end" here?
No, g_error() is fatal.
https://docs.gtk.org/glib/func.error.html
Ah, alright, then this is fine, thanks for the clarification!
Thomas