summaryrefslogtreecommitdiffstats
path: root/tests/libptxdisttest.kermit
blob: 178a68b4bc9463e557cd3e11a6fcefbf3de7d939 (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
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
96
97
98
99
100
101
102
#!/usr/bin/kermit	# -*-sh-*-

define ptx_init {

	take \%1

        set line \m(PTXCONF_BOARDSETUP_SERIALPORT)
        set speed \m(PTXCONF_BOARDSETUP_SERIALBAUDRATE)
        set parity none
        set stop-bits 1
        set carrier-watch off
        set handshake none
        set flow-control none
        robust

        set input cancellation off
        set input case observe
        set input buffer-length 16384

	writeln ERROR "Communicating via \m(PTXCONF_BOARDSETUP_SERIALPORT) at \m(PTXCONF_BOARDSETUP_SERIALBAUDRATE) bps."
	writeln ERROR
        writeln ERROR "==============================="
        writeln ERROR "Please power on your board now!"
        writeln ERROR "==============================="
        writeln ERROR
}

define ptx_exit {

	writeln ERROR "All OK!"
	exit 0
}

define ptx_test_start {

	#do padding with '.'
	write ERROR "\frpad(\%1,40,.)"
}

define ptx_test_end {

	writeln ERROR "OK"
}

define ptx_wait_string {

        input \%1 \%2
        if failure {
	        writeln ERROR "FAILED! (waiting for '\%2')"
        	exit 1
        }
}

define ptx_uboot_enter_shell {

	ptx_test_start "Logging into U-Boot"
	minput 120 "U-Boot 1" "U-Boot 2"
        if failure {
	        writeln ERROR "FAILED! (waiting for u-boot-signature)"
        	exit 1
        }
	lineout
	.uboot_version := \v(minput)
	ptx_wait_string 10 "\m(PTXCONF_BOARDSETUP_UBOOTPROMPT)"
	ptx_test_end
}

define ptx_uboot_exec {

	lineout "\%2"
	input \%1 \m(PTXCONF_BOARDSETUP_UBOOTPROMPT)
	if failure {
		writeln ERROR "FAILED! (timeout while waiting for u-boot prompt after \%2)"
		exit 1
	}

	if = \m(uboot_version) 2 {
		lineout "echo k-res:$?"
		input 10 \fpattern(k-res:0$)

		if failure {
			writeln ERROR "FAILED! (returncode from \%2 is not 0)"
			exit 1
		}

		input 10 \m(PTXCONF_BOARDSETUP_UBOOTPROMPT)
	}
}

define ptx_uboot_exec_single {

	ptx_test_start "\%1"
	ptx_uboot_exec "\%2" "\%3"
	ptx_test_end
}

define ptx_wait_string_single {

        ptx_test_start "\%1"
	ptx_wait_string "\%2" "\%3"
	ptx_test_end
}