Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions optee-utee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ once_cell = "1.20.2"
serde = { version = "1.0.215" }
serde_json = { version = "1.0.133" }
# disable linking when running unit tests
optee-utee-sys = { version = "0.7.0", path = "optee-utee-sys", features = ["no_link"] }
optee-utee-mock = { version = "0.7.0", path = "optee-utee-mock" }
optee-utee-sys = { version = "0.7.0", path = "optee-utee-sys", features = ["mock"] }

[features]
default = []
Expand Down
30 changes: 0 additions & 30 deletions optee-utee/optee-utee-mock/Cargo.toml

This file was deleted.

231 changes: 0 additions & 231 deletions optee-utee/optee-utee-mock/src/object.rs

This file was deleted.

2 changes: 2 additions & 0 deletions optee-utee/optee-utee-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ links = "utee"

[dependencies]
libc = "0.2"
mockall = { version = "0.14.0", optional = true }

[features]
default = []
std = []
no_link = []
mock = ["dep:mockall", "std", "no_link"]
21 changes: 16 additions & 5 deletions optee-utee/optee-utee-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(non_camel_case_types, non_snake_case)]

pub use tee_api::*;
pub use tee_api::api::*;
pub use tee_api_defines::*;
pub use tee_api_types::*;
pub use tee_internal_api_extensions::*;
pub use tee_internal_api_extensions::api::*;
pub use tee_ipsocket::*;
pub use tee_isocket::*;
pub use tee_tcpsocket::*;
pub use tee_udpsocket::*;
pub use tee_ipsocket::*;
pub use trace::*;
pub use user_ta_header::*;
pub use utee_syscalls::*;
Expand All @@ -35,14 +35,14 @@ mod tee_api;
mod tee_api_defines;
mod tee_api_types;
mod tee_internal_api_extensions;
mod tee_ipsocket;
mod tee_isocket;
mod tee_tcpsocket;
mod tee_udpsocket;
mod trace;
mod user_ta_header;
mod utee_syscalls;
mod utee_types;
mod tee_ipsocket;

// Currently, the libc crate does not support optee_os, and patching it in
// Xargo.toml within the TA project does not affect optee-utee-sys. Therefore,
Expand All @@ -55,5 +55,16 @@ mod libc_compat {

#[cfg(not(feature = "std"))]
mod libc_compat {
pub use libc::{size_t, intmax_t};
pub use libc::{intmax_t, size_t};
}

#[cfg(feature = "mock")]
pub mod mock_api {
pub use crate::tee_api::mock_api::*;
pub mod extension {
pub use crate::tee_internal_api_extensions::mock_api::*;
}
}

#[cfg(feature = "mock")]
pub mod mock_utils;
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.

#[allow(non_snake_case)]
pub mod object;
use std::sync::Mutex;

// Use this lock to prevent concurrent execution of the test.
pub static SERIAL_TEST_LOCK: Mutex<()> = Mutex::new(());

// re-export some dependencies;
pub use mockall;
pub use optee_utee_sys as raw;
pub mod object;
29 changes: 29 additions & 0 deletions optee-utee/optee-utee-sys/src/mock_utils/object.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

use crate::TEE_ObjectHandle;

pub struct MockHandle(crate::__TEE_ObjectHandle);

impl MockHandle {
pub fn new() -> Self {
Self(unsafe { core::mem::zeroed() })
}
pub fn as_handle(&mut self) -> TEE_ObjectHandle {
&mut self.0
}
}
Loading
Loading