xref: /spdk/test/external_code/test_make.sh (revision 838e61c3772fdefb17e1a0b8f9880e2bcb9c4c0d)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2020 Intel Corporation
4#  All rights reserved.
5#
6test_root=$(readlink -f $(dirname $0))
7rootdir="$test_root/../.."
8
9source "$rootdir/test/common/autotest_common.sh"
10
11set -e
12SPDK_DIR=$1
13
14if [ -z "$EXTERNAL_MAKE_HUGEMEM" ]; then
15	EXTERNAL_MAKE_HUGEMEM=$HUGEMEM
16fi
17
18sudo HUGEMEM="$EXTERNAL_MAKE_HUGEMEM" $SPDK_DIR/scripts/setup.sh
19
20if [ -n "$SPDK_RUN_EXTERNAL_DPDK" ]; then
21	WITH_DPDK="--with-dpdk=$SPDK_RUN_EXTERNAL_DPDK"
22fi
23if [[ -e $SPDK_DIR/mk/config.mk ]]; then
24	make -C $SPDK_DIR clean
25fi
26$SPDK_DIR/configure --with-shared --without-ocf --disable-asan $WITH_DPDK
27make -C $SPDK_DIR -j$(nproc)
28
29export SPDK_HEADER_DIR="$SPDK_DIR/include"
30export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$test_root/passthru"
31_sudo="sudo -E --preserve-env=PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
32
33# The default target is to make both the app and bdev and link them against the combined SPDK shared library libspdk.so.
34run_test "external_make_hello_bdev_shared_combo" make -C $test_root hello_world_bdev_shared_combo
35run_test "external_run_hello_bdev_shared_combo" $_sudo $test_root/hello_world/hello_bdev \
36	--json $test_root/hello_world/bdev_external.json -b TestPT
37
38make -C $test_root clean
39
40# Make just the application linked against the combined SPDK shared library libspdk.so.
41run_test "external_make_hello_no_bdev_shared_combo" make -C $test_root hello_world_no_bdev_shared_combo
42run_test "external_run_hello_no_bdev_shared_combo" $_sudo $test_root/hello_world/hello_bdev \
43	--json $test_root/hello_world/bdev.json -b Malloc0
44
45make -C $test_root clean
46
47# Make both the application and bdev against individual SPDK shared libraries.
48run_test "external_make_hello_bdev_shared_iso" make -C $test_root hello_world_bdev_shared_iso
49run_test "external_run_hello_bdev_shared_iso" $_sudo $test_root/hello_world/hello_bdev \
50	--json $test_root/hello_world/bdev_external.json -b TestPT
51
52make -C $test_root clean
53
54# Make just the application linked against individual SPDK shared libraries.
55run_test "external_make_hello_no_bdev_shared_iso" make -C $test_root hello_world_no_bdev_shared_iso
56run_test "external_run_hello_no_bdev_shared_iso" $_sudo $test_root/hello_world/hello_bdev \
57	--json $test_root/hello_world/bdev.json -b Malloc0
58
59# Make the basic NVMe driver linked against individual shared SPDK libraries.
60run_test "external_make_nvme_shared" make -C $test_root nvme_shared
61run_test "external_run_nvme_shared" $_sudo $test_root/nvme/identify.sh
62
63make -C $test_root clean
64
65make -C $SPDK_DIR clean
66$SPDK_DIR/configure --without-shared --without-ocf --disable-asan $WITH_DPDK
67make -C $SPDK_DIR -j$(nproc)
68
69# Make both the application and bdev against individual SPDK archives.
70run_test "external_make_hello_bdev_static" make -C $test_root hello_world_bdev_static
71run_test "external_run_hello_bdev_static" $_sudo $test_root/hello_world/hello_bdev \
72	--json $test_root/hello_world/bdev_external.json -b TestPT
73
74make -C $test_root clean
75
76# Make just the application linked against individual SPDK archives.
77run_test "external_make_hello_no_bdev_static" make -C $test_root hello_world_no_bdev_static
78run_test "external_run_hello_no_bdev_static" $_sudo $test_root/hello_world/hello_bdev \
79	--json $test_root/hello_world/bdev.json -b Malloc0
80
81# Make the basic NVMe driver statically linked against individual SPDK archives.
82run_test "external_make_nvme_static" make -C $test_root nvme_static
83run_test "external_run_nvme_static" $_sudo $test_root/nvme/identify.sh
84
85make -C $test_root clean
86make -C $SPDK_DIR -j$(nproc) clean
87
88sudo HUGEMEM="$HUGEMEM" $SPDK_DIR/scripts/setup.sh reset
89