blob: 362ed35484c70ccce4d66c5ed422cd66b7685d99 [file] [log] [blame]
Sumit Garge742dc82024-01-11 18:53:06 +05301#!/usr/bin/expect -f
2#
3# This script test OP-TEE rust examples. The return code is 0 for
4# success, >0 for error.
5#
6
Jerome Forissiera5f80522024-03-26 12:44:08 +01007set timeout 60
Jerome Forissier42d7fc92024-01-19 13:38:27 +01008
Sumit Garge742dc82024-01-11 18:53:06 +05309info "Test Rust example applications:\n"
10info "Running acipher-rs...\n"
11send -- "acipher-rs 256 teststring\r"
12expect {
13 -re "Success decrypt the above ciphertext as (\\d+) bytes plain text:" {
14 info "Test success\n"
15 }
16 timeout {
17 info "!!! Timeout: Test failed\n"
18 exit 1
19 }
20}
21
22expect "# "
23info "Running aes-rs...\n"
24send -- "aes-rs\r"
25expect {
26 -re "Prepare encode operation.*Encode buffer from TA.*Clear text and decoded text match" {
27 info "Test success\n"
28 }
29 timeout {
30 info "!!! Timeout: Test failed\n"
31 exit 1
32 }
33}
34
35expect "# "
36info "Running authentication-rs...\n"
37send -- "authentication-rs\r"
38expect {
39 -re "Clear text and decoded text match.*Success" {
40 info "Test success\n"
41 }
42 timeout {
43 info "!!! Timeout: Test failed\n"
44 exit 1
45 }
46}
47
48expect "# "
49info "Running big_int-rs...\n"
50send -- "big_int-rs\r"
51expect {
52 "Success" {
53 info "Test success\n"
54 }
55 timeout {
56 info "!!! Timeout: Test failed\n"
57 exit 1
58 }
59}
60
61expect "# "
62info "Running diffie_hellman-rs...\n"
63send -- "diffie_hellman-rs\r"
64expect {
65 -re "get key (\\d+) pair as public:.*private.*Derived share key as.*Success" {
66 info "Test success\n"
67 }
68 timeout {
69 info "!!! Timeout: Test failed\n"
70 exit 1
71 }
72}
73
74expect "# "
75info "Running digest-rs...\n"
76send -- "digest-rs message1 message2\r"
77expect {
78 -re "Get message hash as:.*Success" {
79 info "Test success\n"
80 }
81 timeout {
82 info "!!! Timeout: Test failed\n"
83 exit 1
84 }
85}
86
87expect "# "
88info "Running hello_world-rs...\n"
89send -- "hello_world-rs\r"
90expect {
91 -re "original value is 29.*inc value is 129.*dec value is 29.*Success" {
92 info "Test success\n"
93 }
94 timeout {
95 info "!!! Timeout: Test failed\n"
96 exit 1
97 }
98}
99
100expect "# "
101info "Running hotp-rs...\n"
102send -- "hotp-rs\r"
103expect {
104 -re "Get HOTP.*Success" {
105 info "Test success\n"
106 }
107 timeout {
108 info "!!! Timeout: Test failed\n"
109 exit 1
110 }
111}
112
113expect "# "
114info "Running random-rs...\n"
115send -- "random-rs\r"
116expect {
117 -re "Generate random UUID: \[a-z0-9]*-\[a-z0-9]*-\[a-z0-9]*-\[a-z0-9]*.*Success" {
118 info "Test success\n"
119 }
120 timeout {
121 info "!!! Timeout: Test failed\n"
122 exit 1
123 }
124}
125
126expect "# "
127info "Running secure_storage-rs...\n"
128send -- "secure_storage-rs\r"
129expect {
130 -re "We're done, close and release TEE resources" {
131 info "Test success\n"
132 }
133 timeout {
134 info "!!! Timeout: Test failed\n"
135 exit 1
136 }
137}
138
139expect "# "
140info "Running supp_plugin-rs...\n"
141send -- "supp_plugin-rs\r"
142expect {
143 -re "invoke commmand finished" {
144 info "Test success\n"
145 }
146 timeout {
147 info "!!! Timeout: Test failed\n"
148 exit 1
149 }
150}
151
152expect "# "
153info "Running time-rs...\n"
154send -- "time-rs\r"
155expect {
156 "Success" {
157 info "Test success\n"
158 }
159 timeout {
160 info "!!! Timeout: Test failed\n"
161 exit 1
162 }
163}
164
165expect "# "
166info "Running signature_verification-rs...\n"
Jerome Forissier9be54bf2024-09-19 10:32:13 +0200167# This one can take up to 6 minutes when CFG_CORE_DEBUG_CHECK_STACKS=y
168# (3-4 minutes is common on my machine)
169set timeout 400
Sumit Garge742dc82024-01-11 18:53:06 +0530170send -- "signature_verification-rs\r"
171expect {
172 "Success" {
173 info "Test success\n"
174 }
175 timeout {
176 info "!!! Timeout: Test failed\n"
177 exit 1
178 }
179}
180
181info "Rust examples tested successfully\n"