tests: Check for valid fd in test_res_init
authorAndreas Schneider <asn@samba.org>
Mon, 23 Mar 2020 07:40:45 +0000 (08:40 +0100)
committerAndreas Schneider <asn@samba.org>
Mon, 23 Mar 2020 07:40:45 +0000 (08:40 +0100)
CID #68268

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
tests/test_res_init.c

index b79e28cfeca3c2ecc7150b6e0c8e067ef7365213..3daa1cb48b8673a9ddf236b3379c436c393e0ec5 100644 (file)
@@ -5,6 +5,7 @@
 #include <setjmp.h>
 #include <cmocka.h>
 
+#include <errno.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -35,6 +36,7 @@ static int setup(void **state)
        test_state->resolv_conf_path = strdup(RWRAP_RESOLV_CONF_TMPL);
        assert_non_null(test_state->resolv_conf_path);
        test_state->rc_fd = mkstemp(test_state->resolv_conf_path);
+       assert_return_code(test_state->rc_fd, errno);
        assert_non_null(test_state->resolv_conf_path);
        test_state->resolv_conf = fdopen(test_state->rc_fd, "a");
        assert_non_null(test_state->resolv_conf);