Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 128 lines (111 sloc) 3.283 kb
3726b66 @makelinux ldt-test cleanup
authored
1 #!/bin/bash
2
3 # LDT - Linux Driver Template
4 #
5 # Test script
6 #
7 # Copyright (C) 2012 Constantine Shulyupin http://www.makelinux.net/
8 #
9 # Dual BSD/GPL License
10
11 RED="\\033[0;31m"
12 NOCOLOR="\\033[0;39m"
13 GREEN="\\033[0;32m"
7f7c4a9 @makelinux + blocking io, wait_event_interruptible
authored
14 GRAY="\\033[0;37m"
425337b @makelinux initial sources
authored
15
16 set -o errtrace
17 tracing=/sys/kernel/debug/tracing
3726b66 @makelinux ldt-test cleanup
authored
18 irq=0 # define irq to bind diriver to HW IRQ, WARING: can hung the system
f2847cf @makelinux UART disabled
authored
19 irq=4 # serial port
425337b @makelinux initial sources
authored
20 # irq=`grep ehci_hcd /proc/interrupts | cut -f1 -d:`
21
22 tracing()
23 {
e9983bb @makelinux +platform_device and small updates
authored
24 sudo sh -c "cd $tracing; $1" || true
425337b @makelinux initial sources
authored
25 }
26
27 tracing_start()
28 {
29 tracing "echo :mod:ldt > set_ftrace_filter"
30 tracing "echo function > current_tracer"
31 tracing "echo 1 > function_profile_enabled"
3726b66 @makelinux ldt-test cleanup
authored
32 #sudo cat $tracing/current_tracer
33 #sudo cat $tracing/set_ftrace_filter
34 #sudo cat $tracing/function_profile_enabled
425337b @makelinux initial sources
authored
35 }
36
e9983bb @makelinux +platform_device and small updates
authored
37 tracing_stop()
425337b @makelinux initial sources
authored
38 {
3726b66 @makelinux ldt-test cleanup
authored
39 ( echo Profiling data per CPU
9bd51e9 @makelinux +ioctl
authored
40 tracing "cat trace_stat/function*" )> trace_stat.log && echo trace_stat.log saved
425337b @makelinux initial sources
authored
41 tracing "echo 0 > function_profile_enabled"
42 tracing "echo nop > current_tracer"
e9983bb @makelinux +platform_device and small updates
authored
43 sudo cp $tracing/trace ftrace.log && echo ftrace.log saved
425337b @makelinux initial sources
authored
44 }
45
46 # sudo rmmod parport_pc parport ppdev lp
f2847cf @makelinux UART disabled
authored
47 sudo dmesg -n 7
5492ec7 @makelinux +mmap
authored
48 sudo rmmod ldt ldt_plat_dev 2> /dev/null
4c8f40b @makelinux + loopback test
authored
49 stty -F /dev/ttyS0 115200
3726b66 @makelinux ldt-test cleanup
authored
50 make -s
9fc0000 @makelinux using ldt_resource
authored
51 set -o errexit
52
53 #
54 # Check for presence looback on /dev/ttyS0.
55 # If loopback is not present, switch loopback on in the driver
56 #
57
4c8f40b @makelinux + loopback test
authored
58 data='loopback?'
59 received=`echo $data | ./dio --ignore_eof --loops 2 --delay 10 /dev/ttyS0`
60 if [ "$data" == "$received" ]; then
61 echo -e "Loopback on /dev/ttyS0 detected"
62 loopback=0
63 else
9fc0000 @makelinux using ldt_resource
authored
64 echo -e "No loopback on /dev/ttyS0 detected, running ldt driver with UART in loopback mode"
4c8f40b @makelinux + loopback test
authored
65 loopback=1
66 fi
bf1286d @makelinux minor
authored
67 junk=`echo | ./dio --ignore_eof --loops 10 --delay 10 /dev/ttyS0`
4c8f40b @makelinux + loopback test
authored
68
69 sudo insmod ldt.ko loopback=$loopback
e9983bb @makelinux +platform_device and small updates
authored
70 sudo insmod ldt_plat_dev.ko
71
72 tracing_start || true
3726b66 @makelinux ldt-test cleanup
authored
73 # lsmod | grep ldt
5842a8d @makelinux +poll
authored
74 #id=`grep -w ldt /proc/misc | cut -c -3`
75 . /sys/class/misc/ldt/uevent # get $MAJOR $MINOR
76 sudo sh -c "rm /dev/ldt;sudo mknod /dev/ldt c $MAJOR $MINOR; chmod o+rw /dev/ldt"
9bd51e9 @makelinux +ioctl
authored
77 data=123rw
4c8f40b @makelinux + loopback test
authored
78 echo $data > /dev/ldt
425337b @makelinux initial sources
authored
79 sleep 0.5
7f7c4a9 @makelinux + blocking io, wait_event_interruptible
authored
80 received=`dd iflag=nonblock if=/dev/ldt 2> /dev/null || true`
3726b66 @makelinux ldt-test cleanup
authored
81 if [ "$data" == "$received" ]; then
7f7c4a9 @makelinux + blocking io, wait_event_interruptible
authored
82 echo -e "${GREEN}LDT nonblocking read/write test passed$NOCOLOR"
3726b66 @makelinux ldt-test cleanup
authored
83 else
7f7c4a9 @makelinux + blocking io, wait_event_interruptible
authored
84 echo -e "${RED}LDT nonblock read/write test failed$NOCOLOR"
85 echo expected $data
86 echo received $received
87 fi
88
89 data=123bl
90 cat /dev/ldt > R.tmp &
4c8f40b @makelinux + loopback test
authored
91 sleep 0.5; echo $data > /dev/ldt;
7f7c4a9 @makelinux + blocking io, wait_event_interruptible
authored
92 sleep 0.5
93 kill %1; wait %1 2> /dev/null || true
94 received=`cat R.tmp`
95
96 if [ "$data" == "$received" ]; then
97 echo -e "${GREEN}LDT blocking read/write test passed$NOCOLOR"
98 else
99 echo -e "${RED}LDT blocking read/write test failed$NOCOLOR"
100 echo expected $data
101 echo received $received
f5b5e6f @makelinux +mmap
authored
102 fi
103
9bd51e9 @makelinux +ioctl
authored
104 data=123mmap
4c8f40b @makelinux + loopback test
authored
105 received=`sudo echo $data | ./dio --mmap /dev/ldt`
f5b5e6f @makelinux +mmap
authored
106 if [ "$data" == "$received" ]; then
107 echo -e "${GREEN}LDT mmap test passed$NOCOLOR"
108 else
109 echo -e "${RED}LDT mmap test failed$NOCOLOR"
110 echo expected $data
111 echo received $received
3726b66 @makelinux ldt-test cleanup
authored
112 fi
113
9bd51e9 @makelinux +ioctl
authored
114 data=123ioctl
4c8f40b @makelinux + loopback test
authored
115 received=`sudo echo $data | ./dio --ioctl /dev/ldt`
9bd51e9 @makelinux +ioctl
authored
116 if [ "$data" == "$received" ]; then
117 echo -e "${GREEN}LDT ioctl test passed$NOCOLOR"
118 else
119 echo -e "${RED}LDT ioctl test failed$NOCOLOR"
120 echo expected $data
121 echo received $received
122 fi
123
425337b @makelinux initial sources
authored
124 grep ldt /proc/interrupts || true
e9983bb @makelinux +platform_device and small updates
authored
125 tracing_stop || true
9bd51e9 @makelinux +ioctl
authored
126 sudo dmesg --show-delta --notime --read-clear 2>/dev/null > kernel.log || \
e9983bb @makelinux +platform_device and small updates
authored
127 sudo dmesg -c > kernel.log && echo kernel.log saved
Something went wrong with that request. Please try again.