1Title: Memory Slab APIs
2
3Description:
4
5This test verifies that the kernel memory slab APIs operate as expected.
6
7--------------------------------------------------------------------------------
8
9Building and Running Project:
10
11This project outputs to the console.  It can be built and executed
12on QEMU as follows:
13
14    make run
15
16--------------------------------------------------------------------------------
17
18Troubleshooting:
19
20Problems caused by out-dated project information can be addressed by
21issuing one of the following commands then rebuilding the project:
22
23    make clean          # discard results of previous builds
24                        # but keep existing configuration info
25or
26    make pristine       # discard results of previous builds
27                        # and restore pre-defined configuration info
28
29--------------------------------------------------------------------------------
30
31Sample Output:
32
33starting test - Test Kernel memory slabs
34Starts main
35===================================================================
36(1) - Allocate and free 2 blocks in <main>
37===================================================================
38Function test_slab_get_all_blocks
39MAP_LgBlks used 0 blocks
40  k_mem_slab_alloc OK, p[0] = 0x00406400
41MAP_LgBlks used 1 blocks
42  k_mem_slab_alloc OK, p[1] = 0x00406000
43MAP_LgBlks used 2 blocks
44  k_mem_slab_alloc RC_FAIL expected as all (2) blocks are used.
45===================================================================
46print_pointers: p[0] = 0x00406400, p[1] = 0x00406000,
47===================================================================
48Function test_slab_free_all_blocks
49MAP_LgBlks used 2 blocks
50  block ptr to free p[0] = 0x00406400
51MAP_LgBlks freed 1 block
52MAP_LgBlks used 1 blocks
53  block ptr to free p[1] = 0x00406000
54MAP_LgBlks freed 2 block
55MAP_LgBlks used 0 blocks
56===================================================================
57Starts helper_thread
58===================================================================
59(2) - Allocate 2 blocks in <helper_thread>
60===================================================================
61Function test_slab_get_all_blocks
62MAP_LgBlks used 0 blocks
63  k_mem_slab_alloc OK, p[0] = 0x00406000
64MAP_LgBlks used 1 blocks
65  k_mem_slab_alloc OK, p[1] = 0x00406400
66MAP_LgBlks used 2 blocks
67  k_mem_slab_alloc RC_FAIL expected as all (2) blocks are used.
68===================================================================
69===================================================================
70(3) - Further allocation results in  timeout in <main>
71===================================================================
72main: k_mem_slab_alloc times out which is expected
73main: start to wait for block
74===================================================================
75(4) - Free a block in <helper_thread> to unblock the other task from alloc timeout
76===================================================================
77helper_thread: About to free a memory block
78main: k_mem_slab_alloc OK, block allocated at 0x00406000
79main: start to wait for block
80===================================================================
81(5) <helper_thread> freeing the next block
82===================================================================
83helper_thread: About to free another memory block
84main: k_mem_slab_alloc OK, block allocated at 0x00406400
85helper_thread: freed all blocks allocated by this task
86PASS - helper_thread.
87===================================================================
88main: Used 2 block
89main: 1 block freed, used 1 block
90PASS - main.
91===================================================================
92===================================================================
93PROJECT EXECUTION SUCCESSFUL
94
95