zephyr/tests/include/tc_nano_timeout_common.h
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00

59 lines
1.7 KiB
C

/*
* Copyright (c) 2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _samples_include_tc_nano_timeout_common__h_
#define _samples_include_tc_nano_timeout_common__h_
/*
* SHORT_TIMEOUTS should be the preferred configuration, but they cause a
* problem with the Jenkins auto-builders for the ARM QEMU. Until this is
* fixed, do not use them by default.
*/
#define SHORT_TIMEOUTS 0
#if SHORT_TIMEOUTS
#define TIMEOUT_BASE 10
#define TIMEOUT_INCREMENT 5
#else
#define TIMEOUT_BASE 50
#define TIMEOUT_INCREMENT 25
#endif
#define TIMEOUT(x) (TIMEOUT_BASE + ((x) * TIMEOUT_INCREMENT))
#define TIMEOUT_TWO_INTERVALS TIMEOUT(1)
#define TIMEOUT_TEN_INTERVALS TIMEOUT(9)
/*
* Verify a timeout is in range, either a diff of 0 or 1 to account for tick
* boundaries.
*/
static inline int is_timeout_in_range(int32_t orig_ticks, int32_t expected)
{
int32_t diff = sys_tick_get() - orig_ticks;
#if SHORT_TIMEOUTS
/*
* This should be the real test: however, there is an issue with the
* Jenkins auto-builders and QEMU for ARM, where (it seems) if the
* builder is overloaded, they do not give enough time to a QEMU instance
* so the Zephyr ticker can increment multiple times (so the interrupt
* handling happens) before the regular processing does occur, which gives
* the impression that more ticks have elapsed than expected.
*/
if (diff != expected && diff != expected + 1) {
TC_ERROR(" *** timeout skew: expected %d/%d, got %d\n",
expected, expected + 1, diff);
return 0;
}
/* TC_PRINT("timeout in range (%d vs %d)\n", diff, expected); */
return 1;
#else
return diff >= expected;
#endif
}
#endif /* _samples_include_tc_nano_timeout_common__h_ */