xref: /freebsd/lib/libc/tests/sys/errno_test.c (revision a91a2465)
1 /*-
2  * Copyright (c) 2024 The FreeBSD Foundation
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  *
6  * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
7  * under sponsorship from the FreeBSD Foundation.
8  */
9 
10 #include <errno.h>
11 #include <unistd.h>
12 
13 #include <atf-c.h>
14 
15 ATF_TC(errno_basic);
16 ATF_TC_HEAD(errno_basic, tc)
17 {
18 	atf_tc_set_md_var(tc, "descr",
19 	    "Verify basic functionality of errno");
20 }
21 
22 ATF_TC_BODY(errno_basic, tc)
23 {
24 	int res;
25 
26 	res = unlink("/non/existent/file");
27 	ATF_REQUIRE(res == -1);
28 	ATF_REQUIRE(errno == ENOENT);
29 }
30 
31 ATF_TP_ADD_TCS(tp)
32 {
33 	ATF_TP_ADD_TC(tp, errno_basic);
34 
35 	return (atf_no_error());
36 }
37