diff --git a/qemu-check.exp b/qemu-check.exp index 22e9b530..7c46513c 100644 --- a/qemu-check.exp +++ b/qemu-check.exp @@ -20,6 +20,11 @@ if {[info exists ::env(XEN_FFA)] && $::env(XEN_FFA) == "y"} { set cmd3 "xl console domu" set quiet 0 set xtest_args "" +if {[info exists ::env(RUST_ENABLE)] && $::env(RUST_ENABLE) == "y"} { + set rust_enable 1 +} else { + set rust_enable 0 +} # The time required to run some tests (e.g., key generation tests [4007.*]) # can be significant and vary widely -- typically, from about one minute to @@ -28,6 +33,7 @@ set xtest_args "" # ('xtest') with all testsuites enabled (regression+gp+pkcs11). set timeout 900 set tests "all" +set basedir [file dirname $argv0] # Parse command line set myargs $argv @@ -179,6 +185,10 @@ if {$::env(XEN_BOOT) == "y"} { } if {$tests == "all" || $tests == "trusted-keys"} { # Invoke Trusted Keys tests - set basedir [file dirname $argv0] source $basedir/trusted-keys.exp } +if {$tests == "all" || $tests == "rust"} { + if {$::rust_enable==0} { return } + # Invoke Rust tests + source $basedir/rust.exp +} diff --git a/qemu_v8.mk b/qemu_v8.mk index 584de1fa..6f8409f5 100644 --- a/qemu_v8.mk +++ b/qemu_v8.mk @@ -29,6 +29,9 @@ GICV3 = y QEMU_VIRTFS_AUTOMOUNT = y endif +# Option to enable Rust examples +RUST_ENABLE ?= y + include common.mk DEBUG ?= 1 @@ -547,6 +550,7 @@ check: $(CHECK_DEPS) export QEMU_VIRT=$(QEMU_VIRT) && \ export XEN_BOOT=$(XEN_BOOT) && \ export XEN_FFA=$(XEN_FFA) && \ + export RUST_ENABLE=$(RUST_ENABLE) && \ expect $(ROOT)/build/qemu-check.exp -- $(check-args) || \ (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \ echo "== $$PWD/serial0.log:"; \ @@ -559,25 +563,5 @@ check: $(CHECK_DEPS) check-only: check -check-rust: $(CHECK_DEPS) - ln -sf $(ROOT)/out-br/images/rootfs.cpio.gz $(BINARIES_PATH)/ - cd $(BINARIES_PATH) && \ - export QEMU=$(QEMU_BUILD)/aarch64-softmmu/qemu-system-aarch64 && \ - export QEMU_SMP=$(QEMU_SMP) && \ - export QEMU_MTE=$(QEMU_MTE) && \ - export QEMU_GIC=$(QEMU_GIC_VERSION) && \ - export QEMU_MEM=$(QEMU_MEM) && \ - expect $(ROOT)/optee_rust/ci/qemu-check.exp -- $(check-args) || \ - (if [ "$(DUMP_LOGS_ON_ERROR)" ]; then \ - echo "== $$PWD/serial0.log:"; \ - cat serial0.log; \ - echo "== end of $$PWD/serial0.log:"; \ - echo "== $$PWD/serial1.log:"; \ - cat serial1.log; \ - echo "== end of $$PWD/serial1.log:"; \ - fi; false) - -check-only-rust: check-rust - check-clean: rm -f serial0.log serial1.log diff --git a/rust.exp b/rust.exp new file mode 100644 index 00000000..a41058a6 --- /dev/null +++ b/rust.exp @@ -0,0 +1,176 @@ +#!/usr/bin/expect -f +# +# This script test OP-TEE rust examples. The return code is 0 for +# success, >0 for error. +# + +info "Test Rust example applications:\n" +info "Running acipher-rs...\n" +send -- "acipher-rs 256 teststring\r" +expect { + -re "Success decrypt the above ciphertext as (\\d+) bytes plain text:" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running aes-rs...\n" +send -- "aes-rs\r" +expect { + -re "Prepare encode operation.*Encode buffer from TA.*Clear text and decoded text match" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running authentication-rs...\n" +send -- "authentication-rs\r" +expect { + -re "Clear text and decoded text match.*Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running big_int-rs...\n" +send -- "big_int-rs\r" +expect { + "Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running diffie_hellman-rs...\n" +send -- "diffie_hellman-rs\r" +expect { + -re "get key (\\d+) pair as public:.*private.*Derived share key as.*Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running digest-rs...\n" +send -- "digest-rs message1 message2\r" +expect { + -re "Get message hash as:.*Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running hello_world-rs...\n" +send -- "hello_world-rs\r" +expect { + -re "original value is 29.*inc value is 129.*dec value is 29.*Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running hotp-rs...\n" +send -- "hotp-rs\r" +expect { + -re "Get HOTP.*Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running random-rs...\n" +send -- "random-rs\r" +expect { + -re "Generate random UUID: \[a-z0-9]*-\[a-z0-9]*-\[a-z0-9]*-\[a-z0-9]*.*Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running secure_storage-rs...\n" +send -- "secure_storage-rs\r" +expect { + -re "We're done, close and release TEE resources" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running supp_plugin-rs...\n" +send -- "supp_plugin-rs\r" +expect { + -re "invoke commmand finished" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running time-rs...\n" +send -- "time-rs\r" +expect { + "Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +expect "# " +info "Running signature_verification-rs...\n" +send -- "signature_verification-rs\r" +expect { + "Success" { + info "Test success\n" + } + timeout { + info "!!! Timeout: Test failed\n" + exit 1 + } +} + +info "Rust examples tested successfully\n"