/* read the data from hidraw */
memset(buf, 0, sizeof(buf));
err = read(self->hidraw_fd, buf, sizeof(buf));
ASSERT_EQ(err, 6) TH_LOG("read_hidraw");
ASSERT_EQ(buf[0], 1);
ASSERT_EQ(buf[1], 42);
}
/* * After initial opening/checks of hidraw, revoke the hidraw * node and check that we can not read any more data.
*/
TEST_F(hidraw, raw_event_revoked)
{
__u8 buf[10] = {0}; int err;
/* read the data from hidraw */
memset(buf, 0, sizeof(buf));
err = read(self->hidraw_fd, buf, sizeof(buf));
ASSERT_EQ(err, 6) TH_LOG("read_hidraw");
ASSERT_EQ(buf[0], 1);
ASSERT_EQ(buf[1], 42);
/* call the revoke ioctl */
err = ioctl(self->hidraw_fd, HIDIOCREVOKE, NULL);
ASSERT_OK(err) TH_LOG("couldn't revoke the hidraw fd");
/* inject one other event */
buf[0] = 1;
buf[1] = 43;
uhid_send_event(_metadata, &self->hid, buf, 6);
/* read the data from hidraw */
memset(buf, 0, sizeof(buf));
err = read(self->hidraw_fd, buf, sizeof(buf));
ASSERT_EQ(err, -1) TH_LOG("read_hidraw");
ASSERT_EQ(errno, ENODEV) TH_LOG("unexpected error code while reading the hidraw node: %d",
errno);
}
/* * Revoke the hidraw node and check that we can not do any ioctl.
*/
TEST_F(hidraw, ioctl_revoked)
{ int err, desc_size = 0;
/* call the revoke ioctl */
err = ioctl(self->hidraw_fd, HIDIOCREVOKE, NULL);
ASSERT_OK(err) TH_LOG("couldn't revoke the hidraw fd");
/* do an ioctl */
err = ioctl(self->hidraw_fd, HIDIOCGRDESCSIZE, &desc_size);
ASSERT_EQ(err, -1) TH_LOG("ioctl_hidraw");
ASSERT_EQ(errno, ENODEV) TH_LOG("unexpected error code while doing an ioctl: %d",
errno);
}
/* * Setup polling of the fd, and check that revoke works properly.
*/
TEST_F(hidraw, poll_revoked)
{ struct pollfd pfds[1];
__u8 buf[10] = {0}; int err, ready;
/* * After initial opening/checks of hidraw, revoke the hidraw * node and check that we can not read any more data.
*/
TEST_F(hidraw, write_event_revoked)
{ struct timespec time_to_wait;
__u8 buf[10] = {0}; int err;
/* inject one event from hidraw */
buf[0] = 1; /* report ID */
buf[1] = 2;
buf[2] = 42;
err = write(self->hidraw_fd, buf, 3);
ASSERT_EQ(err, 3) TH_LOG("unexpected error while writing to hidraw node: %d", err);
err = pthread_cond_timedwait(&uhid_output_cond, &uhid_output_mtx, &time_to_wait);
ASSERT_OK(err) TH_LOG("error while calling waiting for the condition");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.