]> git.proxmox.com Git - ceph.git/blame - ceph/qa/workunits/rados/test_librados_build.sh
import ceph quincy 17.2.6
[ceph.git] / ceph / qa / workunits / rados / test_librados_build.sh
CommitLineData
91327a77
AA
1#!/bin/bash -ex
2#
3# Compile and run a librados application outside of the ceph build system, so
4# that we can be sure librados.h[pp] is still usable and hasn't accidentally
5# started depending on internal headers.
6#
7# The script assumes all dependencies - e.g. curl, make, gcc, librados headers,
8# libradosstriper headers, boost headers, etc. - are already installed.
9#
10
494da23a
TL
11source $(dirname $0)/../ceph-helpers-root.sh
12
91327a77
AA
13trap cleanup EXIT
14
15SOURCES="hello_radosstriper.cc
16hello_world_c.c
17hello_world.cc
18Makefile
19"
20BINARIES_TO_RUN="hello_world_c
21hello_world_cpp
22"
23BINARIES="${BINARIES_TO_RUN}hello_radosstriper_cpp
24"
9f95a23c
TL
25# parse output like "octopus (dev)"
26case $(librados-config --release | grep -Po ' \(\K[^\)]+') in
27 dev)
28 BRANCH=master;;
29 rc|stable)
30 BRANCH=$(librados-config --release | cut -d' ' -f1);;
31 *)
32 echo "unknown release '$(librados-config --release)'" >&2
33 return 1;;
34esac
35DL_PREFIX="http://git.ceph.com/?p=ceph.git;a=blob_plain;hb=${BRANCH};f=examples/librados/"
36#DL_PREFIX="https://raw.githubusercontent.com/ceph/ceph/master/examples/librados/"
91327a77
AA
37DESTDIR=$(pwd)
38
39function cleanup () {
40 for f in $BINARIES$SOURCES ; do
41 rm -f "${DESTDIR}/$f"
42 done
43}
44
45function get_sources () {
46 for s in $SOURCES ; do
39ae355f 47 curl --progress-bar --output $s -L ${DL_PREFIX}$s
91327a77
AA
48 done
49}
50
51function check_sources () {
52 for s in $SOURCES ; do
53 test -f $s
54 done
55}
56
57function check_binaries () {
58 for b in $BINARIES ; do
59 file $b
60 test -f $b
61 done
62}
63
64function run_binaries () {
65 for b in $BINARIES_TO_RUN ; do
66 ./$b -c /etc/ceph/ceph.conf
67 done
68}
69
70pushd $DESTDIR
494da23a
TL
71case $(distro_id) in
72 centos|fedora|rhel|opensuse*|suse|sles)
73 install gcc-c++ make libradospp-devel librados-devel;;
20effc67 74 ubuntu|debian|devuan|softiron)
494da23a
TL
75 install g++ make libradospp-dev librados-dev;;
76 *)
77 echo "$(distro_id) is unknown, $@ will have to be installed manually."
78esac
91327a77
AA
79get_sources
80check_sources
81make all-system
82check_binaries
83run_binaries
84popd