Ejemplo n.º 1
0
void SyncObjTest::_doTests()
{
	SyncObj so;

	bool passed = true;
	so.lock();
	so.unlock();
	reportResult("Simple lock/unlock", passed);

	uint64_t now = offsetTime();
	unsigned long wait_in_us = 5000;
	so.lock();
	int rv = so.waitOnSignal(wait_in_us);
	so.unlock();
	uint64_t after = offsetTime();
	uint64_t delta_usec = after - now;

	if (rv != ETIMEDOUT) {
		DF_LOG_ERR("waitSignal() did not return ETIMEDOUT");
		passed = false;
	}

#ifdef __APPLE__
	const float error_factor = 2.0f;
#else
	const float error_factor = 1.2f;
#endif

	bool dtime_ok = (delta_usec > wait_in_us) && (delta_usec < wait_in_us * error_factor);

	if (!dtime_ok) {
		DF_LOG_ERR("waitSignal() timeout of %luus was %" PRIu64 "us", wait_in_us, delta_usec);
		passed = false;
	}

	reportResult("waitSignal() timeout", passed && dtime_ok);
}
Ejemplo n.º 2
0
int
GPSSIM::devIOCTL(unsigned long cmd, unsigned long arg)
{
	_sync.lock();

	int ret = OK;

	switch (cmd) {
	case SENSORIOCRESET:
		cmd_reset();
		break;

	default:
		/* give it to parent if no one wants it */
		ret = VirtDevObj::devIOCTL(cmd, arg);
		break;
	}

	_sync.unlock();

	return ret;
}