rtld-elf: add some tests for parse_integer()
Reviewed by: des, dim Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57549
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include <src.opts.mk>
|
||||
|
||||
SUBDIR+= libpythagoras libdeep libval libval2 target
|
||||
TESTS_SUBDIRS+= rtld_deepbind
|
||||
|
||||
@@ -16,6 +18,14 @@ SRCS.$t= $t.c common.c
|
||||
ATF_TESTS_C+= dlopen_test
|
||||
ATF_TESTS_C+= dlopen_hash_test
|
||||
|
||||
ATF_TESTS_C+= parse_integer_test
|
||||
parse_integer_test.c: parse_integer_func.c
|
||||
CFLAGS.parse_integer_test.c+= -I${.OBJDIR}
|
||||
parse_integer_func.c: ${SRCTOP}/libexec/rtld-elf/rtld.c
|
||||
sed -ne '/^parse_integer/,/^\}/p' ${SRCTOP}/libexec/rtld-elf/rtld.c \
|
||||
>parse_integer_func.c
|
||||
CLEANFILES+= parse_integer_func.c
|
||||
|
||||
WARNS?= 3
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright 2026 The FreeBSD Foundation
|
||||
*
|
||||
* Portions of this software were developed by Konstantin Belousov
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <atf-c.h>
|
||||
|
||||
static int
|
||||
#include "parse_integer_func.c"
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(integers);
|
||||
ATF_TC_BODY(integers, tc)
|
||||
{
|
||||
ATF_REQUIRE_EQ(parse_integer("0"), 0);
|
||||
ATF_REQUIRE_EQ(parse_integer("10"), 10);
|
||||
ATF_REQUIRE_EQ(parse_integer("10001"), 10001);
|
||||
ATF_REQUIRE_EQ(parse_integer("0b101"), 0b101);
|
||||
ATF_REQUIRE_EQ(parse_integer("0x10"), 0x10);
|
||||
ATF_REQUIRE_EQ(parse_integer("020"), 020);
|
||||
ATF_REQUIRE_EQ(parse_integer("090"), -1);
|
||||
/* This test assumes some value for INT_MAX */
|
||||
ATF_REQUIRE_EQ(parse_integer("1111111111111111111111111111"), -1);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, integers);
|
||||
return (atf_no_error());
|
||||
}
|
||||
Reference in New Issue
Block a user