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

require-lib bcache-test-libs.sh

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

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
}

main()
{
    setup_tracing 'bcache:*'

    if [ $NR_REBOOTS = 0 ]; then
	setup_bcache

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

	setup_fs ext4

	run_antagonist

	run_dbench &
	run_bonnie &

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