apparmor: test: make static symbols visible during kunit testing
authorRae Moar <rmoar@google.com>
Wed, 7 Dec 2022 01:40:24 +0000 (01:40 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:52:09 +0000 (11:52 +0100)
commitcef064fddee8d01c99cba67d9515a57f32ecf3d4
tree6f060147580a17a02c45f8f9686cf1fd1a9e8812
parentcfce1e26b4c93d0b850d3f2de1783ee049ffe870
apparmor: test: make static symbols visible during kunit testing

[ Upstream commit b11e51dd70947107fa4076c6286dce301671afc1 ]

Use macros, VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT, to allow
static symbols to be conditionally set to be visible during
apparmor_policy_unpack_test, which removes the need to include the testing
file in the implementation file.

Change the namespace of the symbols that are now conditionally visible (by
adding the prefix aa_) to avoid confusion with symbols of the same name.

Allow the test to be built as a module and namespace the module name from
policy_unpack_test to apparmor_policy_unpack_test to improve clarity of
the module name.

Provide an example of how static symbols can be dealt with in testing.

Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Stable-dep-of: 8884ba07786c ("apparmor: fix invalid reference on profile->disconnected")
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/apparmor/Kconfig
security/apparmor/Makefile
security/apparmor/include/policy_unpack.h
security/apparmor/policy_unpack.c
security/apparmor/policy_unpack_test.c