Skip to contentSkip to conversation

Build android fixes

PATCH New Petr Vorel 5 participants 13 messages Jan 30, 2019 – Feb 5, 2019 Library code

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover Build android fixes

Hi,

some obvious failures for Android.

Kind regards,
Petr

Petr Vorel (3):
lib: Add missing <string.h> and <strings.h> includes lib/tst_kernel.c: Use <sys/personality.h>
lib: Build tst_path_has_mnt_flags.c also on Android

 lib/Makefile                         | 2 +-
 lib/newlib_tests/tst_strstatus.c     | 1 +
 lib/tst_kconfig.c                    | 1 +
 lib/tst_kernel.c                     | 2 +-
 lib/tst_sys_conf.c                   | 1 +
 lib/tst_timer_test.c                 | 1 +
 utils/sctp/func_tests/test_getname.c | 1 +
 7 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/3 lib: Add missing <string.h> and <strings.h> includes

---
 lib/newlib_tests/tst_strstatus.c     | 1 +
 lib/tst_kconfig.c                    | 1 +
 lib/tst_sys_conf.c                   | 1 +
 lib/tst_timer_test.c                 | 1 +
 utils/sctp/func_tests/test_getname.c | 1 +
 5 files changed, 5 insertions(+)
lib/newlib_tests/tst_strstatus.c +1 -0
index b35ea8ce3..ca6be49cc 100644
@@ -20,6 +20,7 @@
  * Basic unit test for the tst_strstatus() function.
  */
 
