diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-02-22 18:29:20 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-02-23 01:05:00 +0000 |
commit | b2a2a0bbc7c3aac655bc9efc1c8f385adfe90a3f (patch) | |
tree | aa371fe57a4859c18f61b3bead5f532f3d50437b | |
parent | 223745e0782602c780c0d66b0c342750fdbd58db (diff) |
Link all tests to the android cpufeatures library if available.
This is needed for libvpx to work on android.
This also means that we can upload our test binaries to an android device
and actually run them, now that libcheck is no longer a blocker.
-rw-r--r-- | CMakeLists.txt | 37 | ||||
-rw-r--r-- | auto_tests/file_saving_test.c | 4 | ||||
-rw-r--r-- | other/cpufeatures.c | 6 |
3 files changed, 32 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d14538d1..2f46824d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -438,9 +438,22 @@ elseif(FORMAT_TEST) | |||
438 | message(FATAL_ERROR "format_test can not be run, because ASTYLE (${ASTYLE}) could not be found") | 438 | message(FATAL_ERROR "format_test can not be run, because ASTYLE (${ASTYLE}) could not be found") |
439 | endif() | 439 | endif() |
440 | 440 | ||
441 | if(ANDROID_CPU_FEATURES) | ||
442 | # We need to compile cpufeatures.c as many times as there are executables, | ||
443 | # because libvpx doesn't include it although it depends on it. We can't get | ||
444 | # the link ordering right in cmake, so we need to compile the cpufeatures | ||
445 | # library into every binary explicitly. | ||
446 | # | ||
447 | # The alternative is to #include the library in every main file, but I | ||
448 | # (@iphydf) felt that this solution was cleaner. | ||
449 | add_definitions(-DANDROID_CPU_FEATURES="${ANDROID_CPU_FEATURES}") | ||
450 | set(CPUFEATURES other/cpufeatures.c) | ||
451 | endif() | ||
452 | |||
441 | function(auto_test target) | 453 | function(auto_test target) |
442 | if(NOT (MSVC AND ARGV1 STREQUAL "MSVC_DONT_BUILD")) | 454 | if(NOT (MSVC AND ARGV1 STREQUAL "MSVC_DONT_BUILD")) |
443 | add_executable(auto_${target}_test auto_tests/${target}_test.c) | 455 | add_executable(auto_${target}_test ${CPUFEATURES} |
456 | auto_tests/${target}_test.c) | ||
444 | target_link_modules(auto_${target}_test toxcore) | 457 | target_link_modules(auto_${target}_test toxcore) |
445 | if(NOT ARGV1 STREQUAL "DONT_RUN") | 458 | if(NOT ARGV1 STREQUAL "DONT_RUN") |
446 | add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test) | 459 | add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test) |
@@ -451,15 +464,10 @@ endfunction() | |||
451 | 464 | ||
452 | if(BUILD_TOXAV) | 465 | if(BUILD_TOXAV) |
453 | add_definitions(-D__STDC_LIMIT_MACROS=1) | 466 | add_definitions(-D__STDC_LIMIT_MACROS=1) |
454 | add_executable(auto_monolith_test | 467 | add_executable(auto_monolith_test ${CPUFEATURES} |
455 | auto_tests/monolith_test.cpp | 468 | auto_tests/monolith_test.cpp) |
456 | ${ANDROID_CPU_FEATURES}) | ||
457 | target_link_libraries(auto_monolith_test ${toxcore_LINK_MODULES}) | 469 | target_link_libraries(auto_monolith_test ${toxcore_LINK_MODULES}) |
458 | add_test(NAME monolith COMMAND ${CROSSCOMPILING_EMULATOR} auto_monolith_test) | 470 | add_test(NAME monolith COMMAND ${CROSSCOMPILING_EMULATOR} auto_monolith_test) |
459 | |||
460 | if(ANDROID_CPU_FEATURES) | ||
461 | target_compile_definitions(auto_monolith_test PRIVATE -Dtypeof=__typeof__) | ||
462 | endif() | ||
463 | endif() | 471 | endif() |
464 | 472 | ||
465 | auto_test(TCP) | 473 | auto_test(TCP) |
@@ -509,7 +517,7 @@ endif() | |||
509 | 517 | ||
510 | option(DHT_BOOTSTRAP "Enable building of DHT_bootstrap" ON) | 518 | option(DHT_BOOTSTRAP "Enable building of DHT_bootstrap" ON) |
511 | if(DHT_BOOTSTRAP) | 519 | if(DHT_BOOTSTRAP) |
512 | add_executable(DHT_bootstrap | 520 | add_executable(DHT_bootstrap ${CPUFEATURES} |
513 | other/DHT_bootstrap.c | 521 | other/DHT_bootstrap.c |
514 | other/bootstrap_node_packets.c) | 522 | other/bootstrap_node_packets.c) |
515 | target_link_modules(DHT_bootstrap toxcore) | 523 | target_link_modules(DHT_bootstrap toxcore) |
@@ -522,7 +530,7 @@ if(BOOTSTRAP_DAEMON AND WIN32) | |||
522 | endif() | 530 | endif() |
523 | if(BOOTSTRAP_DAEMON) | 531 | if(BOOTSTRAP_DAEMON) |
524 | if(LIBCONFIG_FOUND) | 532 | if(LIBCONFIG_FOUND) |
525 | add_executable(tox-bootstrapd | 533 | add_executable(tox-bootstrapd ${CPUFEATURES} |
526 | other/bootstrap_daemon/src/command_line_arguments.c | 534 | other/bootstrap_daemon/src/command_line_arguments.c |
527 | other/bootstrap_daemon/src/command_line_arguments.h | 535 | other/bootstrap_daemon/src/command_line_arguments.h |
528 | other/bootstrap_daemon/src/config.c | 536 | other/bootstrap_daemon/src/config.c |
@@ -553,7 +561,8 @@ option(BUILD_AV_TEST "Build toxav test" ON) | |||
553 | if(NOT WIN32 | 561 | if(NOT WIN32 |
554 | AND BUILD_AV_TEST AND BUILD_TOXAV | 562 | AND BUILD_AV_TEST AND BUILD_TOXAV |
555 | AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FOUND) | 563 | AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FOUND) |
556 | add_executable(av_test testing/av_test.c) | 564 | add_executable(av_test ${CPUFEATURES} |
565 | testing/av_test.c) | ||
557 | target_link_modules(av_test | 566 | target_link_modules(av_test |
558 | toxcore | 567 | toxcore |
559 | ${OPENCV_LIBRARIES} | 568 | ${OPENCV_LIBRARIES} |
@@ -566,8 +575,10 @@ if(NOT WIN32 | |||
566 | endif() | 575 | endif() |
567 | endif() | 576 | endif() |
568 | 577 | ||
569 | add_executable(DHT_test testing/DHT_test.c) | 578 | add_executable(DHT_test ${CPUFEATURES} |
579 | testing/DHT_test.c) | ||
570 | target_link_modules(DHT_test toxcore) | 580 | target_link_modules(DHT_test toxcore) |
571 | 581 | ||
572 | add_executable(Messenger_test testing/Messenger_test.c) | 582 | add_executable(Messenger_test ${CPUFEATURES} |
583 | testing/Messenger_test.c) | ||
573 | target_link_modules(Messenger_test toxcore) | 584 | target_link_modules(Messenger_test toxcore) |
diff --git a/auto_tests/file_saving_test.c b/auto_tests/file_saving_test.c index 11c81ad2..8aa14dc3 100644 --- a/auto_tests/file_saving_test.c +++ b/auto_tests/file_saving_test.c | |||
@@ -61,7 +61,7 @@ static void save_data_encrypted(void) | |||
61 | } | 61 | } |
62 | 62 | ||
63 | size_t written_value = fwrite(cipher, sizeof(*cipher), size, f); | 63 | size_t written_value = fwrite(cipher, sizeof(*cipher), size, f); |
64 | printf("written written_value = %li of %li\n", written_value, size); | 64 | printf("written written_value = %zu of %zu\n", written_value, size); |
65 | 65 | ||
66 | free(cipher); | 66 | free(cipher); |
67 | free(clear); | 67 | free(clear); |
@@ -79,7 +79,7 @@ static void load_data_decrypted(void) | |||
79 | uint8_t *cipher = (uint8_t *)malloc(size); | 79 | uint8_t *cipher = (uint8_t *)malloc(size); |
80 | uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH); | 80 | uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH); |
81 | size_t read_value = fread(cipher, sizeof(*cipher), size, f); | 81 | size_t read_value = fread(cipher, sizeof(*cipher), size, f); |
82 | printf("read read_vavue = %li of %li\n", read_value, size); | 82 | printf("read read_vavue = %zu of %ld\n", read_value, size); |
83 | 83 | ||
84 | TOX_ERR_DECRYPTION derr; | 84 | TOX_ERR_DECRYPTION derr; |
85 | 85 | ||
diff --git a/other/cpufeatures.c b/other/cpufeatures.c new file mode 100644 index 00000000..e52a90ff --- /dev/null +++ b/other/cpufeatures.c | |||
@@ -0,0 +1,6 @@ | |||
1 | #define typeof __typeof__ | ||
2 | #ifdef ANDROID_CPU_FEATURES | ||
3 | #include ANDROID_CPU_FEATURES | ||
4 | #endif | ||
5 | |||
6 | extern int unused_declaration; | ||