diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index 20962e03e..82e76e575 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -73,6 +73,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/interface/static_analysis NV_REPOSITORY_COMPONENTS += userspace/units/interface/string NV_REPOSITORY_COMPONENTS += userspace/units/interface/worker NV_REPOSITORY_COMPONENTS += userspace/units/interface/kref +NV_REPOSITORY_COMPONENTS += userspace/units/interface/list NV_REPOSITORY_COMPONENTS += userspace/units/bus NV_REPOSITORY_COMPONENTS += userspace/units/pramin NV_REPOSITORY_COMPONENTS += userspace/units/priv_ring @@ -137,7 +138,6 @@ NV_REPOSITORY_COMPONENTS += userspace/units/fifo/tsg/gv11b NV_REPOSITORY_COMPONENTS += userspace/units/fifo/userd/gk20a NV_REPOSITORY_COMPONENTS += userspace/units/fifo/usermode/gv11b NV_REPOSITORY_COMPONENTS += userspace/units/fuse -NV_REPOSITORY_COMPONENTS += userspace/units/list NV_REPOSITORY_COMPONENTS += userspace/units/ltc NV_REPOSITORY_COMPONENTS += userspace/units/enabled NV_REPOSITORY_COMPONENTS += userspace/units/falcon diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index fde275993..29eac8c3f 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -74,6 +74,7 @@ UNITS := \ $(UNIT_SRC)/interface/string \ $(UNIT_SRC)/interface/worker \ $(UNIT_SRC)/interface/kref \ + $(UNIT_SRC)/interface/list \ $(UNIT_SRC)/mc \ $(UNIT_SRC)/mm/nvgpu_sgt \ $(UNIT_SRC)/mm/allocators/buddy_allocator \ @@ -134,7 +135,6 @@ UNITS := \ $(UNIT_SRC)/fifo/tsg/gv11b \ $(UNIT_SRC)/fifo/userd/gk20a \ $(UNIT_SRC)/fifo/usermode/gv11b \ - $(UNIT_SRC)/list \ $(UNIT_SRC)/ltc \ $(UNIT_SRC)/enabled \ $(UNIT_SRC)/falcon \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index f28b22a9f..dd4a8bf80 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -40,6 +40,7 @@ * - @ref SWUTS-interface-string * - @ref SWUTS-interface-worker * - @ref SWUTS-interface-kref + * - @ref SWUTS-interface-list * - @ref SWUTS-bus * - @ref SWUTS-falcon * - @ref SWUTS-netlist diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index bc0b8fb81..7ef9b7261 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -11,6 +11,7 @@ INPUT += ../../../userspace/units/interface/static_analysis/static_analysis.h INPUT += ../../../userspace/units/interface/string/nvgpu-string.h INPUT += ../../../userspace/units/interface/worker/worker.h INPUT += ../../../userspace/units/interface/kref/kref.h +INPUT += ../../../userspace/units/interface/list/list.h INPUT += ../../../userspace/units/bus/nvgpu-bus.h INPUT += ../../../userspace/units/falcon/falcon_tests/nvgpu-falcon.h INPUT += ../../../userspace/units/netlist/nvgpu-netlist.h diff --git a/userspace/required_tests.json b/userspace/required_tests.json index 61ca85902..d6ff6566a 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -1334,25 +1334,25 @@ { "test": "test_list_add", "case": "list_all_head", - "unit": "list", + "unit": "interface_list", "test_level": 0 }, { "test": "test_list_add", "case": "list_all_tail", - "unit": "list", + "unit": "interface_list", "test_level": 0 }, { "test": "test_list_move", "case": "list_move", - "unit": "list", + "unit": "interface_list", "test_level": 0 }, { "test": "test_list_replace", "case": "list_replace", - "unit": "list", + "unit": "interface_list", "test_level": 0 }, { diff --git a/userspace/units/list/Makefile b/userspace/units/interface/list/Makefile similarity index 97% rename from userspace/units/list/Makefile rename to userspace/units/interface/list/Makefile index c9bd77794..faeb4e070 100644 --- a/userspace/units/list/Makefile +++ b/userspace/units/interface/list/Makefile @@ -23,4 +23,4 @@ OBJS = list.o MODULE = list -include ../Makefile.units +include ../../Makefile.units diff --git a/userspace/units/list/Makefile.interface.tmk b/userspace/units/interface/list/Makefile.interface.tmk similarity index 95% rename from userspace/units/list/Makefile.interface.tmk rename to userspace/units/interface/list/Makefile.interface.tmk index 4b150b0d5..efd5eaab6 100644 --- a/userspace/units/list/Makefile.interface.tmk +++ b/userspace/units/interface/list/Makefile.interface.tmk @@ -26,7 +26,7 @@ NVGPU_UNIT_NAME=list -include $(NV_COMPONENT_DIR)/../Makefile.units.common.interface.tmk +include $(NV_COMPONENT_DIR)/../../Makefile.units.common.interface.tmk # Local Variables: # indent-tabs-mode: t diff --git a/userspace/units/list/Makefile.tmk b/userspace/units/interface/list/Makefile.tmk similarity index 96% rename from userspace/units/list/Makefile.tmk rename to userspace/units/interface/list/Makefile.tmk index bc054a706..801e7c543 100644 --- a/userspace/units/list/Makefile.tmk +++ b/userspace/units/interface/list/Makefile.tmk @@ -26,7 +26,7 @@ NVGPU_UNIT_NAME=list -include $(NV_COMPONENT_DIR)/../Makefile.units.common.tmk +include $(NV_COMPONENT_DIR)/../../Makefile.units.common.tmk # Local Variables: # indent-tabs-mode: t diff --git a/userspace/units/list/list.c b/userspace/units/interface/list/list.c similarity index 88% rename from userspace/units/list/list.c rename to userspace/units/interface/list/list.c index 45bc8ee53..dc5377e3e 100644 --- a/userspace/units/list/list.c +++ b/userspace/units/interface/list/list.c @@ -26,6 +26,7 @@ #include #include +#include "list.h" #define ELEMENTS 10 @@ -126,13 +127,8 @@ static int init_list_elements(struct unit_module *m, return 0; } -/* - * Test case to verify that elements get added and stay in the right order. - * __args is a boolean to indicate if adding to the head (false) or to the tail - * (true) - */ -static int test_list_add(struct unit_module *m, struct gk20a *g, - void *__args) + +int test_list_add(struct unit_module *m, struct gk20a *g, void *__args) { struct integer_list *pos; int i; @@ -161,13 +157,7 @@ static int test_list_add(struct unit_module *m, struct gk20a *g, return UNIT_SUCCESS; } -/* - * Test case to verify that elements get added and stay in the right order. - * __args is a boolean to indicate if adding to the head (false) or to the tail - * (true) - */ -static int test_list_move(struct unit_module *m, struct gk20a *g, - void *__args) +int test_list_move(struct unit_module *m, struct gk20a *g, void *__args) { struct integer_list *pos; int i; @@ -211,12 +201,7 @@ static int test_list_move(struct unit_module *m, struct gk20a *g, return UNIT_SUCCESS; } -/* - * Test case to test the replace operation by replacing the last node by a new - * one. - */ -static int test_list_replace(struct unit_module *m, struct gk20a *g, - void *__args) +int test_list_replace(struct unit_module *m, struct gk20a *g, void *__args) { struct integer_list *pos, *new_elem; struct nvgpu_list_node head; @@ -256,4 +241,4 @@ struct unit_module_test list_tests[] = { UNIT_TEST(list_replace, test_list_replace, NULL, 0), }; -UNIT_MODULE(list, list_tests, UNIT_PRIO_NVGPU_TEST); +UNIT_MODULE(interface_list, list_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/interface/list/list.h b/userspace/units/interface/list/list.h new file mode 100644 index 000000000..9c932f287 --- /dev/null +++ b/userspace/units/interface/list/list.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2020, 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_LIST_H +#define UNIT_LIST_H + +struct gk20a; +struct unit_module; + +/** @addtogroup SWUTS-interface-list + * @{ + * + * Software Unit Test Specification for interface.list + */ + +/** + * Test specification for: test_list_add + * + * Description: Test case to verify that elements get added and stay in the + * right order. + * + * Test Type: Feature + * + * Targets: nvgpu_init_list_node, nvgpu_list_empty, nvgpu_list_add_tail, + * nvgpu_list_add, nvgpu_list_del + * + * Input: __args is a boolean to indicate if adding to the head (false) or to + * the tail (true) + * + * Steps: + * - Create a test list with a known number of elements of consecutive values. + * - For each element in the list, ensure it is consecutive with the previous + * one (ascending if adding to head, descending if adding to tail). + * - Delete all known elements from the list and ensure the resulting list + * is empty. + * + * Output: Returns PASS if the steps above were executed successfully. FAIL + * otherwise. + */ +int test_list_add(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_list_move + * + * Description: Test case to verify that elements get added and stay in the + * right order. + * + * Test Type: Feature + * + * Targets: nvgpu_init_list_node, nvgpu_list_empty, nvgpu_list_add_tail, + * nvgpu_list_add, nvgpu_list_move, nvgpu_list_del + * + * Input: None + * + * Steps: + * - Create a test list with a known number of elements of consecutive values. + * - Add an extra element to the tail so that the list is not ordered anymore. + * - Move the last element to the head. + * - Ensure the list is now ordered. + * - Delete all known elements from the list and ensure the resulting list + * is empty. + * + * Output: Returns PASS if the steps above were executed successfully. FAIL + * otherwise. + */ +int test_list_move(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_list_replace + * + * Description: Test case to test the replace operation by replacing the last + * node by a new one. + * + * Test Type: Feature + * + * Targets: nvgpu_init_list_node, nvgpu_list_empty, nvgpu_list_add_tail, + * nvgpu_list_add, nvgpu_list_replace_init, nvgpu_list_del + * + * Input: None + * + * Steps: + * - Create a test list with a known number of elements of consecutive values. + * - Create a new node. + * - Get the last element of the list and replace it by the new node. + * - Ensure the last element of the list is indeed the new node. + * - Delete all known elements from the list and ensure the resulting list + * is empty. + * + * Output: Returns PASS if the steps above were executed successfully. FAIL + * otherwise. + */ +int test_list_replace(struct unit_module *m, struct gk20a *g, void *__args); + +/** }@ */ +#endif /* UNIT_LIST_H */