Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passed more testcases #20

Merged
merged 1 commit into from
Sep 30, 2024
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
2 changes: 1 addition & 1 deletion rsbinder-tools/src/bin/rsb_hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let _ = clap::Command::new("rsb_hub")
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
.about("Linux daemon that emulates functionality similar to Android's ServiceManager")
.about("A service manager for Binder IPC on Linux. Facilitates service registration, discovery, and management.")
.get_matches();

env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init();
Expand Down
8 changes: 4 additions & 4 deletions rsbinder/src/ref_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ impl RefCounter {
pub fn dec(&self, f: impl FnOnce() -> Result<()>) -> Result<()> {
let c = self.count.fetch_sub(1, Ordering::Relaxed);
if c == 1 {
self.count.compare_exchange(0, INITIAL_STRONG_VALUE,
Ordering::Relaxed, Ordering::Relaxed)
.expect("Failed to exchange the reference count.");
f()?;
if self.count.compare_exchange(0, INITIAL_STRONG_VALUE,
Ordering::Relaxed, Ordering::Relaxed).is_ok() {
f()?;
}
}
Ok(())
}
Expand Down
64 changes: 32 additions & 32 deletions tests/src/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,40 +968,40 @@ fn test_renamed_interface_old_as_old() {
});
}

// #[test]
// fn test_renamed_interface_new_as_new() {
// test_renamed_interface(|_, new_name| {
// assert_eq!(
// <BpNewName as INewName::INewName>::descriptor(),
// "android.aidl.tests.IOldName"
// );

// let real_name = new_name.RealName();
// assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName"));
// });
// }
#[test]
fn test_renamed_interface_new_as_new() {
test_renamed_interface(|_, new_name| {
assert_eq!(
<BpNewName as INewName::INewName>::descriptor(),
"android.aidl.tests.IOldName"
);

// #[test]
// fn test_renamed_interface_old_as_new() {
// test_renamed_interface(|old_name, _| {
// let new_name = old_name.as_binder().into_interface::<dyn INewName::INewName>();
// assert!(new_name.is_ok());

// let real_name = new_name.unwrap().RealName();
// assert_eq!(real_name.as_ref().map(String::as_str), Ok("OldName"));
// });
// }
let real_name = new_name.RealName();
assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName"));
});
}

// #[test]
// fn test_renamed_interface_new_as_old() {
// test_renamed_interface(|_, new_name| {
// let old_name = new_name.as_binder().into_interface::<dyn IOldName::IOldName>();
// assert!(old_name.is_ok());

// let real_name = old_name.unwrap().RealName();
// assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName"));
// });
// }
#[test]
fn test_renamed_interface_old_as_new() {
test_renamed_interface(|old_name, _| {
let new_name = old_name.as_binder().into_interface::<dyn INewName::INewName>();
assert!(new_name.is_ok());

let real_name = new_name.unwrap().RealName();
assert_eq!(real_name.as_ref().map(String::as_str), Ok("OldName"));
});
}

#[test]
fn test_renamed_interface_new_as_old() {
test_renamed_interface(|_, new_name| {
let old_name = new_name.as_binder().into_interface::<dyn IOldName::IOldName>();
assert!(old_name.is_ok());

let real_name = old_name.unwrap().RealName();
assert_eq!(real_name.as_ref().map(String::as_str), Ok("NewName"));
});
}

#[derive(Debug, Default)]
struct Callback {
Expand Down