-
Notifications
You must be signed in to change notification settings - Fork 99
Resource Lifetime
In the most general sense, resources are those objects tnvme uses to setup and test a DUT. Resources are commands from any command set, any type of queue, memory (both contiguous and discontigous with various alignment requirements). The quickest way to determine if a C++ class is considered a resource or not is to investigate if it has a base class of Trackable. Any class derived from the Trackable class is therefore trackable by the resource manager. But this isn't the entire story, not all classes are meant to be instantiated, rather some class definitions might inherit from Trackable but aren't meant to be used directly. These intermediate classes are present to provide building blocks to give extra characteristics to child classes. A good example of an intermediate class is the NVMCmd class which is the parent of all commands within the NVM command set, another is the AdminCmd for the administrator command set. To determine if a class is both meant to be instantiated directly and is also considered a resource you need to investigate whether or not the resource manager allows the creation/allocation of it.
The resource manager is called gRsrcMngr and is of type class RsrcMngr. It is a global object and thus has a prepended 'g' character in its name. It is created automatically by the framework. It is also a singleton, meaning only 1 object of its kind will ever exist for each running instance of tnvme. The main job of the gRsrcMngr is to allocate resources and allow thier deallocation when thier lifetime has expired. All objects born of the gRsrcMngr have what is called group lifetime. These objects are guaranteed to exist/live for the entire duration of a group's processing. In other words, after all tests have executed within a group, then and only then, will the framework force the deallocation of all objects born of the gRsrcMngr. The framework simply notifies the gRsrcMngr to initiate all deallocation tasks.
Test objects represent test cases. A test is given control when the framework calls its RunCoreTest() method. Any test within a group can call upon the gRsrcMngr to create resources for the benefit of a test. A test simply calls method gRsrcMngr->AllocObj() and supplies the type of object/resource for which to allocate. Those objects/resources will now live until all tests within the containing group have either completed execution or an error occurs causing control to exit group execution prematurely. When group execution ends all resources are deallocated.