]> git.sesse.net Git - bcachefs-tools-debian/blob - smoke_test
15a9fcee1ac1c438e898036a667b57955e94a3ff
[bcachefs-tools-debian] / smoke_test
1 #!/bin/bash
2 #
3 # This is a smoke test of bcachefs-tools.
4 #
5 # It builds the source with multiple options (debug, release, valgrind, FUSE)
6 # and runs the test suite.
7 #
8 # Returns 0 on success, nonzero on any failure.
9 #
10 # Dependencies:
11 #
12 # valgrind, python3-pytest, python3-pytest-xdist
13 #
14 # On debian/ubuntu based systems, install with:
15 #
16 #   apt install valgrind python3-pytest python3-pytest-xdist
17 #
18 # You also currently need fuse 3.7 or later.  Fuse 3.7 unfortunately requires
19 # debian sid or bullseye at this time, so you may need to install from source.
20
21 set -e
22
23 PYTEST="${PYTEST:-pytest-3}"
24 spam=$(tempfile)
25 unset BCACHEFS_FUSE BCACHEFS_TEST_USE_VALGRIND BCACHEFS_DEBUG
26
27 trap "set +x; cat ${spam}; rm -f ${spam} ; echo; echo FAILED." EXIT
28
29 echo -- Verify dependencies --
30 pkg-config --atleast-version 3.7.0 fuse3
31 python3 -c "import pytest"
32 python3 -c "import xdist"
33 which valgrind > /dev/null
34 echo OK
35
36 JOBS=$(nproc)
37 function build() {
38     echo Building.
39     make -j ${JOBS} clean          > ${spam} 2>&1
40     make -j ${JOBS} tests bcachefs > ${spam} 2>&1
41     truncate -s0 ${spam}
42 }
43
44 function test() {
45     echo Running tests.
46     (
47         cd tests
48         ${PYTEST} -n${JOBS}
49     ) > ${spam} 2>&1
50 }
51
52 function test_vg() {
53     echo Running tests with valgrind.
54     (
55         export BCACHEFS_TEST_USE_VALGRIND=yes
56         cd tests
57         ${PYTEST} -n${JOBS}
58     ) > ${spam} 2>&1
59 }
60
61
62 echo -- Test: default --
63 build
64 test
65
66 echo -- Test: debug --
67 export BCACHEFS_DEBUG=1
68 build
69 test
70
71 echo -- Test: debug with valgrind --
72 test_vg
73
74 echo -- Test: fuse debug --
75 export BCACHEFS_FUSE=1
76 build
77 test
78
79 echo -- Test: fuse debug with valgrind --
80 test_vg
81
82 rm -f ${spam}
83 trap "set +x; echo; echo SUCCESS." EXIT