diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -7,6 +7,7 @@ ATF_TESTS_C+= brk_test .endif ATF_TESTS_C+= cpuset_test +ATF_TESTS_C+= errno_test ATF_TESTS_C+= queue_test ATF_TESTS_C+= sendfile_test diff --git a/lib/libc/tests/sys/errno_test.c b/lib/libc/tests/sys/errno_test.c new file mode 100644 --- /dev/null +++ b/lib/libc/tests/sys/errno_test.c @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2024 The FreeBSD Foundation + * + * SPDX-License-Identifier: BSD-2-Clause + * + * This software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + */ + +#include +#include + +#include + +ATF_TC(errno_basic); +ATF_TC_HEAD(errno_basic, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Verify basic functionality of errno"); +} + +ATF_TC_BODY(errno_basic, tc) +{ + int res; + + res = unlink("/non/existent/file"); + ATF_REQUIRE(res == -1); + ATF_REQUIRE(errno == ENOENT); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, errno_basic); + + return (atf_no_error()); +}