summaryrefslogtreecommitdiff
path: root/smoke_test
blob: 112280889c63099a912f49d1cbecdca8550cbd24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#
# This is a smoke test of bcachefs-tools.
#
# It builds the source with multiple options (debug, release, valgrind, FUSE)
# and runs the test suite.
#
# Returns 0 on success, nonzero on any failure.
#
# Dependencies:
#
# valgrind, python3-pytest, python3-pytest-xdist
#
# On debian/ubuntu based systems, install with:
#
#   apt install valgrind python3-pytest python3-pytest-xdist
#
# You also currently need fuse 3.7 or later.  Fuse 3.7 unfortunately requires
# debian sid or bullseye at this time, so you may need to install from source.

set -e

PYTEST="${PYTEST:-pytest-3}"
spam=$(mktemp)
unset BCACHEFS_FUSE BCACHEFS_TEST_USE_VALGRIND BCACHEFS_DEBUG

trap "set +x; cat ${spam}; rm -f ${spam} ; echo; echo FAILED." EXIT

echo -- Verify dependencies --
pkg-config --atleast-version 3.7.0 fuse3
python3 -c "import pytest"
python3 -c "import xdist"
which valgrind > /dev/null
echo OK

JOBS=$(nproc)
function build() {
    echo Building.
    make -j ${JOBS} clean          > ${spam} 2>&1
    make -j ${JOBS} tests bcachefs > ${spam} 2>&1
    truncate -s0 ${spam}
}

function test() {
    echo Running tests.
    (
        ${PYTEST} -n${JOBS}
    ) > ${spam} 2>&1
}

function test_vg() {
    echo Running tests with valgrind.
    (
        export BCACHEFS_TEST_USE_VALGRIND=yes
        ${PYTEST} -n${JOBS}
    ) > ${spam} 2>&1
}


echo -- Test: default --
build
test

echo -- Test: debug --
export BCACHEFS_DEBUG=1
build
test

echo -- Test: debug with valgrind --
test_vg

#echo -- Test: fuse debug --
#export BCACHEFS_FUSE=1
#build
#test

#echo -- Test: fuse debug with valgrind --
#test_vg

rm -f ${spam}
trap "set +x; echo; echo SUCCESS." EXIT