Skip to content

Commit cd200a7

Browse files
dwsusekawasaki
authored andcommitted
bcache: add bcache/001
So far we are missing tests for bcache. Besides a relative simple setup/teardown tests add also the corresponding infrastructure. More tests are to be expected to depend on this. _create_bcache/_remove_bcache are tracking the resources and if anything is missing it will complain. Signed-off-by: Daniel Wagner <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> [Shin'ichiro: added /dev prefix to _bcache_wipe_devs() arguments] Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 8f05fe6 commit cd200a7

3 files changed

Lines changed: 428 additions & 0 deletions

File tree

tests/bcache/001

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2026 Daniel Wagner, SUSE Labs
4+
#
5+
# Test bcache setup and teardown
6+
7+
. tests/bcache/rc
8+
9+
DESCRIPTION="test bcache setup and teardown"
10+
11+
test_device_array() {
12+
echo "Running ${TEST_NAME}"
13+
14+
if [[ ${#TEST_DEV_ARRAY[@]} -lt 3 ]]; then
15+
SKIP_REASONS+=("requires at least 3 devices")
16+
return 1
17+
fi
18+
19+
_setup_bcache "${TEST_DEV_ARRAY[@]}"
20+
21+
local -a bcache_nodes
22+
23+
mapfile -t bcache_nodes < <(_create_bcache \
24+
--cache "${TEST_DEV_ARRAY[0]##*/}" \
25+
--bdev "${TEST_DEV_ARRAY[1]##*/}" \
26+
--writeback)
27+
28+
echo "number of bcaches: ${#bcache_nodes[*]}"
29+
30+
_remove_bcache --bcache "${bcache_nodes[@]}" \
31+
--cache "${TEST_DEV_ARRAY[0]##*/}" \
32+
--bdev "${TEST_DEV_ARRAY[1]##*/}" \
33+
34+
mapfile -t bcache_nodes < <(_create_bcache \
35+
--cache "${TEST_DEV_ARRAY[0]##*/}" \
36+
--bdev "${TEST_DEV_ARRAY[1]##*/}" "${TEST_DEV_ARRAY[2]##*/}" \
37+
--writeback)
38+
39+
echo "number of bcaches: ${#bcache_nodes[*]}"
40+
41+
_remove_bcache --bcache "${bcache_nodes[@]}" \
42+
--cache "${TEST_DEV_ARRAY[0]##*/}" \
43+
--bdev "${TEST_DEV_ARRAY[1]##*/}" "${TEST_DEV_ARRAY[2]##*/}"
44+
}

tests/bcache/001.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Running bcache/001
2+
number of bcaches: 1
3+
number of bcaches: 2

0 commit comments

Comments
 (0)