summaryrefslogtreecommitdiff
path: root/tests/bcache/init_errors.ktest
blob: 5a8ffc6858bd03e20d4a82c9e89cf974fe2f33ba (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
#!/usr/bin/env bash

. $(dirname $(readlink -e ${BASH_SOURCE[0]}))/bcache-test-libs.sh

config-cache 2G
config-tier 4G
config-bucket-size 32k
config-block-size 4k
config-timeout 300
config-volume 1600M

run_test_faults()
{
    control=/sys/kernel/debug/dynamic_fault/control
    grep $1 $control
    echo

    for id in {0..99}; do
	fault="$1 index $id"

	echo "class $fault enable" > $control || break

	echo "TESTING FAULT $id"

	echo "Registering sdb"
	echo /dev/sdb > /sys/fs/bcache/register || true

	echo "Registering sdc"
	echo /dev/sdc > /sys/fs/bcache/register || true

	sleep 2
	echo "class $fault disable" > $control
	sleep 2

	if test -e /sys/fs/bcache/*-*-*-*-*; then
	    echo "Registration should have failed"
	    false
	fi
    done
}

test_main()
{
    setup_tracing 'bcache:*'

    if [ $NR_REBOOTS = 0 ]; then
	setup_bcache

	echo readonly > /sys/fs/bcache/*/errors | true

	setup_fs ext4

	run_antagonist

	run_dbench &
	run_bonnie &

	sleep 10
	do_reboot
    else
	run_test_faults "bcache:cache_set_init"
	run_test_faults "bcache:meta:read"
    fi
}