[unit] Refactored binder simulation. JB#42956
The old one was way too hackish and prone to race conditions. This one is more accurate and hopefully more reliable.
This commit is contained in:
parent
b1a3dc5c64
commit
d7eacd455f
File diff suppressed because it is too large
Load Diff
|
@ -45,56 +45,72 @@
|
||||||
#define BINDER_OBJECT_SIZE_32 (16)
|
#define BINDER_OBJECT_SIZE_32 (16)
|
||||||
#define BINDER_OBJECT_SIZE_64 (24)
|
#define BINDER_OBJECT_SIZE_64 (24)
|
||||||
|
|
||||||
typedef struct test_binder TestBinder;
|
typedef enum test_br_thread {
|
||||||
|
THIS_THREAD = -3,
|
||||||
|
LOOPER_THREAD = -2,
|
||||||
|
TX_THREAD = -1,
|
||||||
|
ANY_THREAD = 0
|
||||||
|
} TEST_BR_THREAD;
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_noop(
|
test_binder_br_noop(
|
||||||
int fd);
|
int fd,
|
||||||
|
TEST_BR_THREAD dest);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_increfs(
|
test_binder_br_increfs(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
void* ptr);
|
void* ptr);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_acquire(
|
test_binder_br_acquire(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
void* ptr);
|
void* ptr);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_release(
|
test_binder_br_release(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
void* ptr);
|
void* ptr);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_decrefs(
|
test_binder_br_decrefs(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
void* ptr);
|
void* ptr);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_transaction_complete(
|
test_binder_br_transaction_complete(
|
||||||
int fd);
|
int fd,
|
||||||
|
TEST_BR_THREAD dest);
|
||||||
void
|
|
||||||
test_binder_br_transaction_complete_later(
|
|
||||||
int fd);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_dead_binder(
|
test_binder_br_dead_binder(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
guint handle);
|
guint handle);
|
||||||
|
|
||||||
|
void
|
||||||
|
test_binder_br_dead_binder_obj(
|
||||||
|
int fd,
|
||||||
|
GBinderLocalObject* obj);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_dead_reply(
|
test_binder_br_dead_reply(
|
||||||
int fd);
|
int fd,
|
||||||
|
TEST_BR_THREAD dest);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_failed_reply(
|
test_binder_br_failed_reply(
|
||||||
int fd);
|
int fd,
|
||||||
|
TEST_BR_THREAD dest);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_transaction(
|
test_binder_br_transaction(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
void* target,
|
void* target,
|
||||||
guint32 code,
|
guint32 code,
|
||||||
const GByteArray* bytes);
|
const GByteArray* bytes);
|
||||||
|
@ -102,6 +118,7 @@ test_binder_br_transaction(
|
||||||
void
|
void
|
||||||
test_binder_br_reply(
|
test_binder_br_reply(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
guint32 handle,
|
guint32 handle,
|
||||||
guint32 code,
|
guint32 code,
|
||||||
const GByteArray* bytes);
|
const GByteArray* bytes);
|
||||||
|
@ -109,35 +126,12 @@ test_binder_br_reply(
|
||||||
void
|
void
|
||||||
test_binder_br_reply_status(
|
test_binder_br_reply_status(
|
||||||
int fd,
|
int fd,
|
||||||
|
TEST_BR_THREAD dest,
|
||||||
gint32 status);
|
gint32 status);
|
||||||
|
|
||||||
void
|
void
|
||||||
test_binder_br_reply_later(
|
test_binder_ignore_dead_object(
|
||||||
int fd,
|
int fd);
|
||||||
guint32 handle,
|
|
||||||
guint32 code,
|
|
||||||
const GByteArray* bytes);
|
|
||||||
|
|
||||||
void
|
|
||||||
test_binder_br_reply_status_later(
|
|
||||||
int fd,
|
|
||||||
gint32 status);
|
|
||||||
|
|
||||||
typedef enum test_looper {
|
|
||||||
TEST_LOOPER_DISABLE,
|
|
||||||
TEST_LOOPER_ENABLE,
|
|
||||||
TEST_LOOPER_ENABLE_ONE
|
|
||||||
} TEST_LOOPER;
|
|
||||||
|
|
||||||
void
|
|
||||||
test_binder_set_looper_enabled(
|
|
||||||
int fd,
|
|
||||||
TEST_LOOPER value);
|
|
||||||
|
|
||||||
void
|
|
||||||
test_binder_set_passthrough(
|
|
||||||
int fd,
|
|
||||||
gboolean passthrough);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
test_binder_handle(
|
test_binder_handle(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 Jolla Ltd.
|
* Copyright (C) 2021-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of BSD license as follows:
|
* You may use this file under the terms of BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -277,9 +277,10 @@ test_servicemanager_hidl_add(
|
||||||
const char* sep = strrchr(instance, '/');
|
const char* sep = strrchr(instance, '/');
|
||||||
|
|
||||||
GDEBUG("Adding '%s'", instance);
|
GDEBUG("Adding '%s'", instance);
|
||||||
|
/* Transfer remote_obj reference to the hashtable */
|
||||||
g_hash_table_replace(self->objects, g_strdup(instance), remote_obj);
|
g_hash_table_replace(self->objects, g_strdup(instance), remote_obj);
|
||||||
if (sep) {
|
if (sep) {
|
||||||
/* Alread know the interface */
|
/* Already know the interface */
|
||||||
char* iface = g_strndup(instance, sep - instance);
|
char* iface = g_strndup(instance, sep - instance);
|
||||||
|
|
||||||
test_servicemanager_hidl_notify_all(self, iface, sep + 1, FALSE);
|
test_servicemanager_hidl_notify_all(self, iface, sep + 1, FALSE);
|
||||||
|
@ -350,7 +351,7 @@ test_servicemanager_hidl_register_for_notifications(
|
||||||
iface = gbinder_reader_read_hidl_string_c(&reader);
|
iface = gbinder_reader_read_hidl_string_c(&reader);
|
||||||
instance = gbinder_reader_read_hidl_string_c(&reader);
|
instance = gbinder_reader_read_hidl_string_c(&reader);
|
||||||
watcher = gbinder_reader_read_object(&reader);
|
watcher = gbinder_reader_read_object(&reader);
|
||||||
|
|
||||||
if (watcher) {
|
if (watcher) {
|
||||||
GBinderClient* wc = gbinder_client_new(watcher, NOTIFICATION_IFACE);
|
GBinderClient* wc = gbinder_client_new(watcher, NOTIFICATION_IFACE);
|
||||||
GHashTableIter it;
|
GHashTableIter it;
|
||||||
|
@ -481,6 +482,38 @@ test_servicemanager_hidl_lookup(
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
test_servicemanager_hidl_remove(
|
||||||
|
TestServiceManagerHidl* self,
|
||||||
|
const char* fqname)
|
||||||
|
{
|
||||||
|
gboolean removed = FALSE;
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
GBinderRemoteObject* obj;
|
||||||
|
|
||||||
|
/* Lock */
|
||||||
|
g_mutex_lock(&self->mutex);
|
||||||
|
obj = g_hash_table_lookup(self->objects, fqname);
|
||||||
|
if (obj) {
|
||||||
|
GHashTableIter it;
|
||||||
|
gpointer key, value;
|
||||||
|
|
||||||
|
g_hash_table_iter_init(&it, self->objects);
|
||||||
|
while (g_hash_table_iter_next(&it, &key, &value)) {
|
||||||
|
if (value == obj) {
|
||||||
|
GDEBUG("Removed name '%s' => %p", (char*) key, value);
|
||||||
|
g_hash_table_iter_remove(&it);
|
||||||
|
removed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_mutex_unlock(&self->mutex);
|
||||||
|
/* Unlock */
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* Internals
|
* Internals
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 Jolla Ltd.
|
* Copyright (C) 2021-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of BSD license as follows:
|
* You may use this file under the terms of BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -58,6 +58,11 @@ test_servicemanager_hidl_lookup(
|
||||||
TestServiceManagerHidl* self,
|
TestServiceManagerHidl* self,
|
||||||
const char* name);
|
const char* name);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
test_servicemanager_hidl_remove(
|
||||||
|
TestServiceManagerHidl* self,
|
||||||
|
const char* fqname);
|
||||||
|
|
||||||
#endif /* TEST_SERVICEMANAGER_HIDL_H */
|
#endif /* TEST_SERVICEMANAGER_HIDL_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -52,9 +52,7 @@
|
||||||
static TestOpt test_opt;
|
static TestOpt test_opt;
|
||||||
|
|
||||||
#define SRC_DEV "/dev/srcbinder"
|
#define SRC_DEV "/dev/srcbinder"
|
||||||
#define SRC_PRIV_DEV SRC_DEV "-private"
|
|
||||||
#define DEST_DEV "/dev/dstbinder"
|
#define DEST_DEV "/dev/dstbinder"
|
||||||
#define DEST_PRIV_DEV DEST_DEV "-private"
|
|
||||||
#define TEST_IFACE "gbinder@1.0::ITest"
|
#define TEST_IFACE "gbinder@1.0::ITest"
|
||||||
|
|
||||||
#define TX_CODE GBINDER_FIRST_CALL_TRANSACTION
|
#define TX_CODE GBINDER_FIRST_CALL_TRANSACTION
|
||||||
|
@ -74,75 +72,6 @@ typedef struct test_config {
|
||||||
char* file;
|
char* file;
|
||||||
} TestConfig;
|
} TestConfig;
|
||||||
|
|
||||||
/*==========================================================================*
|
|
||||||
* Test object (registered with two GBinderIpc's)
|
|
||||||
*==========================================================================*/
|
|
||||||
|
|
||||||
typedef GBinderLocalObjectClass TestLocalObjectClass;
|
|
||||||
typedef struct test_local_object {
|
|
||||||
GBinderLocalObject parent;
|
|
||||||
GBinderIpc* ipc2;
|
|
||||||
} TestLocalObject;
|
|
||||||
G_DEFINE_TYPE(TestLocalObject, test_local_object, GBINDER_TYPE_LOCAL_OBJECT)
|
|
||||||
#define TEST_TYPE_LOCAL_OBJECT test_local_object_get_type()
|
|
||||||
#define TEST_LOCAL_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
|
||||||
TEST_TYPE_LOCAL_OBJECT, TestLocalObject))
|
|
||||||
|
|
||||||
TestLocalObject*
|
|
||||||
test_local_object_new(
|
|
||||||
GBinderIpc* ipc,
|
|
||||||
GBinderIpc* ipc2,
|
|
||||||
const char* const* ifaces,
|
|
||||||
GBinderLocalTransactFunc txproc,
|
|
||||||
void* user_data)
|
|
||||||
{
|
|
||||||
TestLocalObject* self = TEST_LOCAL_OBJECT
|
|
||||||
(gbinder_local_object_new_with_type(TEST_TYPE_LOCAL_OBJECT,
|
|
||||||
ipc, ifaces, txproc, user_data));
|
|
||||||
|
|
||||||
self->ipc2 = gbinder_ipc_ref(ipc2);
|
|
||||||
gbinder_ipc_register_local_object(ipc2, &self->parent);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
test_local_object_dispose(
|
|
||||||
GObject* object)
|
|
||||||
{
|
|
||||||
TestLocalObject* self = TEST_LOCAL_OBJECT(object);
|
|
||||||
|
|
||||||
gbinder_ipc_local_object_disposed(self->ipc2, &self->parent);
|
|
||||||
G_OBJECT_CLASS(test_local_object_parent_class)->dispose(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
test_local_object_finalize(
|
|
||||||
GObject* object)
|
|
||||||
{
|
|
||||||
gbinder_ipc_unref(TEST_LOCAL_OBJECT(object)->ipc2);
|
|
||||||
G_OBJECT_CLASS(test_local_object_parent_class)->finalize(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
test_local_object_init(
|
|
||||||
TestLocalObject* self)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
test_local_object_class_init(
|
|
||||||
TestLocalObjectClass* klass)
|
|
||||||
{
|
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
object_class->dispose = test_local_object_dispose;
|
|
||||||
object_class->finalize = test_local_object_finalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* Common
|
* Common
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
@ -187,7 +116,6 @@ test_servicemanager_impl_new(
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
TestServiceManagerHidl* sm = test_servicemanager_hidl_new(ipc);
|
TestServiceManagerHidl* sm = test_servicemanager_hidl_new(ipc);
|
||||||
|
|
||||||
test_binder_set_looper_enabled(fd, TRUE);
|
|
||||||
test_binder_register_object(fd, GBINDER_LOCAL_OBJECT(sm),
|
test_binder_register_object(fd, GBINDER_LOCAL_OBJECT(sm),
|
||||||
GBINDER_SERVICEMANAGER_HANDLE);
|
GBINDER_SERVICEMANAGER_HANDLE);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
@ -338,18 +266,15 @@ test_basic_run(
|
||||||
GBinderServiceManager* src;
|
GBinderServiceManager* src;
|
||||||
GBinderServiceManager* dest;
|
GBinderServiceManager* dest;
|
||||||
GBinderIpc* src_ipc;
|
GBinderIpc* src_ipc;
|
||||||
GBinderIpc* src_priv_ipc;
|
|
||||||
GBinderIpc* dest_ipc;
|
GBinderIpc* dest_ipc;
|
||||||
GBinderIpc* dest_priv_ipc;
|
|
||||||
GBinderBridge* bridge;
|
GBinderBridge* bridge;
|
||||||
TestLocalObject* obj;
|
GBinderLocalObject* obj;
|
||||||
GBinderRemoteObject* br_src_obj;
|
|
||||||
GBinderRemoteObject* src_obj;
|
GBinderRemoteObject* src_obj;
|
||||||
GBinderLocalRequest* req;
|
GBinderLocalRequest* req;
|
||||||
GBinderClient* src_client;
|
GBinderClient* src_client;
|
||||||
const char* name = "test";
|
const char* name = "test";
|
||||||
const char* fqname = TEST_IFACE "/test";
|
const char* fqname = TEST_IFACE "/test";
|
||||||
int src_fd, dest_fd, h, n = 0;
|
int src_fd, dest_fd, n = 0;
|
||||||
gulong id;
|
gulong id;
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
|
@ -358,21 +283,14 @@ test_basic_run(
|
||||||
|
|
||||||
/* obj (DEST) <=> bridge <=> (SRC) mirror */
|
/* obj (DEST) <=> bridge <=> (SRC) mirror */
|
||||||
src_ipc = gbinder_ipc_new(SRC_DEV, NULL);
|
src_ipc = gbinder_ipc_new(SRC_DEV, NULL);
|
||||||
src_priv_ipc = gbinder_ipc_new(SRC_PRIV_DEV, NULL);
|
|
||||||
dest_ipc = gbinder_ipc_new(DEST_DEV, NULL);
|
dest_ipc = gbinder_ipc_new(DEST_DEV, NULL);
|
||||||
dest_priv_ipc = gbinder_ipc_new(DEST_PRIV_DEV, NULL);
|
test.src_impl = test_servicemanager_impl_new(SRC_DEV);
|
||||||
test.src_impl = test_servicemanager_impl_new(SRC_PRIV_DEV);
|
dest_impl = test_servicemanager_impl_new(DEST_DEV);
|
||||||
dest_impl = test_servicemanager_impl_new(DEST_PRIV_DEV);
|
|
||||||
src_fd = gbinder_driver_fd(src_ipc->driver);
|
src_fd = gbinder_driver_fd(src_ipc->driver);
|
||||||
dest_fd = gbinder_driver_fd(dest_ipc->driver);
|
dest_fd = gbinder_driver_fd(dest_ipc->driver);
|
||||||
obj = test_local_object_new(dest_ipc, dest_priv_ipc, TEST_IFACES,
|
obj = gbinder_local_object_new(dest_ipc, TEST_IFACES, test_basic_cb, &n);
|
||||||
test_basic_cb, &n);
|
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_set_passthrough(src_fd, TRUE);
|
|
||||||
test_binder_set_passthrough(dest_fd, TRUE);
|
|
||||||
test_binder_set_looper_enabled(src_fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_set_looper_enabled(dest_fd, TEST_LOOPER_ENABLE);
|
|
||||||
src = gbinder_servicemanager_new(SRC_DEV);
|
src = gbinder_servicemanager_new(SRC_DEV);
|
||||||
dest = gbinder_servicemanager_new(DEST_DEV);
|
dest = gbinder_servicemanager_new(DEST_DEV);
|
||||||
|
|
||||||
|
@ -387,7 +305,7 @@ test_basic_run(
|
||||||
|
|
||||||
/* Register the object and wait for completion */
|
/* Register the object and wait for completion */
|
||||||
GDEBUG("Registering object '%s' => %p", name, obj);
|
GDEBUG("Registering object '%s' => %p", name, obj);
|
||||||
g_assert(gbinder_servicemanager_add_service(dest, name, &obj->parent,
|
g_assert(gbinder_servicemanager_add_service(dest, name, obj,
|
||||||
test_basic_add_cb, &test));
|
test_basic_add_cb, &test));
|
||||||
|
|
||||||
/* This loop quits after the name is added and notification is received */
|
/* This loop quits after the name is added and notification is received */
|
||||||
|
@ -398,25 +316,12 @@ test_basic_run(
|
||||||
gbinder_servicemanager_remove_handler(src, id);
|
gbinder_servicemanager_remove_handler(src, id);
|
||||||
|
|
||||||
/* Get a remote reference to the object created by the bridge */
|
/* Get a remote reference to the object created by the bridge */
|
||||||
br_src_obj = gbinder_servicemanager_get_service_sync(src, fqname, NULL);
|
src_obj = gbinder_servicemanager_get_service_sync(src, fqname, NULL);
|
||||||
g_assert(gbinder_remote_object_ref(br_src_obj)); /* autoreleased */
|
g_assert(!src_obj->dead);
|
||||||
g_assert(!br_src_obj->dead);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a trick specific to test_binder simulation. We need to
|
|
||||||
* associate src_obj with the other side of the socket, so that the
|
|
||||||
* call goes like this:
|
|
||||||
*
|
|
||||||
* src_obj (src_priv) => (src) bridge (dest) => (dest_priv) => obj
|
|
||||||
*
|
|
||||||
* Note that the original src_obj gets autoreleased and doesn't need
|
|
||||||
* to be explicitly unreferenced.
|
|
||||||
*/
|
|
||||||
src_obj = gbinder_remote_object_new(src_priv_ipc,
|
|
||||||
br_src_obj->handle, REMOTE_OBJECT_CREATE_ALIVE);
|
|
||||||
|
|
||||||
/* Make a call */
|
/* Make a call */
|
||||||
GDEBUG("Submitting a call");
|
GDEBUG("Submitting a call");
|
||||||
|
/* src_client will hold a reference to src_obj */
|
||||||
src_client = gbinder_client_new(src_obj, TEST_IFACE);
|
src_client = gbinder_client_new(src_obj, TEST_IFACE);
|
||||||
req = gbinder_client_new_request(src_client);
|
req = gbinder_client_new_request(src_client);
|
||||||
gbinder_local_request_append_int32(req, TX_PARAM);
|
gbinder_local_request_append_int32(req, TX_PARAM);
|
||||||
|
@ -427,40 +332,38 @@ test_basic_run(
|
||||||
/* Wait for completion */
|
/* Wait for completion */
|
||||||
test_run(&test_opt, test.loop);
|
test_run(&test_opt, test.loop);
|
||||||
|
|
||||||
/* Kill the destination object and wait for auto-created object to die */
|
/* Kill the objects and wait for one of them to die */
|
||||||
g_assert(!br_src_obj->dead);
|
g_assert(!src_obj->dead);
|
||||||
id = gbinder_remote_object_add_death_handler(br_src_obj, test_basic_death,
|
id = gbinder_remote_object_add_death_handler(src_obj, test_basic_death,
|
||||||
test.loop);
|
test.loop);
|
||||||
h = test_binder_handle(dest_fd, &obj->parent);
|
|
||||||
g_assert_cmpint(h, > ,0); /* Zero is servicemanager */
|
|
||||||
|
|
||||||
GDEBUG("Killing destination object, handle %d", h);
|
g_assert(test_servicemanager_hidl_remove(dest_impl, fqname));
|
||||||
gbinder_local_object_drop(&obj->parent);
|
GDEBUG("Killing destination objects");
|
||||||
test_binder_br_dead_binder(dest_fd, h);
|
/*
|
||||||
|
* Need these BR_DEAD_BINDER because both servicemanagers and the
|
||||||
|
* bridge live inside the same process and reference the same objects.
|
||||||
|
* BR_DEAD_BINDER forces the bridge (proxy) to drop its reference.
|
||||||
|
*/
|
||||||
|
test_binder_br_dead_binder_obj(dest_fd, obj);
|
||||||
|
test_binder_br_dead_binder(src_fd, ANY_THREAD, src_obj->handle);
|
||||||
|
|
||||||
/* Wait for the auto-created object to die */
|
/* Wait for the auto-created object to die */
|
||||||
test_run(&test_opt, test.loop);
|
test_run(&test_opt, test.loop);
|
||||||
g_assert(br_src_obj->dead);
|
g_assert(src_obj->dead);
|
||||||
gbinder_remote_object_remove_handler(br_src_obj, id);
|
gbinder_remote_object_remove_handler(src_obj, id);
|
||||||
|
|
||||||
GDEBUG("Done");
|
GDEBUG("Done");
|
||||||
|
|
||||||
|
gbinder_local_object_drop(obj);
|
||||||
gbinder_bridge_free(bridge);
|
gbinder_bridge_free(bridge);
|
||||||
gbinder_remote_object_unref(src_obj);
|
|
||||||
gbinder_remote_object_unref(br_src_obj);
|
|
||||||
test_servicemanager_hidl_free(test.src_impl);
|
test_servicemanager_hidl_free(test.src_impl);
|
||||||
test_servicemanager_hidl_free(dest_impl);
|
test_servicemanager_hidl_free(dest_impl);
|
||||||
gbinder_servicemanager_unref(src);
|
gbinder_servicemanager_unref(src);
|
||||||
gbinder_servicemanager_unref(dest);
|
gbinder_servicemanager_unref(dest);
|
||||||
gbinder_client_unref(src_client);
|
gbinder_client_unref(src_client);
|
||||||
test_binder_unregister_objects(src_fd);
|
|
||||||
test_binder_unregister_objects(dest_fd);
|
|
||||||
gbinder_ipc_unref(src_ipc);
|
gbinder_ipc_unref(src_ipc);
|
||||||
gbinder_ipc_unref(src_priv_ipc);
|
|
||||||
gbinder_ipc_unref(dest_ipc);
|
gbinder_ipc_unref(dest_ipc);
|
||||||
gbinder_ipc_unref(dest_priv_ipc);
|
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, test.loop);
|
test_binder_exit_wait(&test_opt, test.loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
g_main_loop_unref(test.loop);
|
g_main_loop_unref(test.loop);
|
||||||
|
|
|
@ -114,6 +114,7 @@ test_basic(
|
||||||
gbinder_client_unref(client);
|
gbinder_client_unref(client);
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -175,6 +176,7 @@ test_interfaces(
|
||||||
|
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -189,11 +191,12 @@ test_no_header(
|
||||||
GBinderClient* client = test_client_new(0, NULL);
|
GBinderClient* client = test_client_new(0, NULL);
|
||||||
int fd = gbinder_driver_fd(gbinder_client_ipc(client)->driver);
|
int fd = gbinder_driver_fd(gbinder_client_ipc(client)->driver);
|
||||||
|
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_ignore_dead_object(fd);
|
||||||
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
g_assert(gbinder_client_transact_sync_oneway(client, 0, NULL) ==
|
g_assert(gbinder_client_transact_sync_oneway(client, 0, NULL) ==
|
||||||
GBINDER_STATUS_OK);
|
GBINDER_STATUS_OK);
|
||||||
|
|
||||||
gbinder_client_unref(client);
|
gbinder_client_unref(client);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -220,10 +223,9 @@ test_dead(
|
||||||
GBinderRemoteObject* obj = client->remote;
|
GBinderRemoteObject* obj = client->remote;
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
const int fd = gbinder_driver_fd(gbinder_client_ipc(client)->driver);
|
const int fd = gbinder_driver_fd(gbinder_client_ipc(client)->driver);
|
||||||
gbinder_remote_object_add_death_handler(obj, test_dead_done, loop);
|
|
||||||
|
|
||||||
test_binder_br_dead_binder(fd, handle);
|
gbinder_remote_object_add_death_handler(obj, test_dead_done, loop);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
test_binder_br_dead_binder(fd, ANY_THREAD, handle);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
g_assert(gbinder_remote_object_is_dead(obj));
|
g_assert(gbinder_remote_object_is_dead(obj));
|
||||||
|
|
||||||
|
@ -232,7 +234,6 @@ test_dead(
|
||||||
g_assert(!gbinder_client_transact(client, 0, 0, NULL, NULL, NULL, NULL));
|
g_assert(!gbinder_client_transact(client, 0, 0, NULL, NULL, NULL, NULL));
|
||||||
|
|
||||||
gbinder_client_unref(client);
|
gbinder_client_unref(client);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -251,17 +252,18 @@ test_sync_oneway(
|
||||||
int fd = gbinder_driver_fd(gbinder_client_ipc(client)->driver);
|
int fd = gbinder_driver_fd(gbinder_client_ipc(client)->driver);
|
||||||
|
|
||||||
g_assert(req);
|
g_assert(req);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
g_assert(gbinder_client_transact_sync_oneway(client, 0, req) ==
|
g_assert(gbinder_client_transact_sync_oneway(client, 0, req) ==
|
||||||
GBINDER_STATUS_OK);
|
GBINDER_STATUS_OK);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
|
|
||||||
/* Same but using the internal (empty) request */
|
/* Same but using the internal (empty) request */
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
g_assert(gbinder_client_transact_sync_oneway(client, 0, NULL) ==
|
g_assert(gbinder_client_transact_sync_oneway(client, 0, NULL) ==
|
||||||
GBINDER_STATUS_OK);
|
GBINDER_STATUS_OK);
|
||||||
|
|
||||||
gbinder_client_unref(client);
|
gbinder_client_unref(client);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -291,10 +293,11 @@ test_sync_reply_tx(
|
||||||
data = gbinder_local_reply_data(reply);
|
data = gbinder_local_reply_data(reply);
|
||||||
g_assert(data);
|
g_assert(data);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_ignore_dead_object(fd);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_reply(fd, handle, code, data->bytes);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
|
test_binder_br_reply(fd, THIS_THREAD, handle, code, data->bytes);
|
||||||
|
|
||||||
tx_reply = gbinder_client_transact_sync_reply(client, 0, req, &status);
|
tx_reply = gbinder_client_transact_sync_reply(client, 0, req, &status);
|
||||||
g_assert(tx_reply);
|
g_assert(tx_reply);
|
||||||
|
@ -323,6 +326,7 @@ test_sync_reply(
|
||||||
test_sync_reply_tx(client, NULL);
|
test_sync_reply_tx(client, NULL);
|
||||||
|
|
||||||
gbinder_client_unref(client);
|
gbinder_client_unref(client);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -393,10 +397,11 @@ test_reply_tx(
|
||||||
data = gbinder_local_reply_data(reply);
|
data = gbinder_local_reply_data(reply);
|
||||||
g_assert(data);
|
g_assert(data);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_ignore_dead_object(fd);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_reply(fd, handle, code, data->bytes);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
|
test_binder_br_reply(fd, TX_THREAD, handle, code, data->bytes);
|
||||||
|
|
||||||
id = gbinder_client_transact(client, 0, 0, req, done, destroy, loop);
|
id = gbinder_client_transact(client, 0, 0, req, done, destroy, loop);
|
||||||
g_assert(id);
|
g_assert(id);
|
||||||
|
@ -424,6 +429,7 @@ test_reply(
|
||||||
test_reply_tx(client, NULL, done, destroy);
|
test_reply_tx(client, NULL, done, destroy);
|
||||||
|
|
||||||
gbinder_client_unref(client);
|
gbinder_client_unref(client);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -82,6 +82,7 @@ test_basic(
|
||||||
|
|
||||||
g_assert(!gbinder_handler_transact(NULL, NULL, NULL, 0, 0, NULL));
|
g_assert(!gbinder_handler_transact(NULL, NULL, NULL, 0, 0, NULL));
|
||||||
g_assert(!gbinder_handler_can_loop(NULL));
|
g_assert(!gbinder_handler_can_loop(NULL));
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -98,11 +99,12 @@ test_noop(
|
||||||
|
|
||||||
g_assert(driver);
|
g_assert(driver);
|
||||||
g_assert(fd >= 0);
|
g_assert(fd >= 0);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
g_assert(gbinder_driver_poll(driver, NULL) == POLLIN);
|
g_assert(gbinder_driver_poll(driver, NULL) == POLLIN);
|
||||||
g_assert(gbinder_driver_read(driver, NULL, NULL) == 0);
|
g_assert(gbinder_driver_read(driver, NULL, NULL) == 0);
|
||||||
|
|
||||||
gbinder_driver_unref(driver);
|
gbinder_driver_unref(driver);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -131,6 +133,7 @@ test_local_request(
|
||||||
g_assert(!memcmp(data->bytes->data, rpc_header, sizeof(rpc_header)));
|
g_assert(!memcmp(data->bytes->data, rpc_header, sizeof(rpc_header)));
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_driver_unref(driver);
|
gbinder_driver_unref(driver);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
|
|
@ -180,7 +180,6 @@ test_basic(
|
||||||
/* Invalid path */
|
/* Invalid path */
|
||||||
g_assert(!gbinder_ipc_new("invalid path", NULL));
|
g_assert(!gbinder_ipc_new("invalid path", NULL));
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +202,6 @@ test_protocol(
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_unref(ipc2);
|
gbinder_ipc_unref(ipc2);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +233,7 @@ test_async_oneway(
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
gulong id;
|
gulong id;
|
||||||
|
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
id = gbinder_ipc_transact(ipc, 0, 1, GBINDER_TX_FLAG_ONEWAY,
|
id = gbinder_ipc_transact(ipc, 0, 1, GBINDER_TX_FLAG_ONEWAY,
|
||||||
req, test_async_oneway_done, NULL, loop);
|
req, test_async_oneway_done, NULL, loop);
|
||||||
g_assert(id);
|
g_assert(id);
|
||||||
|
@ -259,11 +257,10 @@ test_sync_oneway(
|
||||||
GBinderLocalRequest* req = test_local_request_new(ipc);
|
GBinderLocalRequest* req = test_local_request_new(ipc);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
g_assert_cmpint(gbinder_ipc_sync_main.sync_oneway(ipc, 0, 1, req), == ,0);
|
g_assert_cmpint(gbinder_ipc_sync_main.sync_oneway(ipc, 0, 1, req), == ,0);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,10 +288,10 @@ test_sync_reply_ok_status(
|
||||||
data = gbinder_local_reply_data(reply);
|
data = gbinder_local_reply_data(reply);
|
||||||
g_assert(data);
|
g_assert(data);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_reply(fd, handle, code, data->bytes);
|
test_binder_br_reply(fd, THIS_THREAD, handle, code, data->bytes);
|
||||||
|
|
||||||
tx_reply = gbinder_ipc_sync_main.sync_reply(ipc, handle, code, req, status);
|
tx_reply = gbinder_ipc_sync_main.sync_reply(ipc, handle, code, req, status);
|
||||||
g_assert(tx_reply);
|
g_assert(tx_reply);
|
||||||
|
@ -307,7 +304,6 @@ test_sync_reply_ok_status(
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,26 +337,27 @@ test_sync_reply_error(
|
||||||
const gint unexpected_status = GBINDER_STATUS_FAILED;
|
const gint unexpected_status = GBINDER_STATUS_FAILED;
|
||||||
int status = INT_MAX;
|
int status = INT_MAX;
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_ignore_dead_object(fd);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_reply_status(fd, expected_status);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
|
test_binder_br_reply_status(fd, TX_THREAD, expected_status);
|
||||||
|
|
||||||
g_assert(!gbinder_ipc_sync_main.sync_reply(ipc,handle,code,req,&status));
|
g_assert(!gbinder_ipc_sync_main.sync_reply(ipc,handle,code,req,&status));
|
||||||
g_assert_cmpint(status, == ,expected_status);
|
g_assert_cmpint(status, == ,expected_status);
|
||||||
|
|
||||||
/* GBINDER_STATUS_FAILED gets replaced with -EFAULT */
|
/* GBINDER_STATUS_FAILED gets replaced with -EFAULT */
|
||||||
test_binder_br_noop(fd);
|
test_binder_ignore_dead_object(fd);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_reply_status(fd, unexpected_status);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
|
test_binder_br_reply_status(fd, TX_THREAD, unexpected_status);
|
||||||
|
|
||||||
g_assert(!gbinder_ipc_sync_main.sync_reply(ipc,handle,code,req,&status));
|
g_assert(!gbinder_ipc_sync_main.sync_reply(ipc,handle,code,req,&status));
|
||||||
g_assert_cmpint(status, == ,-EFAULT);
|
g_assert_cmpint(status, == ,-EFAULT);
|
||||||
|
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,10 +411,10 @@ test_transact_ok(
|
||||||
data = gbinder_local_reply_data(reply);
|
data = gbinder_local_reply_data(reply);
|
||||||
g_assert(data);
|
g_assert(data);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_reply(fd, handle, code, data->bytes);
|
test_binder_br_reply(fd, TX_THREAD, handle, code, data->bytes);
|
||||||
|
|
||||||
id = gbinder_ipc_transact(ipc, handle, code, 0, req,
|
id = gbinder_ipc_transact(ipc, handle, code, 0, req,
|
||||||
test_transact_ok_done, test_transact_ok_destroy, loop);
|
test_transact_ok_done, test_transact_ok_destroy, loop);
|
||||||
|
@ -430,7 +427,6 @@ test_transact_ok(
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -464,8 +460,8 @@ test_transact_dead(
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
gulong id;
|
gulong id;
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_dead_reply(fd);
|
test_binder_br_dead_reply(fd, TX_THREAD);
|
||||||
|
|
||||||
id = gbinder_ipc_transact(ipc, 1, 2, 0, req, test_transact_dead_done,
|
id = gbinder_ipc_transact(ipc, 1, 2, 0, req, test_transact_dead_done,
|
||||||
NULL, loop);
|
NULL, loop);
|
||||||
|
@ -477,7 +473,6 @@ test_transact_dead(
|
||||||
gbinder_ipc_cancel(ipc, id);
|
gbinder_ipc_cancel(ipc, id);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -511,8 +506,8 @@ test_transact_failed(
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
gulong id;
|
gulong id;
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_failed_reply(fd);
|
test_binder_br_failed_reply(fd, TX_THREAD);
|
||||||
|
|
||||||
id = gbinder_ipc_transact(ipc, 1, 2, 0, req, test_transact_failed_done,
|
id = gbinder_ipc_transact(ipc, 1, 2, 0, req, test_transact_failed_done,
|
||||||
NULL, loop);
|
NULL, loop);
|
||||||
|
@ -524,7 +519,6 @@ test_transact_failed(
|
||||||
gbinder_ipc_cancel(ipc, id);
|
gbinder_ipc_cancel(ipc, id);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -560,8 +554,8 @@ test_transact_status(
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
gulong id;
|
gulong id;
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_reply_status(fd, EXPECTED_STATUS);
|
test_binder_br_reply_status(fd, TX_THREAD, EXPECTED_STATUS);
|
||||||
|
|
||||||
id = gbinder_ipc_transact(ipc, 1, 2, 0, req, test_transact_status_done,
|
id = gbinder_ipc_transact(ipc, 1, 2, 0, req, test_transact_status_done,
|
||||||
NULL, loop);
|
NULL, loop);
|
||||||
|
@ -573,7 +567,6 @@ test_transact_status(
|
||||||
gbinder_ipc_cancel(ipc, id);
|
gbinder_ipc_cancel(ipc, id);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -671,7 +664,6 @@ test_transact_custom3(
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* Reference to GBinderIpc is released by test_transact_custom3_exec */
|
/* Reference to GBinderIpc is released by test_transact_custom3_exec */
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -721,7 +713,6 @@ test_transact_cancel(
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -767,7 +758,6 @@ test_transact_cancel2(
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -831,12 +821,13 @@ test_transact_2way_run(
|
||||||
prot->write_rpc_header(&writer, "test");
|
prot->write_rpc_header(&writer, "test");
|
||||||
gbinder_writer_append_string8(&writer, "message");
|
gbinder_writer_append_string8(&writer, "message");
|
||||||
|
|
||||||
test_binder_br_transaction(fd, obj, 2,
|
test_binder_ignore_dead_object(fd);
|
||||||
|
test_binder_br_transaction(fd, TX_THREAD, obj, 2,
|
||||||
gbinder_local_request_data(req)->bytes);
|
gbinder_local_request_data(req)->bytes);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, TX_THREAD);
|
||||||
test_binder_br_reply(fd, handle, code,
|
test_binder_br_reply(fd, TX_THREAD, handle, code,
|
||||||
gbinder_local_reply_data(reply)->bytes);
|
gbinder_local_reply_data(reply)->bytes);
|
||||||
|
|
||||||
/* NB. Reusing test_transact_ok_done and test_transact_ok_destroy */
|
/* NB. Reusing test_transact_ok_done and test_transact_ok_destroy */
|
||||||
|
@ -855,7 +846,6 @@ test_transact_2way_run(
|
||||||
g_idle_add(test_unref_ipc, ipc);
|
g_idle_add(test_unref_ipc, ipc);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -895,10 +885,6 @@ test_transact_unhandled_run(
|
||||||
GBinderDriver* driver = ipc->driver;
|
GBinderDriver* driver = ipc->driver;
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
GBinderLocalRequest* req = gbinder_driver_local_request_new_ping(driver);
|
GBinderLocalRequest* req = gbinder_driver_local_request_new_ping(driver);
|
||||||
int fd = gbinder_driver_fd(driver);
|
|
||||||
|
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
|
|
||||||
g_assert(gbinder_ipc_transact(ipc, 1 /* Non-existent object */,
|
g_assert(gbinder_ipc_transact(ipc, 1 /* Non-existent object */,
|
||||||
gbinder_driver_protocol(driver)->ping_tx, 0, req,
|
gbinder_driver_protocol(driver)->ping_tx, 0, req,
|
||||||
|
@ -907,7 +893,6 @@ test_transact_unhandled_run(
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -971,13 +956,12 @@ test_transact_incoming_run(
|
||||||
prot->write_rpc_header(&writer, "test");
|
prot->write_rpc_header(&writer, "test");
|
||||||
gbinder_writer_append_string8(&writer, "message");
|
gbinder_writer_append_string8(&writer, "message");
|
||||||
|
|
||||||
test_binder_br_transaction(fd, obj, prot->ping_tx,
|
test_binder_br_transaction(fd, LOOPER_THREAD, obj, prot->ping_tx,
|
||||||
gbinder_local_request_data(ping)->bytes);
|
gbinder_local_request_data(ping)->bytes);
|
||||||
test_binder_br_transaction_complete(fd); /* For reply */
|
test_binder_br_transaction_complete(fd, LOOPER_THREAD); /* For reply */
|
||||||
test_binder_br_transaction(fd, obj, 1,
|
test_binder_br_transaction(fd, LOOPER_THREAD, obj, 1,
|
||||||
gbinder_local_request_data(req)->bytes);
|
gbinder_local_request_data(req)->bytes);
|
||||||
test_binder_br_transaction_complete(fd); /* For reply */
|
test_binder_br_transaction_complete(fd, LOOPER_THREAD); /* For reply */
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* Now we need to wait until GBinderIpc is destroyed */
|
/* Now we need to wait until GBinderIpc is destroyed */
|
||||||
|
@ -989,7 +973,6 @@ test_transact_incoming_run(
|
||||||
g_idle_add(test_unref_ipc, ipc);
|
g_idle_add(test_unref_ipc, ipc);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -1049,9 +1032,8 @@ test_transact_status_reply_run(
|
||||||
gbinder_writer_append_string8(&writer, "message");
|
gbinder_writer_append_string8(&writer, "message");
|
||||||
data = gbinder_local_request_data(req);
|
data = gbinder_local_request_data(req);
|
||||||
|
|
||||||
test_binder_br_transaction(fd, obj, 1, data->bytes);
|
test_binder_br_transaction(fd, LOOPER_THREAD, obj, 1, data->bytes);
|
||||||
test_binder_br_transaction_complete(fd); /* For reply */
|
test_binder_br_transaction_complete(fd, LOOPER_THREAD); /* For reply */
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE_ONE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* Now we need to wait until GBinderIpc is destroyed */
|
/* Now we need to wait until GBinderIpc is destroyed */
|
||||||
|
@ -1062,7 +1044,6 @@ test_transact_status_reply_run(
|
||||||
g_idle_add(test_unref_ipc, ipc);
|
g_idle_add(test_unref_ipc, ipc);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -1165,9 +1146,8 @@ test_transact_async_run(
|
||||||
gbinder_writer_append_string8(&writer, "message");
|
gbinder_writer_append_string8(&writer, "message");
|
||||||
data = gbinder_local_request_data(req);
|
data = gbinder_local_request_data(req);
|
||||||
|
|
||||||
test_binder_br_transaction(fd, obj, 1, data->bytes);
|
test_binder_br_transaction(fd, LOOPER_THREAD, obj, 1, data->bytes);
|
||||||
test_binder_br_transaction_complete(fd); /* For reply */
|
test_binder_br_transaction_complete(fd, LOOPER_THREAD); /* For reply */
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE_ONE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* Now we need to wait until GBinderIpc is destroyed */
|
/* Now we need to wait until GBinderIpc is destroyed */
|
||||||
|
@ -1178,7 +1158,6 @@ test_transact_async_run(
|
||||||
g_idle_add(test_unref_ipc, ipc);
|
g_idle_add(test_unref_ipc, ipc);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -1247,9 +1226,8 @@ test_transact_async_sync_run(
|
||||||
gbinder_writer_append_string8(&writer, "message");
|
gbinder_writer_append_string8(&writer, "message");
|
||||||
data = gbinder_local_request_data(req);
|
data = gbinder_local_request_data(req);
|
||||||
|
|
||||||
test_binder_br_transaction(fd, obj, 1, data->bytes);
|
test_binder_br_transaction(fd, LOOPER_THREAD, obj, 1, data->bytes);
|
||||||
test_binder_br_transaction_complete(fd); /* For reply */
|
test_binder_br_transaction_complete(fd, LOOPER_THREAD); /* For reply */
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE_ONE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* Now we need to wait until GBinderIpc is destroyed */
|
/* Now we need to wait until GBinderIpc is destroyed */
|
||||||
|
@ -1260,7 +1238,6 @@ test_transact_async_sync_run(
|
||||||
g_idle_add(test_unref_ipc, ipc);
|
g_idle_add(test_unref_ipc, ipc);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -1301,8 +1278,7 @@ test_drop_remote_refs_run(
|
||||||
gulong id = gbinder_local_object_add_strong_refs_changed_handler(obj,
|
gulong id = gbinder_local_object_add_strong_refs_changed_handler(obj,
|
||||||
test_drop_remote_refs_cb, loop);
|
test_drop_remote_refs_cb, loop);
|
||||||
|
|
||||||
test_binder_br_acquire(fd, obj);
|
test_binder_br_acquire(fd, ANY_THREAD, obj);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
g_assert(obj->strong_refs == 1);
|
g_assert(obj->strong_refs == 1);
|
||||||
|
@ -1350,7 +1326,7 @@ test_cancel_on_exit(
|
||||||
int fd = gbinder_driver_fd(ipc->driver);
|
int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
/* This transaction will be cancelled by gbinder_ipc_exit */
|
/* This transaction will be cancelled by gbinder_ipc_exit */
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
gbinder_ipc_transact(ipc, 0, 1, GBINDER_TX_FLAG_ONEWAY,
|
gbinder_ipc_transact(ipc, 0, 1, GBINDER_TX_FLAG_ONEWAY,
|
||||||
req, test_cancel_on_exit_not_reached, NULL, NULL);
|
req, test_cancel_on_exit_not_reached, NULL, NULL);
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ test_basic(
|
||||||
g_assert(gbinder_local_object_ref(bar) == bar);
|
g_assert(gbinder_local_object_ref(bar) == bar);
|
||||||
gbinder_local_object_drop(bar);
|
gbinder_local_object_drop(bar);
|
||||||
gbinder_local_object_unref(bar);
|
gbinder_local_object_unref(bar);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -233,6 +234,7 @@ test_ping(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -282,6 +284,7 @@ test_interface(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -332,6 +335,7 @@ test_hidl_ping(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -385,6 +389,7 @@ test_get_descriptor(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -436,6 +441,7 @@ test_descriptor_chain(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -546,6 +552,7 @@ test_custom_iface(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -603,6 +610,7 @@ test_reply_status(
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_remote_request_unref(req);
|
gbinder_remote_request_unref(req);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -634,16 +642,15 @@ test_increfs_run(
|
||||||
test_increfs_cb, loop);
|
test_increfs_cb, loop);
|
||||||
|
|
||||||
/* ipc is not an object, will be ignored */
|
/* ipc is not an object, will be ignored */
|
||||||
test_binder_br_increfs(fd, ipc);
|
test_binder_br_increfs(fd, ANY_THREAD, ipc);
|
||||||
test_binder_br_increfs(fd, obj);
|
test_binder_br_increfs(fd, ANY_THREAD, obj);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
g_assert(obj->weak_refs == 1);
|
g_assert(obj->weak_refs == 1);
|
||||||
gbinder_local_object_remove_handler(obj, id);
|
gbinder_local_object_remove_handler(obj, id);
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,17 +692,16 @@ test_decrefs_run(
|
||||||
test_decrefs_cb, loop);
|
test_decrefs_cb, loop);
|
||||||
|
|
||||||
/* ipc is not an object, will be ignored */
|
/* ipc is not an object, will be ignored */
|
||||||
test_binder_br_decrefs(fd, ipc);
|
test_binder_br_decrefs(fd, ANY_THREAD, ipc);
|
||||||
test_binder_br_increfs(fd, obj);
|
test_binder_br_increfs(fd, ANY_THREAD, obj);
|
||||||
test_binder_br_decrefs(fd, obj);
|
test_binder_br_decrefs(fd, ANY_THREAD, obj);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
g_assert(obj->weak_refs == 0);
|
g_assert(obj->weak_refs == 0);
|
||||||
gbinder_local_object_remove_handler(obj, id);
|
gbinder_local_object_remove_handler(obj, id);
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,16 +742,15 @@ test_acquire_run(
|
||||||
test_acquire_cb, loop);
|
test_acquire_cb, loop);
|
||||||
|
|
||||||
/* ipc is not an object, will be ignored */
|
/* ipc is not an object, will be ignored */
|
||||||
test_binder_br_acquire(fd, ipc);
|
test_binder_br_acquire(fd, ANY_THREAD, ipc);
|
||||||
test_binder_br_acquire(fd, obj);
|
test_binder_br_acquire(fd, ANY_THREAD, obj);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
g_assert(obj->strong_refs == 1);
|
g_assert(obj->strong_refs == 1);
|
||||||
gbinder_local_object_remove_handler(obj, id);
|
gbinder_local_object_remove_handler(obj, id);
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,17 +791,16 @@ test_release_run(
|
||||||
test_release_cb, loop);
|
test_release_cb, loop);
|
||||||
|
|
||||||
/* ipc is not an object, will be ignored */
|
/* ipc is not an object, will be ignored */
|
||||||
test_binder_br_release(fd, ipc);
|
test_binder_br_release(fd, ANY_THREAD, ipc);
|
||||||
test_binder_br_acquire(fd, obj);
|
test_binder_br_acquire(fd, ANY_THREAD, obj);
|
||||||
test_binder_br_release(fd, obj);
|
test_binder_br_release(fd, ANY_THREAD, obj);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
g_assert(obj->strong_refs == 0);
|
g_assert(obj->strong_refs == 0);
|
||||||
gbinder_local_object_remove_handler(obj, id);
|
gbinder_local_object_remove_handler(obj, id);
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021-2022 Jolla Ltd.
|
* Copyright (C) 2021-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
|
* Copyright (C) 2023 Slava Monich <slava@monich.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of BSD license as follows:
|
* You may use this file under the terms of BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -50,9 +51,7 @@
|
||||||
static TestOpt test_opt;
|
static TestOpt test_opt;
|
||||||
|
|
||||||
#define DEV "/dev/xbinder"
|
#define DEV "/dev/xbinder"
|
||||||
#define DEV_PRIV DEV "-private"
|
|
||||||
#define DEV2 "/dev/ybinder"
|
#define DEV2 "/dev/ybinder"
|
||||||
#define DEV2_PRIV DEV2 "-private"
|
|
||||||
|
|
||||||
enum test_tx_codes {
|
enum test_tx_codes {
|
||||||
TX_CODE = GBINDER_FIRST_CALL_TRANSACTION,
|
TX_CODE = GBINDER_FIRST_CALL_TRANSACTION,
|
||||||
|
@ -190,8 +189,7 @@ test_basic_run(
|
||||||
GBinderLocalObject* obj;
|
GBinderLocalObject* obj;
|
||||||
GBinderProxyObject* proxy;
|
GBinderProxyObject* proxy;
|
||||||
GBinderRemoteObject* remote_obj;
|
GBinderRemoteObject* remote_obj;
|
||||||
GBinderRemoteObject* remote_proxy;
|
GBinderClient* client;
|
||||||
GBinderClient* proxy_client;
|
|
||||||
GBinderIpc* ipc_obj;
|
GBinderIpc* ipc_obj;
|
||||||
GBinderIpc* ipc_proxy;
|
GBinderIpc* ipc_proxy;
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
|
@ -199,29 +197,20 @@ test_basic_run(
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
ipc_proxy = gbinder_ipc_new(DEV, NULL);
|
ipc_proxy = gbinder_ipc_new(DEV, NULL);
|
||||||
ipc_obj = gbinder_ipc_new(DEV_PRIV, NULL);
|
ipc_obj = gbinder_ipc_new(DEV2, NULL);
|
||||||
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
|
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
|
||||||
fd_obj = gbinder_driver_fd(ipc_obj->driver);
|
fd_obj = gbinder_driver_fd(ipc_obj->driver);
|
||||||
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_basic_cb, &n);
|
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_basic_cb, &n);
|
||||||
remote_obj = gbinder_remote_object_new(ipc_proxy,
|
remote_obj = gbinder_remote_object_new(ipc_obj,
|
||||||
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
|
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
|
||||||
REMOTE_OBJECT_CREATE_ALIVE);
|
REMOTE_OBJECT_CREATE_ALIVE);
|
||||||
|
|
||||||
/* remote_proxy(DEV_PRIV) => proxy (DEV) => obj (DEV) => DEV_PRIV */
|
|
||||||
g_assert(!gbinder_proxy_object_new(NULL, remote_obj));
|
g_assert(!gbinder_proxy_object_new(NULL, remote_obj));
|
||||||
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
|
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
|
||||||
remote_proxy = gbinder_remote_object_new(ipc_obj,
|
client = gbinder_client_new(proxy->remote, TEST_IFACE);
|
||||||
test_binder_register_object(fd_proxy, &proxy->parent, AUTO_HANDLE),
|
|
||||||
REMOTE_OBJECT_CREATE_ALIVE);
|
|
||||||
proxy_client = gbinder_client_new(remote_proxy, TEST_IFACE);
|
|
||||||
|
|
||||||
test_binder_set_passthrough(fd_obj, TRUE);
|
|
||||||
test_binder_set_passthrough(fd_proxy, TRUE);
|
|
||||||
test_binder_set_looper_enabled(fd_obj, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_set_looper_enabled(fd_proxy, TEST_LOOPER_ENABLE);
|
|
||||||
|
|
||||||
/* Perform a transaction via proxy */
|
/* Perform a transaction via proxy */
|
||||||
g_assert(gbinder_client_transact(proxy_client, TX_CODE, 0, NULL,
|
g_assert(gbinder_client_transact(client, TX_CODE, 0, NULL,
|
||||||
test_basic_reply, NULL, loop));
|
test_basic_reply, NULL, loop));
|
||||||
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
@ -232,11 +221,9 @@ test_basic_run(
|
||||||
gbinder_local_object_drop(obj);
|
gbinder_local_object_drop(obj);
|
||||||
gbinder_local_object_drop(&proxy->parent);
|
gbinder_local_object_drop(&proxy->parent);
|
||||||
gbinder_remote_object_unref(remote_obj);
|
gbinder_remote_object_unref(remote_obj);
|
||||||
gbinder_remote_object_unref(remote_proxy);
|
gbinder_client_unref(client);
|
||||||
gbinder_client_unref(proxy_client);
|
|
||||||
gbinder_ipc_unref(ipc_obj);
|
gbinder_ipc_unref(ipc_obj);
|
||||||
gbinder_ipc_unref(ipc_proxy);
|
gbinder_ipc_unref(ipc_proxy);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
|
@ -303,6 +290,19 @@ test_param_cb(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_param_canceled(
|
||||||
|
GBinderClient* client,
|
||||||
|
GBinderRemoteReply* reply,
|
||||||
|
int status,
|
||||||
|
void* unused)
|
||||||
|
{
|
||||||
|
g_assert(!reply);
|
||||||
|
g_assert_cmpint(status, == ,-ECANCELED);
|
||||||
|
GDEBUG("Transaction cancelled");
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
test_param_reply(
|
test_param_reply(
|
||||||
|
@ -311,35 +311,19 @@ test_param_reply(
|
||||||
int status,
|
int status,
|
||||||
void* loop)
|
void* loop)
|
||||||
{
|
{
|
||||||
/*
|
GBinderReader reader;
|
||||||
* Due to limitations of our binder simulation, the result can be
|
gint32 result = 0;
|
||||||
* delivered to a wrong thread. As a result, we only known that one
|
|
||||||
* of the callbacks get NULL result and one gets NULL loop, but we
|
|
||||||
* don't really know which one gets what, i.e. we have to be ready
|
|
||||||
* for any combination of these parameters.
|
|
||||||
*
|
|
||||||
* It's too difficult to fix (without writing almost a full-blown
|
|
||||||
* binder implementation), let's just live with it for now :/
|
|
||||||
*/
|
|
||||||
if (reply) {
|
|
||||||
GBinderReader reader;
|
|
||||||
gint32 result = 0;
|
|
||||||
|
|
||||||
GDEBUG("Reply received");
|
g_assert(reply);
|
||||||
|
g_assert_cmpint(status, == ,0);
|
||||||
|
GDEBUG("Reply received");
|
||||||
|
|
||||||
/* Make sure that result got delivered intact */
|
/* Make sure that result got delivered intact */
|
||||||
gbinder_remote_reply_init_reader(reply, &reader);
|
gbinder_remote_reply_init_reader(reply, &reader);
|
||||||
g_assert(gbinder_reader_read_int32(&reader, &result));
|
g_assert(gbinder_reader_read_int32(&reader, &result));
|
||||||
g_assert(gbinder_reader_at_end(&reader));
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
g_assert_cmpint(result, == ,TX_RESULT);
|
g_assert_cmpint(result, == ,TX_RESULT);
|
||||||
} else {
|
g_main_loop_quit((GMainLoop*)loop);
|
||||||
/* The cancelled one */
|
|
||||||
GDEBUG("Transaction cancelled");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loop) {
|
|
||||||
g_main_loop_quit((GMainLoop*)loop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -351,54 +335,40 @@ test_param_run(
|
||||||
GBinderLocalObject* obj;
|
GBinderLocalObject* obj;
|
||||||
GBinderProxyObject* proxy;
|
GBinderProxyObject* proxy;
|
||||||
GBinderRemoteObject* remote_obj;
|
GBinderRemoteObject* remote_obj;
|
||||||
GBinderRemoteObject* remote_proxy;
|
GBinderClient* client;
|
||||||
GBinderClient* proxy_client;
|
|
||||||
GBinderLocalRequest* req;
|
GBinderLocalRequest* req;
|
||||||
GBinderIpc* ipc_obj;
|
GBinderIpc* ipc_obj;
|
||||||
GBinderIpc* ipc_remote_obj;
|
|
||||||
GBinderIpc* ipc_proxy;
|
GBinderIpc* ipc_proxy;
|
||||||
GBinderIpc* ipc_remote_proxy;
|
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
int fd_obj, fd_proxy, n = 0;
|
int fd_obj, fd_proxy, n = 0;
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
ipc_obj = gbinder_ipc_new(DEV, NULL);
|
|
||||||
ipc_remote_obj = gbinder_ipc_new(DEV_PRIV, NULL);
|
|
||||||
ipc_proxy = gbinder_ipc_new(DEV2, NULL);
|
ipc_proxy = gbinder_ipc_new(DEV2, NULL);
|
||||||
ipc_remote_proxy = gbinder_ipc_new(DEV2_PRIV, NULL);
|
ipc_obj = gbinder_ipc_new(DEV, NULL);
|
||||||
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
|
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
|
||||||
fd_obj = gbinder_driver_fd(ipc_obj->driver);
|
fd_obj = gbinder_driver_fd(ipc_obj->driver);
|
||||||
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_param_cb, &n);
|
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_param_cb, &n);
|
||||||
remote_obj = gbinder_remote_object_new(ipc_remote_obj,
|
remote_obj = gbinder_remote_object_new(ipc_obj,
|
||||||
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
|
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
|
||||||
REMOTE_OBJECT_CREATE_ALIVE);
|
REMOTE_OBJECT_CREATE_ALIVE);
|
||||||
|
|
||||||
/* remote_proxy(DEV2_PRIV) => proxy (DEV2) => obj (DEV) => DEV_PRIV */
|
|
||||||
g_assert(!gbinder_proxy_object_new(NULL, remote_obj));
|
g_assert(!gbinder_proxy_object_new(NULL, remote_obj));
|
||||||
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
|
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
|
||||||
remote_proxy = gbinder_remote_object_new(ipc_remote_proxy,
|
client = gbinder_client_new(proxy->remote, TEST_IFACE);
|
||||||
test_binder_register_object(fd_proxy, &proxy->parent, AUTO_HANDLE),
|
|
||||||
REMOTE_OBJECT_CREATE_ALIVE);
|
|
||||||
proxy_client = gbinder_client_new(remote_proxy, TEST_IFACE);
|
|
||||||
|
|
||||||
test_binder_set_passthrough(fd_obj, TRUE);
|
|
||||||
test_binder_set_passthrough(fd_proxy, TRUE);
|
|
||||||
test_binder_set_looper_enabled(fd_obj, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_set_looper_enabled(fd_proxy, TEST_LOOPER_ENABLE);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform two transactions via proxy. First one never gets completed
|
* Perform two transactions via proxy. First one never gets completed
|
||||||
* and eventually is cancelled, and the second one is replied to.
|
* and eventually is cancelled, and the second one is replied to.
|
||||||
*/
|
*/
|
||||||
req = gbinder_client_new_request(proxy_client);
|
req = gbinder_client_new_request(client);
|
||||||
gbinder_local_request_append_int32(req, TX_PARAM_DONT_REPLY);
|
gbinder_local_request_append_int32(req, TX_PARAM_DONT_REPLY);
|
||||||
gbinder_client_transact(proxy_client, TX_CODE, 0, req, test_param_reply,
|
gbinder_client_transact(client, TX_CODE, 0, req, test_param_canceled,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
|
|
||||||
req = gbinder_client_new_request(proxy_client);
|
req = gbinder_client_new_request(client);
|
||||||
gbinder_local_request_append_int32(req, TX_PARAM_REPLY);
|
gbinder_local_request_append_int32(req, TX_PARAM_REPLY);
|
||||||
g_assert(gbinder_client_transact(proxy_client, TX_CODE, 0, req,
|
g_assert(gbinder_client_transact(client, TX_CODE, 0, req,
|
||||||
test_param_reply, NULL, loop));
|
test_param_reply, NULL, loop));
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
|
|
||||||
|
@ -412,13 +382,9 @@ test_param_run(
|
||||||
gbinder_local_object_drop(obj);
|
gbinder_local_object_drop(obj);
|
||||||
gbinder_local_object_drop(&proxy->parent);
|
gbinder_local_object_drop(&proxy->parent);
|
||||||
gbinder_remote_object_unref(remote_obj);
|
gbinder_remote_object_unref(remote_obj);
|
||||||
gbinder_remote_object_unref(remote_proxy);
|
gbinder_client_unref(client);
|
||||||
gbinder_client_unref(proxy_client);
|
|
||||||
gbinder_ipc_unref(ipc_obj);
|
gbinder_ipc_unref(ipc_obj);
|
||||||
gbinder_ipc_unref(ipc_remote_obj);
|
|
||||||
gbinder_ipc_unref(ipc_proxy);
|
gbinder_ipc_unref(ipc_proxy);
|
||||||
gbinder_ipc_unref(ipc_remote_proxy);
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
|
@ -597,62 +563,39 @@ test_obj_run(
|
||||||
GBinderLocalObject* obj2;
|
GBinderLocalObject* obj2;
|
||||||
GBinderProxyObject* proxy;
|
GBinderProxyObject* proxy;
|
||||||
GBinderRemoteObject* remote_obj;
|
GBinderRemoteObject* remote_obj;
|
||||||
GBinderRemoteObject* remote_proxy;
|
GBinderClient* client;
|
||||||
GBinderClient* proxy_client;
|
|
||||||
GBinderIpc* ipc_remote_obj;
|
|
||||||
GBinderIpc* ipc_obj;
|
GBinderIpc* ipc_obj;
|
||||||
GBinderIpc* ipc_proxy;
|
GBinderIpc* ipc_proxy;
|
||||||
GBinderIpc* ipc_remote_proxy;
|
|
||||||
GBinderLocalRequest* req;
|
GBinderLocalRequest* req;
|
||||||
int fd_remote_obj, fd_obj, fd_proxy, fd_remote_proxy;
|
int fd_obj, fd_proxy;
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
memset(&test, 0, sizeof(test));
|
memset(&test, 0, sizeof(test));
|
||||||
test.loop = g_main_loop_new(NULL, FALSE);
|
test.loop = g_main_loop_new(NULL, FALSE);
|
||||||
|
|
||||||
ipc_remote_obj = gbinder_ipc_new(DEV_PRIV, NULL);
|
|
||||||
ipc_obj = gbinder_ipc_new(DEV, NULL);
|
|
||||||
ipc_proxy = gbinder_ipc_new(DEV2, NULL);
|
ipc_proxy = gbinder_ipc_new(DEV2, NULL);
|
||||||
ipc_remote_proxy = gbinder_ipc_new(DEV2_PRIV, NULL);
|
ipc_obj = gbinder_ipc_new(DEV, NULL);
|
||||||
|
|
||||||
fd_remote_obj = gbinder_driver_fd(ipc_remote_obj->driver);
|
|
||||||
fd_obj = gbinder_driver_fd(ipc_obj->driver);
|
|
||||||
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
|
fd_proxy = gbinder_driver_fd(ipc_proxy->driver);
|
||||||
fd_remote_proxy = gbinder_driver_fd(ipc_remote_proxy->driver);
|
fd_obj = gbinder_driver_fd(ipc_obj->driver);
|
||||||
|
|
||||||
obj = gbinder_local_object_new(ipc_remote_obj, TEST_IFACES,
|
obj = gbinder_local_object_new(ipc_obj, TEST_IFACES, test_obj_cb, &test);
|
||||||
test_obj_cb, &test);
|
|
||||||
GDEBUG("obj %p", obj);
|
GDEBUG("obj %p", obj);
|
||||||
remote_obj = gbinder_remote_object_new(ipc_obj,
|
remote_obj = gbinder_remote_object_new(ipc_obj,
|
||||||
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
|
test_binder_register_object(fd_obj, obj, AUTO_HANDLE),
|
||||||
REMOTE_OBJECT_CREATE_ALIVE);
|
REMOTE_OBJECT_CREATE_ALIVE);
|
||||||
|
|
||||||
/* remote_proxy(DEV2_PRIV) => proxy (DEV) => obj(DEV2_PRIV) */
|
|
||||||
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
|
g_assert((proxy = gbinder_proxy_object_new(ipc_proxy, remote_obj)));
|
||||||
GDEBUG("proxy %p", proxy);
|
GDEBUG("proxy %p", proxy);
|
||||||
remote_proxy = gbinder_remote_object_new(ipc_remote_proxy,
|
client = gbinder_client_new(proxy->remote, TEST_IFACE);
|
||||||
test_binder_register_object(fd_proxy, &proxy->parent, AUTO_HANDLE),
|
|
||||||
REMOTE_OBJECT_CREATE_ALIVE);
|
|
||||||
proxy_client = gbinder_client_new(remote_proxy, TEST_IFACE);
|
|
||||||
|
|
||||||
test_binder_set_passthrough(fd_remote_obj, TRUE);
|
|
||||||
test_binder_set_passthrough(fd_obj, TRUE);
|
|
||||||
test_binder_set_passthrough(fd_proxy, TRUE);
|
|
||||||
test_binder_set_passthrough(fd_remote_proxy, TRUE);
|
|
||||||
|
|
||||||
test_binder_set_looper_enabled(fd_remote_obj, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_set_looper_enabled(fd_obj, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_set_looper_enabled(fd_proxy, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_set_looper_enabled(fd_remote_proxy, TEST_LOOPER_ENABLE);
|
|
||||||
|
|
||||||
/* Pass object reference via proxy */
|
/* Pass object reference via proxy */
|
||||||
obj2 = gbinder_local_object_new(ipc_remote_proxy, TEST_IFACES2, test_obj2_cb, &test);
|
obj2 = gbinder_local_object_new(ipc_obj, TEST_IFACES2, test_obj2_cb, &test);
|
||||||
GDEBUG("obj2 %p", obj2);
|
GDEBUG("obj2 %p", obj2);
|
||||||
req = gbinder_client_new_request(proxy_client);
|
req = gbinder_client_new_request(client);
|
||||||
gbinder_local_request_append_int32(req, TX_PARAM1);
|
gbinder_local_request_append_int32(req, TX_PARAM1);
|
||||||
gbinder_local_request_append_local_object(req, obj2);
|
gbinder_local_request_append_local_object(req, obj2);
|
||||||
gbinder_local_request_append_int32(req, TX_PARAM2);
|
gbinder_local_request_append_int32(req, TX_PARAM2);
|
||||||
gbinder_client_transact(proxy_client, TX_CODE, 0, req, test_obj_reply,
|
gbinder_client_transact(client, TX_CODE, 0, req, test_obj_reply,
|
||||||
NULL, &test);
|
NULL, &test);
|
||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
|
|
||||||
|
@ -665,22 +608,16 @@ test_obj_run(
|
||||||
g_assert(test.obj2);
|
g_assert(test.obj2);
|
||||||
gbinder_local_object_unref(test.obj2);
|
gbinder_local_object_unref(test.obj2);
|
||||||
|
|
||||||
test_binder_unregister_objects(fd_remote_obj);
|
|
||||||
test_binder_unregister_objects(fd_obj);
|
test_binder_unregister_objects(fd_obj);
|
||||||
test_binder_unregister_objects(fd_proxy);
|
test_binder_unregister_objects(fd_proxy);
|
||||||
test_binder_unregister_objects(fd_remote_proxy);
|
|
||||||
|
|
||||||
gbinder_local_object_drop(obj);
|
gbinder_local_object_drop(obj);
|
||||||
gbinder_local_object_drop(obj2);
|
gbinder_local_object_drop(obj2);
|
||||||
gbinder_local_object_drop(&proxy->parent);
|
gbinder_local_object_drop(&proxy->parent);
|
||||||
gbinder_remote_object_unref(remote_obj);
|
gbinder_remote_object_unref(remote_obj);
|
||||||
gbinder_remote_object_unref(remote_proxy);
|
gbinder_client_unref(client);
|
||||||
gbinder_client_unref(proxy_client);
|
|
||||||
gbinder_ipc_unref(ipc_remote_obj);
|
|
||||||
gbinder_ipc_unref(ipc_obj);
|
gbinder_ipc_unref(ipc_obj);
|
||||||
gbinder_ipc_unref(ipc_proxy);
|
gbinder_ipc_unref(ipc_proxy);
|
||||||
gbinder_ipc_unref(ipc_remote_proxy);
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, test.loop);
|
test_binder_exit_wait(&test_opt, test.loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
g_main_loop_unref(test.loop);
|
g_main_loop_unref(test.loop);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2022 Jolla Ltd.
|
* Copyright (C) 2018-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2018-2023 Slava Monich <slava@monich.com>
|
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
|
* Copyright (C) 2023 Slava Monich <slava@monich.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of BSD license as follows:
|
* You may use this file under the terms of BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test_common.h"
|
#include "test_common.h"
|
||||||
|
#include "test_binder.h"
|
||||||
|
|
||||||
#include "gbinder_buffer_p.h"
|
#include "gbinder_buffer_p.h"
|
||||||
#include "gbinder_driver.h"
|
#include "gbinder_driver.h"
|
||||||
|
@ -59,12 +61,9 @@ typedef struct binder_buffer_object_64 {
|
||||||
} BinderObject64;
|
} BinderObject64;
|
||||||
|
|
||||||
#define BINDER_TYPE_(c1,c2,c3) GBINDER_FOURCC(c1,c2,c3,0x85)
|
#define BINDER_TYPE_(c1,c2,c3) GBINDER_FOURCC(c1,c2,c3,0x85)
|
||||||
#define BINDER_TYPE_HANDLE BINDER_TYPE_('s','h','*')
|
|
||||||
#define BINDER_TYPE_PTR BINDER_TYPE_('p','t','*')
|
|
||||||
#define BINDER_TYPE_FD BINDER_TYPE_('f', 'd', '*')
|
#define BINDER_TYPE_FD BINDER_TYPE_('f', 'd', '*')
|
||||||
#define BINDER_BUFFER_FLAG_HAS_PARENT 0x01
|
#define BINDER_BUFFER_FLAG_HAS_PARENT 0x01
|
||||||
#define BINDER_FLAG_ACCEPTS_FDS 0x100
|
#define BINDER_FLAG_ACCEPTS_FDS 0x100
|
||||||
#define BUFFER_OBJECT_SIZE_64 (GBINDER_MAX_BUFFER_OBJECT_SIZE)
|
|
||||||
G_STATIC_ASSERT(sizeof(BinderObject64) == BUFFER_OBJECT_SIZE_64);
|
G_STATIC_ASSERT(sizeof(BinderObject64) == BUFFER_OBJECT_SIZE_64);
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -789,6 +788,7 @@ test_hidl_struct(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1024,6 +1024,7 @@ test_hidl_vec(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1105,6 +1106,7 @@ test_hidl_string_err(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -1139,6 +1141,7 @@ test_hidl_string_err_skip(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1182,6 +1185,7 @@ test_fd_ok(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1213,6 +1217,7 @@ test_fd_shortbuf(
|
||||||
g_assert(gbinder_reader_read_fd(&reader) < 0);
|
g_assert(gbinder_reader_read_fd(&reader) < 0);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1256,6 +1261,7 @@ test_fd_badtype(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1303,6 +1309,7 @@ test_dupfd_ok(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1346,6 +1353,7 @@ test_dupfd_badtype(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1389,6 +1397,7 @@ test_dupfd_badfd(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1429,6 +1438,7 @@ test_hidl_string(
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -1707,6 +1717,7 @@ test_buffer(
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1840,6 +1851,7 @@ test_object(
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1896,6 +1908,7 @@ test_object_invalid(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1948,6 +1961,7 @@ test_vec(
|
||||||
g_free(data.objects);
|
g_free(data.objects);
|
||||||
gbinder_buffer_free(data.buffer);
|
gbinder_buffer_free(data.buffer);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1984,8 +1998,7 @@ test_hidl_string_vec(
|
||||||
data.objects[i] = NULL;
|
data.objects[i] = NULL;
|
||||||
|
|
||||||
gbinder_reader_init(&reader, &data, 0, buf->size);
|
gbinder_reader_init(&reader, &data, 0, buf->size);
|
||||||
out = gbinder_reader_read_hidl_string_vec(&reader)
|
out = gbinder_reader_read_hidl_string_vec(&reader);
|
||||||
;
|
|
||||||
if (out) {
|
if (out) {
|
||||||
const guint n = g_strv_length(out);
|
const guint n = g_strv_length(out);
|
||||||
|
|
||||||
|
@ -2003,6 +2016,7 @@ test_hidl_string_vec(
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_buffer_free(buf);
|
gbinder_buffer_free(buf);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -89,6 +89,7 @@ test_basic(
|
||||||
gbinder_remote_object_unref(obj1);
|
gbinder_remote_object_unref(obj1);
|
||||||
gbinder_remote_object_unref(obj2);
|
gbinder_remote_object_unref(obj2);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -119,8 +120,7 @@ test_dead_run(
|
||||||
gulong id = gbinder_remote_object_add_death_handler
|
gulong id = gbinder_remote_object_add_death_handler
|
||||||
(obj, test_dead_done, loop);
|
(obj, test_dead_done, loop);
|
||||||
|
|
||||||
test_binder_br_dead_binder(fd, h);
|
test_binder_br_dead_binder(fd, ANY_THREAD, h);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
g_assert(gbinder_remote_object_is_dead(obj));
|
g_assert(gbinder_remote_object_is_dead(obj));
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ test_dead_run(
|
||||||
gbinder_remote_object_remove_handler(obj, 0); /* has no effect */
|
gbinder_remote_object_remove_handler(obj, 0); /* has no effect */
|
||||||
gbinder_remote_object_unref(obj);
|
gbinder_remote_object_unref(obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,9 +133,9 @@ test_setup_ping(
|
||||||
{
|
{
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_reply(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, THIS_THREAD, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -484,6 +484,7 @@ test_invalid(
|
||||||
gbinder_servicemanager_remove_handlers(sm, &id, 0);
|
gbinder_servicemanager_remove_handlers(sm, &id, 0);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -513,7 +514,7 @@ test_basic(
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -556,7 +557,7 @@ test_legacy(
|
||||||
|
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_servicemanager_exit();
|
gbinder_servicemanager_exit();
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -634,6 +635,7 @@ test_config(
|
||||||
gbinder_servicemanager_exit();
|
gbinder_servicemanager_exit();
|
||||||
gbinder_config_exit();
|
gbinder_config_exit();
|
||||||
gbinder_config_file = NULL;
|
gbinder_config_file = NULL;
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
|
|
||||||
remove(file);
|
remove(file);
|
||||||
remove(dir);
|
remove(dir);
|
||||||
|
@ -656,7 +658,7 @@ test_not_present(
|
||||||
GBinderServiceManager* sm;
|
GBinderServiceManager* sm;
|
||||||
|
|
||||||
/* This makes presence detection PING fail */
|
/* This makes presence detection PING fail */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
g_assert(sm);
|
g_assert(sm);
|
||||||
|
@ -664,6 +666,7 @@ test_not_present(
|
||||||
|
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -685,7 +688,7 @@ test_wait(
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
/* This makes presence detection PING fail */
|
/* This makes presence detection PING fail */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
g_assert(sm);
|
g_assert(sm);
|
||||||
|
@ -696,13 +699,13 @@ test_wait(
|
||||||
g_assert(id);
|
g_assert(id);
|
||||||
|
|
||||||
/* Make this wait fail */
|
/* Make this wait fail */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
g_assert(!gbinder_servicemanager_wait(sm, 0));
|
g_assert(!gbinder_servicemanager_wait(sm, 0));
|
||||||
|
|
||||||
/* This makes presence detection PING succeed */
|
/* This makes presence detection PING succeed */
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_reply(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, THIS_THREAD, 0, 0, NULL);
|
||||||
g_assert(gbinder_servicemanager_wait(sm, forever));
|
g_assert(gbinder_servicemanager_wait(sm, forever));
|
||||||
|
|
||||||
/* The next check succeeds too (without any I/O ) */
|
/* The next check succeeds too (without any I/O ) */
|
||||||
|
@ -714,7 +717,7 @@ test_wait(
|
||||||
gbinder_servicemanager_remove_handler(sm, id);
|
gbinder_servicemanager_remove_handler(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -734,7 +737,7 @@ test_wait_long(
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
/* This makes presence detection PING fail */
|
/* This makes presence detection PING fail */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
g_assert(sm);
|
g_assert(sm);
|
||||||
|
@ -745,10 +748,10 @@ test_wait_long(
|
||||||
g_assert(id);
|
g_assert(id);
|
||||||
|
|
||||||
/* Make the first presence detection PING fail and second succeed */
|
/* Make the first presence detection PING fail and second succeed */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
test_binder_br_reply_status_later(fd, -1);
|
test_binder_br_reply_status(fd, TX_THREAD, -1);
|
||||||
test_binder_br_transaction_complete_later(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_reply_later(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, TX_THREAD, 0, 0, NULL);
|
||||||
g_assert(gbinder_servicemanager_wait(sm, TEST_TIMEOUT_SEC * 1000));
|
g_assert(gbinder_servicemanager_wait(sm, TEST_TIMEOUT_SEC * 1000));
|
||||||
|
|
||||||
/* The next check succeeds too (without any I/O ) */
|
/* The next check succeeds too (without any I/O ) */
|
||||||
|
@ -760,7 +763,7 @@ test_wait_long(
|
||||||
gbinder_servicemanager_remove_handler(sm, id);
|
gbinder_servicemanager_remove_handler(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -781,7 +784,7 @@ test_wait_async(
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
/* This makes presence detection PING fail */
|
/* This makes presence detection PING fail */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
g_assert(sm);
|
g_assert(sm);
|
||||||
|
@ -794,9 +797,9 @@ test_wait_async(
|
||||||
g_assert(id[1]);
|
g_assert(id[1]);
|
||||||
|
|
||||||
/* Make the first presence detection PING fail and second succeed */
|
/* Make the first presence detection PING fail and second succeed */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
test_binder_br_transaction_complete_later(fd);
|
test_binder_br_transaction_complete(fd, TX_THREAD);
|
||||||
test_binder_br_reply_later(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, TX_THREAD, 0, 0, NULL);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* The listener must have been invoked exactly once */
|
/* The listener must have been invoked exactly once */
|
||||||
|
@ -804,7 +807,7 @@ test_wait_async(
|
||||||
gbinder_servicemanager_remove_all_handlers(sm, id);
|
gbinder_servicemanager_remove_all_handlers(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,9 +841,8 @@ test_death_run()
|
||||||
g_assert(id[1]);
|
g_assert(id[1]);
|
||||||
g_assert(id[2]);
|
g_assert(id[2]);
|
||||||
|
|
||||||
/* Generate death notification (need looper for that) */
|
/* Generate death notification */
|
||||||
test_binder_br_dead_binder(fd, 0);
|
test_binder_br_dead_binder(fd, ANY_THREAD, 0);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* No registrations must have occured */
|
/* No registrations must have occured */
|
||||||
|
@ -852,7 +854,6 @@ test_death_run()
|
||||||
gbinder_servicemanager_remove_all_handlers(sm, id);
|
gbinder_servicemanager_remove_all_handlers(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -880,11 +881,10 @@ test_reanimate_quit(
|
||||||
} else {
|
} else {
|
||||||
const int fd = gbinder_driver_fd(sm->client->remote->ipc->driver);
|
const int fd = gbinder_driver_fd(sm->client->remote->ipc->driver);
|
||||||
|
|
||||||
/* Disable looper and reanimate the object */
|
/* Reanimate the object */
|
||||||
GDEBUG("Reanimating...");
|
GDEBUG("Reanimating...");
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_DISABLE);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_reply(fd, THIS_THREAD, 0, 0, NULL);
|
||||||
test_binder_br_reply(fd, 0, 0, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,9 +917,8 @@ test_reanimate(
|
||||||
g_assert(id[1]);
|
g_assert(id[1]);
|
||||||
g_assert(id[2]);
|
g_assert(id[2]);
|
||||||
|
|
||||||
/* Generate death notification (need looper for that) */
|
/* Generate death notification */
|
||||||
test_binder_br_dead_binder(fd, 0);
|
test_binder_br_dead_binder(fd, ANY_THREAD, 0);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
/* No registrations must have occured */
|
/* No registrations must have occured */
|
||||||
|
@ -932,7 +931,6 @@ test_reanimate(
|
||||||
gbinder_servicemanager_remove_all_handlers(sm, id);
|
gbinder_servicemanager_remove_all_handlers(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -991,7 +989,7 @@ test_reuse(
|
||||||
gbinder_ipc_unref(binder_ipc);
|
gbinder_ipc_unref(binder_ipc);
|
||||||
gbinder_ipc_unref(vndbinder_ipc);
|
gbinder_ipc_unref(vndbinder_ipc);
|
||||||
gbinder_ipc_unref(hwbinder_ipc);
|
gbinder_ipc_unref(hwbinder_ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -1036,7 +1034,7 @@ test_notify_type(
|
||||||
gbinder_servicemanager_remove_handler(sm, id2);
|
gbinder_servicemanager_remove_handler(sm, id2);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -1094,7 +1092,7 @@ test_list(
|
||||||
|
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1158,7 +1156,7 @@ test_get(
|
||||||
|
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,7 +1204,7 @@ test_add(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,6 @@ typedef GBinderLocalObjectClass ServiceManagerAidlClass;
|
||||||
typedef struct service_manager_aidl {
|
typedef struct service_manager_aidl {
|
||||||
GBinderLocalObject parent;
|
GBinderLocalObject parent;
|
||||||
GHashTable* objects;
|
GHashTable* objects;
|
||||||
gboolean handle_on_looper_thread;
|
|
||||||
} ServiceManagerAidl;
|
} ServiceManagerAidl;
|
||||||
|
|
||||||
#define SERVICE_MANAGER_AIDL_TYPE (service_manager_aidl_get_type())
|
#define SERVICE_MANAGER_AIDL_TYPE (service_manager_aidl_get_type())
|
||||||
|
@ -185,18 +184,15 @@ servicemanager_aidl_handler(
|
||||||
static
|
static
|
||||||
ServiceManagerAidl*
|
ServiceManagerAidl*
|
||||||
servicemanager_aidl_new(
|
servicemanager_aidl_new(
|
||||||
const char* dev,
|
const char* dev)
|
||||||
gboolean handle_on_looper_thread)
|
|
||||||
{
|
{
|
||||||
ServiceManagerAidl* self = g_object_new(SERVICE_MANAGER_AIDL_TYPE, NULL);
|
ServiceManagerAidl* self = g_object_new(SERVICE_MANAGER_AIDL_TYPE, NULL);
|
||||||
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
self->handle_on_looper_thread = handle_on_looper_thread;
|
|
||||||
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
||||||
servicemanager_aidl_handler, self);
|
servicemanager_aidl_handler, self);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
||||||
gbinder_ipc_register_local_object(ipc, obj);
|
gbinder_ipc_register_local_object(ipc, obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
@ -211,41 +207,6 @@ servicemanager_aidl_free(
|
||||||
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(self));
|
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
GBINDER_LOCAL_TRANSACTION_SUPPORT
|
|
||||||
service_manager_aidl_can_handle_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
const char* iface,
|
|
||||||
guint code)
|
|
||||||
{
|
|
||||||
ServiceManagerAidl* self = SERVICE_MANAGER_AIDL(object);
|
|
||||||
|
|
||||||
if (self->handle_on_looper_thread && !g_strcmp0(SVCMGR_IFACE, iface)) {
|
|
||||||
return GBINDER_LOCAL_TRANSACTION_LOOPER;
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl_parent_class)->
|
|
||||||
can_handle_transaction(object, iface, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
GBinderLocalReply*
|
|
||||||
service_manager_aidl_handle_looper_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
GBinderRemoteRequest* req,
|
|
||||||
guint code,
|
|
||||||
guint flags,
|
|
||||||
int* status)
|
|
||||||
{
|
|
||||||
if (!g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE)) {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl_parent_class)->
|
|
||||||
handle_transaction(object, req, code, flags, status);
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl_parent_class)->
|
|
||||||
handle_looper_transaction(object, req, code, flags, status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
service_manager_aidl_finalize(
|
service_manager_aidl_finalize(
|
||||||
|
@ -271,14 +232,7 @@ void
|
||||||
service_manager_aidl_class_init(
|
service_manager_aidl_class_init(
|
||||||
ServiceManagerAidlClass* klass)
|
ServiceManagerAidlClass* klass)
|
||||||
{
|
{
|
||||||
GObjectClass* object = G_OBJECT_CLASS(klass);
|
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl_finalize;
|
||||||
GBinderLocalObjectClass* local_object = GBINDER_LOCAL_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
object->finalize = service_manager_aidl_finalize;
|
|
||||||
local_object->can_handle_transaction =
|
|
||||||
service_manager_aidl_can_handle_transaction;
|
|
||||||
local_object->handle_looper_transaction =
|
|
||||||
service_manager_aidl_handle_looper_transaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -329,9 +283,8 @@ void
|
||||||
test_get_run()
|
test_get_run()
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
ServiceManagerAidl* smsvc = servicemanager_aidl_new(other_dev, FALSE);
|
ServiceManagerAidl* smsvc = servicemanager_aidl_new(dev);
|
||||||
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
const char* name = "name";
|
const char* name = "name";
|
||||||
|
@ -340,7 +293,6 @@ test_get_run()
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
|
|
||||||
/* Query the object (it's not there yet) and wait for completion */
|
/* Query the object (it's not there yet) and wait for completion */
|
||||||
|
@ -369,7 +321,6 @@ test_get_run()
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -411,9 +362,8 @@ void
|
||||||
test_list_run()
|
test_list_run()
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
ServiceManagerAidl* smsvc = servicemanager_aidl_new(other_dev, FALSE);
|
ServiceManagerAidl* smsvc = servicemanager_aidl_new(dev);
|
||||||
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
const char* name = "name";
|
const char* name = "name";
|
||||||
|
@ -425,7 +375,6 @@ test_list_run()
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
|
|
||||||
/* Request the list and wait for completion */
|
/* Request the list and wait for completion */
|
||||||
|
@ -455,7 +404,6 @@ test_list_run()
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, test.loop);
|
test_binder_exit_wait(&test_opt, test.loop);
|
||||||
|
|
||||||
g_strfreev(test.list);
|
g_strfreev(test.list);
|
||||||
|
@ -490,9 +438,8 @@ void
|
||||||
test_notify_run()
|
test_notify_run()
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
ServiceManagerAidl* svc = servicemanager_aidl_new(other_dev, FALSE);
|
ServiceManagerAidl* svc = servicemanager_aidl_new(dev);
|
||||||
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
const char* name = "name";
|
const char* name = "name";
|
||||||
|
@ -502,7 +449,6 @@ test_notify_run()
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
gbinder_ipc_set_max_threads(ipc, 1);
|
gbinder_ipc_set_max_threads(ipc, 1);
|
||||||
|
|
||||||
|
@ -526,7 +472,6 @@ test_notify_run()
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -547,9 +492,8 @@ void
|
||||||
test_notify2_run()
|
test_notify2_run()
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
ServiceManagerAidl* smsvc = servicemanager_aidl_new(other_dev, TRUE);
|
ServiceManagerAidl* smsvc = servicemanager_aidl_new(dev);
|
||||||
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
GBinderLocalObject* obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
GBinderServiceManager* sm;
|
GBinderServiceManager* sm;
|
||||||
|
@ -560,7 +504,6 @@ test_notify2_run()
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
gbinder_ipc_set_max_threads(ipc, 1);
|
gbinder_ipc_set_max_threads(ipc, 1);
|
||||||
|
|
||||||
|
@ -593,7 +536,6 @@ test_notify2_run()
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ typedef GBinderLocalObjectClass ServiceManagerAidl2Class;
|
||||||
typedef struct service_manager_aidl2 {
|
typedef struct service_manager_aidl2 {
|
||||||
GBinderLocalObject parent;
|
GBinderLocalObject parent;
|
||||||
GHashTable* objects;
|
GHashTable* objects;
|
||||||
gboolean handle_on_looper_thread;
|
|
||||||
} ServiceManagerAidl2;
|
} ServiceManagerAidl2;
|
||||||
|
|
||||||
#define SERVICE_MANAGER_AIDL2_TYPE (service_manager_aidl2_get_type())
|
#define SERVICE_MANAGER_AIDL2_TYPE (service_manager_aidl2_get_type())
|
||||||
|
@ -170,59 +169,21 @@ servicemanager_aidl2_handler(
|
||||||
static
|
static
|
||||||
ServiceManagerAidl2*
|
ServiceManagerAidl2*
|
||||||
servicemanager_aidl2_new(
|
servicemanager_aidl2_new(
|
||||||
const char* dev,
|
const char* dev)
|
||||||
gboolean handle_on_looper_thread)
|
|
||||||
{
|
{
|
||||||
ServiceManagerAidl2* self = g_object_new(SERVICE_MANAGER_AIDL2_TYPE, NULL);
|
ServiceManagerAidl2* self = g_object_new(SERVICE_MANAGER_AIDL2_TYPE, NULL);
|
||||||
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
self->handle_on_looper_thread = handle_on_looper_thread;
|
|
||||||
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
||||||
servicemanager_aidl2_handler, self);
|
servicemanager_aidl2_handler, self);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
||||||
gbinder_ipc_register_local_object(ipc, obj);
|
gbinder_ipc_register_local_object(ipc, obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
GBINDER_LOCAL_TRANSACTION_SUPPORT
|
|
||||||
service_manager_aidl2_can_handle_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
const char* iface,
|
|
||||||
guint code)
|
|
||||||
{
|
|
||||||
ServiceManagerAidl2* self = SERVICE_MANAGER_AIDL2(object);
|
|
||||||
|
|
||||||
if (self->handle_on_looper_thread && !g_strcmp0(SVCMGR_IFACE, iface)) {
|
|
||||||
return GBINDER_LOCAL_TRANSACTION_LOOPER;
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl2_parent_class)->
|
|
||||||
can_handle_transaction(object, iface, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
GBinderLocalReply*
|
|
||||||
service_manager_aidl2_handle_looper_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
GBinderRemoteRequest* req,
|
|
||||||
guint code,
|
|
||||||
guint flags,
|
|
||||||
int* status)
|
|
||||||
{
|
|
||||||
if (!g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE)) {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl2_parent_class)->
|
|
||||||
handle_transaction(object, req, code, flags, status);
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl2_parent_class)->
|
|
||||||
handle_looper_transaction(object, req, code, flags, status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
service_manager_aidl2_finalize(
|
service_manager_aidl2_finalize(
|
||||||
|
@ -248,14 +209,7 @@ void
|
||||||
service_manager_aidl2_class_init(
|
service_manager_aidl2_class_init(
|
||||||
ServiceManagerAidl2Class* klass)
|
ServiceManagerAidl2Class* klass)
|
||||||
{
|
{
|
||||||
GObjectClass* object = G_OBJECT_CLASS(klass);
|
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl2_finalize;
|
||||||
GBinderLocalObjectClass* local_object = GBINDER_LOCAL_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
object->finalize = service_manager_aidl2_finalize;
|
|
||||||
local_object->can_handle_transaction =
|
|
||||||
service_manager_aidl2_can_handle_transaction;
|
|
||||||
local_object->handle_looper_transaction =
|
|
||||||
service_manager_aidl2_handle_looper_transaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -271,6 +225,7 @@ typedef struct test_context {
|
||||||
GBinderLocalObject* object;
|
GBinderLocalObject* object;
|
||||||
ServiceManagerAidl2* service;
|
ServiceManagerAidl2* service;
|
||||||
GBinderServiceManager* client;
|
GBinderServiceManager* client;
|
||||||
|
GMainLoop* loop;
|
||||||
int fd;
|
int fd;
|
||||||
} TestContext;
|
} TestContext;
|
||||||
|
|
||||||
|
@ -280,11 +235,6 @@ test_context_init(
|
||||||
TestContext* test)
|
TestContext* test)
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
/*
|
|
||||||
* Also set defaults so that both /dev/binder and /dev/binder-private
|
|
||||||
* use the same protocol.
|
|
||||||
*/
|
|
||||||
const char* config =
|
const char* config =
|
||||||
"[Protocol]\n"
|
"[Protocol]\n"
|
||||||
"Default = aidl2\n"
|
"Default = aidl2\n"
|
||||||
|
@ -308,13 +258,10 @@ test_context_init(
|
||||||
ipc = gbinder_ipc_new(dev, NULL);
|
ipc = gbinder_ipc_new(dev, NULL);
|
||||||
test->fd = gbinder_driver_fd(ipc->driver);
|
test->fd = gbinder_driver_fd(ipc->driver);
|
||||||
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* Set up binder simulator */
|
|
||||||
test_binder_register_object(test->fd, test->object, AUTO_HANDLE);
|
test_binder_register_object(test->fd, test->object, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(test->fd, TRUE);
|
test->service = servicemanager_aidl2_new(dev);
|
||||||
|
|
||||||
test->service = servicemanager_aidl2_new(other_dev, TRUE);
|
|
||||||
test->client = gbinder_servicemanager_new(dev);
|
test->client = gbinder_servicemanager_new(dev);
|
||||||
|
test->loop = g_main_loop_new(NULL, FALSE);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,22 +270,47 @@ void
|
||||||
test_context_deinit(
|
test_context_deinit(
|
||||||
TestContext* test)
|
TestContext* test)
|
||||||
{
|
{
|
||||||
test_binder_unregister_objects(test->fd);
|
test_binder_br_dead_binder_obj(test->fd, test->object);
|
||||||
gbinder_local_object_unref(test->object);
|
gbinder_local_object_unref(test->object);
|
||||||
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
|
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
|
||||||
gbinder_servicemanager_unref(test->client);
|
gbinder_servicemanager_unref(test->client);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, test->loop);
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
|
||||||
remove(test->config_file);
|
remove(test->config_file);
|
||||||
remove(test->config_dir);
|
remove(test->config_dir);
|
||||||
g_free(test->config_file);
|
g_free(test->config_file);
|
||||||
g_free(test->config_subdir);
|
g_free(test->config_subdir);
|
||||||
g_free(test->config_dir);
|
g_free(test->config_dir);
|
||||||
|
g_main_loop_unref(test->loop);
|
||||||
gbinder_config_dir = test->default_config_dir;
|
gbinder_config_dir = test->default_config_dir;
|
||||||
gbinder_config_file = test->default_config_file;
|
gbinder_config_file = test->default_config_file;
|
||||||
gbinder_config_exit();
|
gbinder_config_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_context_wait_ref_cb(
|
||||||
|
GBinderLocalObject* obj,
|
||||||
|
void* user_data)
|
||||||
|
{
|
||||||
|
GDEBUG("strong_refs %d", obj->strong_refs);
|
||||||
|
if (obj->strong_refs > 0) {
|
||||||
|
test_quit_later((GMainLoop*)user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_context_wait_ref(
|
||||||
|
TestContext* test)
|
||||||
|
{
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
gulong id = gbinder_local_object_add_strong_refs_changed_handler
|
||||||
|
(test->object, test_context_wait_ref_cb, test->loop);
|
||||||
|
|
||||||
|
test_run(&test_opt, test->loop);
|
||||||
|
gbinder_local_object_remove_handler(test->object, id);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* get
|
* get
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
@ -367,12 +339,16 @@ test_get_run()
|
||||||
g_assert_cmpuint(g_hash_table_size(test.service->objects), == ,1);
|
g_assert_cmpuint(g_hash_table_size(test.service->objects), == ,1);
|
||||||
g_assert(g_hash_table_contains(test.service->objects, name));
|
g_assert(g_hash_table_contains(test.service->objects, name));
|
||||||
|
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
test_context_wait_ref(&test);
|
||||||
|
|
||||||
/* Query the object (this time it must be there) */
|
/* Query the object (this time it must be there) */
|
||||||
GDEBUG("Querying '%s' again", name);
|
GDEBUG("Querying '%s' again", name);
|
||||||
g_assert(gbinder_servicemanager_get_service_sync(test.client, name,
|
g_assert(gbinder_servicemanager_get_service_sync(test.client, name,
|
||||||
&status));
|
&status));
|
||||||
g_assert_cmpint(status, == ,GBINDER_STATUS_OK);
|
g_assert_cmpint(status, == ,GBINDER_STATUS_OK);
|
||||||
|
|
||||||
|
GDEBUG("Done");
|
||||||
test_context_deinit(&test);
|
test_context_deinit(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,6 +386,9 @@ test_list_run()
|
||||||
g_assert_cmpint(gbinder_servicemanager_add_service_sync(test.client,
|
g_assert_cmpint(gbinder_servicemanager_add_service_sync(test.client,
|
||||||
name, test.object), == ,GBINDER_STATUS_OK);
|
name, test.object), == ,GBINDER_STATUS_OK);
|
||||||
|
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
test_context_wait_ref(&test);
|
||||||
|
|
||||||
/* Request the list again */
|
/* Request the list again */
|
||||||
list = gbinder_servicemanager_list_sync(test.client);
|
list = gbinder_servicemanager_list_sync(test.client);
|
||||||
|
|
||||||
|
@ -418,6 +397,7 @@ test_list_run()
|
||||||
g_assert_cmpstr(list[0], == ,name);
|
g_assert_cmpstr(list[0], == ,name);
|
||||||
g_strfreev(list);
|
g_strfreev(list);
|
||||||
|
|
||||||
|
GDEBUG("Done");
|
||||||
test_context_deinit(&test);
|
test_context_deinit(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ typedef GBinderLocalObjectClass ServiceManagerAidl3Class;
|
||||||
typedef struct service_manager_aidl3 {
|
typedef struct service_manager_aidl3 {
|
||||||
GBinderLocalObject parent;
|
GBinderLocalObject parent;
|
||||||
GHashTable* objects;
|
GHashTable* objects;
|
||||||
gboolean handle_on_looper_thread;
|
|
||||||
} ServiceManagerAidl3;
|
} ServiceManagerAidl3;
|
||||||
|
|
||||||
#define SERVICE_MANAGER_AIDL3_TYPE (service_manager_aidl3_get_type())
|
#define SERVICE_MANAGER_AIDL3_TYPE (service_manager_aidl3_get_type())
|
||||||
|
@ -179,59 +178,21 @@ servicemanager_aidl3_handler(
|
||||||
static
|
static
|
||||||
ServiceManagerAidl3*
|
ServiceManagerAidl3*
|
||||||
servicemanager_aidl3_new(
|
servicemanager_aidl3_new(
|
||||||
const char* dev,
|
const char* dev)
|
||||||
gboolean handle_on_looper_thread)
|
|
||||||
{
|
{
|
||||||
ServiceManagerAidl3* self = g_object_new(SERVICE_MANAGER_AIDL3_TYPE, NULL);
|
ServiceManagerAidl3* self = g_object_new(SERVICE_MANAGER_AIDL3_TYPE, NULL);
|
||||||
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
self->handle_on_looper_thread = handle_on_looper_thread;
|
|
||||||
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
||||||
servicemanager_aidl3_handler, self);
|
servicemanager_aidl3_handler, self);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
||||||
gbinder_ipc_register_local_object(ipc, obj);
|
gbinder_ipc_register_local_object(ipc, obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
GBINDER_LOCAL_TRANSACTION_SUPPORT
|
|
||||||
service_manager_aidl3_can_handle_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
const char* iface,
|
|
||||||
guint code)
|
|
||||||
{
|
|
||||||
ServiceManagerAidl3* self = SERVICE_MANAGER_AIDL3(object);
|
|
||||||
|
|
||||||
if (self->handle_on_looper_thread && !g_strcmp0(SVCMGR_IFACE, iface)) {
|
|
||||||
return GBINDER_LOCAL_TRANSACTION_LOOPER;
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl3_parent_class)->
|
|
||||||
can_handle_transaction(object, iface, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
GBinderLocalReply*
|
|
||||||
service_manager_aidl3_handle_looper_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
GBinderRemoteRequest* req,
|
|
||||||
guint code,
|
|
||||||
guint flags,
|
|
||||||
int* status)
|
|
||||||
{
|
|
||||||
if (!g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE)) {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl3_parent_class)->
|
|
||||||
handle_transaction(object, req, code, flags, status);
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl3_parent_class)->
|
|
||||||
handle_looper_transaction(object, req, code, flags, status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
service_manager_aidl3_finalize(
|
service_manager_aidl3_finalize(
|
||||||
|
@ -257,14 +218,7 @@ void
|
||||||
service_manager_aidl3_class_init(
|
service_manager_aidl3_class_init(
|
||||||
ServiceManagerAidl3Class* klass)
|
ServiceManagerAidl3Class* klass)
|
||||||
{
|
{
|
||||||
GObjectClass* object = G_OBJECT_CLASS(klass);
|
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl3_finalize;
|
||||||
GBinderLocalObjectClass* local_object = GBINDER_LOCAL_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
object->finalize = service_manager_aidl3_finalize;
|
|
||||||
local_object->can_handle_transaction =
|
|
||||||
service_manager_aidl3_can_handle_transaction;
|
|
||||||
local_object->handle_looper_transaction =
|
|
||||||
service_manager_aidl3_handle_looper_transaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -280,6 +234,7 @@ typedef struct test_context {
|
||||||
GBinderLocalObject* object;
|
GBinderLocalObject* object;
|
||||||
ServiceManagerAidl3* service;
|
ServiceManagerAidl3* service;
|
||||||
GBinderServiceManager* client;
|
GBinderServiceManager* client;
|
||||||
|
GMainLoop* loop;
|
||||||
int fd;
|
int fd;
|
||||||
} TestContext;
|
} TestContext;
|
||||||
|
|
||||||
|
@ -289,11 +244,6 @@ test_context_init(
|
||||||
TestContext* test)
|
TestContext* test)
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
/*
|
|
||||||
* Also set defaults so that both /dev/binder and /dev/binder-private
|
|
||||||
* use the same protocol.
|
|
||||||
*/
|
|
||||||
const char* config =
|
const char* config =
|
||||||
"[Protocol]\n"
|
"[Protocol]\n"
|
||||||
"Default = aidl3\n"
|
"Default = aidl3\n"
|
||||||
|
@ -317,13 +267,10 @@ test_context_init(
|
||||||
ipc = gbinder_ipc_new(dev, NULL);
|
ipc = gbinder_ipc_new(dev, NULL);
|
||||||
test->fd = gbinder_driver_fd(ipc->driver);
|
test->fd = gbinder_driver_fd(ipc->driver);
|
||||||
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* Set up binder simulator */
|
|
||||||
test_binder_register_object(test->fd, test->object, AUTO_HANDLE);
|
test_binder_register_object(test->fd, test->object, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(test->fd, TRUE);
|
test->service = servicemanager_aidl3_new(dev);
|
||||||
|
|
||||||
test->service = servicemanager_aidl3_new(other_dev, TRUE);
|
|
||||||
test->client = gbinder_servicemanager_new(dev);
|
test->client = gbinder_servicemanager_new(dev);
|
||||||
|
test->loop = g_main_loop_new(NULL, FALSE);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,22 +279,47 @@ void
|
||||||
test_context_deinit(
|
test_context_deinit(
|
||||||
TestContext* test)
|
TestContext* test)
|
||||||
{
|
{
|
||||||
test_binder_unregister_objects(test->fd);
|
test_binder_br_dead_binder_obj(test->fd, test->object);
|
||||||
gbinder_local_object_unref(test->object);
|
gbinder_local_object_unref(test->object);
|
||||||
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
|
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
|
||||||
gbinder_servicemanager_unref(test->client);
|
gbinder_servicemanager_unref(test->client);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, test->loop);
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
|
||||||
remove(test->config_file);
|
remove(test->config_file);
|
||||||
remove(test->config_dir);
|
remove(test->config_dir);
|
||||||
g_free(test->config_file);
|
g_free(test->config_file);
|
||||||
g_free(test->config_subdir);
|
g_free(test->config_subdir);
|
||||||
g_free(test->config_dir);
|
g_free(test->config_dir);
|
||||||
|
g_main_loop_unref(test->loop);
|
||||||
gbinder_config_dir = test->default_config_dir;
|
gbinder_config_dir = test->default_config_dir;
|
||||||
gbinder_config_file = test->default_config_file;
|
gbinder_config_file = test->default_config_file;
|
||||||
gbinder_config_exit();
|
gbinder_config_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_context_wait_ref_cb(
|
||||||
|
GBinderLocalObject* obj,
|
||||||
|
void* user_data)
|
||||||
|
{
|
||||||
|
GDEBUG("strong_refs %d", obj->strong_refs);
|
||||||
|
if (obj->strong_refs > 0) {
|
||||||
|
test_quit_later((GMainLoop*)user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_context_wait_ref(
|
||||||
|
TestContext* test)
|
||||||
|
{
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
gulong id = gbinder_local_object_add_strong_refs_changed_handler
|
||||||
|
(test->object, test_context_wait_ref_cb, test->loop);
|
||||||
|
|
||||||
|
test_run(&test_opt, test->loop);
|
||||||
|
gbinder_local_object_remove_handler(test->object, id);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* get
|
* get
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
@ -376,12 +348,16 @@ test_get_run()
|
||||||
g_assert_cmpuint(g_hash_table_size(test.service->objects), == ,1);
|
g_assert_cmpuint(g_hash_table_size(test.service->objects), == ,1);
|
||||||
g_assert(g_hash_table_contains(test.service->objects, name));
|
g_assert(g_hash_table_contains(test.service->objects, name));
|
||||||
|
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
test_context_wait_ref(&test);
|
||||||
|
|
||||||
/* Query the object (this time it must be there) */
|
/* Query the object (this time it must be there) */
|
||||||
GDEBUG("Querying '%s' again", name);
|
GDEBUG("Querying '%s' again", name);
|
||||||
g_assert(gbinder_servicemanager_get_service_sync(test.client, name,
|
g_assert(gbinder_servicemanager_get_service_sync(test.client, name,
|
||||||
&status));
|
&status));
|
||||||
g_assert_cmpint(status, == ,GBINDER_STATUS_OK);
|
g_assert_cmpint(status, == ,GBINDER_STATUS_OK);
|
||||||
|
|
||||||
|
GDEBUG("Done");
|
||||||
test_context_deinit(&test);
|
test_context_deinit(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,6 +395,9 @@ test_list_run()
|
||||||
g_assert_cmpint(gbinder_servicemanager_add_service_sync(test.client,
|
g_assert_cmpint(gbinder_servicemanager_add_service_sync(test.client,
|
||||||
name, test.object), == ,GBINDER_STATUS_OK);
|
name, test.object), == ,GBINDER_STATUS_OK);
|
||||||
|
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
test_context_wait_ref(&test);
|
||||||
|
|
||||||
/* Request the list again */
|
/* Request the list again */
|
||||||
list = gbinder_servicemanager_list_sync(test.client);
|
list = gbinder_servicemanager_list_sync(test.client);
|
||||||
|
|
||||||
|
@ -427,6 +406,7 @@ test_list_run()
|
||||||
g_assert_cmpstr(list[0], == ,name);
|
g_assert_cmpstr(list[0], == ,name);
|
||||||
g_strfreev(list);
|
g_strfreev(list);
|
||||||
|
|
||||||
|
GDEBUG("Done");
|
||||||
test_context_deinit(&test);
|
test_context_deinit(&test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2022 Jolla Ltd.
|
* Copyright (C) 2020-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
|
* Copyright (C) 2023 Slava Monich <slava@monich.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of BSD license as follows:
|
* You may use this file under the terms of BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -78,7 +79,6 @@ typedef GBinderLocalObjectClass ServiceManagerAidl4Class;
|
||||||
typedef struct service_manager_aidl4 {
|
typedef struct service_manager_aidl4 {
|
||||||
GBinderLocalObject parent;
|
GBinderLocalObject parent;
|
||||||
GHashTable* objects;
|
GHashTable* objects;
|
||||||
gboolean handle_on_looper_thread;
|
|
||||||
} ServiceManagerAidl4;
|
} ServiceManagerAidl4;
|
||||||
|
|
||||||
#define SERVICE_MANAGER_AIDL4_TYPE (service_manager_aidl4_get_type())
|
#define SERVICE_MANAGER_AIDL4_TYPE (service_manager_aidl4_get_type())
|
||||||
|
@ -87,19 +87,6 @@ typedef struct service_manager_aidl4 {
|
||||||
G_DEFINE_TYPE(ServiceManagerAidl4, service_manager_aidl4, \
|
G_DEFINE_TYPE(ServiceManagerAidl4, service_manager_aidl4, \
|
||||||
GBINDER_TYPE_LOCAL_OBJECT)
|
GBINDER_TYPE_LOCAL_OBJECT)
|
||||||
|
|
||||||
/* This should be eventually handled at lower level. */
|
|
||||||
typedef struct category {
|
|
||||||
/*
|
|
||||||
* This is the version of the wire protocol associated with the host
|
|
||||||
* process of a particular binder. As the wire protocol changes, if
|
|
||||||
* sending a transaction to a binder with an old version, the Parcel
|
|
||||||
* class must write parcels according to the version documented here.
|
|
||||||
*/
|
|
||||||
gint8 version;
|
|
||||||
gint8 reserved[2];
|
|
||||||
gint8 level; /* bitmask of Stability::Level */
|
|
||||||
} Category;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
GBinderLocalReply*
|
GBinderLocalReply*
|
||||||
servicemanager_aidl4_handler(
|
servicemanager_aidl4_handler(
|
||||||
|
@ -116,7 +103,6 @@ servicemanager_aidl4_handler(
|
||||||
GBinderRemoteObject* remote_obj;
|
GBinderRemoteObject* remote_obj;
|
||||||
guint32 allow_isolated, dumpsys_priority;
|
guint32 allow_isolated, dumpsys_priority;
|
||||||
char* str;
|
char* str;
|
||||||
Category category;
|
|
||||||
|
|
||||||
g_assert(!flags);
|
g_assert(!flags);
|
||||||
GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
|
GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
|
||||||
|
@ -152,10 +138,9 @@ servicemanager_aidl4_handler(
|
||||||
gbinder_remote_request_init_reader(req, &reader);
|
gbinder_remote_request_init_reader(req, &reader);
|
||||||
str = gbinder_reader_read_string16(&reader);
|
str = gbinder_reader_read_string16(&reader);
|
||||||
remote_obj = gbinder_reader_read_object(&reader);
|
remote_obj = gbinder_reader_read_object(&reader);
|
||||||
gbinder_reader_read_uint32(&reader, (guint32*)&category);
|
|
||||||
if (str && remote_obj &&
|
if (str && remote_obj &&
|
||||||
category.level == GBINDER_STABILITY_SYSTEM &&
|
/* This field should be eventually handled at lower level. */
|
||||||
category.version == 1 &&
|
gbinder_reader_read_uint32(&reader, NULL) &&
|
||||||
gbinder_reader_read_uint32(&reader, &allow_isolated) &&
|
gbinder_reader_read_uint32(&reader, &allow_isolated) &&
|
||||||
gbinder_reader_read_uint32(&reader, &dumpsys_priority)) {
|
gbinder_reader_read_uint32(&reader, &dumpsys_priority)) {
|
||||||
GDEBUG("Adding '%s'", str);
|
GDEBUG("Adding '%s'", str);
|
||||||
|
@ -200,59 +185,21 @@ servicemanager_aidl4_handler(
|
||||||
static
|
static
|
||||||
ServiceManagerAidl4*
|
ServiceManagerAidl4*
|
||||||
servicemanager_aidl4_new(
|
servicemanager_aidl4_new(
|
||||||
const char* dev,
|
const char* dev)
|
||||||
gboolean handle_on_looper_thread)
|
|
||||||
{
|
{
|
||||||
ServiceManagerAidl4* self = g_object_new(SERVICE_MANAGER_AIDL4_TYPE, NULL);
|
ServiceManagerAidl4* self = g_object_new(SERVICE_MANAGER_AIDL4_TYPE, NULL);
|
||||||
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
self->handle_on_looper_thread = handle_on_looper_thread;
|
|
||||||
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
|
||||||
servicemanager_aidl4_handler, self);
|
servicemanager_aidl4_handler, self);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
test_binder_register_object(fd, obj, SVCMGR_HANDLE);
|
||||||
gbinder_ipc_register_local_object(ipc, obj);
|
gbinder_ipc_register_local_object(ipc, obj);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
GBINDER_LOCAL_TRANSACTION_SUPPORT
|
|
||||||
service_manager_aidl4_can_handle_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
const char* iface,
|
|
||||||
guint code)
|
|
||||||
{
|
|
||||||
ServiceManagerAidl4* self = SERVICE_MANAGER_AIDL4(object);
|
|
||||||
|
|
||||||
if (self->handle_on_looper_thread && !g_strcmp0(SVCMGR_IFACE, iface)) {
|
|
||||||
return GBINDER_LOCAL_TRANSACTION_LOOPER;
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl4_parent_class)->
|
|
||||||
can_handle_transaction(object, iface, code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
GBinderLocalReply*
|
|
||||||
service_manager_aidl4_handle_looper_transaction(
|
|
||||||
GBinderLocalObject* object,
|
|
||||||
GBinderRemoteRequest* req,
|
|
||||||
guint code,
|
|
||||||
guint flags,
|
|
||||||
int* status)
|
|
||||||
{
|
|
||||||
if (!g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE)) {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl4_parent_class)->
|
|
||||||
handle_transaction(object, req, code, flags, status);
|
|
||||||
} else {
|
|
||||||
return GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl4_parent_class)->
|
|
||||||
handle_looper_transaction(object, req, code, flags, status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
service_manager_aidl4_finalize(
|
service_manager_aidl4_finalize(
|
||||||
|
@ -278,14 +225,7 @@ void
|
||||||
service_manager_aidl4_class_init(
|
service_manager_aidl4_class_init(
|
||||||
ServiceManagerAidl4Class* klass)
|
ServiceManagerAidl4Class* klass)
|
||||||
{
|
{
|
||||||
GObjectClass* object = G_OBJECT_CLASS(klass);
|
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl4_finalize;
|
||||||
GBinderLocalObjectClass* local_object = GBINDER_LOCAL_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
object->finalize = service_manager_aidl4_finalize;
|
|
||||||
local_object->can_handle_transaction =
|
|
||||||
service_manager_aidl4_can_handle_transaction;
|
|
||||||
local_object->handle_looper_transaction =
|
|
||||||
service_manager_aidl4_handle_looper_transaction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -301,6 +241,7 @@ typedef struct test_context {
|
||||||
GBinderLocalObject* object;
|
GBinderLocalObject* object;
|
||||||
ServiceManagerAidl4* service;
|
ServiceManagerAidl4* service;
|
||||||
GBinderServiceManager* client;
|
GBinderServiceManager* client;
|
||||||
|
GMainLoop* loop;
|
||||||
int fd;
|
int fd;
|
||||||
} TestContext;
|
} TestContext;
|
||||||
|
|
||||||
|
@ -310,11 +251,6 @@ test_context_init(
|
||||||
TestContext* test)
|
TestContext* test)
|
||||||
{
|
{
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
const char* other_dev = GBINDER_DEFAULT_BINDER "-private";
|
|
||||||
/*
|
|
||||||
* Also set defaults so that both /dev/binder and /dev/binder-private
|
|
||||||
* use the same protocol.
|
|
||||||
*/
|
|
||||||
const char* config =
|
const char* config =
|
||||||
"[Protocol]\n"
|
"[Protocol]\n"
|
||||||
"Default = aidl3\n"
|
"Default = aidl3\n"
|
||||||
|
@ -338,13 +274,10 @@ test_context_init(
|
||||||
ipc = gbinder_ipc_new(dev, NULL);
|
ipc = gbinder_ipc_new(dev, NULL);
|
||||||
test->fd = gbinder_driver_fd(ipc->driver);
|
test->fd = gbinder_driver_fd(ipc->driver);
|
||||||
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
test->object = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* Set up binder simulator */
|
|
||||||
test_binder_register_object(test->fd, test->object, AUTO_HANDLE);
|
test_binder_register_object(test->fd, test->object, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(test->fd, TRUE);
|
test->service = servicemanager_aidl4_new(dev);
|
||||||
|
|
||||||
test->service = servicemanager_aidl4_new(other_dev, TRUE);
|
|
||||||
test->client = gbinder_servicemanager_new(dev);
|
test->client = gbinder_servicemanager_new(dev);
|
||||||
|
test->loop = g_main_loop_new(NULL, FALSE);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,18 +290,43 @@ test_context_deinit(
|
||||||
gbinder_local_object_unref(test->object);
|
gbinder_local_object_unref(test->object);
|
||||||
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
|
gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
|
||||||
gbinder_servicemanager_unref(test->client);
|
gbinder_servicemanager_unref(test->client);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, test->loop);
|
||||||
test_binder_exit_wait(&test_opt, NULL);
|
|
||||||
remove(test->config_file);
|
remove(test->config_file);
|
||||||
remove(test->config_dir);
|
remove(test->config_dir);
|
||||||
g_free(test->config_file);
|
g_free(test->config_file);
|
||||||
g_free(test->config_subdir);
|
g_free(test->config_subdir);
|
||||||
g_free(test->config_dir);
|
g_free(test->config_dir);
|
||||||
|
g_main_loop_unref(test->loop);
|
||||||
gbinder_config_dir = test->default_config_dir;
|
gbinder_config_dir = test->default_config_dir;
|
||||||
gbinder_config_file = test->default_config_file;
|
gbinder_config_file = test->default_config_file;
|
||||||
gbinder_config_exit();
|
gbinder_config_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_context_wait_ref_cb(
|
||||||
|
GBinderLocalObject* obj,
|
||||||
|
void* user_data)
|
||||||
|
{
|
||||||
|
GDEBUG("strong_refs %d", obj->strong_refs);
|
||||||
|
if (obj->strong_refs > 0) {
|
||||||
|
test_quit_later((GMainLoop*)user_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_context_wait_ref(
|
||||||
|
TestContext* test)
|
||||||
|
{
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
gulong id = gbinder_local_object_add_strong_refs_changed_handler
|
||||||
|
(test->object, test_context_wait_ref_cb, test->loop);
|
||||||
|
|
||||||
|
test_run(&test_opt, test->loop);
|
||||||
|
gbinder_local_object_remove_handler(test->object, id);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* get
|
* get
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
|
@ -397,6 +355,9 @@ test_get_run()
|
||||||
g_assert_cmpuint(g_hash_table_size(test.service->objects), == ,1);
|
g_assert_cmpuint(g_hash_table_size(test.service->objects), == ,1);
|
||||||
g_assert(g_hash_table_contains(test.service->objects, name));
|
g_assert(g_hash_table_contains(test.service->objects, name));
|
||||||
|
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
test_context_wait_ref(&test);
|
||||||
|
|
||||||
/* Query the object (this time it must be there) */
|
/* Query the object (this time it must be there) */
|
||||||
GDEBUG("Querying '%s' again", name);
|
GDEBUG("Querying '%s' again", name);
|
||||||
g_assert(gbinder_servicemanager_get_service_sync(test.client, name,
|
g_assert(gbinder_servicemanager_get_service_sync(test.client, name,
|
||||||
|
@ -440,6 +401,9 @@ test_list_run()
|
||||||
g_assert_cmpint(gbinder_servicemanager_add_service_sync(test.client,
|
g_assert_cmpint(gbinder_servicemanager_add_service_sync(test.client,
|
||||||
name, test.object), == ,GBINDER_STATUS_OK);
|
name, test.object), == ,GBINDER_STATUS_OK);
|
||||||
|
|
||||||
|
/* Wait until the object gets referenced by servicemanager */
|
||||||
|
test_context_wait_ref(&test);
|
||||||
|
|
||||||
/* Request the list again */
|
/* Request the list again */
|
||||||
list = gbinder_servicemanager_list_sync(test.client);
|
list = gbinder_servicemanager_list_sync(test.client);
|
||||||
|
|
||||||
|
|
|
@ -43,15 +43,13 @@
|
||||||
#include <gutil_strv.h>
|
#include <gutil_strv.h>
|
||||||
|
|
||||||
static TestOpt test_opt;
|
static TestOpt test_opt;
|
||||||
#define MAIN_DEV GBINDER_DEFAULT_HWBINDER
|
#define DEV GBINDER_DEFAULT_HWBINDER
|
||||||
#define OTHER_DEV GBINDER_DEFAULT_HWBINDER "-private"
|
|
||||||
static const char TMP_DIR_TEMPLATE[] = "gbinder-test-svcmgr-hidl-XXXXXX";
|
static const char TMP_DIR_TEMPLATE[] = "gbinder-test-svcmgr-hidl-XXXXXX";
|
||||||
static const char DEFAULT_CONFIG_DATA[] =
|
static const char DEFAULT_CONFIG_DATA[] =
|
||||||
"[Protocol]\n"
|
"[Protocol]\n"
|
||||||
MAIN_DEV " = hidl\n"
|
DEV " = hidl\n"
|
||||||
OTHER_DEV " = hidl\n"
|
|
||||||
"[ServiceManager]\n"
|
"[ServiceManager]\n"
|
||||||
MAIN_DEV " = hidl\n";
|
DEV " = hidl\n";
|
||||||
|
|
||||||
typedef struct test_config {
|
typedef struct test_config {
|
||||||
char* dir;
|
char* dir;
|
||||||
|
@ -134,7 +132,6 @@ test_servicemanager_impl_new(
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
TestServiceManagerHidl* sm = test_servicemanager_hidl_new(ipc);
|
TestServiceManagerHidl* sm = test_servicemanager_hidl_new(ipc);
|
||||||
|
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
test_binder_register_object(fd, GBINDER_LOCAL_OBJECT(sm),
|
test_binder_register_object(fd, GBINDER_LOCAL_OBJECT(sm),
|
||||||
GBINDER_SERVICEMANAGER_HANDLE);
|
GBINDER_SERVICEMANAGER_HANDLE);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
@ -199,16 +196,14 @@ test_get_run()
|
||||||
const char* name = "android.hidl.base@1.0::IBase/test";
|
const char* name = "android.hidl.base@1.0::IBase/test";
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
ipc = gbinder_ipc_new(MAIN_DEV, NULL);
|
ipc = gbinder_ipc_new(DEV, NULL);
|
||||||
smsvc = test_servicemanager_impl_new(OTHER_DEV);
|
smsvc = test_servicemanager_impl_new(DEV);
|
||||||
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
fd = gbinder_driver_fd(ipc->driver);
|
fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
sm = gbinder_servicemanager_new(DEV);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
sm = gbinder_servicemanager_new(MAIN_DEV);
|
|
||||||
|
|
||||||
/* This one fails because of unexpected name format */
|
/* This one fails because of unexpected name format */
|
||||||
g_assert(!gbinder_servicemanager_get_service_sync(sm, "test", NULL));
|
g_assert(!gbinder_servicemanager_get_service_sync(sm, "test", NULL));
|
||||||
|
@ -233,13 +228,11 @@ test_get_run()
|
||||||
g_assert(gbinder_servicemanager_get_service(sm, name, test_get_cb, loop));
|
g_assert(gbinder_servicemanager_get_service(sm, name, test_get_cb, loop));
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
test_binder_unregister_objects(fd);
|
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
test_servicemanager_hidl_free(smsvc);
|
test_servicemanager_hidl_free(smsvc);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
|
@ -294,16 +287,14 @@ test_list_run()
|
||||||
test.loop = g_main_loop_new(NULL, FALSE);
|
test.loop = g_main_loop_new(NULL, FALSE);
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
ipc = gbinder_ipc_new(MAIN_DEV, NULL);
|
ipc = gbinder_ipc_new(DEV, NULL);
|
||||||
smsvc = test_servicemanager_impl_new(OTHER_DEV);
|
smsvc = test_servicemanager_impl_new(DEV);
|
||||||
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
fd = gbinder_driver_fd(ipc->driver);
|
fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
sm = gbinder_servicemanager_new(DEV);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
sm = gbinder_servicemanager_new(MAIN_DEV);
|
|
||||||
|
|
||||||
/* Request the list and wait for completion */
|
/* Request the list and wait for completion */
|
||||||
g_assert(gbinder_servicemanager_list(sm, test_list_cb, &test));
|
g_assert(gbinder_servicemanager_list(sm, test_list_cb, &test));
|
||||||
|
@ -326,13 +317,11 @@ test_list_run()
|
||||||
g_assert_cmpuint(gutil_strv_length(test.list), == ,1);
|
g_assert_cmpuint(gutil_strv_length(test.list), == ,1);
|
||||||
g_assert_cmpstr(test.list[0], == ,name);
|
g_assert_cmpstr(test.list[0], == ,name);
|
||||||
|
|
||||||
test_binder_unregister_objects(fd);
|
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
test_servicemanager_hidl_free(smsvc);
|
test_servicemanager_hidl_free(smsvc);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, test.loop);
|
test_binder_exit_wait(&test_opt, test.loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
|
|
||||||
|
@ -422,16 +411,14 @@ test_notify_run()
|
||||||
test.loop = g_main_loop_new(NULL, FALSE);
|
test.loop = g_main_loop_new(NULL, FALSE);
|
||||||
|
|
||||||
test_config_init(&config, NULL);
|
test_config_init(&config, NULL);
|
||||||
ipc = gbinder_ipc_new(MAIN_DEV, NULL);
|
ipc = gbinder_ipc_new(DEV, NULL);
|
||||||
test.smsvc = test_servicemanager_impl_new(OTHER_DEV);
|
test.smsvc = test_servicemanager_impl_new(DEV);
|
||||||
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
obj = gbinder_local_object_new(ipc, NULL, NULL, NULL);
|
||||||
fd = gbinder_driver_fd(ipc->driver);
|
fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
/* Set up binder simulator */
|
/* Set up binder simulator */
|
||||||
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
test_binder_register_object(fd, obj, AUTO_HANDLE);
|
||||||
test_binder_set_passthrough(fd, TRUE);
|
sm = gbinder_servicemanager_new(DEV);
|
||||||
test_binder_set_looper_enabled(fd, TEST_LOOPER_ENABLE);
|
|
||||||
sm = gbinder_servicemanager_new(MAIN_DEV);
|
|
||||||
|
|
||||||
/* This one fails because of invalid names */
|
/* This one fails because of invalid names */
|
||||||
g_assert(!gbinder_servicemanager_add_registration_handler(sm, NULL,
|
g_assert(!gbinder_servicemanager_add_registration_handler(sm, NULL,
|
||||||
|
@ -455,13 +442,11 @@ test_notify_run()
|
||||||
test_run(&test_opt, test.loop);
|
test_run(&test_opt, test.loop);
|
||||||
gbinder_servicemanager_remove_handler(sm, id);
|
gbinder_servicemanager_remove_handler(sm, id);
|
||||||
|
|
||||||
test_binder_unregister_objects(fd);
|
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
test_servicemanager_hidl_free(test.smsvc);
|
test_servicemanager_hidl_free(test.smsvc);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, test.loop);
|
test_binder_exit_wait(&test_opt, test.loop);
|
||||||
test_config_deinit(&config);
|
test_config_deinit(&config);
|
||||||
g_main_loop_unref(test.loop);
|
g_main_loop_unref(test.loop);
|
||||||
|
|
|
@ -62,9 +62,9 @@ test_setup_ping(
|
||||||
{
|
{
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_reply(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, THIS_THREAD, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -145,7 +145,7 @@ test_servicemanager_add_service(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
test_binder_br_dead_binder(gbinder_driver_fd(obj->ipc->driver),
|
test_binder_br_dead_binder(gbinder_driver_fd(obj->ipc->driver),
|
||||||
GBINDER_SERVICEMANAGER_HANDLE);
|
ANY_THREAD, GBINDER_SERVICEMANAGER_HANDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ test_basic(
|
||||||
gbinder_local_object_unref(obj);
|
gbinder_local_object_unref(obj);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,8 +345,7 @@ test_present(
|
||||||
g_assert_cmpstr(sn->name, == ,obj_name);
|
g_assert_cmpstr(sn->name, == ,obj_name);
|
||||||
|
|
||||||
/* Immediately generate death notification (need looper for that) */
|
/* Immediately generate death notification (need looper for that) */
|
||||||
test_binder_br_dead_binder(fd, GBINDER_SERVICEMANAGER_HANDLE);
|
test_binder_br_dead_binder(fd, ANY_THREAD, GBINDER_SERVICEMANAGER_HANDLE);
|
||||||
test_binder_set_looper_enabled(fd, TRUE);
|
|
||||||
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
|
@ -355,7 +354,6 @@ test_present(
|
||||||
gbinder_servicemanager_remove_handler(sm, id);
|
gbinder_servicemanager_remove_handler(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +395,7 @@ test_not_present(
|
||||||
gulong id;
|
gulong id;
|
||||||
|
|
||||||
/* This makes presence detection PING fail */
|
/* This makes presence detection PING fail */
|
||||||
test_binder_br_reply_status(fd, -1);
|
test_binder_br_reply_status(fd, THIS_THREAD, -1);
|
||||||
sm = gbinder_servicemanager_new(dev);
|
sm = gbinder_servicemanager_new(dev);
|
||||||
g_assert(!gbinder_servicemanager_is_present(sm));
|
g_assert(!gbinder_servicemanager_is_present(sm));
|
||||||
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
||||||
|
@ -408,8 +406,8 @@ test_not_present(
|
||||||
g_assert_cmpstr(sn->name, == ,obj_name);
|
g_assert_cmpstr(sn->name, == ,obj_name);
|
||||||
|
|
||||||
/* Make the next presence detection PING succeed */
|
/* Make the next presence detection PING succeed */
|
||||||
test_binder_br_transaction_complete_later(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_reply_later(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, THIS_THREAD, 0, 0, NULL);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
gbinder_servicename_unref(sn);
|
gbinder_servicename_unref(sn);
|
||||||
|
@ -417,7 +415,7 @@ test_not_present(
|
||||||
gbinder_servicemanager_remove_handler(sm, id);
|
gbinder_servicemanager_remove_handler(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +432,6 @@ test_retry(
|
||||||
const char* const ifaces[] = { "interface", NULL };
|
const char* const ifaces[] = { "interface", NULL };
|
||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
|
||||||
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
|
||||||
GBinderLocalObject* obj;
|
GBinderLocalObject* obj;
|
||||||
GBinderServiceManager* sm;
|
GBinderServiceManager* sm;
|
||||||
|
@ -450,8 +447,6 @@ test_retry(
|
||||||
g_assert(sn);
|
g_assert(sn);
|
||||||
g_assert_cmpstr(sn->name, == ,obj_name);
|
g_assert_cmpstr(sn->name, == ,obj_name);
|
||||||
|
|
||||||
/* Need looper for death notifications */
|
|
||||||
test_binder_set_looper_enabled(fd, TRUE);
|
|
||||||
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
|
@ -460,7 +455,7 @@ test_retry(
|
||||||
gbinder_servicemanager_remove_handler(sm, id);
|
gbinder_servicemanager_remove_handler(sm, id);
|
||||||
gbinder_servicemanager_unref(sm);
|
gbinder_servicemanager_unref(sm);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,9 +495,8 @@ test_cancel(
|
||||||
g_assert(sn);
|
g_assert(sn);
|
||||||
g_assert_cmpstr(sn->name, == ,obj_name);
|
g_assert_cmpstr(sn->name, == ,obj_name);
|
||||||
|
|
||||||
/* Immediately generate death notification (need looper for that) */
|
/* Immediately generate death notification */
|
||||||
test_binder_br_dead_binder(fd, GBINDER_SERVICEMANAGER_HANDLE);
|
test_binder_br_dead_binder(fd, ANY_THREAD, GBINDER_SERVICEMANAGER_HANDLE);
|
||||||
test_binder_set_looper_enabled(fd, TRUE);
|
|
||||||
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
id = gbinder_servicemanager_add_presence_handler(sm, test_quit, loop);
|
||||||
test_run(&test_opt, loop);
|
test_run(&test_opt, loop);
|
||||||
|
|
||||||
|
@ -519,7 +513,6 @@ test_cancel(
|
||||||
g_mutex_unlock(&test->mutex);
|
g_mutex_unlock(&test->mutex);
|
||||||
|
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
gbinder_ipc_exit();
|
|
||||||
test_binder_exit_wait(&test_opt, loop);
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,9 @@ test_setup_ping(
|
||||||
{
|
{
|
||||||
const int fd = gbinder_driver_fd(ipc->driver);
|
const int fd = gbinder_driver_fd(ipc->driver);
|
||||||
|
|
||||||
test_binder_br_noop(fd);
|
test_binder_br_noop(fd, THIS_THREAD);
|
||||||
test_binder_br_transaction_complete(fd);
|
test_binder_br_transaction_complete(fd, THIS_THREAD);
|
||||||
test_binder_br_reply(fd, 0, 0, NULL);
|
test_binder_br_reply(fd, THIS_THREAD, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -268,6 +268,7 @@ test_basic(
|
||||||
|
|
||||||
gbinder_servicemanager_unref(manager);
|
gbinder_servicemanager_unref(manager);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -352,6 +353,7 @@ test_notify1(
|
||||||
g_assert(!weakptr);
|
g_assert(!weakptr);
|
||||||
gbinder_servicemanager_unref(manager);
|
gbinder_servicemanager_unref(manager);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +432,7 @@ test_notify2(
|
||||||
g_assert(!weakptr);
|
g_assert(!weakptr);
|
||||||
gbinder_servicemanager_unref(manager);
|
gbinder_servicemanager_unref(manager);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,6 +481,7 @@ test_already_there(
|
||||||
g_assert(!weakptr);
|
g_assert(!weakptr);
|
||||||
gbinder_servicemanager_unref(manager);
|
gbinder_servicemanager_unref(manager);
|
||||||
gbinder_ipc_unref(ipc);
|
gbinder_ipc_unref(ipc);
|
||||||
|
test_binder_exit_wait(&test_opt, loop);
|
||||||
g_main_loop_unref(loop);
|
g_main_loop_unref(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2022 Jolla Ltd.
|
* Copyright (C) 2018-2022 Jolla Ltd.
|
||||||
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
|
||||||
|
* Copyright (C) 2023 Slava Monich <slava@monich.com>
|
||||||
*
|
*
|
||||||
* You may use this file under the terms of BSD license as follows:
|
* You may use this file under the terms of BSD license as follows:
|
||||||
*
|
*
|
||||||
|
@ -252,9 +253,7 @@ void
|
||||||
test_int8(
|
test_int8(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
const char encoded[] = {
|
const char encoded[] = { 0x80, 0x00, 0x00, 0x00 };
|
||||||
TEST_INT8_BYTES_4(0x80)
|
|
||||||
};
|
|
||||||
GBinderLocalRequest* req = test_local_request_new();
|
GBinderLocalRequest* req = test_local_request_new();
|
||||||
GBinderOutputData* data;
|
GBinderOutputData* data;
|
||||||
GBinderWriter writer;
|
GBinderWriter writer;
|
||||||
|
@ -279,9 +278,7 @@ void
|
||||||
test_int16(
|
test_int16(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
const char encoded[] = {
|
const char encoded[] = { TEST_INT16_BYTES(0x80ff), 0x00, 0x00 };
|
||||||
TEST_INT16_BYTES_4(0x80ff)
|
|
||||||
};
|
|
||||||
GBinderLocalRequest* req = test_local_request_new();
|
GBinderLocalRequest* req = test_local_request_new();
|
||||||
GBinderOutputData* data;
|
GBinderOutputData* data;
|
||||||
GBinderWriter writer;
|
GBinderWriter writer;
|
||||||
|
@ -417,8 +414,8 @@ test_bool(
|
||||||
{
|
{
|
||||||
const char encoded[] = {
|
const char encoded[] = {
|
||||||
TEST_INT8_BYTES_4(0),
|
TEST_INT8_BYTES_4(0),
|
||||||
TEST_INT8_BYTES_4(1),
|
0x01, 0x00, 0x00, 0x00,
|
||||||
TEST_INT8_BYTES_4(1)
|
0x01, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
GBinderLocalRequest* req = test_local_request_new();
|
GBinderLocalRequest* req = test_local_request_new();
|
||||||
GBinderOutputData* data;
|
GBinderOutputData* data;
|
||||||
|
|
Loading…
Reference in New Issue