File: cache-test.sh

package info (click to toggle)
rapiddisk 9.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 952 kB
  • sloc: ansic: 6,760; sh: 1,364; makefile: 325; python: 105
file content (95 lines) | stat: -rwxr-xr-x 1,621 bytes parent folder | download | duplicates (3)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash

who="$(whoami)"
if [ "$who" != "root" ] ; then
  echo "Please run as root!"
  exit 0
fi

if [ ! "$BASH_VERSION" ] ; then
	exec /bin/bash "$0" "$@"
fi

PATH=$PATH:$(pwd)
RD=rd0

function cleanup()
{       
	../src/rapiddisk -u rc-wa_loop7
	../src/rapiddisk -d ${RD}
	losetup -d /dev/loop7
	rm -f /tmp/test1
}

function createLoopbackDevices()
{       
	dd if=/dev/zero of=/tmp/test1 bs=1M count=256
	losetup /dev/loop7 /tmp/test1
}

function removeLoopbackDevices()
{       
	losetup -d /dev/loop7
	rm -f /tmp/test1
}

function createCacheVolumes()
{
	RD=`../src/rapiddisk -a 64 -g|cut -d' ' -f3`
	../src/rapiddisk -m ${RD} -b /dev/loop7
	RETVAL=$?
	if [ ${RETVAL} -ne 0 ]; then
		cleanup
		exit ${RETVAL}
	fi
}

function removeCacheVolumes()
{
	../src/rapiddisk -u rc-wt_loop7
	../src/rapiddisk -d ${RD}
	RETVAL=$?
	if [ ${RETVAL} -ne 0 ]; then
		cleanup
		exit ${RETVAL}
	fi
}

function statCacheVolumes()
{       
	../src/rapiddisk -s rc-wt_loop7
	RETVAL=$?
	if [ ${RETVAL} -ne 0 ]; then
		cleanup
		exit ${RETVAL}
	fi
}

#
#
#


COUNT=`lsmod|grep rapiddisk|wc -l`
if [ ${COUNT} -ne 2 ]; then
	insmod ../module/rapiddisk.ko max_sectors=2048 nr_requests=1024 2>&1 >/dev/null
	insmod ../module/rapiddisk-cache.ko 2>&1 >/dev/null
fi

echo "Create Loopback Devices..."
createLoopbackDevices
echo "Create Cache Volumes..."
createCacheVolumes
ls -l /dev/mapper|grep "rc-wa_"
echo "Stat Cache Volumes..."
statCacheVolumes
echo "Remove Cache Volumes..."
removeCacheVolumes
ls -l /dev/mapper|grep "rc-wa_"
echo "Remove Loopback Devices..."
removeLoopbackDevices

rmmod rapiddisk.ko
rmmod rapiddisk-cache.ko

exit 0