]> git.sesse.net Git - bcachefs-tools-debian/blob - smoke_test
Add packaging workflow
[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=$(mktemp)
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         ${PYTEST} -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         ${PYTEST} -n${JOBS}
56     ) > ${spam} 2>&1
57 }
58
59
60 echo -- Test: default --
61 build
62 test
63
64 echo -- Test: debug --
65 export BCACHEFS_DEBUG=1
66 build
67 test
68
69 echo -- Test: debug with valgrind --
70 test_vg
71
72 #echo -- Test: fuse debug --
73 #export BCACHEFS_FUSE=1
74 #build
75 #test
76
77 #echo -- Test: fuse debug with valgrind --
78 #test_vg
79
80 rm -f ${spam}
81 trap "set +x; echo; echo SUCCESS." EXIT