From fe25b3bcb6dc112378b90b8414db6bcbe31e50c5 Mon Sep 17 00:00:00 2001 From: Arpad Kovacs Date: Sat, 13 Mar 2021 17:48:44 -0800 Subject: [PATCH 1/4] Fix duplicate symbol: mword16 error which occurs with modern compilers (GCC10, LLVM/Clang 11) --- tests.c | 3 +++ types.h | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests.c b/tests.c index be1b350..d793846 100644 --- a/tests.c +++ b/tests.c @@ -27,6 +27,9 @@ char progress[] = "-\\|/"; #define PROGRESSOFTEN 2500 #define ONE 0x00000001L +union mword8_type mword8; +union mword16_type mword16; + /* Function definitions. */ int compare_regions(ulv *bufa, ulv *bufb, size_t count) { diff --git a/types.h b/types.h index ad7ce73..7ddae07 100644 --- a/types.h +++ b/types.h @@ -25,12 +25,12 @@ struct test { int (*fp)(); }; -union { +union mword8_type { unsigned char bytes[UL_LEN/8]; ul val; -} mword8; +}; -union { +union mword16_type { unsigned short u16s[UL_LEN/16]; ul val; -} mword16; +}; From f5573830c223a3aa6742c5c44c8f5fe7ea3381df Mon Sep 17 00:00:00 2001 From: Arpad Kovacs Date: Sat, 13 Mar 2021 17:55:55 -0800 Subject: [PATCH 2/4] Move code into jni/ directory to conform with ndk-build's expected filesystem structure --- Android.mk => jni/Android.mk | 0 Makefile => jni/Makefile | 0 conf-cc => jni/conf-cc | 0 conf-ld => jni/conf-ld | 0 extra-libs.sh => jni/extra-libs.sh | 0 find-systype.sh => jni/find-systype.sh | 0 make-compile.sh => jni/make-compile.sh | 0 make-load.sh => jni/make-load.sh | 0 make-makelib.sh => jni/make-makelib.sh | 0 memtester.8 => jni/memtester.8 | 0 memtester.c => jni/memtester.c | 0 memtester.h => jni/memtester.h | 0 sizes.h => jni/sizes.h | 0 tests.c => jni/tests.c | 0 tests.h => jni/tests.h | 0 trycpp.c => jni/trycpp.c | 0 types.h => jni/types.h | 0 warn-auto.sh => jni/warn-auto.sh | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename Android.mk => jni/Android.mk (100%) rename Makefile => jni/Makefile (100%) rename conf-cc => jni/conf-cc (100%) rename conf-ld => jni/conf-ld (100%) rename extra-libs.sh => jni/extra-libs.sh (100%) rename find-systype.sh => jni/find-systype.sh (100%) rename make-compile.sh => jni/make-compile.sh (100%) rename make-load.sh => jni/make-load.sh (100%) rename make-makelib.sh => jni/make-makelib.sh (100%) rename memtester.8 => jni/memtester.8 (100%) rename memtester.c => jni/memtester.c (100%) rename memtester.h => jni/memtester.h (100%) rename sizes.h => jni/sizes.h (100%) rename tests.c => jni/tests.c (100%) rename tests.h => jni/tests.h (100%) rename trycpp.c => jni/trycpp.c (100%) rename types.h => jni/types.h (100%) rename warn-auto.sh => jni/warn-auto.sh (100%) diff --git a/Android.mk b/jni/Android.mk similarity index 100% rename from Android.mk rename to jni/Android.mk diff --git a/Makefile b/jni/Makefile similarity index 100% rename from Makefile rename to jni/Makefile diff --git a/conf-cc b/jni/conf-cc similarity index 100% rename from conf-cc rename to jni/conf-cc diff --git a/conf-ld b/jni/conf-ld similarity index 100% rename from conf-ld rename to jni/conf-ld diff --git a/extra-libs.sh b/jni/extra-libs.sh similarity index 100% rename from extra-libs.sh rename to jni/extra-libs.sh diff --git a/find-systype.sh b/jni/find-systype.sh similarity index 100% rename from find-systype.sh rename to jni/find-systype.sh diff --git a/make-compile.sh b/jni/make-compile.sh similarity index 100% rename from make-compile.sh rename to jni/make-compile.sh diff --git a/make-load.sh b/jni/make-load.sh similarity index 100% rename from make-load.sh rename to jni/make-load.sh diff --git a/make-makelib.sh b/jni/make-makelib.sh similarity index 100% rename from make-makelib.sh rename to jni/make-makelib.sh diff --git a/memtester.8 b/jni/memtester.8 similarity index 100% rename from memtester.8 rename to jni/memtester.8 diff --git a/memtester.c b/jni/memtester.c similarity index 100% rename from memtester.c rename to jni/memtester.c diff --git a/memtester.h b/jni/memtester.h similarity index 100% rename from memtester.h rename to jni/memtester.h diff --git a/sizes.h b/jni/sizes.h similarity index 100% rename from sizes.h rename to jni/sizes.h diff --git a/tests.c b/jni/tests.c similarity index 100% rename from tests.c rename to jni/tests.c diff --git a/tests.h b/jni/tests.h similarity index 100% rename from tests.h rename to jni/tests.h diff --git a/trycpp.c b/jni/trycpp.c similarity index 100% rename from trycpp.c rename to jni/trycpp.c diff --git a/types.h b/jni/types.h similarity index 100% rename from types.h rename to jni/types.h diff --git a/warn-auto.sh b/jni/warn-auto.sh similarity index 100% rename from warn-auto.sh rename to jni/warn-auto.sh From b87740c8366d534d405bcd2e00e58a1b6bc7d86f Mon Sep 17 00:00:00 2001 From: Arpad Kovacs Date: Sat, 13 Mar 2021 19:04:23 -0800 Subject: [PATCH 3/4] Add instructions for building memtester as a standalone binary using ndk-build --- README | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/README b/README index 578741c..68baee6 100644 --- a/README +++ b/README @@ -1,12 +1,57 @@ +Modified from https://github.com/royzhao/memtester4Android.git to build +using `ndk-build` without any dependencies other than Android NDK. + +This is based on memtester version 4.3.0, tested on 32-bit ARM (armeabi-v7a). +Requires root to test more than 64MB of memory. + +## Prerequisites + +Install Android NDK. The easiest way to do this is: + +1. [Install Android Studio](https://developer.android.com/studio/install). + +2. Open Android Studio, and under Configure or Tools, open the SDK Manager. + +3. Under Appearance and Behavior > System Settings > Android SDK, click on + the SDK Tools tab. + +4. Note the Android SDK Location (you will need this path later, typically it + will be ~/Android/Sdk), and make sure that it doesn't contain spaces. + +5. Tick the checkbox next to NDK (Side by side) and Apply. + +6. Accept the EULAs and install the NDK (default path is ~/Android/Sdk/ndk/). + ===================================== -usage: - cd android/ - source ./build/envsetup.sh - lunch xx - cd android/external/ - git clone https://github.com/royzhao/memtester4Android.git + +Usage: + # Clone this repository. + git clone https://github.com/akovacs/memtester4Android cd memtester4Android - mm + + # Make sure there are no spaces in the path to this directory: + pwd + + # Configure environment variables + export NDK_PROJECT_PATH=`pwd` + export APP_PLATFORM=android-16 + + # Compile the binary using your version of the Android NDK's ndk-build + # Path to ndk-build within the Android SDK Location you recorded earlier + ~/Android/Sdk/ndk/23.0.7123448/ndk-build . + + # Push the appropriate binary to your device (here I'm using 32-bit ARM) + # You can also use arm64-v8a for 64-bit ARM, or x86 + adb push libs/armeabi-v7a/memtester /data/local/tmp/ + adb shell chmod 777 /data/local/tmp/memtester + + # Open an adb shell into your device + adb shell + # Run as root, otherwise you will be limited to testing only 64MB memory + su + # Acquire and test 600MB of memory, run 3 loops + /data/local/tmp/memtester 600M 3 + ===================================== memtester From 0b10242271d5bd35b3f27a7a940834a55d61842d Mon Sep 17 00:00:00 2001 From: Arpad Kovacs Date: Sat, 13 Mar 2021 19:06:39 -0800 Subject: [PATCH 4/4] Compile as a statically-linked standalone binary --- jni/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/jni/Android.mk b/jni/Android.mk index f1d211b..627aa73 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -5,6 +5,7 @@ LOCAL_SRC_FILES:= \ LOCAL_MODULE:= memtester LOCAL_MODULE_FILENAME:=memtester LOCAL_C_INCLUDES:=$(LOCAL_PATH) +LOCAL_LDFLAGS := -static #LOCAL_C_INCLUDES := #LOCAL_STATIC_LIBRARIES := #LOCAL_SHARED_LIBRARIES :=