test-shadow-vars.sh (3769B)
1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# Copyright (C) 2018 Joe Lawrence <joe.lawrence@redhat.com> 4 5. $(dirname $0)/functions.sh 6 7MOD_TEST=test_klp_shadow_vars 8 9setup_config 10 11 12# - load a module that exercises the shadow variable API 13 14start_test "basic shadow variable API" 15 16load_mod $MOD_TEST 17unload_mod $MOD_TEST 18 19check_result "% modprobe $MOD_TEST 20$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR0 21$MOD_TEST: got expected NULL result 22$MOD_TEST: shadow_ctor: PTR3 -> PTR2 23$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR2 = PTR3 24$MOD_TEST: shadow_ctor: PTR6 -> PTR5 25$MOD_TEST: klp_shadow_alloc(obj=PTR1, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR5 = PTR6 26$MOD_TEST: shadow_ctor: PTR8 -> PTR7 27$MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR7 = PTR8 28$MOD_TEST: shadow_ctor: PTR11 -> PTR10 29$MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR10 = PTR11 30$MOD_TEST: shadow_ctor: PTR13 -> PTR12 31$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR12 = PTR13 32$MOD_TEST: shadow_ctor: PTR16 -> PTR15 33$MOD_TEST: klp_shadow_alloc(obj=PTR14, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR15 = PTR16 34$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR3 35$MOD_TEST: got expected PTR3 -> PTR2 result 36$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR6 37$MOD_TEST: got expected PTR6 -> PTR5 result 38$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR8 39$MOD_TEST: got expected PTR8 -> PTR7 result 40$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR11 41$MOD_TEST: got expected PTR11 -> PTR10 result 42$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234) = PTR13 43$MOD_TEST: got expected PTR13 -> PTR12 result 44$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR16 45$MOD_TEST: got expected PTR16 -> PTR15 result 46$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR2 = PTR3 47$MOD_TEST: got expected PTR3 -> PTR2 result 48$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR7 = PTR8 49$MOD_TEST: got expected PTR8 -> PTR7 result 50$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR12 = PTR13 51$MOD_TEST: got expected PTR13 -> PTR12 result 52$MOD_TEST: shadow_dtor(obj=PTR1, shadow_data=PTR3) 53$MOD_TEST: klp_shadow_free(obj=PTR1, id=0x1234, dtor=PTR17) 54$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR0 55$MOD_TEST: got expected NULL result 56$MOD_TEST: shadow_dtor(obj=PTR9, shadow_data=PTR8) 57$MOD_TEST: klp_shadow_free(obj=PTR9, id=0x1234, dtor=PTR17) 58$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR0 59$MOD_TEST: got expected NULL result 60$MOD_TEST: shadow_dtor(obj=PTR14, shadow_data=PTR13) 61$MOD_TEST: klp_shadow_free(obj=PTR14, id=0x1234, dtor=PTR17) 62$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234) = PTR0 63$MOD_TEST: got expected NULL result 64$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR6 65$MOD_TEST: got expected PTR6 -> PTR5 result 66$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR11 67$MOD_TEST: got expected PTR11 -> PTR10 result 68$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR16 69$MOD_TEST: got expected PTR16 -> PTR15 result 70$MOD_TEST: klp_shadow_free_all(id=0x1235, dtor=PTR0) 71$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR0 72$MOD_TEST: got expected NULL result 73$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR0 74$MOD_TEST: got expected NULL result 75$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR0 76$MOD_TEST: got expected NULL result 77% rmmod $MOD_TEST" 78 79exit 0