Skip to content

Commit

Permalink
Passed more testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kim committed Sep 30, 2024
1 parent 35e8b4c commit ef2b74b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
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

0 comments on commit ef2b74b

Please sign in to comment.