-
Notifications
You must be signed in to change notification settings - Fork 2
/
module-test.sh
executable file
·61 lines (51 loc) · 839 Bytes
/
module-test.sh
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
uid=$(id -u)
if [ ${uid} -ne 0 ]
then
echo "Must be root to run this script"
exit 1
fi
if [ "$1" = "" ]
then
echo Must specify source file
exit 1
fi
SOURCE=../linux-staging/drivers/hwmon/$1.c
if [ ! -e ${SOURCE} ]
then
echo Missing source file ${SOURCE}
exit 1
fi
sed -e "s/TESTME/$1/" Makefile.template > Makefile
rm -f *.[ch]
cp ${SOURCE} .
cp ../linux-staging/drivers/hwmon/lm75.h .
make clean >/dev/null 2>/dev/null
make
if [ $? -ne 0 ]
then
echo Build failed, exiting
exit 1
fi
if [ ! -e scripts/$1.sh ]
then
echo No test script, exiting
exit 0
fi
modprobe -r $1 >/dev/null 2>&1
make install
modprobe $1
if [ $? -ne 0 ]
then
echo "Failed to load $1.ko"
exit 1
fi
sudo scripts/$1.sh
rv=$?
if [ ${rv} -ne 0 ]
then
echo Module test failed
else
echo Module test passed
fi
modprobe -r $1 >/dev/null 2>&1
exit ${rv}