test-linkage: drop brittle test for secondary library dependencies
[deb_dpdk.git] / debian / tests / test-linkage
1 #!/bin/bash
2 set -eux
3 binary="build/testlinkage"
4
5 basedir=$(dirname "$0")
6 . "${basedir}"/check-dpdk-supported-arch.sh
7
8 cat > testlinkage.c << EOF
9 #include <stdio.h>
10 #include <rte_common.h>
11
12 int main(void)
13 {
14         printf("Hello rte_exit %p\n", rte_exit);
15         return 0;
16 }
17 EOF
18
19 cat >  Makefile-testlinkage << 'EOF'
20 # Based on examples/helloworld/Makefile
21
22 ifeq ($(RTE_SDK),)
23 $(error "Please define RTE_SDK environment variable")
24 endif
25
26 # Default target, can be overridden by command line or environment
27 RTE_TARGET ?= x86_64-native-linuxapp-gcc
28
29 include $(RTE_SDK)/mk/rte.vars.mk
30
31 # binary name
32 APP = testlinkage
33
34 # all source are stored in SRCS-y
35 SRCS-y := testlinkage.c
36
37 CFLAGS += -O3
38 CFLAGS += $(WERROR_FLAGS)
39
40 include $(RTE_SDK)/mk/rte.extapp.mk
41 EOF
42
43
44 printf "\n\nSet up DPDK'ish build environment\n"
45 . /usr/share/dpdk/dpdk-sdk-env.sh
46 export CFLAGS=$(pkg-config --libs --cflags libdpdk)
47
48 # -ldpdk actually refers to a linker script now, not a real .so
49 # with broken linkage this will fail with undefined symbols
50 printf "\n\nChecking compile with link against DPDK\n"
51 make V=1 -f Makefile-testlinkage
52 echo "OK"
53
54 printf "\n\nLinkage info\n"
55 lddtree ${binary}
56
57 printf "\n\nChecking for expected internal libraries\n"
58 # a few of the sublibs that it should use
59 lddtree ${binary} | grep '^    librte_eal.so'
60 echo "OK"
61
62 printf "\n\nChecking for expected feature dependent library dependencies\n"
63 # features only used by the lib that we enabled
64 ldd /usr/lib/*/librte_pmd_pcap.so | grep libpcap
65 echo "OK"
66
67 printf "\n\nChecking test execution\n"
68 # It doesn't do much, but it should work - so calling it is a minor extra test.
69 # It is known to fail without SSE3 in e.g. some adt environments, in that
70 # case check at least that we get the correct error message (this will trigger
71 # a test fail if it neither finds the success nor the expected error message)
72 (./${binary} 2>&1 || /bin/true ) | \
73 grep -E 'ERROR: This system does not support "SSSE3".|Hello rte_exit 0x'
74
75 echo "OK"