Hack around wall clock time going backwards.
As reported in https://github.com/jmmv/kyua/issues/155, the wall clock time can go backwards resulting in an apparent negative delta. As a workaround, convert such deltas to 1us. This allows tests to run successfully in MIPS64 qemu. Approved by: jmmv (maintainer) Sponsored by: DARPA, AFRL
This commit is contained in:
parent
c15fa9a292
commit
3180fead43
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=436312
2 changed files with 24 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
PORTNAME= kyua
|
||||
PORTVERSION= 0.13
|
||||
PORTEPOCH= 3
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= devel
|
||||
MASTER_SITES= https://github.com/jmmv/kyua/releases/download/${PORTNAME}-${PORTVERSION}/ \
|
||||
LOCAL/jmmv
|
||||
|
|
23
devel/kyua/files/patch-utils_datetime.cpp
Normal file
23
devel/kyua/files/patch-utils_datetime.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
$FreeBSD$
|
||||
|
||||
--- utils/datetime.cpp.orig
|
||||
+++ utils/datetime.cpp
|
||||
@@ -590,11 +590,12 @@
|
||||
datetime::delta
|
||||
datetime::timestamp::operator-(const datetime::timestamp& other) const
|
||||
{
|
||||
- if ((*this) < other) {
|
||||
- throw std::runtime_error(
|
||||
- F("Cannot subtract %s from %s as it would result in a negative "
|
||||
- "datetime::delta, which are not supported") % other % (*this));
|
||||
- }
|
||||
+ /*
|
||||
+ * XXX-BD: gettimeofday isn't necessicarily monotonic so return the
|
||||
+ * smallest non-zero delta if time went backwards.
|
||||
+ */
|
||||
+ if ((*this) < other)
|
||||
+ return datetime::delta::from_microseconds(1);
|
||||
return datetime::delta::from_microseconds(to_microseconds() -
|
||||
other.to_microseconds());
|
||||
}
|
Loading…
Reference in a new issue