Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //! Rust Binder crate integration tests |
| 18 | |
Stephen Crane | 7bca105 | 2021-10-25 17:52:51 -0700 | [diff] [blame] | 19 | use binder::{declare_binder_enum, declare_binder_interface}; |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 20 | use binder::{BinderFeatures, Interface, StatusCode, ThreadState}; |
| 21 | // Import from internal API for testing only, do not use this module in |
| 22 | // production. |
| 23 | use binder::binder_impl::{ |
| 24 | Binder, BorrowedParcel, IBinderInternal, TransactionCode, FIRST_CALL_TRANSACTION, |
Andrew Walbran | 12400d8 | 2021-03-04 17:04:34 +0000 | [diff] [blame] | 25 | }; |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 26 | |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 27 | use std::convert::{TryFrom, TryInto}; |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 28 | use std::ffi::CStr; |
Andrei Homescu | d23c049 | 2023-11-09 01:51:59 +0000 | [diff] [blame^] | 29 | use std::io::Write; |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 30 | use std::sync::Mutex; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 31 | |
| 32 | /// Name of service runner. |
| 33 | /// |
| 34 | /// Must match the binary name in Android.bp |
| 35 | const RUST_SERVICE_BINARY: &str = "rustBinderTestService"; |
| 36 | |
| 37 | /// Binary to run a test service. |
| 38 | /// |
| 39 | /// This needs to be in a separate process from the tests, so we spawn this |
| 40 | /// binary as a child, providing the service name as an argument. |
| 41 | fn main() -> Result<(), &'static str> { |
| 42 | // Ensure that we can handle all transactions on the main thread. |
| 43 | binder::ProcessState::set_thread_pool_max_thread_count(0); |
| 44 | binder::ProcessState::start_thread_pool(); |
| 45 | |
| 46 | let mut args = std::env::args().skip(1); |
| 47 | if args.len() < 1 || args.len() > 2 { |
| 48 | print_usage(); |
| 49 | return Err(""); |
| 50 | } |
| 51 | let service_name = args.next().ok_or_else(|| { |
| 52 | print_usage(); |
| 53 | "Missing SERVICE_NAME argument" |
| 54 | })?; |
| 55 | let extension_name = args.next(); |
| 56 | |
| 57 | { |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 58 | let mut service = Binder::new(BnTest(Box::new(TestService::new(&service_name)))); |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 59 | service.set_requesting_sid(true); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 60 | if let Some(extension_name) = extension_name { |
Andrew Walbran | 88eca4f | 2021-04-13 14:26:01 +0000 | [diff] [blame] | 61 | let extension = |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 62 | BnTest::new_binder(TestService::new(&extension_name), BinderFeatures::default()); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 63 | service.set_extension(&mut extension.as_binder()).expect("Could not add extension"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 64 | } |
| 65 | binder::add_service(&service_name, service.as_binder()) |
| 66 | .expect("Could not register service"); |
| 67 | } |
| 68 | |
| 69 | binder::ProcessState::join_thread_pool(); |
| 70 | Err("Unexpected exit after join_thread_pool") |
| 71 | } |
| 72 | |
| 73 | fn print_usage() { |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 74 | eprintln!("Usage: {} SERVICE_NAME [EXTENSION_NAME]", RUST_SERVICE_BINARY); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 75 | eprintln!(concat!( |
| 76 | "Spawn a Binder test service identified by SERVICE_NAME,", |
| 77 | " optionally with an extesion named EXTENSION_NAME", |
| 78 | )); |
| 79 | } |
| 80 | |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 81 | struct TestService { |
| 82 | s: String, |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 83 | dump_args: Mutex<Vec<String>>, |
| 84 | } |
| 85 | |
| 86 | impl TestService { |
| 87 | fn new(s: &str) -> Self { |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 88 | Self { s: s.to_string(), dump_args: Mutex::new(Vec::new()) } |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 89 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 92 | #[repr(u32)] |
| 93 | enum TestTransactionCode { |
Andrew Walbran | 12400d8 | 2021-03-04 17:04:34 +0000 | [diff] [blame] | 94 | Test = FIRST_CALL_TRANSACTION, |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 95 | GetDumpArgs, |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 96 | GetSelinuxContext, |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 97 | GetIsHandlingTransaction, |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | impl TryFrom<u32> for TestTransactionCode { |
| 101 | type Error = StatusCode; |
| 102 | |
| 103 | fn try_from(c: u32) -> Result<Self, Self::Error> { |
| 104 | match c { |
| 105 | _ if c == TestTransactionCode::Test as u32 => Ok(TestTransactionCode::Test), |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 106 | _ if c == TestTransactionCode::GetDumpArgs as u32 => { |
| 107 | Ok(TestTransactionCode::GetDumpArgs) |
| 108 | } |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 109 | _ if c == TestTransactionCode::GetSelinuxContext as u32 => { |
| 110 | Ok(TestTransactionCode::GetSelinuxContext) |
| 111 | } |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 112 | _ if c == TestTransactionCode::GetIsHandlingTransaction as u32 => { |
| 113 | Ok(TestTransactionCode::GetIsHandlingTransaction) |
| 114 | } |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 115 | _ => Err(StatusCode::UNKNOWN_TRANSACTION), |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 120 | impl Interface for TestService { |
Andrei Homescu | d23c049 | 2023-11-09 01:51:59 +0000 | [diff] [blame^] | 121 | fn dump(&self, _writer: &mut dyn Write, args: &[&CStr]) -> Result<(), StatusCode> { |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 122 | let mut dump_args = self.dump_args.lock().unwrap(); |
| 123 | dump_args.extend(args.iter().map(|s| s.to_str().unwrap().to_owned())); |
| 124 | Ok(()) |
| 125 | } |
| 126 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 127 | |
| 128 | impl ITest for TestService { |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 129 | fn test(&self) -> Result<String, StatusCode> { |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 130 | Ok(self.s.clone()) |
| 131 | } |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 132 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 133 | fn get_dump_args(&self) -> Result<Vec<String>, StatusCode> { |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 134 | let args = self.dump_args.lock().unwrap().clone(); |
| 135 | Ok(args) |
| 136 | } |
| 137 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 138 | fn get_selinux_context(&self) -> Result<String, StatusCode> { |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 139 | let sid = |
| 140 | ThreadState::with_calling_sid(|sid| sid.map(|s| s.to_string_lossy().into_owned())); |
| 141 | sid.ok_or(StatusCode::UNEXPECTED_NULL) |
| 142 | } |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 143 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 144 | fn get_is_handling_transaction(&self) -> Result<bool, StatusCode> { |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 145 | Ok(binder::is_handling_transaction()) |
| 146 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /// Trivial testing binder interface |
| 150 | pub trait ITest: Interface { |
| 151 | /// Returns a test string |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 152 | fn test(&self) -> Result<String, StatusCode>; |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 153 | |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 154 | /// Return the arguments sent via dump |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 155 | fn get_dump_args(&self) -> Result<Vec<String>, StatusCode>; |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 156 | |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 157 | /// Returns the caller's SELinux context |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 158 | fn get_selinux_context(&self) -> Result<String, StatusCode>; |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 159 | |
| 160 | /// Returns the value of calling `is_handling_transaction`. |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 161 | fn get_is_handling_transaction(&self) -> Result<bool, StatusCode>; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 164 | /// Async trivial testing binder interface |
| 165 | pub trait IATest<P>: Interface { |
| 166 | /// Returns a test string |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 167 | fn test(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>>; |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 168 | |
| 169 | /// Return the arguments sent via dump |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 170 | fn get_dump_args(&self) -> binder::BoxFuture<'static, Result<Vec<String>, StatusCode>>; |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 171 | |
| 172 | /// Returns the caller's SELinux context |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 173 | fn get_selinux_context(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>>; |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 174 | |
| 175 | /// Returns the value of calling `is_handling_transaction`. |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 176 | fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, Result<bool, StatusCode>>; |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 179 | declare_binder_interface! { |
| 180 | ITest["android.os.ITest"] { |
| 181 | native: BnTest(on_transact), |
| 182 | proxy: BpTest { |
| 183 | x: i32 = 100 |
| 184 | }, |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 185 | async: IATest, |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
| 189 | fn on_transact( |
| 190 | service: &dyn ITest, |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 191 | code: TransactionCode, |
Alice Ryhl | 8618c48 | 2021-11-09 15:35:35 +0000 | [diff] [blame] | 192 | _data: &BorrowedParcel<'_>, |
| 193 | reply: &mut BorrowedParcel<'_>, |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 194 | ) -> Result<(), StatusCode> { |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 195 | match code.try_into()? { |
| 196 | TestTransactionCode::Test => reply.write(&service.test()?), |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 197 | TestTransactionCode::GetDumpArgs => reply.write(&service.get_dump_args()?), |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 198 | TestTransactionCode::GetSelinuxContext => reply.write(&service.get_selinux_context()?), |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 199 | TestTransactionCode::GetIsHandlingTransaction => { |
| 200 | reply.write(&service.get_is_handling_transaction()?) |
| 201 | } |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 202 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | impl ITest for BpTest { |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 206 | fn test(&self) -> Result<String, StatusCode> { |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 207 | let reply = |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 208 | self.binder.transact(TestTransactionCode::Test as TransactionCode, 0, |_| Ok(()))?; |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 209 | reply.read() |
| 210 | } |
| 211 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 212 | fn get_dump_args(&self) -> Result<Vec<String>, StatusCode> { |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 213 | let reply = |
| 214 | self.binder |
| 215 | .transact(TestTransactionCode::GetDumpArgs as TransactionCode, 0, |_| Ok(()))?; |
| 216 | reply.read() |
| 217 | } |
| 218 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 219 | fn get_selinux_context(&self) -> Result<String, StatusCode> { |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 220 | let reply = self.binder.transact( |
| 221 | TestTransactionCode::GetSelinuxContext as TransactionCode, |
| 222 | 0, |
| 223 | |_| Ok(()), |
| 224 | )?; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 225 | reply.read() |
| 226 | } |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 227 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 228 | fn get_is_handling_transaction(&self) -> Result<bool, StatusCode> { |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 229 | let reply = self.binder.transact( |
| 230 | TestTransactionCode::GetIsHandlingTransaction as TransactionCode, |
| 231 | 0, |
| 232 | |_| Ok(()), |
| 233 | )?; |
| 234 | reply.read() |
| 235 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 238 | impl<P: binder::BinderAsyncPool> IATest<P> for BpTest { |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 239 | fn test(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> { |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 240 | let binder = self.binder.clone(); |
| 241 | P::spawn( |
Alice Ryhl | 8618c48 | 2021-11-09 15:35:35 +0000 | [diff] [blame] | 242 | move || binder.transact(TestTransactionCode::Test as TransactionCode, 0, |_| Ok(())), |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 243 | |reply| async move { reply?.read() }, |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 244 | ) |
| 245 | } |
| 246 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 247 | fn get_dump_args(&self) -> binder::BoxFuture<'static, Result<Vec<String>, StatusCode>> { |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 248 | let binder = self.binder.clone(); |
| 249 | P::spawn( |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 250 | move || { |
| 251 | binder.transact(TestTransactionCode::GetDumpArgs as TransactionCode, 0, |_| Ok(())) |
| 252 | }, |
| 253 | |reply| async move { reply?.read() }, |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 254 | ) |
| 255 | } |
| 256 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 257 | fn get_selinux_context(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> { |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 258 | let binder = self.binder.clone(); |
| 259 | P::spawn( |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 260 | move || { |
| 261 | binder.transact( |
| 262 | TestTransactionCode::GetSelinuxContext as TransactionCode, |
| 263 | 0, |
| 264 | |_| Ok(()), |
| 265 | ) |
| 266 | }, |
| 267 | |reply| async move { reply?.read() }, |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 268 | ) |
| 269 | } |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 270 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 271 | fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, Result<bool, StatusCode>> { |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 272 | let binder = self.binder.clone(); |
| 273 | P::spawn( |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 274 | move || { |
| 275 | binder.transact( |
| 276 | TestTransactionCode::GetIsHandlingTransaction as TransactionCode, |
| 277 | 0, |
| 278 | |_| Ok(()), |
| 279 | ) |
| 280 | }, |
| 281 | |reply| async move { reply?.read() }, |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 282 | ) |
| 283 | } |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 284 | } |
| 285 | |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 286 | impl ITest for Binder<BnTest> { |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 287 | fn test(&self) -> Result<String, StatusCode> { |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 288 | self.0.test() |
| 289 | } |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 290 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 291 | fn get_dump_args(&self) -> Result<Vec<String>, StatusCode> { |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 292 | self.0.get_dump_args() |
| 293 | } |
| 294 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 295 | fn get_selinux_context(&self) -> Result<String, StatusCode> { |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 296 | self.0.get_selinux_context() |
| 297 | } |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 298 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 299 | fn get_is_handling_transaction(&self) -> Result<bool, StatusCode> { |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 300 | self.0.get_is_handling_transaction() |
| 301 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 304 | impl<P: binder::BinderAsyncPool> IATest<P> for Binder<BnTest> { |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 305 | fn test(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> { |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 306 | let res = self.0.test(); |
| 307 | Box::pin(async move { res }) |
| 308 | } |
| 309 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 310 | fn get_dump_args(&self) -> binder::BoxFuture<'static, Result<Vec<String>, StatusCode>> { |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 311 | let res = self.0.get_dump_args(); |
| 312 | Box::pin(async move { res }) |
| 313 | } |
| 314 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 315 | fn get_selinux_context(&self) -> binder::BoxFuture<'static, Result<String, StatusCode>> { |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 316 | let res = self.0.get_selinux_context(); |
| 317 | Box::pin(async move { res }) |
| 318 | } |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 319 | |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 320 | fn get_is_handling_transaction(&self) -> binder::BoxFuture<'static, Result<bool, StatusCode>> { |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 321 | let res = self.0.get_is_handling_transaction(); |
| 322 | Box::pin(async move { res }) |
| 323 | } |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 326 | /// Trivial testing binder interface |
| 327 | pub trait ITestSameDescriptor: Interface {} |
| 328 | |
| 329 | declare_binder_interface! { |
| 330 | ITestSameDescriptor["android.os.ITest"] { |
| 331 | native: BnTestSameDescriptor(on_transact_same_descriptor), |
| 332 | proxy: BpTestSameDescriptor, |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | fn on_transact_same_descriptor( |
| 337 | _service: &dyn ITestSameDescriptor, |
| 338 | _code: TransactionCode, |
Alice Ryhl | 8618c48 | 2021-11-09 15:35:35 +0000 | [diff] [blame] | 339 | _data: &BorrowedParcel<'_>, |
| 340 | _reply: &mut BorrowedParcel<'_>, |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 341 | ) -> Result<(), StatusCode> { |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 342 | Ok(()) |
| 343 | } |
| 344 | |
| 345 | impl ITestSameDescriptor for BpTestSameDescriptor {} |
| 346 | |
| 347 | impl ITestSameDescriptor for Binder<BnTestSameDescriptor> {} |
| 348 | |
Stephen Crane | 7bca105 | 2021-10-25 17:52:51 -0700 | [diff] [blame] | 349 | declare_binder_enum! { |
| 350 | TestEnum : [i32; 3] { |
| 351 | FOO = 1, |
| 352 | BAR = 2, |
| 353 | BAZ = 3, |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | declare_binder_enum! { |
| 358 | #[deprecated(since = "1.0.0")] |
| 359 | TestDeprecatedEnum : [i32; 3] { |
| 360 | FOO = 1, |
| 361 | BAR = 2, |
| 362 | BAZ = 3, |
| 363 | } |
| 364 | } |
| 365 | |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 366 | #[cfg(test)] |
| 367 | mod tests { |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 368 | use selinux_bindgen as selinux_sys; |
| 369 | use std::ffi::CStr; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 370 | use std::fs::File; |
| 371 | use std::process::{Child, Command}; |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 372 | use std::ptr; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 373 | use std::sync::atomic::{AtomicBool, Ordering}; |
| 374 | use std::sync::Arc; |
| 375 | use std::thread; |
| 376 | use std::time::Duration; |
| 377 | |
Andrew Walbran | 12400d8 | 2021-03-04 17:04:34 +0000 | [diff] [blame] | 378 | use binder::{ |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 379 | BinderFeatures, DeathRecipient, FromIBinder, IBinder, Interface, SpIBinder, StatusCode, |
| 380 | Strong, |
Andrew Walbran | 12400d8 | 2021-03-04 17:04:34 +0000 | [diff] [blame] | 381 | }; |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 382 | // Import from impl API for testing only, should not be necessary as long as |
| 383 | // you are using AIDL. |
| 384 | use binder::binder_impl::{Binder, IBinderInternal, TransactionCode}; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 385 | |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 386 | use binder_tokio::Tokio; |
| 387 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 388 | use super::{BnTest, IATest, ITest, ITestSameDescriptor, TestService, RUST_SERVICE_BINARY}; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 389 | |
| 390 | pub struct ScopedServiceProcess(Child); |
| 391 | |
| 392 | impl ScopedServiceProcess { |
| 393 | pub fn new(identifier: &str) -> Self { |
| 394 | Self::new_internal(identifier, None) |
| 395 | } |
| 396 | |
| 397 | pub fn new_with_extension(identifier: &str, extension: &str) -> Self { |
| 398 | Self::new_internal(identifier, Some(extension)) |
| 399 | } |
| 400 | |
| 401 | fn new_internal(identifier: &str, extension: Option<&str>) -> Self { |
| 402 | let mut binary_path = |
| 403 | std::env::current_exe().expect("Could not retrieve current executable path"); |
| 404 | binary_path.pop(); |
| 405 | binary_path.push(RUST_SERVICE_BINARY); |
| 406 | let mut command = Command::new(&binary_path); |
| 407 | command.arg(identifier); |
| 408 | if let Some(ext) = extension { |
| 409 | command.arg(ext); |
| 410 | } |
| 411 | let child = command.spawn().expect("Could not start service"); |
| 412 | Self(child) |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | impl Drop for ScopedServiceProcess { |
| 417 | fn drop(&mut self) { |
| 418 | self.0.kill().expect("Could not kill child process"); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 419 | self.0.wait().expect("Could not wait for child process to die"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | |
| 423 | #[test] |
| 424 | fn check_services() { |
| 425 | let mut sm = binder::get_service("manager").expect("Did not get manager binder service"); |
| 426 | assert!(sm.is_binder_alive()); |
| 427 | assert!(sm.ping_binder().is_ok()); |
| 428 | |
| 429 | assert!(binder::get_service("this_service_does_not_exist").is_none()); |
| 430 | assert_eq!( |
| 431 | binder::get_interface::<dyn ITest>("this_service_does_not_exist").err(), |
| 432 | Some(StatusCode::NAME_NOT_FOUND) |
| 433 | ); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 434 | assert_eq!( |
| 435 | binder::get_interface::<dyn IATest<Tokio>>("this_service_does_not_exist").err(), |
| 436 | Some(StatusCode::NAME_NOT_FOUND) |
| 437 | ); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 438 | |
| 439 | // The service manager service isn't an ITest, so this must fail. |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 440 | assert_eq!(binder::get_interface::<dyn ITest>("manager").err(), Some(StatusCode::BAD_TYPE)); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 441 | assert_eq!( |
| 442 | binder::get_interface::<dyn IATest<Tokio>>("manager").err(), |
| 443 | Some(StatusCode::BAD_TYPE) |
| 444 | ); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 445 | } |
| 446 | |
Alice Ryhl | 929804f | 2021-11-02 12:04:39 +0000 | [diff] [blame] | 447 | #[tokio::test] |
| 448 | async fn check_services_async() { |
| 449 | let mut sm = binder::get_service("manager").expect("Did not get manager binder service"); |
| 450 | assert!(sm.is_binder_alive()); |
| 451 | assert!(sm.ping_binder().is_ok()); |
| 452 | |
| 453 | assert!(binder::get_service("this_service_does_not_exist").is_none()); |
| 454 | assert_eq!( |
| 455 | binder_tokio::get_interface::<dyn ITest>("this_service_does_not_exist").await.err(), |
| 456 | Some(StatusCode::NAME_NOT_FOUND) |
| 457 | ); |
| 458 | assert_eq!( |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 459 | binder_tokio::get_interface::<dyn IATest<Tokio>>("this_service_does_not_exist") |
| 460 | .await |
| 461 | .err(), |
Alice Ryhl | 929804f | 2021-11-02 12:04:39 +0000 | [diff] [blame] | 462 | Some(StatusCode::NAME_NOT_FOUND) |
| 463 | ); |
| 464 | |
| 465 | // The service manager service isn't an ITest, so this must fail. |
| 466 | assert_eq!( |
| 467 | binder_tokio::get_interface::<dyn ITest>("manager").await.err(), |
| 468 | Some(StatusCode::BAD_TYPE) |
| 469 | ); |
| 470 | assert_eq!( |
| 471 | binder_tokio::get_interface::<dyn IATest<Tokio>>("manager").await.err(), |
| 472 | Some(StatusCode::BAD_TYPE) |
| 473 | ); |
| 474 | } |
| 475 | |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 476 | #[test] |
Andrew Walbran | c3ce5c3 | 2021-06-03 16:15:56 +0000 | [diff] [blame] | 477 | fn check_wait_for_service() { |
| 478 | let mut sm = |
| 479 | binder::wait_for_service("manager").expect("Did not get manager binder service"); |
| 480 | assert!(sm.is_binder_alive()); |
| 481 | assert!(sm.ping_binder().is_ok()); |
| 482 | |
| 483 | // The service manager service isn't an ITest, so this must fail. |
| 484 | assert_eq!( |
| 485 | binder::wait_for_interface::<dyn ITest>("manager").err(), |
| 486 | Some(StatusCode::BAD_TYPE) |
| 487 | ); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 488 | assert_eq!( |
| 489 | binder::wait_for_interface::<dyn IATest<Tokio>>("manager").err(), |
| 490 | Some(StatusCode::BAD_TYPE) |
| 491 | ); |
Andrew Walbran | c3ce5c3 | 2021-06-03 16:15:56 +0000 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | #[test] |
Stephen Crane | 098bbc9 | 2022-02-14 13:31:53 -0800 | [diff] [blame] | 495 | fn get_declared_instances() { |
| 496 | // At the time of writing this test, there is no good VINTF interface |
| 497 | // guaranteed to be on all devices. Cuttlefish has light, so this will |
| 498 | // generally test things. |
| 499 | let has_lights = binder::is_declared("android.hardware.light.ILights/default") |
| 500 | .expect("Could not check for declared interface"); |
| 501 | |
| 502 | let instances = binder::get_declared_instances("android.hardware.light.ILights") |
| 503 | .expect("Could not get declared instances"); |
| 504 | |
Chris Wailes | 4247166 | 2022-11-16 15:41:38 -0800 | [diff] [blame] | 505 | let expected_defaults = usize::from(has_lights); |
Stephen Crane | 098bbc9 | 2022-02-14 13:31:53 -0800 | [diff] [blame] | 506 | assert_eq!(expected_defaults, instances.iter().filter(|i| i.as_str() == "default").count()); |
| 507 | } |
| 508 | |
| 509 | #[test] |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 510 | fn trivial_client() { |
| 511 | let service_name = "trivial_client_test"; |
| 512 | let _process = ScopedServiceProcess::new(service_name); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 513 | let test_client: Strong<dyn ITest> = |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 514 | binder::get_interface(service_name).expect("Did not get manager binder service"); |
| 515 | assert_eq!(test_client.test().unwrap(), "trivial_client_test"); |
| 516 | } |
| 517 | |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 518 | #[tokio::test] |
| 519 | async fn trivial_client_async() { |
| 520 | let service_name = "trivial_client_test"; |
| 521 | let _process = ScopedServiceProcess::new(service_name); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 522 | let test_client: Strong<dyn IATest<Tokio>> = binder_tokio::get_interface(service_name) |
| 523 | .await |
| 524 | .expect("Did not get manager binder service"); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 525 | assert_eq!(test_client.test().await.unwrap(), "trivial_client_test"); |
| 526 | } |
| 527 | |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 528 | #[test] |
Andrew Walbran | c3ce5c3 | 2021-06-03 16:15:56 +0000 | [diff] [blame] | 529 | fn wait_for_trivial_client() { |
| 530 | let service_name = "wait_for_trivial_client_test"; |
| 531 | let _process = ScopedServiceProcess::new(service_name); |
| 532 | let test_client: Strong<dyn ITest> = |
| 533 | binder::wait_for_interface(service_name).expect("Did not get manager binder service"); |
| 534 | assert_eq!(test_client.test().unwrap(), "wait_for_trivial_client_test"); |
| 535 | } |
| 536 | |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 537 | #[tokio::test] |
| 538 | async fn wait_for_trivial_client_async() { |
| 539 | let service_name = "wait_for_trivial_client_test"; |
| 540 | let _process = ScopedServiceProcess::new(service_name); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 541 | let test_client: Strong<dyn IATest<Tokio>> = binder_tokio::wait_for_interface(service_name) |
| 542 | .await |
| 543 | .expect("Did not get manager binder service"); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 544 | assert_eq!(test_client.test().await.unwrap(), "wait_for_trivial_client_test"); |
| 545 | } |
| 546 | |
| 547 | fn get_expected_selinux_context() -> &'static str { |
Andrew Walbran | 4ed9d77 | 2023-07-21 18:21:05 +0100 | [diff] [blame] | 548 | // SAFETY: The pointer we pass to `getcon` is valid because it comes from a reference, and |
| 549 | // `getcon` doesn't retain it after it returns. If `getcon` succeeds then `out_ptr` will |
| 550 | // point to a valid C string, otherwise it will remain null. We check for null, so the |
| 551 | // pointer we pass to `CStr::from_ptr` must be a valid pointer to a C string. There is a |
| 552 | // memory leak as we don't call `freecon`, but that's fine because this is just a test. |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 553 | unsafe { |
| 554 | let mut out_ptr = ptr::null_mut(); |
| 555 | assert_eq!(selinux_sys::getcon(&mut out_ptr), 0); |
| 556 | assert!(!out_ptr.is_null()); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 557 | CStr::from_ptr(out_ptr).to_str().expect("context was invalid UTF-8") |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 558 | } |
| 559 | } |
| 560 | |
Andrew Walbran | c3ce5c3 | 2021-06-03 16:15:56 +0000 | [diff] [blame] | 561 | #[test] |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 562 | fn get_selinux_context() { |
| 563 | let service_name = "get_selinux_context"; |
| 564 | let _process = ScopedServiceProcess::new(service_name); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 565 | let test_client: Strong<dyn ITest> = |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 566 | binder::get_interface(service_name).expect("Did not get manager binder service"); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 567 | assert_eq!(test_client.get_selinux_context().unwrap(), get_expected_selinux_context()); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | #[tokio::test] |
| 571 | async fn get_selinux_context_async() { |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 572 | let service_name = "get_selinux_context_async"; |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 573 | let _process = ScopedServiceProcess::new(service_name); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 574 | let test_client: Strong<dyn IATest<Tokio>> = binder_tokio::get_interface(service_name) |
| 575 | .await |
| 576 | .expect("Did not get manager binder service"); |
Alice Ryhl | 05f5a2c | 2021-09-15 12:56:10 +0000 | [diff] [blame] | 577 | assert_eq!( |
| 578 | test_client.get_selinux_context().await.unwrap(), |
| 579 | get_expected_selinux_context() |
Janis Danisevskis | 798a09a | 2020-08-18 08:35:38 -0700 | [diff] [blame] | 580 | ); |
| 581 | } |
| 582 | |
Alice Ryhl | c173684 | 2021-11-23 12:38:51 +0000 | [diff] [blame] | 583 | #[tokio::test] |
| 584 | async fn get_selinux_context_sync_to_async() { |
| 585 | let service_name = "get_selinux_context"; |
| 586 | let _process = ScopedServiceProcess::new(service_name); |
| 587 | let test_client: Strong<dyn ITest> = |
| 588 | binder::get_interface(service_name).expect("Did not get manager binder service"); |
| 589 | let test_client = test_client.into_async::<Tokio>(); |
| 590 | assert_eq!( |
| 591 | test_client.get_selinux_context().await.unwrap(), |
| 592 | get_expected_selinux_context() |
| 593 | ); |
| 594 | } |
| 595 | |
| 596 | #[tokio::test] |
| 597 | async fn get_selinux_context_async_to_sync() { |
| 598 | let service_name = "get_selinux_context"; |
| 599 | let _process = ScopedServiceProcess::new(service_name); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 600 | let test_client: Strong<dyn IATest<Tokio>> = binder_tokio::get_interface(service_name) |
| 601 | .await |
| 602 | .expect("Did not get manager binder service"); |
Alice Ryhl | c173684 | 2021-11-23 12:38:51 +0000 | [diff] [blame] | 603 | let test_client = test_client.into_sync(); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 604 | assert_eq!(test_client.get_selinux_context().unwrap(), get_expected_selinux_context()); |
Alice Ryhl | c173684 | 2021-11-23 12:38:51 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 607 | struct Bools { |
| 608 | binder_died: Arc<AtomicBool>, |
| 609 | binder_dealloc: Arc<AtomicBool>, |
| 610 | } |
| 611 | |
| 612 | impl Bools { |
| 613 | fn is_dead(&self) -> bool { |
| 614 | self.binder_died.load(Ordering::Relaxed) |
| 615 | } |
| 616 | fn assert_died(&self) { |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 617 | assert!(self.is_dead(), "Did not receive death notification"); |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 618 | } |
| 619 | fn assert_dropped(&self) { |
| 620 | assert!( |
| 621 | self.binder_dealloc.load(Ordering::Relaxed), |
| 622 | "Did not dealloc death notification" |
| 623 | ); |
| 624 | } |
| 625 | fn assert_not_dropped(&self) { |
| 626 | assert!( |
| 627 | !self.binder_dealloc.load(Ordering::Relaxed), |
| 628 | "Dealloc death notification too early" |
| 629 | ); |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | fn register_death_notification(binder: &mut SpIBinder) -> (Bools, DeathRecipient) { |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 634 | let binder_died = Arc::new(AtomicBool::new(false)); |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 635 | let binder_dealloc = Arc::new(AtomicBool::new(false)); |
| 636 | |
| 637 | struct SetOnDrop { |
| 638 | binder_dealloc: Arc<AtomicBool>, |
| 639 | } |
| 640 | impl Drop for SetOnDrop { |
| 641 | fn drop(&mut self) { |
| 642 | self.binder_dealloc.store(true, Ordering::Relaxed); |
| 643 | } |
| 644 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 645 | |
| 646 | let mut death_recipient = { |
| 647 | let flag = binder_died.clone(); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 648 | let set_on_drop = SetOnDrop { binder_dealloc: binder_dealloc.clone() }; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 649 | DeathRecipient::new(move || { |
| 650 | flag.store(true, Ordering::Relaxed); |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 651 | // Force the closure to take ownership of set_on_drop. When the closure is |
| 652 | // dropped, the destructor of `set_on_drop` will run. |
| 653 | let _ = &set_on_drop; |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 654 | }) |
| 655 | }; |
| 656 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 657 | binder.link_to_death(&mut death_recipient).expect("link_to_death failed"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 658 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 659 | let bools = Bools { binder_died, binder_dealloc }; |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 660 | |
| 661 | (bools, death_recipient) |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | /// Killing a remote service should unregister the service and trigger |
| 665 | /// death notifications. |
| 666 | #[test] |
| 667 | fn test_death_notifications() { |
| 668 | binder::ProcessState::start_thread_pool(); |
| 669 | |
| 670 | let service_name = "test_death_notifications"; |
| 671 | let service_process = ScopedServiceProcess::new(service_name); |
| 672 | let mut remote = binder::get_service(service_name).expect("Could not retrieve service"); |
| 673 | |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 674 | let (bools, recipient) = register_death_notification(&mut remote); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 675 | |
| 676 | drop(service_process); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 677 | remote.ping_binder().expect_err("Service should have died already"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 678 | |
| 679 | // Pause to ensure any death notifications get delivered |
| 680 | thread::sleep(Duration::from_secs(1)); |
| 681 | |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 682 | bools.assert_died(); |
| 683 | bools.assert_not_dropped(); |
| 684 | |
| 685 | drop(recipient); |
| 686 | |
| 687 | bools.assert_dropped(); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | /// Test unregistering death notifications. |
| 691 | #[test] |
| 692 | fn test_unregister_death_notifications() { |
| 693 | binder::ProcessState::start_thread_pool(); |
| 694 | |
| 695 | let service_name = "test_unregister_death_notifications"; |
| 696 | let service_process = ScopedServiceProcess::new(service_name); |
| 697 | let mut remote = binder::get_service(service_name).expect("Could not retrieve service"); |
| 698 | |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 699 | let (bools, mut recipient) = register_death_notification(&mut remote); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 700 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 701 | remote.unlink_to_death(&mut recipient).expect("Could not unlink death notifications"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 702 | |
| 703 | drop(service_process); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 704 | remote.ping_binder().expect_err("Service should have died already"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 705 | |
| 706 | // Pause to ensure any death notifications get delivered |
| 707 | thread::sleep(Duration::from_secs(1)); |
| 708 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 709 | assert!(!bools.is_dead(), "Received unexpected death notification after unlinking",); |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 710 | |
| 711 | bools.assert_not_dropped(); |
| 712 | drop(recipient); |
| 713 | bools.assert_dropped(); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | /// Dropping a remote handle should unregister any death notifications. |
| 717 | #[test] |
| 718 | fn test_death_notification_registration_lifetime() { |
| 719 | binder::ProcessState::start_thread_pool(); |
| 720 | |
| 721 | let service_name = "test_death_notification_registration_lifetime"; |
| 722 | let service_process = ScopedServiceProcess::new(service_name); |
| 723 | let mut remote = binder::get_service(service_name).expect("Could not retrieve service"); |
| 724 | |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 725 | let (bools, recipient) = register_death_notification(&mut remote); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 726 | |
| 727 | // This should automatically unregister our death notification. |
| 728 | drop(remote); |
| 729 | |
| 730 | drop(service_process); |
| 731 | |
| 732 | // Pause to ensure any death notifications get delivered |
| 733 | thread::sleep(Duration::from_secs(1)); |
| 734 | |
| 735 | // We dropped the remote handle, so we should not receive the death |
| 736 | // notification when the remote process dies here. |
| 737 | assert!( |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 738 | !bools.is_dead(), |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 739 | "Received unexpected death notification after dropping remote handle" |
| 740 | ); |
Alice Ryhl | ea9d9d2 | 2021-08-27 07:51:30 +0000 | [diff] [blame] | 741 | |
| 742 | bools.assert_not_dropped(); |
| 743 | drop(recipient); |
| 744 | bools.assert_dropped(); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | /// Test IBinder interface methods not exercised elsewhere. |
| 748 | #[test] |
| 749 | fn test_misc_ibinder() { |
| 750 | let service_name = "rust_test_ibinder"; |
| 751 | |
| 752 | { |
| 753 | let _process = ScopedServiceProcess::new(service_name); |
| 754 | |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 755 | let test_client: Strong<dyn ITest> = |
Stephen Crane | f2735b4 | 2022-01-19 17:49:46 +0000 | [diff] [blame] | 756 | binder::get_interface(service_name).expect("Did not get test binder service"); |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 757 | let mut remote = test_client.as_binder(); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 758 | assert!(remote.is_binder_alive()); |
| 759 | remote.ping_binder().expect("Could not ping remote service"); |
| 760 | |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 761 | let dump_args = ["dump", "args", "for", "testing"]; |
| 762 | |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 763 | let null_out = File::open("/dev/null").expect("Could not open /dev/null"); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 764 | remote.dump(&null_out, &dump_args).expect("Could not dump remote service"); |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 765 | |
| 766 | let remote_args = test_client.get_dump_args().expect("Could not fetched dumped args"); |
| 767 | assert_eq!(dump_args, remote_args[..], "Remote args don't match call to dump"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | // get/set_extensions is tested in test_extensions() |
| 771 | |
| 772 | // transact is tested everywhere else, and we can't make raw |
| 773 | // transactions outside the [FIRST_CALL_TRANSACTION, |
| 774 | // LAST_CALL_TRANSACTION] range from the NDK anyway. |
| 775 | |
| 776 | // link_to_death is tested in test_*_death_notification* tests. |
| 777 | } |
| 778 | |
| 779 | #[test] |
| 780 | fn test_extensions() { |
| 781 | let service_name = "rust_test_extensions"; |
| 782 | let extension_name = "rust_test_extensions_ext"; |
| 783 | |
| 784 | { |
| 785 | let _process = ScopedServiceProcess::new(service_name); |
| 786 | |
| 787 | let mut remote = binder::get_service(service_name); |
| 788 | assert!(remote.is_binder_alive()); |
| 789 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 790 | let extension = remote.get_extension().expect("Could not check for an extension"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 791 | assert!(extension.is_none()); |
| 792 | } |
| 793 | |
| 794 | { |
| 795 | let _process = ScopedServiceProcess::new_with_extension(service_name, extension_name); |
| 796 | |
| 797 | let mut remote = binder::get_service(service_name); |
| 798 | assert!(remote.is_binder_alive()); |
| 799 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 800 | let maybe_extension = remote.get_extension().expect("Could not check for an extension"); |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 801 | |
| 802 | let extension = maybe_extension.expect("Remote binder did not have an extension"); |
| 803 | |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 804 | let extension: Strong<dyn ITest> = FromIBinder::try_from(extension) |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 805 | .expect("Extension could not be converted to the expected interface"); |
| 806 | |
| 807 | assert_eq!(extension.test().unwrap(), extension_name); |
| 808 | } |
| 809 | } |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 810 | |
| 811 | /// Test re-associating a local binder object with a different class. |
| 812 | /// |
| 813 | /// This is needed because different binder service (e.g. NDK vs Rust) |
| 814 | /// implementations are incompatible and must not be interchanged. A local |
| 815 | /// service with the same descriptor string but a different class pointer |
| 816 | /// may have been created by an NDK service and is therefore incompatible |
| 817 | /// with the Rust service implementation. It must be treated as remote and |
| 818 | /// all API calls parceled and sent through transactions. |
| 819 | /// |
| 820 | /// Further tests of this behavior with the C NDK and Rust API are in |
| 821 | /// rust_ndk_interop.rs |
| 822 | #[test] |
| 823 | fn associate_existing_class() { |
Stephen Crane | 2a3297f | 2021-06-11 16:48:10 -0700 | [diff] [blame] | 824 | let service = Binder::new(BnTest(Box::new(TestService::new("testing_service")))); |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 825 | |
| 826 | // This should succeed although we will have to treat the service as |
| 827 | // remote. |
Andrew Walbran | 12400d8 | 2021-03-04 17:04:34 +0000 | [diff] [blame] | 828 | let _interface: Strong<dyn ITestSameDescriptor> = |
| 829 | FromIBinder::try_from(service.as_binder()) |
| 830 | .expect("Could not re-interpret service as the ITestSameDescriptor interface"); |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | /// Test that we can round-trip a rust service through a generic IBinder |
| 834 | #[test] |
| 835 | fn reassociate_rust_binder() { |
| 836 | let service_name = "testing_service"; |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 837 | let service_ibinder = |
| 838 | BnTest::new_binder(TestService::new(service_name), BinderFeatures::default()) |
| 839 | .as_binder(); |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 840 | |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 841 | let service: Strong<dyn ITest> = |
| 842 | service_ibinder.into_interface().expect("Could not reassociate the generic ibinder"); |
Stephen Crane | 669deb6 | 2020-09-10 17:31:39 -0700 | [diff] [blame] | 843 | |
| 844 | assert_eq!(service.test().unwrap(), service_name); |
| 845 | } |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 846 | |
| 847 | #[test] |
| 848 | fn weak_binder_upgrade() { |
| 849 | let service_name = "testing_service"; |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 850 | let service = BnTest::new_binder(TestService::new(service_name), BinderFeatures::default()); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 851 | |
| 852 | let weak = Strong::downgrade(&service); |
| 853 | |
| 854 | let upgraded = weak.upgrade().expect("Could not upgrade weak binder"); |
| 855 | |
| 856 | assert_eq!(service, upgraded); |
| 857 | } |
| 858 | |
| 859 | #[test] |
| 860 | fn weak_binder_upgrade_dead() { |
| 861 | let service_name = "testing_service"; |
| 862 | let weak = { |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 863 | let service = |
| 864 | BnTest::new_binder(TestService::new(service_name), BinderFeatures::default()); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 865 | |
| 866 | Strong::downgrade(&service) |
| 867 | }; |
| 868 | |
| 869 | assert_eq!(weak.upgrade(), Err(StatusCode::DEAD_OBJECT)); |
| 870 | } |
| 871 | |
| 872 | #[test] |
| 873 | fn weak_binder_clone() { |
| 874 | let service_name = "testing_service"; |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 875 | let service = BnTest::new_binder(TestService::new(service_name), BinderFeatures::default()); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 876 | |
| 877 | let weak = Strong::downgrade(&service); |
| 878 | let cloned = weak.clone(); |
| 879 | assert_eq!(weak, cloned); |
| 880 | |
| 881 | let upgraded = weak.upgrade().expect("Could not upgrade weak binder"); |
| 882 | let clone_upgraded = cloned.upgrade().expect("Could not upgrade weak binder"); |
| 883 | |
| 884 | assert_eq!(service, upgraded); |
| 885 | assert_eq!(service, clone_upgraded); |
| 886 | } |
| 887 | |
| 888 | #[test] |
| 889 | #[allow(clippy::eq_op)] |
| 890 | fn binder_ord() { |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 891 | let service1 = |
| 892 | BnTest::new_binder(TestService::new("testing_service1"), BinderFeatures::default()); |
| 893 | let service2 = |
| 894 | BnTest::new_binder(TestService::new("testing_service2"), BinderFeatures::default()); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 895 | |
Charisee | 1ccdc90 | 2022-02-26 01:22:27 +0000 | [diff] [blame] | 896 | assert!((service1 >= service1)); |
| 897 | assert!((service1 <= service1)); |
| 898 | assert_eq!(service1 < service2, (service2 >= service1)); |
Stephen Crane | ddb3e6d | 2020-12-18 13:27:22 -0800 | [diff] [blame] | 899 | } |
Alice Ryhl | feba6ca | 2021-08-19 10:47:04 +0000 | [diff] [blame] | 900 | |
| 901 | #[test] |
| 902 | fn binder_parcel_mixup() { |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 903 | let service1 = |
| 904 | BnTest::new_binder(TestService::new("testing_service1"), BinderFeatures::default()); |
| 905 | let service2 = |
| 906 | BnTest::new_binder(TestService::new("testing_service2"), BinderFeatures::default()); |
Alice Ryhl | feba6ca | 2021-08-19 10:47:04 +0000 | [diff] [blame] | 907 | |
| 908 | let service1 = service1.as_binder(); |
| 909 | let service2 = service2.as_binder(); |
| 910 | |
| 911 | let parcel = service1.prepare_transact().unwrap(); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 912 | let res = service2.submit_transact( |
| 913 | super::TestTransactionCode::Test as TransactionCode, |
| 914 | parcel, |
| 915 | 0, |
| 916 | ); |
Alice Ryhl | feba6ca | 2021-08-19 10:47:04 +0000 | [diff] [blame] | 917 | |
| 918 | match res { |
| 919 | Ok(_) => panic!("submit_transact should fail"), |
| 920 | Err(err) => assert_eq!(err, binder::StatusCode::BAD_VALUE), |
| 921 | } |
| 922 | } |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 923 | |
| 924 | #[test] |
| 925 | fn get_is_handling_transaction() { |
| 926 | let service_name = "get_is_handling_transaction"; |
| 927 | let _process = ScopedServiceProcess::new(service_name); |
| 928 | let test_client: Strong<dyn ITest> = |
| 929 | binder::get_interface(service_name).expect("Did not get manager binder service"); |
| 930 | // Should be true externally. |
| 931 | assert!(test_client.get_is_handling_transaction().unwrap()); |
| 932 | |
| 933 | // Should be false locally. |
| 934 | assert!(!binder::is_handling_transaction()); |
| 935 | |
| 936 | // Should also be false in spawned thread. |
| 937 | std::thread::spawn(|| { |
| 938 | assert!(!binder::is_handling_transaction()); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 939 | }) |
| 940 | .join() |
| 941 | .unwrap(); |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | #[tokio::test] |
| 945 | async fn get_is_handling_transaction_async() { |
| 946 | let service_name = "get_is_handling_transaction_async"; |
| 947 | let _process = ScopedServiceProcess::new(service_name); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 948 | let test_client: Strong<dyn IATest<Tokio>> = binder_tokio::get_interface(service_name) |
| 949 | .await |
| 950 | .expect("Did not get manager binder service"); |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 951 | // Should be true externally. |
| 952 | assert!(test_client.get_is_handling_transaction().await.unwrap()); |
| 953 | |
| 954 | // Should be false locally. |
| 955 | assert!(!binder::is_handling_transaction()); |
| 956 | |
| 957 | // Should also be false in spawned task. |
| 958 | tokio::spawn(async { |
| 959 | assert!(!binder::is_handling_transaction()); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 960 | }) |
| 961 | .await |
| 962 | .unwrap(); |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 963 | |
| 964 | // And in spawn_blocking task. |
| 965 | tokio::task::spawn_blocking(|| { |
| 966 | assert!(!binder::is_handling_transaction()); |
Matthew Maurer | e268a9f | 2022-07-26 09:31:30 -0700 | [diff] [blame] | 967 | }) |
| 968 | .await |
| 969 | .unwrap(); |
Alice Ryhl | 29a5026 | 2021-12-10 11:14:32 +0000 | [diff] [blame] | 970 | } |
Stephen Crane | 2a3c250 | 2020-06-16 17:48:35 -0700 | [diff] [blame] | 971 | } |