+#include <string.h>
 #include "tst_test.h"
 
 static struct tcase {
lib/tst_kconfig.c +1 -0
index 3683f48c4..4b51413e5 100644
@@ -5,6 +5,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <ctype.h>
 #include <sys/utsname.h>
 
lib/tst_sys_conf.c +1 -0
index 9eccfbd55..e767856ec 100644
@@ -7,6 +7,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <string.h>
 
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
lib/tst_timer_test.c +1 -0
index 2aa27920e..8ad831cab 100644
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <limits.h>
+#include <string.h>
 
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
utils/sctp/func_tests/test_getname.c +1 -0
index 0d4d080d2..ffc47357c 100644
@@ -41,6 +41,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH 2/3 lib/tst_kernel.c: Use <sys/personality.h>

In reply to Petr Vorel

personality() has been defined in <sys/personality.h> since glibc 2.3 (long enough to be used).

This fixes build on Android.

---
 lib/tst_kernel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tst_kernel.c +1 -1
index a7fd38b4d..73ab9f1b1 100644
@@ -15,7 +15,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <linux/personality.h>
+#include <sys/personality.h>
 #include <sys/utsname.h>
 #include "test.h"
 #include "tst_kernel.h"
Signature · 1 line
2.20.1
author
#3 lore raw

PATCH 3/3 lib: Build tst_path_has_mnt_flags.c also on Android

In reply to Petr Vorel

This fixes android build, as since 7313a879d7 is needed in library:
tst_test.c:737: error: undefined reference to 'tst_path_has_mnt_flags_'

Fixes 7313a879d7 ("lib/tst_test.c: Add .needs_devfs flag")
---
 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Makefile +1 -1
index 4ab7c394a..e7fc753da 100644
@@ -29,7 +29,7 @@ CFLAGS			+= -I. -DLTPLIB
 ifneq ($(ANDROID),1)
 FILTER_OUT_DIRS		+= android_libpthread android_librt
 else
-FILTER_OUT_LIBSRCS	+= tlibio.c tst_path_has_mnt_flags.c tst_safe_sysv_ipc.c
+FILTER_OUT_LIBSRCS	+= tlibio.c tst_safe_sysv_ipc.c
 endif
 
 LIB			:= libltp.a
Signature · 1 line
2.20.1
#4 lore raw

cover Build android fixes

In reply to Petr Vorel

----- Original Message -----

Quoted 3 lines

Hi,

some obvious failures for Android.

ack

Quoted 25 lines

Kind regards,
Petr

Petr Vorel (3):
lib: Add missing <string.h> and <strings.h> includes lib/tst_kernel.c: Use <sys/personality.h>
lib: Build tst_path_has_mnt_flags.c also on Android

 lib/Makefile                         | 2 +-
 lib/newlib_tests/tst_strstatus.c     | 1 +
 lib/tst_kconfig.c                    | 1 +
 lib/tst_kernel.c                     | 2 +-
 lib/tst_sys_conf.c                   | 1 +
 lib/tst_timer_test.c                 | 1 +
 utils/sctp/func_tests/test_getname.c | 1 +
 7 files changed, 7 insertions(+), 2 deletions(-)

--
2.20.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

author
#5 lore raw

cover Build android fixes

Hi Jan,

Quoted 3 lines
Quoted 1 line

some obvious failures for Android.

ack

Thanks a lot for review, merged with your ack.

Kind regards,
Petr

#6 lore raw

cover Build android fixes

In reply to Petr Vorel

Hi Petr,

Quoted 10 lines · Petr Vorel

some obvious failures for Android.

Kind regards,
Petr

Petr Vorel (3):
lib: Add missing <string.h> and <strings.h> includes lib/tst_kernel.c: Use <sys/personality.h>
lib: Build tst_path_has_mnt_flags.c also on Android

Quoted 8 lines
  lib/Makefile                         | 2 +-
  lib/newlib_tests/tst_strstatus.c     | 1 +
  lib/tst_kconfig.c                    | 1 +
  lib/tst_kernel.c                     | 2 +-
  lib/tst_sys_conf.c                   | 1 +
  lib/tst_timer_test.c                 | 1 +
  utils/sctp/func_tests/test_getname.c | 1 +
  7 files changed, 7 insertions(+), 2 deletions(-)

How did you come across these issues? We have yet to see them. Did you merge tip of LTP into an Android AOSP tree and build it that way?

thanks,
Steve

author
#7 lore raw

cover Build android fixes

Hi Steve,

Quoted 2 lines

How did you come across these issues? We have yet to see them. Did you merge tip of LTP into an Android AOSP tree and build it that way?

Any sane person who wants to tests Android kernel uses LTP build inside of AOSP to get all your custom (not yet upstreamed) fixes, skip non relevant test etc. But I don't want to store whole AOSP on my disc, so I tried to cross compile upstream LTP with android standalone toolchain (with make ANDROID=1).

Looking now, you're using lib/tst_safe_sysv_ipc.c in gen.bp and that was missing in our Makefile.

I thought you might not build tests needing includes, but you do. Do you pass some flag to compiler?

Compiler used:

$ ~/usr/android-standalone-toolchain.api-27/bin/arm-linux-androideabi-gcc --version
Android (5058415 based on r339409) clang version 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec746213857d083c0e8b0abb568790) (https://android.googlesource.com/toolchain/llvm 7a6618d69e7e8111e1d49dc9e7813767c5ca756a) (based on LLVM 8.0.2svn)
Target: armv7a-unknown-linux-android27
Thread model: posix
InstalledDir: ~/usr/android-standalone-toolchain.api-27/bin

Kind regards,
Petr

#8 lore raw

cover Build android fixes

Quoted 8 lines · Petr Vorel

Hi Steve,

Quoted 2 lines

How did you come across these issues? We have yet to see them. Did you merge tip of LTP into an Android AOSP tree and build it that way?

Any sane person who wants to tests Android kernel uses LTP build inside of AOSP to get all your custom (not yet upstreamed) fixes, skip non relevant test etc. But I don't want to store whole AOSP on my disc, so I tried to cross compile upstream LTP with android standalone toolchain (with make ANDROID=1).

That is correct and I really want to be able to do the same. Admittedly the current AOSP LTP build is "meant for the harness it normally runs under". It really should not be the case and we'd love for AOSP LTP to build standalone.

I think I asked about the "make ANDROID" option a while ago and my understanding was that its building LTP against the Android NDK. Steve, may be this is the path we go? I do remember however that with that build, the number of tests that we can build against Android was far less than what we do right now (haven't tried in a while though).

Also, FWIW, there are almost zero non-upstream tests in AOSP LTP. I can only think of one test suite but that is just very *android specific* and still being worked on.

- ssp

#9 lore raw

cover Build android fixes

Quoted 5 lines · Sandeep Patil

I think I asked about the "make ANDROID" option a while ago and my understanding was that its building LTP against the Android NDK. Steve, may be this is the path we go? I do remember however that with that build, the number of tests that we can build against Android was far less than what we do right now (haven't tried in a while though).

Seems worth a try. Offhand I'm not sure why this should enable fewer tests than building it as part of aosp...

Quoted 3 lines

Also, FWIW, there are almost zero non-upstream tests in AOSP LTP. I can only think of one test suite but that is just very *android specific* and still being worked on.

Is this by chance the eas test suite you're referring to? Despite the name there are eight or so generic scheduler/cpufreq tests that should be fairly upstream-ready, it's just blocked on me getting time to send them upstream for review and work on feedback. Other tests which are specific to EAS need some review to determine how applicable they are to the upstream kernel.

If anyone wants to poke around and look at these they are here:

https://android.googlesource.com/platform/external/ltp/+/master/testcases/kernel/sched/eas/

cheers,
Steve

#10 lore raw

cover Build android fixes

In reply to Sandeep Patil

Hi Sandeep,

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

How did you come across these issues? We have yet to see them. Did you merge tip of LTP into an Android AOSP tree and build it that way?

Any sane person who wants to tests Android kernel uses LTP build inside of AOSP to get all your custom (not yet upstreamed) fixes, skip non relevant test etc. But I don't want to store whole AOSP on my disc, so I tried to cross compile upstream LTP with android standalone toolchain (with make ANDROID=1).

That is correct and I really want to be able to do the same. Admittedly the current AOSP LTP build is "meant for the harness it normally runs under". It really should not be the case and we'd love for AOSP LTP to build standalone.

Great :). I see your bionic-compat.h can handle some errors (e.g. missing getdtablesize(void)). Since we have already some support, this could be probably merged (assuming Cyril is not against).

That layer allows you to build more tests than it's currently allowed in our Makefiles (we filter quite a lot syscalls).

Quoted 5 lines

I think I asked about the "make ANDROID" option a while ago and my understanding was that its building LTP against the Android NDK. Steve, may be this is the path we go? I do remember however that with that build, the number of tests that we can build against Android was far less than what we do right now (haven't tried in a while though).

I do build with configure --host triplet add --with-sysroot and SYSROOT
+ add -I and -L flags to sysroot dirs to CFLAGS and LDFLAGS.
But this way autoconf does detect wrongly some options (at least HAVE_PREADV and HAVE_PWRITEV).

BTW which compiler option allows you to ignore missing <string.h> and <strings.h> ?

Quoted 1 line

Also, FWIW, there are almost zero non-upstream tests in AOSP LTP.

Great!

Quoted 5 lines

I can only
think of one test suite but that is just very *android specific* and still being worked on.

- ssp

Kind regards,
Petr

#11 lore raw

cover Build android fixes

Hi Petr,

Quoted 2 lines · Petr Vorel

BTW which compiler option allows you to ignore missing <string.h> and <strings.h> ?

The AOSP build is providing the bionic headers (which include string.h and strings.h) to LTP. Here's a full build command for a single LTP test, note the instances of bionic/libc/include:

[745/781] PWD=/proc/self/cwd
prebuilts/clang/host/linux-x86/clang-r346389c/bin/clang -c
-Wno-null-pointer-arithmetic -Wno-null-dereference
-Iexternal/ltp/android/include -Iexternal/ltp/include
-Iexternal/ltp/include/old -Iexternal/ltp
-Werror=implicit-function-declaration -DANDROID -fmessage-length=0 -W
-Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes
-DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g
-fno-strict-aliasing -fdebug-prefix-map=/proc/self/cwd=
-D__compiler_offsetof=__builtin_offsetof -Wimplicit-fallthrough
-Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic
-Wno-unused-command-line-argument -fcolor-diagnostics
-Wno-zero-as-null-pointer-constant -Wno-sign-compare
-Wno-defaulted-function-deleted -ffunction-sections -fdata-sections
-fno-short-enums -funwind-tables -fstack-protector-strong
-Wa,--noexecstack -D_FORTIFY_SOURCE=2 -Wstrict-aliasing=2
-Werror=return-type -Werror=non-virtual-dtor -Werror=address
-Werror=sequence-point -Werror=date-time -Werror=format-security
-nostdlibinc -march=armv8-a -Iexternal/libcap/libcap/include
-Iexternal/selinux/libselinux/include -Isystem/core/libasyncio/include
-Iexternal/libcxx/include -Iexternal/libcxxabi/include
-Ibionic/libc/include -D__LIBC_API__=10000 -D__LIBM_API__=10000
-D__LIBDL_API__=10000
-Iout/soong/.intermediates/external/ltp/ltp_syscalls_h/gen
-Isystem/core/include -Isystem/media/audio/include
-Ihardware/libhardware/include -Ihardware/libhardware_legacy/include
-Ihardware/ril/include -Iframeworks/native/include
-Iframeworks/native/opengl/include -Iframeworks/av/include -isystem
bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem
bionic/libc/kernel/uapi/asm-arm64 -isystem
bionic/libc/kernel/android/scsi -isystem bionic/libc/kernel/android/uapi
-Ilibnativehelper/include_jni -include bionic-compat.h -Wall -Werror
-Wno-error=absolute-value -Wno-error=undefined-internal
-Wno-error=uninitialized -Wno-error=user-defined-warnings
-Wno-constant-conversion -Wno-deprecated -Wno-duplicate-decl-specifier
-Wno-empty-body -Wno-format -Wno-gnu-designator
-Wno-implicit-function-declaration
-Wno-incompatible-pointer-types-discards-qualifiers
-Wno-knr-promoted-parameter -Wno-macro-redefined -Wno-missing-braces
-Wno-missing-field-initializers -Wno-parentheses-equality
-Wno-pointer-arith -Wno-pointer-sign -Wno-sign-compare
-Wno-tautological-compare -Wno-unneeded-internal-declaration
-Wno-unused-function -Wno-unused-parameter -Wno-unused-variable
-D_FORTIFY_SOURCE=2 -target aarch64-linux-android -Bprebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin
-fPIE -D_USING_LIBCXX -std=gnu99 -Werror=int-to-pointer-cast
-Werror=pointer-to-int-cast -Werror=address-of-temporary
-Werror=return-type -Wno-tautological-constant-compare
-Wno-tautological-type-limit-compare
-Wno-tautological-unsigned-enum-zero-compare
-Wno-tautological-unsigned-zero-compare -Wno-enum-compare
-Wno-enum-compare-switch -Wno-c++98-compat-extra-semi
-Wno-return-std-move-in-c++11 -MD -MF out/soong/.intermediates/external/ltp/ltp_ustat01/android_arm64_armv8-a_core/obj/external/ltp/testcases/kernel/syscalls/ustat/ustat01.o.d -o out/soong/.intermediates/external/ltp/ltp_ustat01/android_arm64_armv8-a_core/obj/external/ltp/testcases/kernel/syscalls/ustat/ustat01.o external/ltp/testcases/kernel/syscalls/ustat/ustat01.c

cheers,
steve

#12 lore raw

cover Build android fixes

In reply to Petr Vorel
Quoted 15 lines · Petr Vorel

Hi Steve,

Quoted 2 lines

How did you come across these issues? We have yet to see them. Did you merge tip of LTP into an Android AOSP tree and build it that way?

Any sane person who wants to tests Android kernel uses LTP build inside of AOSP to get all your custom (not yet upstreamed) fixes, skip non relevant test etc. But I don't want to store whole AOSP on my disc, so I tried to cross compile upstream LTP with android standalone toolchain (with make ANDROID=1).

Looking now, you're using lib/tst_safe_sysv_ipc.c in gen.bp and that was missing in our Makefile.

I thought you might not build tests needing includes, but you do. Do you pass some flag to compiler?

Quoted 7 lines

Compiler used:

$ ~/usr/android-standalone-toolchain.api-27/bin/arm-linux-androideabi-gcc --version
Android (5058415 based on r339409) clang version 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec746213857d083c0e8b0abb568790) (https://android.googlesource.com/toolchain/llvm 7a6618d69e7e8111e1d49dc9e7813767c5ca756a) (based on LLVM 8.0.2svn)
Target: armv7a-unknown-linux-android27
Thread model: posix
InstalledDir: ~/usr/android-standalone-toolchain.api-27/bin

Thanks. Yes include directories are specified both in gen.bp and also in Android.bp at the top level of our LTP repo.

cheers,
Steve