[test-android] those converted tests are now loaded and run (and fail hard).

This commit is contained in:
atsushieno 2021-06-11 20:47:35 +09:00
parent 12cc9ed74b
commit ecdae699da
9 changed files with 120 additions and 14 deletions

View file

@ -18,4 +18,4 @@ local.properties
app/src/main/cpp/include/
app/src/main/cpp/tests/
app/src/main/jniLibs/
test-names.txt

View file

@ -18,6 +18,7 @@ android {
externalNativeBuild {
cmake {
cppFlags ''
arguments '-DANDROID_STL=c++_shared'
}
}
}
@ -51,9 +52,9 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.+'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fluidsynth.fluidsynth_tests">
package="org.fluidsynth.fluidsynthtests">
<application
android:allowBackup="true"
@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fluidsynthtests">
<activity android:name=".MainActivity">
<activity android:name="org.fluidsynth.fluidsynthtests.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -31,8 +31,34 @@ add_library( # Sets the name of the library.
SHARED
# Provides a relative path to your source file(s).
${TEST_SRC_FILES}
${LINKED_OBJ_FILES}
tests/test_preset_pinning.c
tests/test_seq_event_queue_remove.c
tests/test_seq_scale.c
tests/test_jack_obtaining_synth.c
tests/test_settings_unregister_callback.c
tests/test_pointer_alignment.c
tests/test_sfont_zone.c
tests/test_utf8_open.c
tests/test_seqbind_unregister.c
tests/test_sf3_sfont_loading.c
tests/test_sample_cache.c
tests/test_synth_process.c
tests/test_ct2hz.c
tests/test_seq_evt_order.c
tests/test_snprintf.c
tests/test_seq_event_queue_sort.c
tests/test_sfont_loading.c
tests/test_preset_sample_loading.c
tests/test_sfont_unloading.c
tests/test_sample_rate_change.c
tests/test_sample_validate.c
tests/test_synth_chorus_reverb.c
tests/test_bug_635.c
run_all_tests.c
native-lib.cpp
)
target_include_directories(native-lib
@ -77,7 +103,7 @@ target_link_directories(native-lib
target_link_libraries(native-lib
${log-lib}
c++
c++_shared
gobject-2.0
glib-2.0
sndfile

View file

@ -1,10 +1,14 @@
#include <jni.h>
#include <string>
extern "C" int run_all_fluidsynth_tests();
extern "C" JNIEXPORT jstring JNICALL
Java_org_androidaudioplugin_fluidsynth_1tests_MainActivity_stringFromJNI(
Java_org_fluidsynth_fluidsynthtests_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
run_all_fluidsynth_tests();
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}

View file

@ -0,0 +1,51 @@
int preset_pinning_main();
int seq_event_queue_remove_main();
int seq_scale_main();
int jack_obtaining_synth_main();
int settings_unregister_callback_main();
int pointer_alignment_main();
int sfont_zone_main();
int utf8_open_main();
int seqbind_unregister_main();
int sf3_sfont_loading_main();
int sample_cache_main();
int synth_process_main();
int ct2hz_main();
int seq_evt_order_main();
int snprintf_main();
int seq_event_queue_sort_main();
int sfont_loading_main();
int preset_sample_loading_main();
int sfont_unloading_main();
int sample_rate_change_main();
int sample_validate_main();
int synth_chorus_reverb_main();
int bug_635_main();
int run_all_fluidsynth_tests() {
int ret = 0;
ret += preset_pinning_main();
ret += seq_event_queue_remove_main();
ret += seq_scale_main();
ret += jack_obtaining_synth_main();
ret += settings_unregister_callback_main();
ret += pointer_alignment_main();
ret += sfont_zone_main();
ret += utf8_open_main();
ret += seqbind_unregister_main();
ret += sf3_sfont_loading_main();
ret += sample_cache_main();
ret += synth_process_main();
ret += ct2hz_main();
ret += seq_evt_order_main();
ret += snprintf_main();
ret += seq_event_queue_sort_main();
ret += sfont_loading_main();
ret += preset_sample_loading_main();
ret += sfont_unloading_main();
ret += sample_rate_change_main();
ret += sample_validate_main();
ret += synth_chorus_reverb_main();
ret += bug_635_main();
return ret;
}

View file

@ -1,9 +1,8 @@
package org.fluidsynth.fluidsynth_tests
package org.fluidsynth.fluidsynthtests
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import org.fluidsynth.fluidsynth_tests.databinding.ActivityMainBinding
import org.fluidsynth.fluidsynthtests.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {

View file

@ -18,7 +18,6 @@ allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}

View file

@ -1,4 +1,30 @@
#!/bin/sh
for f in `grep -lR "int main(void)" ../test/` ; do export TESTMAINNAME=`echo $f | sed -e "s/\.\.\/test\/test_\(.*\).c$/\1/"` && sed -e "s/int main(void)/int "$TESTMAINNAME"_main(void)/" $f > app/src/main/cpp/tests/test_$TESTMAINNAME.c ; done
rm -f test-names.txt
for f in `grep -lR "int main(void)" ../test/` ; do
export TESTMAINNAME=`echo $f | sed -e "s/\.\.\/test\/test_\(.*\).c$/\1/"`
echo $TESTMAINNAME >> test-names.txt
export OUTPUTFILE=app/src/main/cpp/tests/test_${TESTMAINNAME}.c
sed -e "s/int main(void)/int "$TESTMAINNAME"_main(void)/" $f > $OUTPUTFILE ;
done
RUN_ALL_TESTS=app/src/main/cpp/run_all_tests.c
rm -f $RUN_ALL_TESTS
while IFS= read -r line; do
echo "int "$line"_main();" >> $RUN_ALL_TESTS ;
done < test-names.txt
echo "extern \"C\" {" >> $RUN_ALL_TESTS
echo "int run_all_fluidsynth_tests() {" >> $RUN_ALL_TESTS
echo " int ret = 0; " >> $RUN_ALL_TESTS
while IFS= read -r line; do
echo " ret += "$line"_main();" >> $RUN_ALL_TESTS ;
done < test-names.txt
echo " return ret;" >> $RUN_ALL_TESTS
echo "}" >> $RUN_ALL_TESTS
echo "}" >> $RUN_ALL_TESTS