]> git.sesse.net Git - bcachefs-tools-debian/blob - smoke_test
Add upstream files
[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 spam=$(tempfile)
24 unset BCACHEFS_FUSE BCACHEFS_TEST_USE_VALGRIND D
25
26 trap "set +x; cat ${spam}; rm -f ${spam} ; echo; echo FAILED." EXIT
27
28 echo -- Verify dependencies --
29 pkg-config --atleast-version 3.7.0 fuse3
30 python3 -c "import pytest"
31 python3 -c "import xdist"
32 which valgrind > /dev/null
33 echo OK
34
35 JOBS=$(nproc)
36 function build() {
37     echo Building.
38     make -j ${JOBS} clean          > ${spam} 2>&1
39     make -j ${JOBS} tests bcachefs > ${spam} 2>&1
40     truncate -s0 ${spam}
41 }
42
43 function test() {
44     echo Running tests.
45     (
46         cd tests
47         pytest-3 -n${JOBS}
48     ) > ${spam} 2>&1
49 }
50
51 function test_vg() {
52     echo Running tests with valgrind.
53     (
54         export BCACHEFS_TEST_USE_VALGRIND=yes
55         cd tests
56         pytest-3 -n${JOBS}
57     ) > ${spam} 2>&1
58 }
59
60
61 echo -- Test: default --
62 build
63 test    
64
65 echo -- Test: debug --
66 export D=1
67 build
68 test
69
70 echo -- Test: debug with valgrind --
71 test_vg
72
73 echo -- Test: fuse debug --
74 export BCACHEFS_FUSE=1
75 build
76 test
77
78 echo -- Test: fuse debug with valgrind --
79 test_vg
80
81 rm -f ${spam}
82 trap "set +x; echo; echo SUCCESS." EXIT