From 5ed26fc5bdfdab0ff41a8861b54395c0bbbad248 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 4 Jan 2018 10:11:34 +0330 Subject: [cmake] Run src/ tests (#675) --- .circleci/config.yml | 9 ++++----- CMakeLists.txt | 35 ++++++++++++++++++++++++++++++++--- src/Makefile.am | 1 + src/check-defs.sh | 3 ++- src/check-libstdc++.sh | 3 ++- src/check-static-inits.sh | 3 ++- src/check-symbols.sh | 3 ++- 7 files changed, 45 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3ddc693b..93913a82 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,15 +52,14 @@ jobs: - run: ninja -Cbuild test - run: ninja -Cbuild install - distdir: + distcheck: docker: - image: dockcross/base steps: - checkout - run: apt update && apt install -y pkg-config ragel gtk-doc-tools libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev - - run: ./autogen.sh && make distdir - - run: cd harfbuzz-* && ./configure && make && make check && make install && make clean - - run: cd harfbuzz-* && cmake -DHB_HAVE_FREETYPE=ON -DHB_HAVE_GLIB=ON -DHB_BUILD_UTILS=ON -Bbuild -H. -GNinja && ninja -Cbuild && ninja -Cbuild test && ninja -Cbuild install + - run: ./autogen.sh && make distcheck + - run: make distdir && cd harfbuzz-* && cmake -DHB_HAVE_FREETYPE=ON -DHB_HAVE_GLIB=ON -DHB_BUILD_UTILS=ON -Bbuild -H. -GNinja && ninja -Cbuild && CTEST_OUTPUT_ON_FAILURE=1 ninja -Cbuild test && ninja -Cbuild install psvita: docker: @@ -144,7 +143,7 @@ workflows: - archlinux - freebsd9 - base - - distdir + - distcheck - psvita - android-arm - browser-asmjs diff --git a/CMakeLists.txt b/CMakeLists.txt index a24b136b..6fdcebda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ endif () include_directories(AFTER ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src - ) +) add_definitions(-DHAVE_OT) add_definitions(-DHAVE_FALLBACK) @@ -427,6 +427,7 @@ if (HB_HAVE_GOBJECT) ) endif () + ## Atomic ops availability detection file(WRITE "${PROJECT_BINARY_DIR}/try_compile_intel_atomic_primitives.c" " void memory_barrier (void) { __sync_synchronize (); } @@ -463,6 +464,7 @@ endif () add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers}) target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) + ## Define harfbuzz-gobject library if (HB_HAVE_GOBJECT) add_library(harfbuzz-gobject @@ -535,7 +537,7 @@ if (HB_HAVE_INTROSPECTION) ${hb_gobject_gen_headers} ${hb_gobject_sources} ${hb_gobject_headers} - ) + ) if (WIN32) # Nasty issue: We need to make drive letters lower case, # otherwise g-ir-scanner won't like it and give us a bunch @@ -599,6 +601,7 @@ if (HB_HAVE_INTROSPECTION) ) endif () + ## Additional framework build configs if (BUILD_FRAMEWORK) set (CMAKE_MACOSX_RPATH ON) @@ -687,7 +690,7 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) install(FILES "${hb_libpath}/HarfBuzz-0.0.gir" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0 - ) + ) install(FILES "${hb_libpath}/HarfBuzz-0.0.typelib" DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0 @@ -696,6 +699,32 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) endif () endif () + +## Tests +if (UNIX) + if (BUILD_SHARED_LIBS) + add_test(NAME check-static-inits.sh + COMMAND ${PROJECT_SOURCE_DIR}/src/check-static-inits.sh + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/CMakeFiles/harfbuzz.dir/src # hack + ) + # does some "make" stuff inside + # add_test(NAME check-defs.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-defs.sh) + add_test(NAME check-libstdc++.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-libstdc++.sh) + add_test(NAME check-symbols.sh COMMAND ${PROJECT_SOURCE_DIR}/src/check-symbols.sh) + else () + message(WARN "You can enable BUILD_SHARED_LIBS for more tests.") + endif () + + # disabled as it doesn't work anyway + if (OFF AND IN_HB_DIST) + add_test(NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) + add_test(NAME check-header-guards.sh COMMAND ./check-header-guards.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) + endif () + + add_test(NAME check-externs.sh COMMAND ./check-externs.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) + add_test(NAME check-includes.sh COMMAND ./check-includes.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) +endif () + # Needs to come last so that variables defined above are passed to # subdirectories. add_subdirectory(test) diff --git a/src/Makefile.am b/src/Makefile.am index 68571822..b34d9421 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -324,6 +324,7 @@ test_ot_tag_LDADD = libharfbuzz.la $(HBLIBS) TESTS = $(dist_check_SCRIPTS) $(check_PROGRAMS) TESTS_ENVIRONMENT = \ srcdir="$(srcdir)" \ + libs=".libs" \ MAKE="$(MAKE) $(AM_MAKEFLAGS)" \ HBSOURCES="$(HBSOURCES)" \ HBHEADERS="$(HBHEADERS) $(HBNODISTHEADERS)" \ diff --git a/src/check-defs.sh b/src/check-defs.sh index 480d4999..ee2cafed 100755 --- a/src/check-defs.sh +++ b/src/check-defs.sh @@ -4,6 +4,7 @@ LC_ALL=C export LC_ALL test -z "$srcdir" && srcdir=. +test -z "$libs" && libs=. test -z "$MAKE" && MAKE=make stat=0 @@ -19,7 +20,7 @@ $MAKE $defs > /dev/null tested=false for def in $defs; do lib=`echo "$def" | sed 's/[.]def$//;s@.*/@@'` - so=.libs/lib${lib}.so + so=$libs/lib${lib}.so EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| llvm_' | cut -d' ' -f3`" diff --git a/src/check-libstdc++.sh b/src/check-libstdc++.sh index b541828b..9d73814e 100755 --- a/src/check-libstdc++.sh +++ b/src/check-libstdc++.sh @@ -4,6 +4,7 @@ LC_ALL=C export LC_ALL test -z "$srcdir" && srcdir=. +test -z "$libs" && libs=. stat=0 @@ -16,7 +17,7 @@ fi tested=false for suffix in so dylib; do - so=.libs/libharfbuzz.$suffix + so=$libs/libharfbuzz.$suffix if ! test -f "$so"; then continue; fi echo "Checking that we are not linking to libstdc++ or libc++" diff --git a/src/check-static-inits.sh b/src/check-static-inits.sh index 1446fa73..aa1b129d 100755 --- a/src/check-static-inits.sh +++ b/src/check-static-inits.sh @@ -4,6 +4,7 @@ LC_ALL=C export LC_ALL test -z "$srcdir" && srcdir=. +test -z "$libs" && libs=. stat=0 @@ -14,7 +15,7 @@ else exit 77 fi -OBJS=.libs/*.o +OBJS=$libs/*.o if test "x`echo $OBJS`" = "x$OBJS" 2>/dev/null >/dev/null; then echo "check-static-inits.sh: object files not found; skipping test" exit 77 diff --git a/src/check-symbols.sh b/src/check-symbols.sh index d4d655d2..f1bba470 100755 --- a/src/check-symbols.sh +++ b/src/check-symbols.sh @@ -4,6 +4,7 @@ LC_ALL=C export LC_ALL test -z "$srcdir" && srcdir=. +test -z "$libs" && libs=. stat=0 @@ -17,7 +18,7 @@ fi echo "Checking that we are not exposing internal symbols" tested=false for suffix in so dylib; do - so=.libs/libharfbuzz.$suffix + so=$libs/libharfbuzz.$suffix if ! test -f "$so"; then continue; fi EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTVW] .' | grep -v ' _fini\>\| _init\>\| _fdata\>\| _ftext\>\| _fbss\>\| __bss_start\>\| __bss_start__\>\| __bss_end__\>\| _edata\>\| _end\>\| _bss_end__\>\| __end__\>\| __gcov_flush\>\| ___gcov_flush\>\| llvm_\| _llvm_' | cut -d' ' -f3`" -- cgit v1.2.3