gpu: nvgpu: unit: SWUTS for mm.allocator.bitmap

Add bitmap_allocator.h header that contains SWUTS for the unit.

Jira NVGPU-3943

Change-Id: I13bd00f306bf66079556d775b2de83fd50760201
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2191878
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2019-09-06 09:28:45 -07:00
committed by Alex Waterman
parent 3b1f679526
commit 64ecb8fb60
4 changed files with 158 additions and 26 deletions

View File

@@ -30,6 +30,7 @@
#include <nvgpu/posix/posix-fault-injection.h>
#include "common/mm/allocators/bitmap_allocator_priv.h"
#include "bitmap_allocator.h"
#define BA_DEFAULT_BASE SZ_1K
#define BA_DEFAULT_LENGTH (SZ_64K << 1)
@@ -41,10 +42,7 @@
static struct nvgpu_allocator *na;
/*
* Test bitmap_allocator with GPU_ALLOC_NO_ALLOC_PAGE enabled
*/
static int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
struct gk20a *g, void *args)
{
u64 base = BA_DEFAULT_BASE;
@@ -59,10 +57,6 @@ static int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
unit_return_fail(m, "Could not allocate nvgpu_allocator\n");
}
/*
* Initialize bitmap allocator
* This ba will be used in this test.
*/
if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length,
blk_size, 0ULL, flags, BITMAP_ALLOCATOR) != 0) {
nvgpu_kfree(g, na);
@@ -118,10 +112,7 @@ fail:
}
/*
* Test bitmap_allocator allocs
*/
static int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
struct gk20a *g, void *args)
{
u64 alloc0, alloc3k, alloc4k, alloc_at64, addr, addr_fail;
@@ -238,11 +229,7 @@ static int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
return UNIT_SUCCESS;
}
/*
* Tests bitmap_allocator basic ops
* Bitmap attributes are set corresponding to default init values
*/
static int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
struct gk20a *g, void *args)
{
u64 addr;
@@ -269,10 +256,7 @@ static int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
return UNIT_SUCCESS;
}
/*
* De-initialize bitmap allocator
*/
static int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
struct gk20a *g, void *args)
{
na->ops->fini(na);
@@ -281,11 +265,7 @@ static int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
return UNIT_SUCCESS;
}
/*
* Tests nvgpu_bitmap_allocator_init()
* This test considers multiple conditions to initialize bitmap allocator
*/
static int test_nvgpu_bitmap_allocator_init(struct unit_module *m,
int test_nvgpu_bitmap_allocator_init(struct unit_module *m,
struct gk20a *g, void *args)
{
u64 base = BA_DEFAULT_BASE;

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef UNIT_BITMAP_ALLOCATOR_H
#define UNIT_BITMAP_ALLOCATOR_H
struct gk20a;
struct unit_module;
/** @addtogroup SWUTS-mm-allocators-bitmap-allocator
* @{
*
* Software Unit Test Specification for mm.allocators.bitmap_allocator
*/
/**
* Test specification for: test_nvgpu_bitmap_allocator_init
*
* Description: Initialize bitmap allocator.
*
* Test Type: Feature based
*
* Input: None
*
* Steps:
* - Initialize bitmap allocator with following characteristics.
* - 1K memory base address.
* - 128K length of memory.
* - 1K block size.
* - Use this bitmap allocator for rest of the tests.
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_bitmap_allocator_init(struct unit_module *m,
struct gk20a *g, void *args);
/**
* Test specification for: test_nvgpu_bitmap_allocator_ops
*
* Description: Check bitmap_allocator attribute values using allocator ops.
*
* Test Type: Feature based
*
* Input: test_nvgpu_bitmap_allocator_init
*
* Steps:
* - Check bitmap_allocator attributes using allocator ops.
* - Execute allocator ops to read attibute value.
* - Confirm that value is equal to the default values set during
* initialization.
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
struct gk20a *g, void *args);
/**
* Test specification for: test_nvgpu_bitmap_allocator_alloc
*
* Description: Allocate various sizes of memory to test different scenarios.
*
* Test Type: Feature based
*
* Input: test_nvgpu_bitmap_allocator_init
*
* Steps:
* - Allocate 3k memory using allocation functions.
* - Confirm that allocation is successful.
* - Allocate 2M which is more than available memory.
* - Allocation is expected to fail.
* - Allocate 4K, 8K, 16K and 32K memory segments.
* - Confirm all allocations are successful.
* - Allocate various memory segments using fixed allocation functions.
* - Confirm aloocations are successful as expected.
* - Free allocations.
* - Confirm allocations are freed.
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
struct gk20a *g, void *args);
/**
* Test specification for: test_nvgpu_bitmap_allocator_destroy
*
* Description: Free memory used for bitmap allocator.
*
* Test Type: Other (clean up)
*
* Input: test_nvgpu_bitmap_allocator_init
*
* Steps:
* - Free bitmap_allocator allocated for this unit test.
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
struct gk20a *g, void *args);
/**
* Test specification for: test_nvgpu_bitmap_allocator_critical
*
* Description: Test allocator functions for bitmap allocator in latency
* critical path.
*
* Test Type: Feature based
*
* Input: None
*
* Steps:
* - Initialize allocator with following characteristics.
* - 1K memory base address.
* - 128K memory length.
* - 1K block size.
* - GPU_ALLOC_NO_ALLOC_PAGE flag value.
* - Allocate memory segments using allocation functions.
* - Confirm allocations are successful.
* - Free allocated memory segments.
* - Free bitmap allocator used for this test.
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
struct gk20a *g, void *args);
#endif /* UNIT_BITMAP_ALLOCATOR_H */