blob: a41058a6e9665c1e2a5c362f4e953380c37249da [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
7info "Test Rust example applications:\n"
8info "Running acipher-rs...\n"
9send -- "acipher-rs 256 teststring\r"
10expect {
11 -re "Success decrypt the above ciphertext as (\\d+) bytes plain text:" {
12 info "Test success\n"
13 }
14 timeout {
15 info "!!! Timeout: Test failed\n"
16 exit 1
17 }
18}
19
20expect "# "
21info "Running aes-rs...\n"
22send -- "aes-rs\r"
23expect {
24 -re "Prepare encode operation.*Encode buffer from TA.*Clear text and decoded text match" {
25 info "Test success\n"
26 }
27 timeout {
28 info "!!! Timeout: Test failed\n"
29 exit 1
30 }
31}
32
33expect "# "
34info "Running authentication-rs...\n"
35send -- "authentication-rs\r"
36expect {
37 -re "Clear text and decoded text match.*Success" {
38 info "Test success\n"
39 }
40 timeout {
41 info "!!! Timeout: Test failed\n"
42 exit 1
43 }
44}
45
46expect "# "
47info "Running big_int-rs...\n"
48send -- "big_int-rs\r"
49expect {
50 "Success" {
51 info "Test success\n"
52 }
53 timeout {
54 info "!!! Timeout: Test failed\n"
55 exit 1
56 }
57}
58
59expect "# "
60info "Running diffie_hellman-rs...\n"
61send -- "diffie_hellman-rs\r"
62expect {
63 -re "get key (\\d+) pair as public:.*private.*Derived share key as.*Success" {
64 info "Test success\n"
65 }
66 timeout {
67 info "!!! Timeout: Test failed\n"
68 exit 1
69 }
70}
71
72expect "# "
73info "Running digest-rs...\n"
74send -- "digest-rs message1 message2\r"
75expect {
76 -re "Get message hash as:.*Success" {
77 info "Test success\n"
78 }
79 timeout {
80 info "!!! Timeout: Test failed\n"
81 exit 1
82 }
83}
84
85expect "# "
86info "Running hello_world-rs...\n"
87send -- "hello_world-rs\r"
88expect {
89 -re "original value is 29.*inc value is 129.*dec value is 29.*Success" {
90 info "Test success\n"
91 }
92 timeout {
93 info "!!! Timeout: Test failed\n"
94 exit 1
95 }
96}
97
98expect "# "
99info "Running hotp-rs...\n"
100send -- "hotp-rs\r"
101expect {
102 -re "Get HOTP.*Success" {
103 info "Test success\n"
104 }
105 timeout {
106 info "!!! Timeout: Test failed\n"
107 exit 1
108 }
109}
110
111expect "# "
112info "Running random-rs...\n"
113send -- "random-rs\r"
114expect {
115 -re "Generate random UUID: \[a-z0-9]*-\[a-z0-9]*-\[a-z0-9]*-\[a-z0-9]*.*Success" {
116 info "Test success\n"
117 }
118 timeout {
119 info "!!! Timeout: Test failed\n"
120 exit 1
121 }
122}
123
124expect "# "
125info "Running secure_storage-rs...\n"
126send -- "secure_storage-rs\r"
127expect {
128 -re "We're done, close and release TEE resources" {
129 info "Test success\n"
130 }
131 timeout {
132 info "!!! Timeout: Test failed\n"
133 exit 1
134 }
135}
136
137expect "# "
138info "Running supp_plugin-rs...\n"
139send -- "supp_plugin-rs\r"
140expect {
141 -re "invoke commmand finished" {
142 info "Test success\n"
143 }
144 timeout {
145 info "!!! Timeout: Test failed\n"
146 exit 1
147 }
148}
149
150expect "# "
151info "Running time-rs...\n"
152send -- "time-rs\r"
153expect {
154 "Success" {
155 info "Test success\n"
156 }
157 timeout {
158 info "!!! Timeout: Test failed\n"
159 exit 1
160 }
161}
162
163expect "# "
164info "Running signature_verification-rs...\n"
165send -- "signature_verification-rs\r"
166expect {
167 "Success" {
168 info "Test success\n"
169 }
170 timeout {
171 info "!!! Timeout: Test failed\n"
172 exit 1
173 }
174}
175
176info "Rust examples tested successfully\n"