Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ca0f1e5f7 | ||
|
|
a9d20563c9 | ||
|
|
26f20c8464 | ||
|
|
a327931f6c | ||
|
|
2860286ff1 | ||
|
|
a61056ce39 | ||
|
|
aa9c095dc4 | ||
|
|
d85982edcb | ||
|
|
a292ee46b8 | ||
|
|
4624e8064f | ||
|
|
e468b27e69 | ||
|
|
a5c0bd0c62 | ||
|
|
ad7701b5a9 | ||
|
|
0a69f00787 | ||
|
|
f6a0202804 | ||
|
|
44c5f392ce | ||
|
|
7d13daa426 | ||
|
|
ed6d3542b9 | ||
|
|
e947e4d315 | ||
|
|
e9faa50f77 | ||
|
|
3178681e7b |
2
AUTHORS
Normal file
2
AUTHORS
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Slava Monich <slava.monich@jolla.com>
|
||||||
|
Matti Lehtimäki <matti.lehtimaki@gmail.com>
|
||||||
2
Makefile
2
Makefile
@@ -24,7 +24,7 @@ all: debug release pkgconfig
|
|||||||
|
|
||||||
VERSION_MAJOR = 1
|
VERSION_MAJOR = 1
|
||||||
VERSION_MINOR = 0
|
VERSION_MINOR = 0
|
||||||
VERSION_RELEASE = 0
|
VERSION_RELEASE = 5
|
||||||
|
|
||||||
# Version for pkg-config
|
# Version for pkg-config
|
||||||
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
||||||
|
|||||||
32
debian/changelog
vendored
32
debian/changelog
vendored
@@ -1,3 +1,35 @@
|
|||||||
|
libgbinder (1.0.5) unstable; urgency=low
|
||||||
|
|
||||||
|
* Added double and float support
|
||||||
|
|
||||||
|
-- Slava Monich <slava.monich@jolla.com> Fri, 17 Aug 2018 00:01:27 +0300
|
||||||
|
|
||||||
|
libgbinder (1.0.4) unstable; urgency=low
|
||||||
|
|
||||||
|
* Handle transaction result on main thread
|
||||||
|
|
||||||
|
-- Slava Monich <slava.monich@jolla.com> Tue, 07 Aug 2018 11:19:29 +0300
|
||||||
|
|
||||||
|
libgbinder (1.0.3) unstable; urgency=low
|
||||||
|
|
||||||
|
* Added gbinder_local_request_append_bool()
|
||||||
|
* Added gbinder_local_reply_append_bool()
|
||||||
|
|
||||||
|
-- Slava Monich <slava.monich@jolla.com> Mon, 06 Aug 2018 19:15:29 +0300
|
||||||
|
|
||||||
|
libgbinder (1.0.2) unstable; urgency=low
|
||||||
|
|
||||||
|
* Added gbinder_remote_request_sender_pid()
|
||||||
|
* Added gbinder_remote_request_sender_euid()
|
||||||
|
|
||||||
|
-- Slava Monich <slava.monich@jolla.com> Wed, 25 Jul 2018 00:51:39 +0300
|
||||||
|
|
||||||
|
libgbinder (1.0.1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initialize the buffer passed to the driver
|
||||||
|
|
||||||
|
-- Slava Monich <slava.monich@jolla.com> Thu, 19 Jul 2018 01:05:36 +0300
|
||||||
|
|
||||||
libgbinder (1.0.0) unstable; urgency=low
|
libgbinder (1.0.0) unstable; urgency=low
|
||||||
|
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ gbinder_local_reply_cleanup(
|
|||||||
GDestroyNotify destroy,
|
GDestroyNotify destroy,
|
||||||
gpointer pointer);
|
gpointer pointer);
|
||||||
|
|
||||||
|
GBinderLocalReply*
|
||||||
|
gbinder_local_reply_append_bool(
|
||||||
|
GBinderLocalReply* reply,
|
||||||
|
gboolean value); /* since 1.0.3 */
|
||||||
|
|
||||||
GBinderLocalReply*
|
GBinderLocalReply*
|
||||||
gbinder_local_reply_append_int32(
|
gbinder_local_reply_append_int32(
|
||||||
GBinderLocalReply* reply,
|
GBinderLocalReply* reply,
|
||||||
@@ -66,6 +71,16 @@ gbinder_local_reply_append_int64(
|
|||||||
GBinderLocalReply* reply,
|
GBinderLocalReply* reply,
|
||||||
guint64 value);
|
guint64 value);
|
||||||
|
|
||||||
|
GBinderLocalReply*
|
||||||
|
gbinder_local_reply_append_float(
|
||||||
|
GBinderLocalReply* reply,
|
||||||
|
gfloat value);
|
||||||
|
|
||||||
|
GBinderLocalReply*
|
||||||
|
gbinder_local_reply_append_double(
|
||||||
|
GBinderLocalReply* reply,
|
||||||
|
gdouble value);
|
||||||
|
|
||||||
GBinderLocalReply*
|
GBinderLocalReply*
|
||||||
gbinder_local_reply_append_string8(
|
gbinder_local_reply_append_string8(
|
||||||
GBinderLocalReply* reply,
|
GBinderLocalReply* reply,
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ gbinder_local_request_cleanup(
|
|||||||
GDestroyNotify destroy,
|
GDestroyNotify destroy,
|
||||||
gpointer pointer);
|
gpointer pointer);
|
||||||
|
|
||||||
|
GBinderLocalRequest*
|
||||||
|
gbinder_local_request_append_bool(
|
||||||
|
GBinderLocalRequest* request,
|
||||||
|
gboolean value); /* since 1.0.3 */
|
||||||
|
|
||||||
GBinderLocalRequest*
|
GBinderLocalRequest*
|
||||||
gbinder_local_request_append_int32(
|
gbinder_local_request_append_int32(
|
||||||
GBinderLocalRequest* request,
|
GBinderLocalRequest* request,
|
||||||
@@ -66,6 +71,16 @@ gbinder_local_request_append_int64(
|
|||||||
GBinderLocalRequest* request,
|
GBinderLocalRequest* request,
|
||||||
guint64 value);
|
guint64 value);
|
||||||
|
|
||||||
|
GBinderLocalRequest*
|
||||||
|
gbinder_local_request_append_float(
|
||||||
|
GBinderLocalRequest* request,
|
||||||
|
gfloat value);
|
||||||
|
|
||||||
|
GBinderLocalRequest*
|
||||||
|
gbinder_local_request_append_double(
|
||||||
|
GBinderLocalRequest* request,
|
||||||
|
gdouble value);
|
||||||
|
|
||||||
GBinderLocalRequest*
|
GBinderLocalRequest*
|
||||||
gbinder_local_request_append_string8(
|
gbinder_local_request_append_string8(
|
||||||
GBinderLocalRequest* request,
|
GBinderLocalRequest* request,
|
||||||
|
|||||||
@@ -85,6 +85,16 @@ gbinder_reader_read_uint64(
|
|||||||
GBinderReader* reader,
|
GBinderReader* reader,
|
||||||
guint64* value);
|
guint64* value);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gbinder_reader_read_float(
|
||||||
|
GBinderReader* reader,
|
||||||
|
gfloat* value);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gbinder_reader_read_double(
|
||||||
|
GBinderReader* reader,
|
||||||
|
gdouble* value);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gbinder_reader_read_nullable_object(
|
gbinder_reader_read_nullable_object(
|
||||||
GBinderReader* reader,
|
GBinderReader* reader,
|
||||||
|
|||||||
@@ -54,6 +54,14 @@ gbinder_remote_request_init_reader(
|
|||||||
GBinderRemoteRequest* req,
|
GBinderRemoteRequest* req,
|
||||||
GBinderReader* reader);
|
GBinderReader* reader);
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
gbinder_remote_request_sender_pid(
|
||||||
|
GBinderRemoteRequest* req); /* since 1.0.2 */
|
||||||
|
|
||||||
|
uid_t
|
||||||
|
gbinder_remote_request_sender_euid(
|
||||||
|
GBinderRemoteRequest* req); /* since 1.0.2 */
|
||||||
|
|
||||||
/* Convenience function to decode requests with just one data item */
|
/* Convenience function to decode requests with just one data item */
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ typedef struct gbinder_parent GBinderParent;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Each RPC call is identified by the interface name returned
|
* Each RPC call is identified by the interface name returned
|
||||||
* by gbinder_remote_request_interface() the the transaction code.
|
* by gbinder_remote_request_interface() the transaction code.
|
||||||
* Transaction code itself is not unique.
|
* Transaction code itself is not unique.
|
||||||
*
|
*
|
||||||
* The value return from GBinderLocalTransactFunc callbacl will be
|
* The value returned from GBinderLocalTransactFunc callback will
|
||||||
* ignored for one-way transactions. If GBINDER_TX_FLAG_ONEWAY is
|
* be ignored for one-way transactions. If GBINDER_TX_FLAG_ONEWAY
|
||||||
* passed in, the callback should return NULL and that won't be
|
* is passed in, the callback may and should return NULL and that
|
||||||
* interpreted as an error.
|
* won't be interpreted as an error.
|
||||||
*/
|
*/
|
||||||
typedef
|
typedef
|
||||||
GBinderLocalReply*
|
GBinderLocalReply*
|
||||||
|
|||||||
@@ -65,6 +65,16 @@ gbinder_writer_append_int64(
|
|||||||
GBinderWriter* writer,
|
GBinderWriter* writer,
|
||||||
guint64 value);
|
guint64 value);
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_append_float(
|
||||||
|
GBinderWriter* writer,
|
||||||
|
gfloat value);
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_append_double(
|
||||||
|
GBinderWriter* writer,
|
||||||
|
gdouble value);
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_writer_append_string16(
|
gbinder_writer_append_string16(
|
||||||
GBinderWriter* writer,
|
GBinderWriter* writer,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
Name: libgbinder
|
Name: libgbinder
|
||||||
Version: 1.0.0
|
Version: 1.0.5
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: Binder client library
|
Summary: Binder client library
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: https://git.merproject.org/mer-core/libgbinder
|
URL: https://github.com/mer-hybris/libgbinder
|
||||||
Source: %{name}-%{version}.tar.bz2
|
Source: %{name}-%{version}.tar.bz2
|
||||||
Requires: libglibutil >= 1.0.29
|
Requires: libglibutil >= 1.0.29
|
||||||
BuildRequires: pkgconfig(glib-2.0)
|
BuildRequires: pkgconfig(glib-2.0)
|
||||||
|
|||||||
@@ -311,10 +311,13 @@ gbinder_driver_read_init(
|
|||||||
rb->buf.ptr = (uintptr_t)(rb->data);
|
rb->buf.ptr = (uintptr_t)(rb->data);
|
||||||
rb->buf.size = sizeof(rb->data);
|
rb->buf.size = sizeof(rb->data);
|
||||||
rb->buf.consumed = 0;
|
rb->buf.consumed = 0;
|
||||||
#ifdef DEBUG
|
|
||||||
/* Otherwise valgrind complains about uninitialised data */
|
/*
|
||||||
|
* It shouldn't be necessary to zero-initialize the buffer but
|
||||||
|
* valgrind complains about access to uninitialised data if we
|
||||||
|
* don't do so. Oh well...
|
||||||
|
*/
|
||||||
memset(rb->data, 0, sizeof(rb->data));
|
memset(rb->data, 0, sizeof(rb->data));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -422,7 +425,7 @@ gbinder_driver_handle_transaction(
|
|||||||
const void* data)
|
const void* data)
|
||||||
{
|
{
|
||||||
GBinderLocalReply* reply = NULL;
|
GBinderLocalReply* reply = NULL;
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, self->protocol);
|
GBinderRemoteRequest* req;
|
||||||
GBinderIoTxData tx;
|
GBinderIoTxData tx;
|
||||||
GBinderLocalObject* obj;
|
GBinderLocalObject* obj;
|
||||||
const char* iface;
|
const char* iface;
|
||||||
@@ -430,6 +433,7 @@ gbinder_driver_handle_transaction(
|
|||||||
|
|
||||||
self->io->decode_transaction_data(data, &tx);
|
self->io->decode_transaction_data(data, &tx);
|
||||||
gbinder_driver_verbose_transaction_data("BR_TRANSACTION", &tx);
|
gbinder_driver_verbose_transaction_data("BR_TRANSACTION", &tx);
|
||||||
|
req = gbinder_remote_request_new(reg, self->protocol, tx.pid, tx.euid);
|
||||||
obj = gbinder_object_registry_get_local(reg, tx.target);
|
obj = gbinder_object_registry_get_local(reg, tx.target);
|
||||||
|
|
||||||
/* Transfer data ownership to the request */
|
/* Transfer data ownership to the request */
|
||||||
|
|||||||
@@ -278,6 +278,8 @@ GBINDER_IO_FN(decode_transaction_data)(
|
|||||||
tx->objects = NULL;
|
tx->objects = NULL;
|
||||||
tx->code = tr->code;
|
tx->code = tr->code;
|
||||||
tx->flags = 0;
|
tx->flags = 0;
|
||||||
|
tx->pid = tr->sender_pid;
|
||||||
|
tx->euid = tr->sender_euid;
|
||||||
tx->target = (void*)(uintptr_t)tr->target.ptr;
|
tx->target = (void*)(uintptr_t)tr->target.ptr;
|
||||||
tx->data = (void*)(uintptr_t)tr->data.ptr.buffer;
|
tx->data = (void*)(uintptr_t)tr->data.ptr.buffer;
|
||||||
if (tr->flags & TF_STATUS_CODE) {
|
if (tr->flags & TF_STATUS_CODE) {
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ typedef struct gbinder_io_tx_data {
|
|||||||
int status;
|
int status;
|
||||||
guint32 code;
|
guint32 code;
|
||||||
guint32 flags; /* GBINDER_TX_FLAG_xxx */
|
guint32 flags; /* GBINDER_TX_FLAG_xxx */
|
||||||
|
pid_t pid;
|
||||||
|
uid_t euid;
|
||||||
void* target;
|
void* target;
|
||||||
void* data;
|
void* data;
|
||||||
gsize size;
|
gsize size;
|
||||||
@@ -57,11 +59,11 @@ typedef struct gbinder_io_tx_data {
|
|||||||
#define GBINDER_IO_READ_BUFFER_SIZE (128)
|
#define GBINDER_IO_READ_BUFFER_SIZE (128)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are (at least) 2 versions of the binder ioctl API, implemented
|
* There are (at least) 2 versions of the binder ioctl API, implemented by
|
||||||
* 32-bit and 64-bit kernels. The ioctl codes, transaction commands - many
|
* 32-bit and 64-bit kernels. The ioctl codes, transaction commands - many
|
||||||
* of those are derived from the sizes of the structures being passed
|
* of those are derived from the sizes of the structures being passed
|
||||||
* between the driver and the user space client. All these differences
|
* between the driver and the user space client. All these differences
|
||||||
* are abstracted away by the GBinderIo interfaces.
|
* are abstracted away by GBinderIo interfaces.
|
||||||
*
|
*
|
||||||
* The API version is returned by BINDER_VERSION ioctl which itself doesn't
|
* The API version is returned by BINDER_VERSION ioctl which itself doesn't
|
||||||
* depend on the API version (it would be very strange if it did).
|
* depend on the API version (it would be very strange if it did).
|
||||||
|
|||||||
@@ -961,6 +961,7 @@ gbinder_ipc_tx_proc(
|
|||||||
GBinderIpcTxPriv* tx = data;
|
GBinderIpcTxPriv* tx = data;
|
||||||
GBinderIpc* self = GBINDER_IPC(object);
|
GBinderIpc* self = GBINDER_IPC(object);
|
||||||
GBinderIpcPriv* priv = self->priv;
|
GBinderIpcPriv* priv = self->priv;
|
||||||
|
GSource* source = g_idle_source_new();
|
||||||
|
|
||||||
if (!tx->pub.cancelled) {
|
if (!tx->pub.cancelled) {
|
||||||
tx->fn_exec(tx);
|
tx->fn_exec(tx);
|
||||||
@@ -969,8 +970,9 @@ gbinder_ipc_tx_proc(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The result is handled by the main thread */
|
/* The result is handled by the main thread */
|
||||||
g_main_context_invoke_full(priv->context, G_PRIORITY_DEFAULT,
|
g_source_set_callback(source, gbinder_ipc_tx_done, tx, gbinder_ipc_tx_free);
|
||||||
gbinder_ipc_tx_done, tx, gbinder_ipc_tx_free);
|
g_source_attach(source, priv->context);
|
||||||
|
g_source_unref(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
|||||||
@@ -160,6 +160,17 @@ gbinder_local_reply_init_writer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBinderLocalReply*
|
||||||
|
gbinder_local_reply_append_bool(
|
||||||
|
GBinderLocalReply* self,
|
||||||
|
gboolean value)
|
||||||
|
{
|
||||||
|
if (G_LIKELY(self)) {
|
||||||
|
gbinder_writer_data_append_bool(&self->data, value);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
GBinderLocalReply*
|
GBinderLocalReply*
|
||||||
gbinder_local_reply_append_int32(
|
gbinder_local_reply_append_int32(
|
||||||
GBinderLocalReply* self,
|
GBinderLocalReply* self,
|
||||||
@@ -182,6 +193,28 @@ gbinder_local_reply_append_int64(
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBinderLocalReply*
|
||||||
|
gbinder_local_reply_append_float(
|
||||||
|
GBinderLocalReply* self,
|
||||||
|
gfloat value)
|
||||||
|
{
|
||||||
|
if (G_LIKELY(self)) {
|
||||||
|
gbinder_writer_data_append_float(&self->data, value);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
GBinderLocalReply*
|
||||||
|
gbinder_local_reply_append_double(
|
||||||
|
GBinderLocalReply* self,
|
||||||
|
gdouble value)
|
||||||
|
{
|
||||||
|
if (G_LIKELY(self)) {
|
||||||
|
gbinder_writer_data_append_double(&self->data, value);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
GBinderLocalReply*
|
GBinderLocalReply*
|
||||||
gbinder_local_reply_append_string8(
|
gbinder_local_reply_append_string8(
|
||||||
GBinderLocalReply* self,
|
GBinderLocalReply* self,
|
||||||
|
|||||||
@@ -169,6 +169,17 @@ gbinder_local_request_init_writer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBinderLocalRequest*
|
||||||
|
gbinder_local_request_append_bool(
|
||||||
|
GBinderLocalRequest* self,
|
||||||
|
gboolean value)
|
||||||
|
{
|
||||||
|
if (G_LIKELY(self)) {
|
||||||
|
gbinder_writer_data_append_bool(&self->data, value);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
GBinderLocalRequest*
|
GBinderLocalRequest*
|
||||||
gbinder_local_request_append_int32(
|
gbinder_local_request_append_int32(
|
||||||
GBinderLocalRequest* self,
|
GBinderLocalRequest* self,
|
||||||
@@ -191,6 +202,28 @@ gbinder_local_request_append_int64(
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBinderLocalRequest*
|
||||||
|
gbinder_local_request_append_float(
|
||||||
|
GBinderLocalRequest* self,
|
||||||
|
gfloat value)
|
||||||
|
{
|
||||||
|
if (G_LIKELY(self)) {
|
||||||
|
gbinder_writer_data_append_float(&self->data, value);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
GBinderLocalRequest*
|
||||||
|
gbinder_local_request_append_double(
|
||||||
|
GBinderLocalRequest* self,
|
||||||
|
gdouble value)
|
||||||
|
{
|
||||||
|
if (G_LIKELY(self)) {
|
||||||
|
gbinder_writer_data_append_double(&self->data, value);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
GBinderLocalRequest*
|
GBinderLocalRequest*
|
||||||
gbinder_local_request_append_string8(
|
gbinder_local_request_append_string8(
|
||||||
GBinderLocalRequest* self,
|
GBinderLocalRequest* self,
|
||||||
|
|||||||
@@ -189,6 +189,46 @@ gbinder_reader_read_uint64(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gbinder_reader_read_float(
|
||||||
|
GBinderReader* reader,
|
||||||
|
gfloat* value)
|
||||||
|
{
|
||||||
|
GBinderReaderPriv* p = gbinder_reader_cast(reader);
|
||||||
|
|
||||||
|
if (gbinder_reader_can_read(p, sizeof(*value))) {
|
||||||
|
if (value) {
|
||||||
|
const gfloat* ptr = (void*)p->ptr;
|
||||||
|
|
||||||
|
*value = *ptr;
|
||||||
|
}
|
||||||
|
p->ptr += sizeof(*value);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gbinder_reader_read_double(
|
||||||
|
GBinderReader* reader,
|
||||||
|
gdouble* value)
|
||||||
|
{
|
||||||
|
GBinderReaderPriv* p = gbinder_reader_cast(reader);
|
||||||
|
|
||||||
|
if (gbinder_reader_can_read(p, sizeof(*value))) {
|
||||||
|
if (value) {
|
||||||
|
const gdouble* ptr = (void*)p->ptr;
|
||||||
|
|
||||||
|
*value = *ptr;
|
||||||
|
}
|
||||||
|
p->ptr += sizeof(*value);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gbinder_reader_read_nullable_object(
|
gbinder_reader_read_nullable_object(
|
||||||
GBinderReader* reader,
|
GBinderReader* reader,
|
||||||
|
|||||||
@@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
struct gbinder_remote_request {
|
struct gbinder_remote_request {
|
||||||
gint refcount;
|
gint refcount;
|
||||||
|
pid_t pid;
|
||||||
|
uid_t euid;
|
||||||
const GBinderRpcProtocol* protocol;
|
const GBinderRpcProtocol* protocol;
|
||||||
const char* iface;
|
const char* iface;
|
||||||
char* iface2;
|
char* iface2;
|
||||||
@@ -51,12 +53,16 @@ struct gbinder_remote_request {
|
|||||||
GBinderRemoteRequest*
|
GBinderRemoteRequest*
|
||||||
gbinder_remote_request_new(
|
gbinder_remote_request_new(
|
||||||
GBinderObjectRegistry* reg,
|
GBinderObjectRegistry* reg,
|
||||||
const GBinderRpcProtocol* protocol)
|
const GBinderRpcProtocol* protocol,
|
||||||
|
pid_t pid,
|
||||||
|
uid_t euid)
|
||||||
{
|
{
|
||||||
GBinderRemoteRequest* self = g_slice_new0(GBinderRemoteRequest);
|
GBinderRemoteRequest* self = g_slice_new0(GBinderRemoteRequest);
|
||||||
GBinderReaderData* data = &self->data;
|
GBinderReaderData* data = &self->data;
|
||||||
|
|
||||||
g_atomic_int_set(&self->refcount, 1);
|
g_atomic_int_set(&self->refcount, 1);
|
||||||
|
self->pid = pid;
|
||||||
|
self->euid = euid;
|
||||||
self->protocol = protocol;
|
self->protocol = protocol;
|
||||||
data->reg = gbinder_object_registry_ref(reg);
|
data->reg = gbinder_object_registry_ref(reg);
|
||||||
return self;
|
return self;
|
||||||
@@ -164,6 +170,20 @@ gbinder_remote_request_init_reader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
gbinder_remote_request_sender_pid(
|
||||||
|
GBinderRemoteRequest* self)
|
||||||
|
{
|
||||||
|
return G_LIKELY(self) ? self->pid : (uid_t)(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
uid_t
|
||||||
|
gbinder_remote_request_sender_euid(
|
||||||
|
GBinderRemoteRequest* self)
|
||||||
|
{
|
||||||
|
return G_LIKELY(self) ? self->euid : (uid_t)(-1);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gbinder_remote_request_read_int32(
|
gbinder_remote_request_read_int32(
|
||||||
GBinderRemoteRequest* self,
|
GBinderRemoteRequest* self,
|
||||||
|
|||||||
@@ -40,7 +40,9 @@
|
|||||||
GBinderRemoteRequest*
|
GBinderRemoteRequest*
|
||||||
gbinder_remote_request_new(
|
gbinder_remote_request_new(
|
||||||
GBinderObjectRegistry* reg,
|
GBinderObjectRegistry* reg,
|
||||||
const GBinderRpcProtocol* protocol);
|
const GBinderRpcProtocol* protocol,
|
||||||
|
pid_t pid,
|
||||||
|
uid_t euid);
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_remote_request_set_data(
|
gbinder_remote_request_set_data(
|
||||||
|
|||||||
@@ -96,6 +96,31 @@ gbinder_writer_init(
|
|||||||
gbinder_writer_cast(self)->data = data;
|
gbinder_writer_cast(self)->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_append_bool(
|
||||||
|
GBinderWriter* self,
|
||||||
|
gboolean value)
|
||||||
|
{
|
||||||
|
GBinderWriterData* data = gbinder_writer_data(self);
|
||||||
|
|
||||||
|
if (G_LIKELY(data)) {
|
||||||
|
gbinder_writer_data_append_bool(data, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_data_append_bool(
|
||||||
|
GBinderWriterData* data,
|
||||||
|
gboolean value)
|
||||||
|
{
|
||||||
|
guint8 padded[4];
|
||||||
|
|
||||||
|
/* Boolean values are padded to 4-byte boundary */
|
||||||
|
padded[0] = (value != FALSE);
|
||||||
|
padded[1] = padded[2] = padded[3] = 0xff;
|
||||||
|
g_byte_array_append(data->bytes, padded, sizeof(padded));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_writer_append_int32(
|
gbinder_writer_append_int32(
|
||||||
GBinderWriter* self,
|
GBinderWriter* self,
|
||||||
@@ -144,6 +169,54 @@ gbinder_writer_data_append_int64(
|
|||||||
*ptr = value;
|
*ptr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_append_float(
|
||||||
|
GBinderWriter* self,
|
||||||
|
gfloat value)
|
||||||
|
{
|
||||||
|
GBinderWriterData* data = gbinder_writer_data(self);
|
||||||
|
|
||||||
|
if (G_LIKELY(data)) {
|
||||||
|
gbinder_writer_data_append_float(data, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_data_append_float(
|
||||||
|
GBinderWriterData* data,
|
||||||
|
gfloat value)
|
||||||
|
{
|
||||||
|
gfloat* ptr;
|
||||||
|
|
||||||
|
g_byte_array_set_size(data->bytes, data->bytes->len + sizeof(*ptr));
|
||||||
|
ptr = (void*)(data->bytes->data + (data->bytes->len - sizeof(*ptr)));
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_append_double(
|
||||||
|
GBinderWriter* self,
|
||||||
|
gdouble value)
|
||||||
|
{
|
||||||
|
GBinderWriterData* data = gbinder_writer_data(self);
|
||||||
|
|
||||||
|
if (G_LIKELY(data)) {
|
||||||
|
gbinder_writer_data_append_double(data, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_data_append_double(
|
||||||
|
GBinderWriterData* data,
|
||||||
|
gdouble value)
|
||||||
|
{
|
||||||
|
gdouble* ptr;
|
||||||
|
|
||||||
|
g_byte_array_set_size(data->bytes, data->bytes->len + sizeof(*ptr));
|
||||||
|
ptr = (void*)(data->bytes->data + (data->bytes->len - sizeof(*ptr)));
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_writer_append_string8(
|
gbinder_writer_append_string8(
|
||||||
GBinderWriter* self,
|
GBinderWriter* self,
|
||||||
@@ -291,19 +364,6 @@ gbinder_writer_data_append_string16_len(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gbinder_writer_append_bool(
|
|
||||||
GBinderWriter* self,
|
|
||||||
gboolean value)
|
|
||||||
{
|
|
||||||
guint8 padded[4];
|
|
||||||
|
|
||||||
/* Boolean values are padded to 4-byte boundary */
|
|
||||||
padded[0] = (value != FALSE);
|
|
||||||
padded[1] = padded[2] = padded[3] = 0xff;
|
|
||||||
gbinder_writer_append_bytes(self, padded, sizeof(padded));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_writer_append_bytes(
|
gbinder_writer_append_bytes(
|
||||||
GBinderWriter* self,
|
GBinderWriter* self,
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ gbinder_writer_init(
|
|||||||
GBinderWriter* writer,
|
GBinderWriter* writer,
|
||||||
GBinderWriterData* data);
|
GBinderWriterData* data);
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_data_append_bool(
|
||||||
|
GBinderWriterData* data,
|
||||||
|
gboolean value);
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_writer_data_append_int32(
|
gbinder_writer_data_append_int32(
|
||||||
GBinderWriterData* data,
|
GBinderWriterData* data,
|
||||||
@@ -60,6 +65,16 @@ gbinder_writer_data_append_int64(
|
|||||||
GBinderWriterData* data,
|
GBinderWriterData* data,
|
||||||
guint64 value);
|
guint64 value);
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_data_append_float(
|
||||||
|
GBinderWriterData* data,
|
||||||
|
gfloat value);
|
||||||
|
|
||||||
|
void
|
||||||
|
gbinder_writer_data_append_double(
|
||||||
|
GBinderWriterData* data,
|
||||||
|
gdouble value);
|
||||||
|
|
||||||
void
|
void
|
||||||
gbinder_writer_data_append_string8(
|
gbinder_writer_data_append_string8(
|
||||||
GBinderWriterData* data,
|
GBinderWriterData* data,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
static GHashTable* test_fd_map = NULL;
|
static GHashTable* test_fd_map = NULL;
|
||||||
static GHashTable* test_node_map = NULL;
|
static GHashTable* test_node_map = NULL;
|
||||||
@@ -263,6 +264,8 @@ test_binder_fill_transaction_data(
|
|||||||
tr->handle = handle;
|
tr->handle = handle;
|
||||||
tr->code = code;
|
tr->code = code;
|
||||||
tr->data_size = bytes->len;
|
tr->data_size = bytes->len;
|
||||||
|
tr->sender_pid = getpid();
|
||||||
|
tr->sender_euid = geteuid();
|
||||||
/* This memory should eventually get deallocated with BC_FREE_BUFFER_64 */
|
/* This memory should eventually get deallocated with BC_FREE_BUFFER_64 */
|
||||||
tr->data_buffer = (gsize)g_memdup(bytes->data, bytes->len);
|
tr->data_buffer = (gsize)g_memdup(bytes->data, bytes->len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
|
|
||||||
#include <gutil_log.h>
|
#include <gutil_log.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
static TestOpt test_opt;
|
static TestOpt test_opt;
|
||||||
|
|
||||||
@@ -593,6 +595,8 @@ test_transact_incoming_proc(
|
|||||||
{
|
{
|
||||||
GVERBOSE_("\"%s\" %u", gbinder_remote_request_interface(req), code);
|
GVERBOSE_("\"%s\" %u", gbinder_remote_request_interface(req), code);
|
||||||
g_assert(!flags);
|
g_assert(!flags);
|
||||||
|
g_assert(gbinder_remote_request_sender_pid(req) == getpid());
|
||||||
|
g_assert(gbinder_remote_request_sender_euid(req) == geteuid());
|
||||||
g_assert(!g_strcmp0(gbinder_remote_request_interface(req), "test"));
|
g_assert(!g_strcmp0(gbinder_remote_request_interface(req), "test"));
|
||||||
g_assert(!g_strcmp0(gbinder_remote_request_read_string8(req), "message"));
|
g_assert(!g_strcmp0(gbinder_remote_request_read_string8(req), "message"));
|
||||||
g_assert(code == 1);
|
g_assert(code == 1);
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ test_get_descriptor(
|
|||||||
const char* dev = GBINDER_DEFAULT_HWBINDER;
|
const char* dev = GBINDER_DEFAULT_HWBINDER;
|
||||||
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new
|
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
|
||||||
(gbinder_ipc_object_registry(ipc), prot);
|
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
|
||||||
GBinderLocalObject* obj =
|
GBinderLocalObject* obj =
|
||||||
gbinder_ipc_new_local_object(ipc, NULL, NULL, NULL);
|
gbinder_ipc_new_local_object(ipc, NULL, NULL, NULL);
|
||||||
GBinderLocalReply* reply;
|
GBinderLocalReply* reply;
|
||||||
@@ -257,8 +257,8 @@ test_descriptor_chain(
|
|||||||
const char* dev = GBINDER_DEFAULT_HWBINDER;
|
const char* dev = GBINDER_DEFAULT_HWBINDER;
|
||||||
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new
|
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
|
||||||
(gbinder_ipc_object_registry(ipc), prot);
|
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
|
||||||
GBinderLocalObject* obj =
|
GBinderLocalObject* obj =
|
||||||
gbinder_ipc_new_local_object(ipc, NULL, NULL, NULL);
|
gbinder_ipc_new_local_object(ipc, NULL, NULL, NULL);
|
||||||
GBinderLocalReply* reply;
|
GBinderLocalReply* reply;
|
||||||
@@ -324,8 +324,8 @@ test_custom_iface(
|
|||||||
const char* dev = GBINDER_DEFAULT_HWBINDER;
|
const char* dev = GBINDER_DEFAULT_HWBINDER;
|
||||||
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new
|
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
|
||||||
(gbinder_ipc_object_registry(ipc), prot);
|
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
|
||||||
GBinderLocalObject* obj = gbinder_ipc_new_local_object(ipc, custom_iface,
|
GBinderLocalObject* obj = gbinder_ipc_new_local_object(ipc, custom_iface,
|
||||||
test_custom_iface_handler, &count);
|
test_custom_iface_handler, &count);
|
||||||
GBinderLocalReply* reply;
|
GBinderLocalReply* reply;
|
||||||
@@ -430,7 +430,7 @@ test_reply_status(
|
|||||||
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
const GBinderRpcProtocol* prot = gbinder_rpc_protocol_for_device(dev);
|
||||||
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
GBinderIpc* ipc = gbinder_ipc_new(dev);
|
||||||
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
|
GBinderObjectRegistry* reg = gbinder_ipc_object_registry(ipc);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot);
|
GBinderRemoteRequest* req = gbinder_remote_request_new(reg, prot, 0, 0);
|
||||||
GBinderLocalObject* obj = gbinder_ipc_new_local_object(ipc, custom_iface,
|
GBinderLocalObject* obj = gbinder_ipc_new_local_object(ipc, custom_iface,
|
||||||
test_reply_status_handler, &count);
|
test_reply_status_handler, &count);
|
||||||
|
|
||||||
|
|||||||
@@ -79,8 +79,11 @@ test_null(
|
|||||||
gbinder_local_reply_cleanup(NULL, test_int_inc, &count);
|
gbinder_local_reply_cleanup(NULL, test_int_inc, &count);
|
||||||
g_assert(count == 1);
|
g_assert(count == 1);
|
||||||
|
|
||||||
|
g_assert(!gbinder_local_reply_append_bool(NULL, FALSE));
|
||||||
g_assert(!gbinder_local_reply_append_int32(NULL, 0));
|
g_assert(!gbinder_local_reply_append_int32(NULL, 0));
|
||||||
g_assert(!gbinder_local_reply_append_int64(NULL, 0));
|
g_assert(!gbinder_local_reply_append_int64(NULL, 0));
|
||||||
|
g_assert(!gbinder_local_reply_append_float(NULL, 0));
|
||||||
|
g_assert(!gbinder_local_reply_append_double(NULL, 0));
|
||||||
g_assert(!gbinder_local_reply_append_string8(NULL, NULL));
|
g_assert(!gbinder_local_reply_append_string8(NULL, NULL));
|
||||||
g_assert(!gbinder_local_reply_append_string16(NULL, NULL));
|
g_assert(!gbinder_local_reply_append_string16(NULL, NULL));
|
||||||
g_assert(!gbinder_local_reply_append_hidl_string(NULL, NULL));
|
g_assert(!gbinder_local_reply_append_hidl_string(NULL, NULL));
|
||||||
@@ -110,6 +113,47 @@ test_cleanup(
|
|||||||
g_assert(count == 2);
|
g_assert(count == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* bool
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_bool(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
static const guint8 output_true[] = { 0x01, 0xff, 0xff, 0xff };
|
||||||
|
static const guint8 output_false[] = { 0x00, 0xff, 0xff, 0xff };
|
||||||
|
GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
|
||||||
|
gbinder_local_reply_append_bool(reply, FALSE);
|
||||||
|
data = gbinder_local_reply_data(reply);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(output_false));
|
||||||
|
g_assert(!memcmp(data->bytes->data, output_false, data->bytes->len));
|
||||||
|
gbinder_local_reply_unref(reply);
|
||||||
|
|
||||||
|
reply = gbinder_local_reply_new(&gbinder_io_32);
|
||||||
|
gbinder_local_reply_append_bool(reply, TRUE);
|
||||||
|
data = gbinder_local_reply_data(reply);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(output_true));
|
||||||
|
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
|
||||||
|
gbinder_local_reply_unref(reply);
|
||||||
|
|
||||||
|
reply = gbinder_local_reply_new(&gbinder_io_32);
|
||||||
|
gbinder_local_reply_append_bool(reply, 42);
|
||||||
|
data = gbinder_local_reply_data(reply);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(output_true));
|
||||||
|
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
|
||||||
|
gbinder_local_reply_unref(reply);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* int32
|
* int32
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
@@ -168,6 +212,50 @@ test_int64(
|
|||||||
gbinder_local_reply_unref(reply);
|
gbinder_local_reply_unref(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* float
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_float(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gfloat value = 123456789;
|
||||||
|
GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
|
||||||
|
gbinder_local_reply_append_float(reply, value);
|
||||||
|
data = gbinder_local_reply_data(reply);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(value));
|
||||||
|
g_assert(!memcmp(data->bytes->data, &value, data->bytes->len));
|
||||||
|
gbinder_local_reply_unref(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* double
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_double(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gdouble value = 123456789;
|
||||||
|
GBinderLocalReply* reply = gbinder_local_reply_new(&gbinder_io_32);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
|
||||||
|
gbinder_local_reply_append_double(reply, value);
|
||||||
|
data = gbinder_local_reply_data(reply);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(value));
|
||||||
|
g_assert(!memcmp(data->bytes->data, &value, data->bytes->len));
|
||||||
|
gbinder_local_reply_unref(reply);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* string8
|
* string8
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
@@ -361,8 +449,11 @@ int main(int argc, char* argv[])
|
|||||||
g_test_init(&argc, &argv, NULL);
|
g_test_init(&argc, &argv, NULL);
|
||||||
g_test_add_func(TEST_PREFIX "null", test_null);
|
g_test_add_func(TEST_PREFIX "null", test_null);
|
||||||
g_test_add_func(TEST_PREFIX "cleanup", test_cleanup);
|
g_test_add_func(TEST_PREFIX "cleanup", test_cleanup);
|
||||||
|
g_test_add_func(TEST_PREFIX "bool", test_bool);
|
||||||
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
||||||
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
||||||
|
g_test_add_func(TEST_PREFIX "float", test_float);
|
||||||
|
g_test_add_func(TEST_PREFIX "double", test_double);
|
||||||
g_test_add_func(TEST_PREFIX "string8", test_string8);
|
g_test_add_func(TEST_PREFIX "string8", test_string8);
|
||||||
g_test_add_func(TEST_PREFIX "string16", test_string16);
|
g_test_add_func(TEST_PREFIX "string16", test_string16);
|
||||||
g_test_add_func(TEST_PREFIX "hidl_string", test_hidl_string);
|
g_test_add_func(TEST_PREFIX "hidl_string", test_hidl_string);
|
||||||
|
|||||||
@@ -76,8 +76,11 @@ test_null(
|
|||||||
g_assert(count == 1);
|
g_assert(count == 1);
|
||||||
|
|
||||||
g_assert(!gbinder_local_request_data(NULL));
|
g_assert(!gbinder_local_request_data(NULL));
|
||||||
|
g_assert(!gbinder_local_request_append_bool(NULL, FALSE));
|
||||||
g_assert(!gbinder_local_request_append_int32(NULL, 0));
|
g_assert(!gbinder_local_request_append_int32(NULL, 0));
|
||||||
g_assert(!gbinder_local_request_append_int64(NULL, 0));
|
g_assert(!gbinder_local_request_append_int64(NULL, 0));
|
||||||
|
g_assert(!gbinder_local_request_append_float(NULL, 0));
|
||||||
|
g_assert(!gbinder_local_request_append_double(NULL, 0));
|
||||||
g_assert(!gbinder_local_request_append_string8(NULL, NULL));
|
g_assert(!gbinder_local_request_append_string8(NULL, NULL));
|
||||||
g_assert(!gbinder_local_request_append_string16(NULL, NULL));
|
g_assert(!gbinder_local_request_append_string16(NULL, NULL));
|
||||||
g_assert(!gbinder_local_request_append_hidl_string(NULL, NULL));
|
g_assert(!gbinder_local_request_append_hidl_string(NULL, NULL));
|
||||||
@@ -140,6 +143,47 @@ test_init_data(
|
|||||||
g_bytes_unref(init_bytes);
|
g_bytes_unref(init_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* bool
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_bool(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
static const guint8 output_true[] = { 0x01, 0xff, 0xff, 0xff };
|
||||||
|
static const guint8 output_false[] = { 0x00, 0xff, 0xff, 0xff };
|
||||||
|
GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
|
||||||
|
gbinder_local_request_append_bool(req, FALSE);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(output_false));
|
||||||
|
g_assert(!memcmp(data->bytes->data, output_false, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
|
||||||
|
req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
gbinder_local_request_append_bool(req, TRUE);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(output_true));
|
||||||
|
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
|
||||||
|
req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
gbinder_local_request_append_bool(req, 42);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(output_true));
|
||||||
|
g_assert(!memcmp(data->bytes->data, output_true, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* int32
|
* int32
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
@@ -184,6 +228,50 @@ test_int64(
|
|||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* float
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_float(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gfloat value = 123456789;
|
||||||
|
GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
|
||||||
|
gbinder_local_request_append_float(req, value);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(value));
|
||||||
|
g_assert(!memcmp(data->bytes->data, &value, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* double
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_double(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gdouble value = 123456789;
|
||||||
|
GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
|
||||||
|
gbinder_local_request_append_double(req, value);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(value));
|
||||||
|
g_assert(!memcmp(data->bytes->data, &value, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* string8
|
* string8
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
@@ -360,8 +448,11 @@ int main(int argc, char* argv[])
|
|||||||
g_test_add_func(TEST_PREFIX "null", test_null);
|
g_test_add_func(TEST_PREFIX "null", test_null);
|
||||||
g_test_add_func(TEST_PREFIX "cleanup", test_cleanup);
|
g_test_add_func(TEST_PREFIX "cleanup", test_cleanup);
|
||||||
g_test_add_func(TEST_PREFIX "init_data", test_init_data);
|
g_test_add_func(TEST_PREFIX "init_data", test_init_data);
|
||||||
|
g_test_add_func(TEST_PREFIX "bool", test_bool);
|
||||||
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
||||||
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
||||||
|
g_test_add_func(TEST_PREFIX "float", test_float);
|
||||||
|
g_test_add_func(TEST_PREFIX "double", test_double);
|
||||||
g_test_add_func(TEST_PREFIX "string8", test_string8);
|
g_test_add_func(TEST_PREFIX "string8", test_string8);
|
||||||
g_test_add_func(TEST_PREFIX "string16", test_string16);
|
g_test_add_func(TEST_PREFIX "string16", test_string16);
|
||||||
g_test_add_func(TEST_PREFIX "hidl_string", test_hidl_string);
|
g_test_add_func(TEST_PREFIX "hidl_string", test_hidl_string);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ test_no_header(
|
|||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(GBINDER_DEFAULT_BINDER));
|
gbinder_rpc_protocol_for_device(GBINDER_DEFAULT_BINDER), 0, 0);
|
||||||
|
|
||||||
gbinder_remote_request_set_data(req, NULL, NULL);
|
gbinder_remote_request_set_data(req, NULL, NULL);
|
||||||
g_assert(!gbinder_remote_request_interface(req));
|
g_assert(!gbinder_remote_request_interface(req));
|
||||||
@@ -142,7 +142,7 @@ test_read_header(
|
|||||||
const TestHeaderData* test = test_data;
|
const TestHeaderData* test = test_data;
|
||||||
GBinderDriver* driver = gbinder_driver_new(test->dev);
|
GBinderDriver* driver = gbinder_driver_new(test->dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(test->dev));
|
gbinder_rpc_protocol_for_device(test->dev), 0, 0);
|
||||||
|
|
||||||
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
||||||
g_memdup(test->header, test->header_size), test->header_size), NULL);
|
g_memdup(test->header, test->header_size), test->header_size), NULL);
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ test_empty(
|
|||||||
g_assert(!gbinder_reader_read_uint32(&reader, NULL));
|
g_assert(!gbinder_reader_read_uint32(&reader, NULL));
|
||||||
g_assert(!gbinder_reader_read_int64(&reader, NULL));
|
g_assert(!gbinder_reader_read_int64(&reader, NULL));
|
||||||
g_assert(!gbinder_reader_read_uint64(&reader, NULL));
|
g_assert(!gbinder_reader_read_uint64(&reader, NULL));
|
||||||
|
g_assert(!gbinder_reader_read_float(&reader, NULL));
|
||||||
|
g_assert(!gbinder_reader_read_double(&reader, NULL));
|
||||||
g_assert(!gbinder_reader_read_object(&reader));
|
g_assert(!gbinder_reader_read_object(&reader));
|
||||||
g_assert(!gbinder_reader_read_nullable_object(&reader, NULL));
|
g_assert(!gbinder_reader_read_nullable_object(&reader, NULL));
|
||||||
g_assert(!gbinder_reader_read_buffer(&reader));
|
g_assert(!gbinder_reader_read_buffer(&reader));
|
||||||
@@ -244,6 +246,84 @@ test_int64(
|
|||||||
gbinder_driver_unref(driver);
|
gbinder_driver_unref(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* float
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_float(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gfloat in = 42;
|
||||||
|
gfloat out1 = 0;
|
||||||
|
gfloat out2 = 0;
|
||||||
|
GBinderDriver* driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER);
|
||||||
|
GBinderReader reader;
|
||||||
|
GBinderReaderData data;
|
||||||
|
|
||||||
|
g_assert(driver);
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
data.buffer = gbinder_buffer_new(driver, g_memdup(&in, sizeof(in)),
|
||||||
|
sizeof(in));
|
||||||
|
|
||||||
|
gbinder_reader_init(&reader, &data, 0, sizeof(in));
|
||||||
|
g_assert(gbinder_reader_read_float(&reader, &out1));
|
||||||
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
|
g_assert(in == out1);
|
||||||
|
|
||||||
|
gbinder_reader_init(&reader, &data, 0, sizeof(in));
|
||||||
|
g_assert(gbinder_reader_read_float(&reader, &out2));
|
||||||
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
|
g_assert(in == (gfloat)out2);
|
||||||
|
|
||||||
|
gbinder_reader_init(&reader, &data, 0, sizeof(in));
|
||||||
|
g_assert(gbinder_reader_read_float(&reader, NULL));
|
||||||
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
|
|
||||||
|
gbinder_buffer_free(data.buffer);
|
||||||
|
gbinder_driver_unref(driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* double
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_double(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gdouble in = 42;
|
||||||
|
gdouble out1 = 0;
|
||||||
|
gdouble out2 = 0;
|
||||||
|
GBinderDriver* driver = gbinder_driver_new(GBINDER_DEFAULT_BINDER);
|
||||||
|
GBinderReader reader;
|
||||||
|
GBinderReaderData data;
|
||||||
|
|
||||||
|
g_assert(driver);
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
data.buffer = gbinder_buffer_new(driver, g_memdup(&in, sizeof(in)),
|
||||||
|
sizeof(in));
|
||||||
|
|
||||||
|
gbinder_reader_init(&reader, &data, 0, sizeof(in));
|
||||||
|
g_assert(gbinder_reader_read_double(&reader, &out1));
|
||||||
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
|
g_assert(in == out1);
|
||||||
|
|
||||||
|
gbinder_reader_init(&reader, &data, 0, sizeof(in));
|
||||||
|
g_assert(gbinder_reader_read_double(&reader, &out2));
|
||||||
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
|
g_assert(in == (gdouble)out2);
|
||||||
|
|
||||||
|
gbinder_reader_init(&reader, &data, 0, sizeof(in));
|
||||||
|
g_assert(gbinder_reader_read_double(&reader, NULL));
|
||||||
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
|
|
||||||
|
gbinder_buffer_free(data.buffer);
|
||||||
|
gbinder_driver_unref(driver);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* string8
|
* string8
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
@@ -659,6 +739,8 @@ int main(int argc, char* argv[])
|
|||||||
g_test_add_func(TEST_PREFIX "bool", test_bool);
|
g_test_add_func(TEST_PREFIX "bool", test_bool);
|
||||||
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
||||||
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
||||||
|
g_test_add_func(TEST_PREFIX "float", test_float);
|
||||||
|
g_test_add_func(TEST_PREFIX "double", test_double);
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(test_string8_tests); i++) {
|
for (i = 0; i < G_N_ELEMENTS(test_string8_tests); i++) {
|
||||||
const TestStringData* test = test_string8_tests + i;
|
const TestStringData* test = test_string8_tests + i;
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ test_null(
|
|||||||
gbinder_remote_request_init_reader(NULL, &reader);
|
gbinder_remote_request_init_reader(NULL, &reader);
|
||||||
g_assert(gbinder_reader_at_end(&reader));
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
g_assert(!gbinder_remote_request_interface(NULL));
|
g_assert(!gbinder_remote_request_interface(NULL));
|
||||||
|
g_assert(gbinder_remote_request_sender_pid(NULL) == (pid_t)(-1));
|
||||||
|
g_assert(gbinder_remote_request_sender_euid(NULL) == (uid_t)(-1));
|
||||||
g_assert(!gbinder_remote_request_read_int32(NULL, NULL));
|
g_assert(!gbinder_remote_request_read_int32(NULL, NULL));
|
||||||
g_assert(!gbinder_remote_request_read_uint32(NULL, NULL));
|
g_assert(!gbinder_remote_request_read_uint32(NULL, NULL));
|
||||||
g_assert(!gbinder_remote_request_read_int64(NULL, NULL));
|
g_assert(!gbinder_remote_request_read_int64(NULL, NULL));
|
||||||
@@ -87,7 +89,7 @@ test_basic(
|
|||||||
{
|
{
|
||||||
GBinderReader reader;
|
GBinderReader reader;
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(NULL));
|
gbinder_rpc_protocol_for_device(NULL), 0, 0);
|
||||||
|
|
||||||
gbinder_remote_request_init_reader(req, &reader);
|
gbinder_remote_request_init_reader(req, &reader);
|
||||||
g_assert(gbinder_reader_at_end(&reader));
|
g_assert(gbinder_reader_at_end(&reader));
|
||||||
@@ -116,7 +118,7 @@ test_int32(
|
|||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
GBinderDriver* driver = gbinder_driver_new(dev);
|
GBinderDriver* driver = gbinder_driver_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(dev));
|
gbinder_rpc_protocol_for_device(dev), 0, 0);
|
||||||
|
|
||||||
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
||||||
g_memdup(request_data, sizeof(request_data)), sizeof(request_data)),
|
g_memdup(request_data, sizeof(request_data)), sizeof(request_data)),
|
||||||
@@ -150,7 +152,7 @@ test_int64(
|
|||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
GBinderDriver* driver = gbinder_driver_new(dev);
|
GBinderDriver* driver = gbinder_driver_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(dev));
|
gbinder_rpc_protocol_for_device(dev), 0, 0);
|
||||||
|
|
||||||
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
||||||
g_memdup(request_data, sizeof(request_data)), sizeof(request_data)),
|
g_memdup(request_data, sizeof(request_data)), sizeof(request_data)),
|
||||||
@@ -182,7 +184,7 @@ test_string8(
|
|||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
GBinderDriver* driver = gbinder_driver_new(dev);
|
GBinderDriver* driver = gbinder_driver_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(dev));
|
gbinder_rpc_protocol_for_device(dev), 0, 0);
|
||||||
|
|
||||||
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
||||||
g_memdup(request_data, sizeof(request_data)), sizeof(request_data)),
|
g_memdup(request_data, sizeof(request_data)), sizeof(request_data)),
|
||||||
@@ -213,7 +215,7 @@ test_string16(
|
|||||||
const char* dev = GBINDER_DEFAULT_BINDER;
|
const char* dev = GBINDER_DEFAULT_BINDER;
|
||||||
GBinderDriver* driver = gbinder_driver_new(dev);
|
GBinderDriver* driver = gbinder_driver_new(dev);
|
||||||
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
GBinderRemoteRequest* req = gbinder_remote_request_new(NULL,
|
||||||
gbinder_rpc_protocol_for_device(dev));
|
gbinder_rpc_protocol_for_device(dev), 0, 0);
|
||||||
char* str;
|
char* str;
|
||||||
|
|
||||||
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
gbinder_remote_request_set_data(req, gbinder_buffer_new(driver,
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ test_null(
|
|||||||
gbinder_writer_append_int32(&writer, 0);
|
gbinder_writer_append_int32(&writer, 0);
|
||||||
gbinder_writer_append_int64(NULL, 0);
|
gbinder_writer_append_int64(NULL, 0);
|
||||||
gbinder_writer_append_int64(&writer, 0);
|
gbinder_writer_append_int64(&writer, 0);
|
||||||
|
gbinder_writer_append_float(NULL, 0);
|
||||||
|
gbinder_writer_append_float(&writer, 0);
|
||||||
|
gbinder_writer_append_double(NULL, 0);
|
||||||
|
gbinder_writer_append_double(&writer, 0);
|
||||||
gbinder_writer_append_string8(NULL, NULL);
|
gbinder_writer_append_string8(NULL, NULL);
|
||||||
gbinder_writer_append_string8(&writer, NULL);
|
gbinder_writer_append_string8(&writer, NULL);
|
||||||
gbinder_writer_append_string8_len(NULL, NULL, 0);
|
gbinder_writer_append_string8_len(NULL, NULL, 0);
|
||||||
@@ -139,6 +143,54 @@ test_int64(
|
|||||||
gbinder_local_request_unref(req);
|
gbinder_local_request_unref(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* float
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_float(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gfloat value = 12345678;
|
||||||
|
GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
GBinderWriter writer;
|
||||||
|
|
||||||
|
gbinder_local_request_init_writer(req, &writer);
|
||||||
|
gbinder_writer_append_float(&writer, value);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(value));
|
||||||
|
g_assert(!memcmp(data->bytes->data, &value, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==========================================================================*
|
||||||
|
* double
|
||||||
|
*==========================================================================*/
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test_double(
|
||||||
|
void)
|
||||||
|
{
|
||||||
|
const gdouble value = 12345678;
|
||||||
|
GBinderLocalRequest* req = gbinder_local_request_new(&gbinder_io_32, NULL);
|
||||||
|
GBinderOutputData* data;
|
||||||
|
GBinderWriter writer;
|
||||||
|
|
||||||
|
gbinder_local_request_init_writer(req, &writer);
|
||||||
|
gbinder_writer_append_double(&writer, value);
|
||||||
|
data = gbinder_local_request_data(req);
|
||||||
|
g_assert(!gbinder_output_data_offsets(data));
|
||||||
|
g_assert(!gbinder_output_data_buffers_size(data));
|
||||||
|
g_assert(data->bytes->len == sizeof(value));
|
||||||
|
g_assert(!memcmp(data->bytes->data, &value, data->bytes->len));
|
||||||
|
gbinder_local_request_unref(req);
|
||||||
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
* bool
|
* bool
|
||||||
*==========================================================================*/
|
*==========================================================================*/
|
||||||
@@ -583,6 +635,8 @@ int main(int argc, char* argv[])
|
|||||||
g_test_add_func(TEST_PREFIX "null", test_null);
|
g_test_add_func(TEST_PREFIX "null", test_null);
|
||||||
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
g_test_add_func(TEST_PREFIX "int32", test_int32);
|
||||||
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
g_test_add_func(TEST_PREFIX "int64", test_int64);
|
||||||
|
g_test_add_func(TEST_PREFIX "float", test_float);
|
||||||
|
g_test_add_func(TEST_PREFIX "double", test_double);
|
||||||
g_test_add_func(TEST_PREFIX "bool", test_bool);
|
g_test_add_func(TEST_PREFIX "bool", test_bool);
|
||||||
g_test_add_func(TEST_PREFIX "bytes", test_bytes);
|
g_test_add_func(TEST_PREFIX "bytes", test_bytes);
|
||||||
g_test_add_func(TEST_PREFIX "string8", test_string8);
|
g_test_add_func(TEST_PREFIX "string8", test_string8);
|
||||||
|
|||||||
Reference in New Issue
Block a user