Sumit Garg | e742dc8 | 2024-01-11 18:53:06 +0530 | [diff] [blame] | 1 | #!/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 Forissier | a5f8052 | 2024-03-26 12:44:08 +0100 | [diff] [blame] | 7 | set timeout 60 |
Jerome Forissier | 42d7fc9 | 2024-01-19 13:38:27 +0100 | [diff] [blame] | 8 | |
Sumit Garg | e742dc8 | 2024-01-11 18:53:06 +0530 | [diff] [blame] | 9 | info "Test Rust example applications:\n" |
| 10 | info "Running acipher-rs...\n" |
| 11 | send -- "acipher-rs 256 teststring\r" |
| 12 | expect { |
| 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 | |
| 22 | expect "# " |
| 23 | info "Running aes-rs...\n" |
| 24 | send -- "aes-rs\r" |
| 25 | expect { |
| 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 | |
| 35 | expect "# " |
| 36 | info "Running authentication-rs...\n" |
| 37 | send -- "authentication-rs\r" |
| 38 | expect { |
| 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 | |
| 48 | expect "# " |
| 49 | info "Running big_int-rs...\n" |
| 50 | send -- "big_int-rs\r" |
| 51 | expect { |
| 52 | "Success" { |
| 53 | info "Test success\n" |
| 54 | } |
| 55 | timeout { |
| 56 | info "!!! Timeout: Test failed\n" |
| 57 | exit 1 |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | expect "# " |
| 62 | info "Running diffie_hellman-rs...\n" |
| 63 | send -- "diffie_hellman-rs\r" |
| 64 | expect { |
| 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 | |
| 74 | expect "# " |
| 75 | info "Running digest-rs...\n" |
| 76 | send -- "digest-rs message1 message2\r" |
| 77 | expect { |
| 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 | |
| 87 | expect "# " |
| 88 | info "Running hello_world-rs...\n" |
| 89 | send -- "hello_world-rs\r" |
| 90 | expect { |
| 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 | |
| 100 | expect "# " |
| 101 | info "Running hotp-rs...\n" |
| 102 | send -- "hotp-rs\r" |
| 103 | expect { |
| 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 | |
| 113 | expect "# " |
| 114 | info "Running random-rs...\n" |
| 115 | send -- "random-rs\r" |
| 116 | expect { |
| 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 | |
| 126 | expect "# " |
| 127 | info "Running secure_storage-rs...\n" |
| 128 | send -- "secure_storage-rs\r" |
| 129 | expect { |
| 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 | |
| 139 | expect "# " |
| 140 | info "Running supp_plugin-rs...\n" |
| 141 | send -- "supp_plugin-rs\r" |
| 142 | expect { |
| 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 | |
| 152 | expect "# " |
| 153 | info "Running time-rs...\n" |
| 154 | send -- "time-rs\r" |
| 155 | expect { |
| 156 | "Success" { |
| 157 | info "Test success\n" |
| 158 | } |
| 159 | timeout { |
| 160 | info "!!! Timeout: Test failed\n" |
| 161 | exit 1 |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | expect "# " |
| 166 | info "Running signature_verification-rs...\n" |
Jerome Forissier | 9be54bf | 2024-09-19 10:32:13 +0200 | [diff] [blame] | 167 | # This one can take up to 6 minutes when CFG_CORE_DEBUG_CHECK_STACKS=y |
| 168 | # (3-4 minutes is common on my machine) |
| 169 | set timeout 400 |
Sumit Garg | e742dc8 | 2024-01-11 18:53:06 +0530 | [diff] [blame] | 170 | send -- "signature_verification-rs\r" |
| 171 | expect { |
| 172 | "Success" { |
| 173 | info "Test success\n" |
| 174 | } |
| 175 | timeout { |
| 176 | info "!!! Timeout: Test failed\n" |
| 177 | exit 1 |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | info "Rust examples tested successfully\n" |