1a2818ee4SJoe Lawrence#!/bin/bash
2a2818ee4SJoe Lawrence# SPDX-License-Identifier: GPL-2.0
3a2818ee4SJoe Lawrence# Copyright (C) 2018 Joe Lawrence <joe.lawrence@redhat.com>
4a2818ee4SJoe Lawrence
5a2818ee4SJoe Lawrence. $(dirname $0)/functions.sh
6a2818ee4SJoe Lawrence
7a2818ee4SJoe LawrenceMOD_TEST=test_klp_shadow_vars
8a2818ee4SJoe Lawrence
9a2818ee4SJoe Lawrenceset_dynamic_debug
10a2818ee4SJoe Lawrence
11a2818ee4SJoe Lawrence
12a2818ee4SJoe Lawrence# TEST: basic shadow variable API
13a2818ee4SJoe Lawrence# - load a module that exercises the shadow variable API
14a2818ee4SJoe Lawrence
15a2818ee4SJoe Lawrenceecho -n "TEST: basic shadow variable API ... "
16a2818ee4SJoe Lawrencedmesg -C
17a2818ee4SJoe Lawrence
18a2818ee4SJoe Lawrenceload_mod $MOD_TEST
19a2818ee4SJoe Lawrenceunload_mod $MOD_TEST
20a2818ee4SJoe Lawrence
21a2818ee4SJoe Lawrencecheck_result "% modprobe $MOD_TEST
22a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR5, id=0x1234) = PTR0
23a2818ee4SJoe Lawrence$MOD_TEST:   got expected NULL result
24a2818ee4SJoe Lawrence$MOD_TEST: shadow_ctor: PTR6 -> PTR1
25a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_alloc(obj=PTR5, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR7, ctor_data=PTR1 = PTR6
26a2818ee4SJoe Lawrence$MOD_TEST: shadow_ctor: PTR8 -> PTR2
27a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR7, ctor_data=PTR2 = PTR8
28a2818ee4SJoe Lawrence$MOD_TEST: shadow_ctor: PTR10 -> PTR3
29a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_alloc(obj=PTR5, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR7, ctor_data=PTR3 = PTR10
30a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR5, id=0x1234) = PTR6
31a2818ee4SJoe Lawrence$MOD_TEST:   got expected PTR6 -> PTR1 result
32a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR8
33a2818ee4SJoe Lawrence$MOD_TEST:   got expected PTR8 -> PTR2 result
34a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR5, id=0x1235) = PTR10
35a2818ee4SJoe Lawrence$MOD_TEST:   got expected PTR10 -> PTR3 result
36a2818ee4SJoe Lawrence$MOD_TEST: shadow_ctor: PTR11 -> PTR4
37a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR12, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR7, ctor_data=PTR4 = PTR11
38a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR12, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR7, ctor_data=PTR4 = PTR11
39a2818ee4SJoe Lawrence$MOD_TEST:   got expected PTR11 -> PTR4 result
40a2818ee4SJoe Lawrence$MOD_TEST: shadow_dtor(obj=PTR5, shadow_data=PTR6)
41a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_free(obj=PTR5, id=0x1234, dtor=PTR13)
42a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR5, id=0x1234) = PTR0
43a2818ee4SJoe Lawrence$MOD_TEST:   got expected NULL result
44a2818ee4SJoe Lawrence$MOD_TEST: shadow_dtor(obj=PTR9, shadow_data=PTR8)
45a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_free(obj=PTR9, id=0x1234, dtor=PTR13)
46a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR0
47a2818ee4SJoe Lawrence$MOD_TEST:   got expected NULL result
48a2818ee4SJoe Lawrence$MOD_TEST: shadow_dtor(obj=PTR12, shadow_data=PTR11)
49a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_free(obj=PTR12, id=0x1234, dtor=PTR13)
50a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR12, id=0x1234) = PTR0
51a2818ee4SJoe Lawrence$MOD_TEST:   got expected NULL result
52a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR5, id=0x1235) = PTR10
53a2818ee4SJoe Lawrence$MOD_TEST:   got expected PTR10 -> PTR3 result
54a2818ee4SJoe Lawrence$MOD_TEST: shadow_dtor(obj=PTR5, shadow_data=PTR10)
55a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_free_all(id=0x1235, dtor=PTR13)
56a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR5, id=0x1234) = PTR0
57a2818ee4SJoe Lawrence$MOD_TEST:   shadow_get() got expected NULL result
58a2818ee4SJoe Lawrence% rmmod test_klp_shadow_vars"
59a2818ee4SJoe Lawrence
60a2818ee4SJoe Lawrenceexit 0
61