trick/test/SIM_alloc_test/RUN_test/input.py
Alex Lin 9ddc786ace Split test sims and fun sims into separate directories.
Moved most of the rest of the sims to test.

refs #191
2016-02-23 16:19:30 -06:00

64 lines
2.7 KiB
Python

# Creates a local class. The class is destructed/deleted when the function returns.
def create_local_alloc_test():
test = trick.AllocTest()
# Creates a class that is controlled by the Memory Manager (MM). It is not freed when the function returns.
# TMM_declare_var returns a void *. We can cast it to the correct type so we can access the class fields
# in python. This allocation will not have a name in the memory manager.
def create_tmm_alloc_test():
return trick.castAsAllocTest(trick.TMM_declare_var_s("AllocTest"))
# Creates a class that is controlled by the Memory Manager (MM). It is not freed when the function returns.
# This allocation will have a name in the memory manager.
def create_new_alloc_test():
# test is known to the memory manager, it must be deleted with TMM_delete_var
return trick.AllocTest(TMMName="my_alloc_test")
# Creates a local class. The class is destructed/deleted when the function returns.
# Underneath this class declares itself to the memory manager and is controlled by the MM. The class destructor
# automatically removes the allocation from the memory manager.
def create_local_alloc_test_with_mm_interface():
test = trick.AllocTestWithMMInterface()
# Creates a class that is controlled by the Memory Manager (MM). It is not freed when the function returns.
# TMM_declare_var returns a void *. We can cast it to the correct type so we can access the class fields
# in python. This allocation will not have a name in the memory manager.
def create_tmm_alloc_test_with_mm_interface():
return trick.castAsAllocTestWithMMInterface(trick.TMM_declare_var_s("AllocTestWithMMInterface"))
# Creates a class that is controlled by the Memory Manager (MM). It is not freed when the function returns.
# This allocation will have a name in the memory manager.
def create_new_alloc_test_with_mm_interface():
return trick.AllocTestWithMMInterface(TMMName="my_alloc_test_with_mm_interface")
def main():
print "\ncreate local python tracked allocation"
create_local_alloc_test()
print "\ncreate through TMM_declare_var"
test = create_tmm_alloc_test()
trick.TMM_delete_var_a(test)
print "\ncreate with TMMName"
test = create_new_alloc_test()
trick.TMM_delete_var_a(test)
print "\ncreate local python tracked allocation. Class uses TRICK_MM_INTERFACE."
create_local_alloc_test_with_mm_interface()
print "\ncreate through TMM_declare_var"
test = create_tmm_alloc_test_with_mm_interface()
trick.TMM_delete_var_a(test)
print "\ncreate through TMMName with TRICK_MM_INTERFACE"
test = create_new_alloc_test_with_mm_interface()
trick.TMM_delete_var_n("my_alloc_test_with_mm_interface")
trick.stop(1.0)
if __name__ == "__main__":
main()