[PATCH 7/8] memblock tests: add tests for memblock_*bottom_up functions

Rebecca Mckeever posted 8 patches 3 years, 8 months ago
There is a newer version of this series
[PATCH 7/8] memblock tests: add tests for memblock_*bottom_up functions
Posted by Rebecca Mckeever 3 years, 8 months ago
Add simple tests for memblock_set_bottom_up() and memblock_bottom_up().

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Rebecca Mckeever <remckee0@gmail.com>
---
 tools/testing/memblock/tests/basic_api.c | 45 ++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c
index ef5642d0863b..d7f008e7a12a 100644
--- a/tools/testing/memblock/tests/basic_api.c
+++ b/tools/testing/memblock/tests/basic_api.c
@@ -1679,6 +1679,50 @@ static int memblock_free_checks(void)
 	return 0;
 }
 
+static int memblock_set_bottom_up_check(void)
+{
+	prefix_push("memblock_set_bottom_up");
+
+	memblock_set_bottom_up(false);
+	ASSERT_EQ(memblock.bottom_up, false);
+	memblock_set_bottom_up(true);
+	ASSERT_EQ(memblock.bottom_up, true);
+
+	reset_memblock_attributes();
+	test_pass_pop();
+
+	return 0;
+}
+
+static int memblock_bottom_up_check(void)
+{
+	prefix_push("memblock_bottom_up");
+
+	memblock_set_bottom_up(false);
+	ASSERT_EQ(memblock_bottom_up(), memblock.bottom_up);
+	ASSERT_EQ(memblock_bottom_up(), false);
+	memblock_set_bottom_up(true);
+	ASSERT_EQ(memblock_bottom_up(), memblock.bottom_up);
+	ASSERT_EQ(memblock_bottom_up(), true);
+
+	reset_memblock_attributes();
+	test_pass_pop();
+
+	return 0;
+}
+
+static int memblock_bottom_up_checks(void)
+{
+	test_print("Running memblock_*bottom_up tests...\n");
+
+	prefix_reset();
+	memblock_set_bottom_up_check();
+	prefix_reset();
+	memblock_bottom_up_check();
+
+	return 0;
+}
+
 int memblock_basic_checks(void)
 {
 	memblock_initialization_check();
@@ -1686,6 +1730,7 @@ int memblock_basic_checks(void)
 	memblock_reserve_checks();
 	memblock_remove_checks();
 	memblock_free_checks();
+	memblock_bottom_up_checks();
 
 	return 0;
 }
-- 
2.25.1
Re: [PATCH 7/8] memblock tests: add tests for memblock_*bottom_up functions
Posted by Huang, Shaoqin 3 years, 7 months ago
Reviewed-by: Shaoqin Huang <shaoqin.huang@intel.com>

On 8/14/2022 1:53 PM, Rebecca Mckeever wrote:
> Add simple tests for memblock_set_bottom_up() and memblock_bottom_up().
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Rebecca Mckeever <remckee0@gmail.com>
> ---
>   tools/testing/memblock/tests/basic_api.c | 45 ++++++++++++++++++++++++
>   1 file changed, 45 insertions(+)
> 
> diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c
> index ef5642d0863b..d7f008e7a12a 100644
> --- a/tools/testing/memblock/tests/basic_api.c
> +++ b/tools/testing/memblock/tests/basic_api.c
> @@ -1679,6 +1679,50 @@ static int memblock_free_checks(void)
>   	return 0;
>   }
>   
> +static int memblock_set_bottom_up_check(void)
> +{
> +	prefix_push("memblock_set_bottom_up");
> +
> +	memblock_set_bottom_up(false);
> +	ASSERT_EQ(memblock.bottom_up, false);
> +	memblock_set_bottom_up(true);
> +	ASSERT_EQ(memblock.bottom_up, true);
> +
> +	reset_memblock_attributes();
> +	test_pass_pop();
> +
> +	return 0;
> +}
> +
> +static int memblock_bottom_up_check(void)
> +{
> +	prefix_push("memblock_bottom_up");
> +
> +	memblock_set_bottom_up(false);
> +	ASSERT_EQ(memblock_bottom_up(), memblock.bottom_up);
> +	ASSERT_EQ(memblock_bottom_up(), false);
> +	memblock_set_bottom_up(true);
> +	ASSERT_EQ(memblock_bottom_up(), memblock.bottom_up);
> +	ASSERT_EQ(memblock_bottom_up(), true);
> +
> +	reset_memblock_attributes();
> +	test_pass_pop();
> +
> +	return 0;
> +}
> +
> +static int memblock_bottom_up_checks(void)
> +{
> +	test_print("Running memblock_*bottom_up tests...\n");
> +
> +	prefix_reset();
> +	memblock_set_bottom_up_check();
> +	prefix_reset();
> +	memblock_bottom_up_check();
> +
> +	return 0;
> +}
> +
>   int memblock_basic_checks(void)
>   {
>   	memblock_initialization_check();
> @@ -1686,6 +1730,7 @@ int memblock_basic_checks(void)
>   	memblock_reserve_checks();
>   	memblock_remove_checks();
>   	memblock_free_checks();
> +	memblock_bottom_up_checks();
>   
>   	return 0;
>   }