diff mbox series

[testsuite] tests/binder: Adjust kernel uapi headers check for building

Message ID 20220209114242.2229-1-gongruiqi1@huawei.com (mailing list archive)
State Accepted
Delegated to: Ondrej Mosnáček
Headers show
Series [testsuite] tests/binder: Adjust kernel uapi headers check for building | expand

Commit Message

GONG, Ruiqi Feb. 9, 2022, 11:42 a.m. UTC
Following compilation errors occur when building the tests with
userspace headers exported from kernel 4.4:

binder_common.c:111:14: error: ‘const struct flat_binder_object’ has no
member named ‘hdr’
   switch (obj->hdr.type) {
              ^
client.c:58:9: error: dereferencing pointer to incomplete type
  if (obj->hdr.type != BINDER_TYPE_FD) {
         ^

It's been checked that member `hdr` of `struct flat_binder_object` and
`struct binder_fd_object` were both introduced into kernel 4.11 by the
same commit feba3900cabb ("binder: Split flat_binder_object"). Change
the check to <linux/android/binder.h> before building binder tests to
see if it contains the definition of `struct binder_fd_object`.

Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
 tests/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ondrej Mosnacek Feb. 9, 2022, 7:28 p.m. UTC | #1
On Wed, Feb 9, 2022 at 12:22 PM GONG, Ruiqi <gongruiqi1@huawei.com> wrote:
> Following compilation errors occur when building the tests with
> userspace headers exported from kernel 4.4:
>
> binder_common.c:111:14: error: ‘const struct flat_binder_object’ has no
> member named ‘hdr’
>    switch (obj->hdr.type) {
>               ^
> client.c:58:9: error: dereferencing pointer to incomplete type
>   if (obj->hdr.type != BINDER_TYPE_FD) {
>          ^
>
> It's been checked that member `hdr` of `struct flat_binder_object` and
> `struct binder_fd_object` were both introduced into kernel 4.11 by the
> same commit feba3900cabb ("binder: Split flat_binder_object"). Change
> the check to <linux/android/binder.h> before building binder tests to
> see if it contains the definition of `struct binder_fd_object`.
>
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
> ---
>  tests/Makefile | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tests/Makefile b/tests/Makefile
> index 3f7cae3..273eed8 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -53,9 +53,11 @@ ifeq ($(shell grep -q getrlimit $(POLDEV)/include/support/all_perms.spt && echo
>  SUBDIRS += prlimit
>  endif
>
> -ifeq ($(shell grep -q binder $(POLDEV)/include/support/all_perms.spt && test -e $(INCLUDEDIR)/linux/android/binder.h && echo true),true)
> +ifeq ($(shell grep -q binder $(POLDEV)/include/support/all_perms.spt && echo true),true)
> +ifeq ($(shell grep -q 'struct binder_fd_object' $(INCLUDEDIR)/linux/android/binder.h && echo true),true)
>  SUBDIRS += binder
>  endif
> +endif
>
>  ifeq ($(shell grep -q bpf $(POLDEV)/include/support/all_perms.spt && echo true),true)
>  ifneq ($(shell ./kvercmp $$(uname -r) 4.15),-1)
> --
> 2.18.0.huawei.25
>

Thanks, the patch is now applied:
https://github.com/SELinuxProject/selinux-testsuite/commit/04382a411d113353c3bd7b6a1d7cbb0ac050d62c

I just added -s to the grep invocation so that it doesn't print an
error when the file doesn't exist, as done by other similar checks.
diff mbox series

Patch

diff --git a/tests/Makefile b/tests/Makefile
index 3f7cae3..273eed8 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -53,9 +53,11 @@  ifeq ($(shell grep -q getrlimit $(POLDEV)/include/support/all_perms.spt && echo
 SUBDIRS += prlimit
 endif
 
-ifeq ($(shell grep -q binder $(POLDEV)/include/support/all_perms.spt && test -e $(INCLUDEDIR)/linux/android/binder.h && echo true),true)
+ifeq ($(shell grep -q binder $(POLDEV)/include/support/all_perms.spt && echo true),true)
+ifeq ($(shell grep -q 'struct binder_fd_object' $(INCLUDEDIR)/linux/android/binder.h && echo true),true)
 SUBDIRS += binder
 endif
+endif
 
 ifeq ($(shell grep -q bpf $(POLDEV)/include/support/all_perms.spt && echo true),true)
 ifneq ($(shell ./kvercmp $$(uname -r) 4.15),-1)