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 935c9e74cSJoe Lawrencesetup_config 10a2818ee4SJoe Lawrence 11a2818ee4SJoe Lawrence 12a2818ee4SJoe Lawrence# - load a module that exercises the shadow variable API 13a2818ee4SJoe Lawrence 142eeb0d45SJoe Lawrencestart_test "basic shadow variable API" 15a2818ee4SJoe Lawrence 16a2818ee4SJoe Lawrenceload_mod $MOD_TEST 17a2818ee4SJoe Lawrenceunload_mod $MOD_TEST 18a2818ee4SJoe Lawrence 19a2818ee4SJoe Lawrencecheck_result "% modprobe $MOD_TEST 2076efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR0 21a2818ee4SJoe Lawrence$MOD_TEST: got expected NULL result 2276efe6daSYannick Cote$MOD_TEST: shadow_ctor: PTR3 -> PTR2 2376efe6daSYannick Cote$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR2 = PTR3 2476efe6daSYannick Cote$MOD_TEST: shadow_ctor: PTR6 -> PTR5 2576efe6daSYannick Cote$MOD_TEST: klp_shadow_alloc(obj=PTR1, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR5 = PTR6 2676efe6daSYannick Cote$MOD_TEST: shadow_ctor: PTR8 -> PTR7 2776efe6daSYannick Cote$MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR7 = PTR8 2876efe6daSYannick Cote$MOD_TEST: shadow_ctor: PTR11 -> PTR10 2976efe6daSYannick Cote$MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR10 = PTR11 3076efe6daSYannick Cote$MOD_TEST: shadow_ctor: PTR13 -> PTR12 3176efe6daSYannick Cote$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR12 = PTR13 3276efe6daSYannick Cote$MOD_TEST: shadow_ctor: PTR16 -> PTR15 3376efe6daSYannick Cote$MOD_TEST: klp_shadow_alloc(obj=PTR14, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR15 = PTR16 3476efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR3 3576efe6daSYannick Cote$MOD_TEST: got expected PTR3 -> PTR2 result 3676efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR6 3776efe6daSYannick Cote$MOD_TEST: got expected PTR6 -> PTR5 result 38a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR8 3976efe6daSYannick Cote$MOD_TEST: got expected PTR8 -> PTR7 result 4076efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR11 4176efe6daSYannick Cote$MOD_TEST: got expected PTR11 -> PTR10 result 4276efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234) = PTR13 4376efe6daSYannick Cote$MOD_TEST: got expected PTR13 -> PTR12 result 4476efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR16 4576efe6daSYannick Cote$MOD_TEST: got expected PTR16 -> PTR15 result 4676efe6daSYannick Cote$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR2 = PTR3 4776efe6daSYannick Cote$MOD_TEST: got expected PTR3 -> PTR2 result 4876efe6daSYannick Cote$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR7 = PTR8 4976efe6daSYannick Cote$MOD_TEST: got expected PTR8 -> PTR7 result 5076efe6daSYannick Cote$MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR12 = PTR13 5176efe6daSYannick Cote$MOD_TEST: got expected PTR13 -> PTR12 result 5276efe6daSYannick Cote$MOD_TEST: shadow_dtor(obj=PTR1, shadow_data=PTR3) 5376efe6daSYannick Cote$MOD_TEST: klp_shadow_free(obj=PTR1, id=0x1234, dtor=PTR17) 5476efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR0 55a2818ee4SJoe Lawrence$MOD_TEST: got expected NULL result 56a2818ee4SJoe Lawrence$MOD_TEST: shadow_dtor(obj=PTR9, shadow_data=PTR8) 5776efe6daSYannick Cote$MOD_TEST: klp_shadow_free(obj=PTR9, id=0x1234, dtor=PTR17) 58a2818ee4SJoe Lawrence$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR0 59a2818ee4SJoe Lawrence$MOD_TEST: got expected NULL result 6076efe6daSYannick Cote$MOD_TEST: shadow_dtor(obj=PTR14, shadow_data=PTR13) 6176efe6daSYannick Cote$MOD_TEST: klp_shadow_free(obj=PTR14, id=0x1234, dtor=PTR17) 6276efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234) = PTR0 63a2818ee4SJoe Lawrence$MOD_TEST: got expected NULL result 6476efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR6 6576efe6daSYannick Cote$MOD_TEST: got expected PTR6 -> PTR5 result 6676efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR11 6776efe6daSYannick Cote$MOD_TEST: got expected PTR11 -> PTR10 result 6876efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR16 6976efe6daSYannick Cote$MOD_TEST: got expected PTR16 -> PTR15 result 7076efe6daSYannick Cote$MOD_TEST: klp_shadow_free_all(id=0x1235, dtor=PTR0) 7176efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR0 7276efe6daSYannick Cote$MOD_TEST: got expected NULL result 7376efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR0 7476efe6daSYannick Cote$MOD_TEST: got expected NULL result 7576efe6daSYannick Cote$MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR0 7676efe6daSYannick Cote$MOD_TEST: got expected NULL result 7776efe6daSYannick Cote% rmmod $MOD_TEST" 78a2818ee4SJoe Lawrence 79a2818ee4SJoe Lawrenceexit 0 80