Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 70 lines (60 sloc) 1.72 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"
425337b @makelinux initial sources
authored
14
15 set -o errtrace
16 tracing=/sys/kernel/debug/tracing
3726b66 @makelinux ldt-test cleanup
authored
17 irq=0 # define irq to bind diriver to HW IRQ, WARING: can hung the system
425337b @makelinux initial sources
authored
18 # irq=`grep ehci_hcd /proc/interrupts | cut -f1 -d:`
19
20 tracing()
21 {
e9983bb @makelinux +platform_device and small updates
authored
22 sudo sh -c "cd $tracing; $1" || true
425337b @makelinux initial sources
authored
23 }
24
25 tracing_start()
26 {
27 tracing "echo :mod:ldt > set_ftrace_filter"
28 tracing "echo function > current_tracer"
29 tracing "echo 1 > function_profile_enabled"
3726b66 @makelinux ldt-test cleanup
authored
30 #sudo cat $tracing/current_tracer
31 #sudo cat $tracing/set_ftrace_filter
32 #sudo cat $tracing/function_profile_enabled
425337b @makelinux initial sources
authored
33 }
34
e9983bb @makelinux +platform_device and small updates
authored
35 tracing_stop()
425337b @makelinux initial sources
authored
36 {
3726b66 @makelinux ldt-test cleanup
authored
37 ( echo Profiling data per CPU
38 tracing "cat trace_stat/function*" )> trace_stat && echo trace_stat saved
425337b @makelinux initial sources
authored
39 tracing "echo 0 > function_profile_enabled"
40 tracing "echo nop > current_tracer"
e9983bb @makelinux +platform_device and small updates
authored
41 sudo cp $tracing/trace ftrace.log && echo ftrace.log saved
425337b @makelinux initial sources
authored
42 }
43
44 # sudo rmmod parport_pc parport ppdev lp
e9983bb @makelinux +platform_device and small updates
authored
45 sudo rmmod ldt ldt_plat_dev
425337b @makelinux initial sources
authored
46 set -o errexit
3726b66 @makelinux ldt-test cleanup
authored
47 make -s
425337b @makelinux initial sources
authored
48 sudo insmod ldt.ko irq=$irq
e9983bb @makelinux +platform_device and small updates
authored
49 sudo insmod ldt_plat_dev.ko
50
51 tracing_start || true
3726b66 @makelinux ldt-test cleanup
authored
52 # lsmod | grep ldt
425337b @makelinux initial sources
authored
53 id=`grep -w ldt /proc/misc | cut -c -3`
54 sudo sh -c "rm /dev/ldt;sudo mknod /dev/ldt c 10 $id; chmod o+rw /dev/ldt"
3726b66 @makelinux ldt-test cleanup
authored
55 data=123
56 echo $data > /dev/ldt
425337b @makelinux initial sources
authored
57 sleep 0.5
3726b66 @makelinux ldt-test cleanup
authored
58 received=`head -n 1 /dev/ldt`
59 if [ "$data" == "$received" ]; then
60 echo -e "${GREEN}LDT test passed$NOCOLOR"
61 else
62 echo -e "${RED}LDT test failed$NOCOLOR"
63 fi
64
425337b @makelinux initial sources
authored
65 grep ldt /proc/interrupts || true
e9983bb @makelinux +platform_device and small updates
authored
66 tracing_stop || true
425337b @makelinux initial sources
authored
67 #sudo dmesg --show-delta --notime --read-clear > kernel.log
e9983bb @makelinux +platform_device and small updates
authored
68 sudo dmesg -c > kernel.log && echo kernel.log saved
425337b @makelinux initial sources
authored
69 #sudo dmesg --show-delta --notime --read-clear > kernel.log
Something went wrong with that request. Please try again.