util: Improve prototype of debug_get_num_option and debug_get_flags_option

Getting debug_get_num_option to return int64_t, as long under 64 bit Linux are 64 bit size,
 so using fixed int64_t for cross platform consistence, as long under win32 is 32 bit size.

Getting DEBUG_GET_ONCE_FLAGS_OPTION to return uint64_t to getting it to be
consistence with debug_get_flags_option.

DEBUG_GET_ONCE_NUM_OPTION is not accessed in codebase, so add unittest for it, it maybe
used in future, remove it is not consistence

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19554>
This commit is contained in:
Yonggang Luo
2022-11-02 14:46:16 +08:00
committed by Marge Bot
parent 2794ad39fd
commit 501a46fd69
3 changed files with 50 additions and 22 deletions

View File

@@ -183,3 +183,34 @@ TEST(u_debug, debug_get_num_option)
EXPECT_EQ(debug_get_num_option("MESA_UNIT_TEST_NUM_VARIABLE_2", 100), 100);
}
}
DEBUG_GET_ONCE_NUM_OPTION(num_once_test_0, "MESA_UNIT_TEST_DEBUG_GET_ONCE_NUM_VARIABLE_0", -33)
DEBUG_GET_ONCE_NUM_OPTION(num_once_test_1, "MESA_UNIT_TEST_DEBUG_GET_ONCE_NUM_VARIABLE_1", 0)
DEBUG_GET_ONCE_NUM_OPTION(num_once_test_2, "MESA_UNIT_TEST_DEBUG_GET_ONCE_NUM_VARIABLE_2", 0)
TEST(u_debug, DEBUG_GET_ONCE_NUM_OPTION_Macro)
{
{
EXPECT_EQ(debug_get_option_num_once_test_0(), -33);
}
{
static char env_str[] = "MESA_UNIT_TEST_DEBUG_GET_ONCE_NUM_VARIABLE_1=9223372036854775807";
putenv(env_str);
EXPECT_EQ(debug_get_option_num_once_test_1(), INT64_MAX);
}
{
static char env_str[] = "MESA_UNIT_TEST_DEBUG_GET_ONCE_NUM_VARIABLE_1=9223372036854775806";
putenv(env_str);
EXPECT_EQ(debug_get_option_num_once_test_1(), INT64_MAX);
}
{
static char env_str[] = "MESA_UNIT_TEST_DEBUG_GET_ONCE_NUM_VARIABLE_2=-9223372036854775808";
putenv(env_str);
EXPECT_EQ(debug_get_option_num_once_test_2(), INT64_MIN);
}
}