diff options
author | Ilho Kim <ilho159.kim@samsung.com> | 2024-04-08 18:35:00 +0900 |
---|---|---|
committer | Ilho Kim <ilho159.kim@samsung.com> | 2024-04-08 18:37:36 +0900 |
commit | 81b3002291a499b3fc3b941a59f8bf44f2230152 (patch) | |
tree | 38a20887d79453bc6e31643b302d7952338b26dd | |
parent | 03362c92cd91cc8e9bee2e8ce569f4c24d1636b2 (diff) | |
download | pkgmgr-server-81b3002291a499b3fc3b941a59f8bf44f2230152.tar.gz pkgmgr-server-81b3002291a499b3fc3b941a59f8bf44f2230152.tar.bz2 pkgmgr-server-81b3002291a499b3fc3b941a59f8bf44f2230152.zip |
Remove CRLF for end of line
Change-Id: I8e3414127e6e4c35ee2f61b676958dab92160983
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
-rwxr-xr-x | src/pkgmgr/server/test/admin_service_tests.rs | 32 | ||||
-rwxr-xr-x | src/pkgmgr/server/test/cache_service_tests.rs | 34 | ||||
-rwxr-xr-x | src/pkgmgr/server/test/delayed_service_tests.rs | 32 | ||||
-rwxr-xr-x | src/pkgmgr/server/test/info_service_tests.rs | 32 | ||||
-rwxr-xr-x | src/pkgmgr/server/test/mod.rs | 12 | ||||
-rwxr-xr-x | src/pkgmgr/server/test/signal_tests.rs | 46 | ||||
-rwxr-xr-x | src/pkgmgr/server/test/util_tests.rs | 584 |
7 files changed, 386 insertions, 386 deletions
diff --git a/src/pkgmgr/server/test/admin_service_tests.rs b/src/pkgmgr/server/test/admin_service_tests.rs index 9825466..849ed90 100755 --- a/src/pkgmgr/server/test/admin_service_tests.rs +++ b/src/pkgmgr/server/test/admin_service_tests.rs @@ -1,17 +1,17 @@ -use super::super::Server;
-use super::super::super::server::admin_service::AdminService;
-use super::super::super::server::service::Service;
-
-#[test]
-fn run_test() {
- let server = Server::new();
- let mut admin_service = AdminService::new(server.clone());
- assert_eq!(Ok(()), admin_service.run());
-}
-
-#[test]
-fn stop_test() {
- let server = Server::new();
- let mut admin_service = AdminService::new(server.clone());
- assert_eq!(Ok(()), admin_service.stop());
+use super::super::Server; +use super::super::super::server::admin_service::AdminService; +use super::super::super::server::service::Service; + +#[test] +fn run_test() { + let server = Server::new(); + let mut admin_service = AdminService::new(server.clone()); + assert_eq!(Ok(()), admin_service.run()); +} + +#[test] +fn stop_test() { + let server = Server::new(); + let mut admin_service = AdminService::new(server.clone()); + assert_eq!(Ok(()), admin_service.stop()); }
\ No newline at end of file diff --git a/src/pkgmgr/server/test/cache_service_tests.rs b/src/pkgmgr/server/test/cache_service_tests.rs index 9c8d6ce..2ce781e 100755 --- a/src/pkgmgr/server/test/cache_service_tests.rs +++ b/src/pkgmgr/server/test/cache_service_tests.rs @@ -1,17 +1,17 @@ -use super::super::Server;
-use super::super::super::server::cache_service::CacheService;
-use super::super::super::server::service::Service;
-
-#[test]
-fn run_test() {
- let server = Server::new();
- let mut cache_service = CacheService::new(server.clone());
- assert_eq!(Ok(()), cache_service.run());
-}
-
-#[test]
-fn stop_test() {
- let server = Server::new();
- let mut cache_service = CacheService::new(server.clone());
- assert_eq!(Ok(()), cache_service.stop());
-}
+use super::super::Server; +use super::super::super::server::cache_service::CacheService; +use super::super::super::server::service::Service; + +#[test] +fn run_test() { + let server = Server::new(); + let mut cache_service = CacheService::new(server.clone()); + assert_eq!(Ok(()), cache_service.run()); +} + +#[test] +fn stop_test() { + let server = Server::new(); + let mut cache_service = CacheService::new(server.clone()); + assert_eq!(Ok(()), cache_service.stop()); +} diff --git a/src/pkgmgr/server/test/delayed_service_tests.rs b/src/pkgmgr/server/test/delayed_service_tests.rs index 199ddac..5fc96ad 100755 --- a/src/pkgmgr/server/test/delayed_service_tests.rs +++ b/src/pkgmgr/server/test/delayed_service_tests.rs @@ -1,17 +1,17 @@ -use super::super::Server;
-use super::super::super::server::delayed_service::DelayedService;
-use super::super::super::server::service::Service;
-
-#[test]
-fn run_test() {
- let server = Server::new();
- let mut delayed_service = DelayedService::new(server.clone());
- assert_eq!(Ok(()), delayed_service.run());
-}
-
-#[test]
-fn stop_test() {
- let server = Server::new();
- let mut delayed_service = DelayedService::new(server.clone());
- assert_eq!(Ok(()), delayed_service.stop());
+use super::super::Server; +use super::super::super::server::delayed_service::DelayedService; +use super::super::super::server::service::Service; + +#[test] +fn run_test() { + let server = Server::new(); + let mut delayed_service = DelayedService::new(server.clone()); + assert_eq!(Ok(()), delayed_service.run()); +} + +#[test] +fn stop_test() { + let server = Server::new(); + let mut delayed_service = DelayedService::new(server.clone()); + assert_eq!(Ok(()), delayed_service.stop()); }
\ No newline at end of file diff --git a/src/pkgmgr/server/test/info_service_tests.rs b/src/pkgmgr/server/test/info_service_tests.rs index dda55d1..c747e50 100755 --- a/src/pkgmgr/server/test/info_service_tests.rs +++ b/src/pkgmgr/server/test/info_service_tests.rs @@ -1,17 +1,17 @@ -use super::super::Server;
-use super::super::super::server::info_service::InfoService;
-use super::super::super::server::service::Service;
-
-#[test]
-fn run_test() {
- let server = Server::new();
- let mut info_service = InfoService::new(server.clone());
- assert_eq!(Ok(()), info_service.run());
-}
-
-#[test]
-fn stop_test() {
- let server = Server::new();
- let mut info_service = InfoService::new(server.clone());
- assert_eq!(Ok(()), info_service.stop());
+use super::super::Server; +use super::super::super::server::info_service::InfoService; +use super::super::super::server::service::Service; + +#[test] +fn run_test() { + let server = Server::new(); + let mut info_service = InfoService::new(server.clone()); + assert_eq!(Ok(()), info_service.run()); +} + +#[test] +fn stop_test() { + let server = Server::new(); + let mut info_service = InfoService::new(server.clone()); + assert_eq!(Ok(()), info_service.stop()); }
\ No newline at end of file diff --git a/src/pkgmgr/server/test/mod.rs b/src/pkgmgr/server/test/mod.rs index 20cbf91..a7f69d1 100755 --- a/src/pkgmgr/server/test/mod.rs +++ b/src/pkgmgr/server/test/mod.rs @@ -1,7 +1,7 @@ -#[cfg(test)]
-pub mod util_tests;
-pub mod signal_tests;
-pub mod admin_service_tests;
-pub mod cache_service_tests;
-pub mod delayed_service_tests;
+#[cfg(test)] +pub mod util_tests; +pub mod signal_tests; +pub mod admin_service_tests; +pub mod cache_service_tests; +pub mod delayed_service_tests; pub mod info_service_tests;
\ No newline at end of file diff --git a/src/pkgmgr/server/test/signal_tests.rs b/src/pkgmgr/server/test/signal_tests.rs index 1706369..40936db 100755 --- a/src/pkgmgr/server/test/signal_tests.rs +++ b/src/pkgmgr/server/test/signal_tests.rs @@ -1,24 +1,24 @@ -use super::super::super::server::signal::*;
-use std::ffi::CString;
-use std::ffi::CStr;
-use std::ffi::c_char;
-use std::mem;
-extern crate mockall;
-use self::mockall::predicate::*;
-use self::mockall::*;
-use std::os::unix::raw::{uid_t, pid_t};
-
-#[test]
-fn get_uid_list_test_return_uidvec1() {
- let mut uid_vec: Vec<uid_t> = vec![];
- uid_vec.push(1);
- assert_eq!(uid_vec, get_uid_list(1));
-}
-
-#[test]
-fn get_uid_list_test_return_uidvec2() {
- let mut uid_vec: Vec<uid_t> = vec![];
- let ctx = msffi::sd_get_uids_context();
- ctx.expect().times(1).returning(|x| 0);
- assert_eq!(uid_vec, get_uid_list(201));
+use super::super::super::server::signal::*; +use std::ffi::CString; +use std::ffi::CStr; +use std::ffi::c_char; +use std::mem; +extern crate mockall; +use self::mockall::predicate::*; +use self::mockall::*; +use std::os::unix::raw::{uid_t, pid_t}; + +#[test] +fn get_uid_list_test_return_uidvec1() { + let mut uid_vec: Vec<uid_t> = vec![]; + uid_vec.push(1); + assert_eq!(uid_vec, get_uid_list(1)); +} + +#[test] +fn get_uid_list_test_return_uidvec2() { + let mut uid_vec: Vec<uid_t> = vec![]; + let ctx = msffi::sd_get_uids_context(); + ctx.expect().times(1).returning(|x| 0); + assert_eq!(uid_vec, get_uid_list(201)); }
\ No newline at end of file diff --git a/src/pkgmgr/server/test/util_tests.rs b/src/pkgmgr/server/test/util_tests.rs index 28ffc13..7605319 100755 --- a/src/pkgmgr/server/test/util_tests.rs +++ b/src/pkgmgr/server/test/util_tests.rs @@ -1,293 +1,293 @@ -use super::super::super::server::util::*;
-
-use std::ffi::CString;
-use std::ffi::CStr;
-use std::ffi::c_char;
-use std::mem;
-
-extern crate mockall;
-use self::mockall::predicate::*;
-use self::mockall::*;
-
-
-#[test]
-fn IsPackageReadonly_test_return_None_from_disable1() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 1);
- assert_eq!(None, Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, false));
-}
-
-#[test]
-fn IsPackageReadonly_test_return_None_from_disable2() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 1);
- assert_eq!(None, Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true));
-}
-
-#[test]
-fn IsPackageReadonly_test_return_None_from_readonly() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_pkginfo_is_readonly_context();
- ctx2.expect().times(1).returning(|x,y| 1);
- assert_eq!(None, Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true));
-}
-
-#[test]
-fn IsPackageReadonly_test_return_someTrue_from_readonly() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_pkginfo_is_readonly_context();
- ctx2.expect().times(1).returning(|x,y: *mut bool| {
- unsafe { *y = true };
- 0
- });
- let ctx_d = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context();
- ctx_d.expect().times(1).returning(|x| 0);
- assert_eq!(Some(true), Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true));
-}
-
-#[test]
-fn IsPackageReadonly_test_return_someFalse_from_readonly() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_pkginfo_is_readonly_context();
- ctx2.expect().times(1).returning(|x,y: *mut bool| {
- unsafe { *y = false };
- 0
- });
- let ctx_d = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context();
- ctx_d.expect().times(1).returning(|x| 0);
- assert_eq!(Some(false), Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true));
-}
-
-
-#[test]
-fn KillApp_test_return_0_from_running() {
- let ctx = mffi::aul_app_is_running_for_uid_context();
- ctx.expect().times(1).returning(|x,y| 0);
- assert_eq!(0, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn KillApp_test_return_minus_from_getpid() {
- let ctx = mffi::aul_app_is_running_for_uid_context();
- ctx.expect().times(1).returning(|x,y| 1);
- let ctx2 = mffi::aul_app_get_pid_for_uid_context();
- ctx2.expect().times(1).returning(|x,y| -1);
- assert_eq!(-1, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn KillApp_test_return_minus_from_terminate() {
- let ctx = mffi::aul_app_is_running_for_uid_context();
- ctx.expect().times(1).returning(|x,y| 1);
- let ctx2 = mffi::aul_app_get_pid_for_uid_context();
- ctx2.expect().times(1).returning(|x,y| 1);
- let ctx3 = mffi::aul_terminate_pid_for_uid_context();
- ctx3.expect().times(1).returning(|x,y| 1);
- assert_eq!(-1, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn KillApp_test_return_0_from_end() {
- let ctx = mffi::aul_app_is_running_for_uid_context();
- ctx.expect().times(1).returning(|x,y| 1);
- let ctx2 = mffi::aul_app_get_pid_for_uid_context();
- ctx2.expect().times(1).returning(|x,y| 1);
- let ctx3 = mffi::aul_terminate_pid_for_uid_context();
- ctx3.expect().times(1).returning(|x,y| 0);
- assert_eq!(0, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-
-#[test]
-fn GetPackageType_test_return_new_from_all() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 1);
- assert_eq!(String::new(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn GetPackageType_test_return_new_from_type() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_pkginfo_get_type_context();
- ctx2.expect().times(1).returning(|x,y| 1);
- let ctx3 = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context();
- ctx3.expect().times(1).returning(|x| 0);
- assert_eq!(String::new(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn GetPackageType_test_return_rpk_from_end() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_pkginfo_get_type_context();
- ctx2.expect().times(1).returning(|x,y| {
- unsafe { *y = CString::new("rpk").unwrap().into_raw() };
- 0
- });
- let ctx3 = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context();
- ctx3.expect().times(1).returning(|x| 0);
- assert_eq!("rpk".to_string(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn GetPackageType_test_return_newtype_from_end() {
- let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_pkginfo_get_type_context();
- ctx2.expect().times(1).returning(|x,y| {
- unsafe { *y = CString::new("ABC").unwrap().into_raw() };
- 0
- });
- let ctx3 = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context();
- ctx3.expect().times(1).returning(|x| 0);
- assert_eq!("ABC".to_string(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-
-#[test]
-fn CreatePkgUpdateInfo_test_return_null1() {
- let ctx = mffi::pkgmgrinfo_updateinfo_create_context();
- ctx.expect().times(1).returning(|x| 1);
- assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn CreatePkgUpdateInfo_test_return_null2() {
- let ctx = mffi::pkgmgrinfo_updateinfo_create_context();
- ctx.expect().times(1).returning(|x| 0);
- let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context();
- ctx2.expect().times(1).returning(|x,y| 1);
- let ctx_d = mffi::pkgmgrinfo_updateinfo_destroy_context();
- ctx_d.expect().times(1).returning(|x| -1);
- assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn CreatePkgUpdateInfo_test_return_null3() {
- let ctx = mffi::pkgmgrinfo_updateinfo_create_context();
- ctx.expect().times(1).returning(|x| 0);
- let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context();
- ctx2.expect().times(1).returning(|x,y| 0);
- let ctx3 = mffi::pkgmgrinfo_updateinfo_set_version_context();
- ctx3.expect().times(1).returning(|x,y| 1);
- let ctx_d = mffi::pkgmgrinfo_updateinfo_destroy_context();
- ctx_d.expect().times(1).returning(|x| -1);
- assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn CreatePkgUpdateInfo_test_return_null4() {
- let ctx = mffi::pkgmgrinfo_updateinfo_create_context();
- ctx.expect().times(1).returning(|x| 0);
- let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context();
- ctx2.expect().times(1).returning(|x,y| 0);
- let ctx3 = mffi::pkgmgrinfo_updateinfo_set_version_context();
- ctx3.expect().times(1).returning(|x,y| 0);
- let ctx4 = mffi::pkgmgrinfo_updateinfo_set_type_context();
- ctx4.expect().times(1).returning(|x,y| 1);
- let ctx_d = mffi::pkgmgrinfo_updateinfo_destroy_context();
- ctx_d.expect().times(1).returning(|x| -1);
- assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn CreatePkgUpdateInfo_test_return_handle() {
- let ctx = mffi::pkgmgrinfo_updateinfo_create_context();
- ctx.expect().times(1).returning(|x| 0);
- let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context();
- ctx2.expect().times(1).returning(|x,y| 0);
- let ctx3 = mffi::pkgmgrinfo_updateinfo_set_version_context();
- ctx3.expect().times(1).returning(|x,y| 0);
- let ctx4 = mffi::pkgmgrinfo_updateinfo_set_type_context();
- ctx4.expect().times(1).returning(|x,y| 0);
- assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1));
-}
-
-
-#[test]
-fn getapplicationinfobyappid_test_return_None_from_appinfo() {
- let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context();
- ctx.expect().times(1).returning(|x,y,z| 1);
- assert_eq!(None, Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn getapplicationinfobyappid_test_return_None_from_global() {
- let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_appinfo_is_global_context();
- ctx2.expect().times(1).returning(|x,y| 1);
- let ctx_d = mffi::pkgmgrinfo_appinfo_destroy_appinfo_context();
- ctx_d.expect().times(1).returning(|x| 0);
- assert_eq!(None, Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn getapplicationinfobyappid_test_return_None_from_pkgid() {
- let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_appinfo_is_global_context();
- ctx2.expect().times(1).returning(|x,y| 0);
- let ctx3 = mffi::pkgmgrinfo_appinfo_get_pkgid_context();
- ctx3.expect().times(1).returning(|x,y| 1);
- let ctx_d = mffi::pkgmgrinfo_appinfo_destroy_appinfo_context();
- ctx_d.expect().times(1).returning(|x| 0);
- assert_eq!(None, Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-#[test]
-fn getapplicationinfobyappid_test_return_Some_from_end() {
- let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context();
- ctx.expect().times(1).returning(|x,y,z| 0);
- let ctx2 = mffi::pkgmgrinfo_appinfo_is_global_context();
- ctx2.expect().times(1).returning(|x,y| {
- unsafe { *y = true };
- 0
- });
- let ctx3 = mffi::pkgmgrinfo_appinfo_get_pkgid_context();
- ctx3.expect().times(1).returning(|x, y| {
- unsafe { *y = CString::new("aaa").unwrap().into_raw() };
- 0
- });
- let ctx_d = mffi::pkgmgrinfo_appinfo_destroy_appinfo_context();
- ctx_d.expect().times(1).returning(|x| 0);
- assert_eq!(Some((CString::new("aaa").unwrap(), true)), Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1));
-}
-
-
-#[test]
-fn get_pkgid_bypid_for_uid_test_return_None() {
- let ctx = mffi::aul_app_get_pkgid_bypid_for_uid_context();
- ctx.expect().times(1).returning(|x,y,z,e| 1);
- assert_eq!(None, Util::get_pkgid_bypid_for_uid(1, 2));
-}
-
-#[test]
-fn get_pkgid_bypid_for_uid_test_return_Some() {
- let ctx = mffi::aul_app_get_pkgid_bypid_for_uid_context();
- ctx.expect().times(1).returning(|x,y,z,e| {
- unsafe {
- *y.offset(0) = 'a' as c_char;
- *y.offset(1) = 'a' as c_char;
- *y.offset(2) = 'a' as c_char;
- }
- 0
- });
- assert_eq!(Some("aaa".to_string()), Util::get_pkgid_bypid_for_uid(1, 2));
-}
-
-#[test]
-fn get_pkgid_bypid_for_uid_test_return_None_from_end() {
- let ctx = mffi::aul_app_get_pkgid_bypid_for_uid_context();
- ctx.expect().times(1).returning(|x,y,z,e| {
- unsafe {
- *y.offset(0) = 0xff
- }
- 0
- });
- assert_eq!(None, Util::get_pkgid_bypid_for_uid(1, 2));
+use super::super::super::server::util::*; + +use std::ffi::CString; +use std::ffi::CStr; +use std::ffi::c_char; +use std::mem; + +extern crate mockall; +use self::mockall::predicate::*; +use self::mockall::*; + + +#[test] +fn IsPackageReadonly_test_return_None_from_disable1() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 1); + assert_eq!(None, Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, false)); +} + +#[test] +fn IsPackageReadonly_test_return_None_from_disable2() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 1); + assert_eq!(None, Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true)); +} + +#[test] +fn IsPackageReadonly_test_return_None_from_readonly() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_pkginfo_is_readonly_context(); + ctx2.expect().times(1).returning(|x,y| 1); + assert_eq!(None, Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true)); +} + +#[test] +fn IsPackageReadonly_test_return_someTrue_from_readonly() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_pkginfo_is_readonly_context(); + ctx2.expect().times(1).returning(|x,y: *mut bool| { + unsafe { *y = true }; + 0 + }); + let ctx_d = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context(); + ctx_d.expect().times(1).returning(|x| 0); + assert_eq!(Some(true), Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true)); +} + +#[test] +fn IsPackageReadonly_test_return_someFalse_from_readonly() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_pkginfo_is_readonly_context(); + ctx2.expect().times(1).returning(|x,y: *mut bool| { + unsafe { *y = false }; + 0 + }); + let ctx_d = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context(); + ctx_d.expect().times(1).returning(|x| 0); + assert_eq!(Some(false), Util::IsPackageReadonly(CString::new("hello").unwrap().as_ptr(), 1, true)); +} + + +#[test] +fn KillApp_test_return_0_from_running() { + let ctx = mffi::aul_app_is_running_for_uid_context(); + ctx.expect().times(1).returning(|x,y| 0); + assert_eq!(0, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn KillApp_test_return_minus_from_getpid() { + let ctx = mffi::aul_app_is_running_for_uid_context(); + ctx.expect().times(1).returning(|x,y| 1); + let ctx2 = mffi::aul_app_get_pid_for_uid_context(); + ctx2.expect().times(1).returning(|x,y| -1); + assert_eq!(-1, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn KillApp_test_return_minus_from_terminate() { + let ctx = mffi::aul_app_is_running_for_uid_context(); + ctx.expect().times(1).returning(|x,y| 1); + let ctx2 = mffi::aul_app_get_pid_for_uid_context(); + ctx2.expect().times(1).returning(|x,y| 1); + let ctx3 = mffi::aul_terminate_pid_for_uid_context(); + ctx3.expect().times(1).returning(|x,y| 1); + assert_eq!(-1, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn KillApp_test_return_0_from_end() { + let ctx = mffi::aul_app_is_running_for_uid_context(); + ctx.expect().times(1).returning(|x,y| 1); + let ctx2 = mffi::aul_app_get_pid_for_uid_context(); + ctx2.expect().times(1).returning(|x,y| 1); + let ctx3 = mffi::aul_terminate_pid_for_uid_context(); + ctx3.expect().times(1).returning(|x,y| 0); + assert_eq!(0, Util::KillApp(CString::new("hello").unwrap().as_ptr(), 1)); +} + + +#[test] +fn GetPackageType_test_return_new_from_all() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 1); + assert_eq!(String::new(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn GetPackageType_test_return_new_from_type() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_pkginfo_get_type_context(); + ctx2.expect().times(1).returning(|x,y| 1); + let ctx3 = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context(); + ctx3.expect().times(1).returning(|x| 0); + assert_eq!(String::new(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn GetPackageType_test_return_rpk_from_end() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_pkginfo_get_type_context(); + ctx2.expect().times(1).returning(|x,y| { + unsafe { *y = CString::new("rpk").unwrap().into_raw() }; + 0 + }); + let ctx3 = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context(); + ctx3.expect().times(1).returning(|x| 0); + assert_eq!("rpk".to_string(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn GetPackageType_test_return_newtype_from_end() { + let ctx = mffi::pkgmgrinfo_pkginfo_get_usr_all_pkginfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_pkginfo_get_type_context(); + ctx2.expect().times(1).returning(|x,y| { + unsafe { *y = CString::new("ABC").unwrap().into_raw() }; + 0 + }); + let ctx3 = mffi::pkgmgrinfo_pkginfo_destroy_pkginfo_context(); + ctx3.expect().times(1).returning(|x| 0); + assert_eq!("ABC".to_string(), Util::GetPackageType(CString::new("hello").unwrap().as_ptr(), 1)); +} + + +#[test] +fn CreatePkgUpdateInfo_test_return_null1() { + let ctx = mffi::pkgmgrinfo_updateinfo_create_context(); + ctx.expect().times(1).returning(|x| 1); + assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1)); +} + +#[test] +fn CreatePkgUpdateInfo_test_return_null2() { + let ctx = mffi::pkgmgrinfo_updateinfo_create_context(); + ctx.expect().times(1).returning(|x| 0); + let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context(); + ctx2.expect().times(1).returning(|x,y| 1); + let ctx_d = mffi::pkgmgrinfo_updateinfo_destroy_context(); + ctx_d.expect().times(1).returning(|x| -1); + assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1)); +} + +#[test] +fn CreatePkgUpdateInfo_test_return_null3() { + let ctx = mffi::pkgmgrinfo_updateinfo_create_context(); + ctx.expect().times(1).returning(|x| 0); + let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context(); + ctx2.expect().times(1).returning(|x,y| 0); + let ctx3 = mffi::pkgmgrinfo_updateinfo_set_version_context(); + ctx3.expect().times(1).returning(|x,y| 1); + let ctx_d = mffi::pkgmgrinfo_updateinfo_destroy_context(); + ctx_d.expect().times(1).returning(|x| -1); + assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1)); +} + +#[test] +fn CreatePkgUpdateInfo_test_return_null4() { + let ctx = mffi::pkgmgrinfo_updateinfo_create_context(); + ctx.expect().times(1).returning(|x| 0); + let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context(); + ctx2.expect().times(1).returning(|x,y| 0); + let ctx3 = mffi::pkgmgrinfo_updateinfo_set_version_context(); + ctx3.expect().times(1).returning(|x,y| 0); + let ctx4 = mffi::pkgmgrinfo_updateinfo_set_type_context(); + ctx4.expect().times(1).returning(|x,y| 1); + let ctx_d = mffi::pkgmgrinfo_updateinfo_destroy_context(); + ctx_d.expect().times(1).returning(|x| -1); + assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1)); +} + +#[test] +fn CreatePkgUpdateInfo_test_return_handle() { + let ctx = mffi::pkgmgrinfo_updateinfo_create_context(); + ctx.expect().times(1).returning(|x| 0); + let ctx2 = mffi::pkgmgrinfo_updateinfo_set_pkgid_context(); + ctx2.expect().times(1).returning(|x,y| 0); + let ctx3 = mffi::pkgmgrinfo_updateinfo_set_version_context(); + ctx3.expect().times(1).returning(|x,y| 0); + let ctx4 = mffi::pkgmgrinfo_updateinfo_set_type_context(); + ctx4.expect().times(1).returning(|x,y| 0); + assert_eq!(std::ptr::null_mut(), Util::CreatePkgUpdateInfo(CString::new("hello").unwrap().as_ptr(), CString::new("version").unwrap().as_ptr(), 1)); +} + + +#[test] +fn getapplicationinfobyappid_test_return_None_from_appinfo() { + let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context(); + ctx.expect().times(1).returning(|x,y,z| 1); + assert_eq!(None, Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn getapplicationinfobyappid_test_return_None_from_global() { + let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_appinfo_is_global_context(); + ctx2.expect().times(1).returning(|x,y| 1); + let ctx_d = mffi::pkgmgrinfo_appinfo_destroy_appinfo_context(); + ctx_d.expect().times(1).returning(|x| 0); + assert_eq!(None, Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn getapplicationinfobyappid_test_return_None_from_pkgid() { + let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_appinfo_is_global_context(); + ctx2.expect().times(1).returning(|x,y| 0); + let ctx3 = mffi::pkgmgrinfo_appinfo_get_pkgid_context(); + ctx3.expect().times(1).returning(|x,y| 1); + let ctx_d = mffi::pkgmgrinfo_appinfo_destroy_appinfo_context(); + ctx_d.expect().times(1).returning(|x| 0); + assert_eq!(None, Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1)); +} + +#[test] +fn getapplicationinfobyappid_test_return_Some_from_end() { + let ctx = mffi::pkgmgrinfo_appinfo_get_usr_all_appinfo_context(); + ctx.expect().times(1).returning(|x,y,z| 0); + let ctx2 = mffi::pkgmgrinfo_appinfo_is_global_context(); + ctx2.expect().times(1).returning(|x,y| { + unsafe { *y = true }; + 0 + }); + let ctx3 = mffi::pkgmgrinfo_appinfo_get_pkgid_context(); + ctx3.expect().times(1).returning(|x, y| { + unsafe { *y = CString::new("aaa").unwrap().into_raw() }; + 0 + }); + let ctx_d = mffi::pkgmgrinfo_appinfo_destroy_appinfo_context(); + ctx_d.expect().times(1).returning(|x| 0); + assert_eq!(Some((CString::new("aaa").unwrap(), true)), Util::get_application_info_by_appid(CString::new("hello").unwrap().as_ptr(), 1)); +} + + +#[test] +fn get_pkgid_bypid_for_uid_test_return_None() { + let ctx = mffi::aul_app_get_pkgid_bypid_for_uid_context(); + ctx.expect().times(1).returning(|x,y,z,e| 1); + assert_eq!(None, Util::get_pkgid_bypid_for_uid(1, 2)); +} + +#[test] +fn get_pkgid_bypid_for_uid_test_return_Some() { + let ctx = mffi::aul_app_get_pkgid_bypid_for_uid_context(); + ctx.expect().times(1).returning(|x,y,z,e| { + unsafe { + *y.offset(0) = 'a' as c_char; + *y.offset(1) = 'a' as c_char; + *y.offset(2) = 'a' as c_char; + } + 0 + }); + assert_eq!(Some("aaa".to_string()), Util::get_pkgid_bypid_for_uid(1, 2)); +} + +#[test] +fn get_pkgid_bypid_for_uid_test_return_None_from_end() { + let ctx = mffi::aul_app_get_pkgid_bypid_for_uid_context(); + ctx.expect().times(1).returning(|x,y,z,e| { + unsafe { + *y.offset(0) = 0xff + } + 0 + }); + assert_eq!(None, Util::get_pkgid_bypid_for_uid(1, 2)); }
\ No newline at end of file |