Raymond Toy pushed to branch rtoy-issue-26 at cmucl / cmucl
Commits:
260c0e45 by Raymond Toy at 2016-11-29T19:03:17-08:00
Adjust comment
- - - - -
1 changed file:
- src/lisp/os-common.c
Changes:
=====================================
src/lisp/os-common.c
=====================================
--- a/src/lisp/os-common.c
+++ b/src/lisp/os-common.c
@@ -579,8 +579,8 @@ os_sleep(double seconds)
fractional = modf(seconds, &integral);
requested.tv_sec = (time_t) integral;
/*
- * Round up just in case; it's probably better to sleep slightly
- * too long than to sleep for too short a time.
+ * Round up---better to sleep slightly too long than to sleep for
+ * too short a time.
*/
requested.tv_nsec = (long) ceil(fractional * 1e9);
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/260c0e45be8064450a13608a9…
Raymond Toy pushed to branch rtoy-issue-26 at cmucl / cmucl
Commits:
1aae3ef9 by Raymond Toy at 2016-11-29T19:01:54-08:00
Verify the process ran and exited successfully
- - - - -
1 changed file:
- tests/issues.lisp
Changes:
=====================================
tests/issues.lisp
=====================================
--- a/tests/issues.lisp
+++ b/tests/issues.lisp
@@ -352,8 +352,12 @@
(:tag :issues)
(let ((start-time (get-universal-time)))
(let ((p (ext:run-program "/usr/bin/env" '("sleep" "1") :wait nil)))
- (declare (ignore p))
(sleep 5)
+ ;; For this test to be valid, the process must have finished
+ ;; with a successful exit.
+ (assert-true (eq (ext:process-status p) :exited))
+ (assert-true (zerop (ext:process-exit-code p)))
+
;; We expect to have slept for at least 5 sec, but since
;; get-universal-time only has an accuracy of 1 sec, just verify
;; more than 3 sec have elapsed.
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/1aae3ef96a2f49ef5743031d7…
Raymond Toy pushed to branch rtoy-issue-26 at cmucl / cmucl
Commits:
05585b8d by Raymond Toy at 2016-11-28T21:05:02-08:00
Minor cosmetic tweaks
o Include math.h before netdb.h (from Carl)
o Use ceil instead of trunc and add comment on why.
o Conform to cmucl style.
- - - - -
9e99edb8 by Raymond Toy at 2016-11-28T21:14:27-08:00
Add test for issue 26
Basically used the repro case from the issue.
- - - - -
2 changed files:
- src/lisp/os-common.c
- tests/issues.lisp
Changes:
=====================================
src/lisp/os-common.c
=====================================
--- a/src/lisp/os-common.c
+++ b/src/lisp/os-common.c
@@ -6,11 +6,11 @@
*/
#include <errno.h>
+#include <math.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <math.h>
#include "os.h"
#include "internals.h"
@@ -568,7 +568,8 @@ int ieee754_rem_pio2(double x, double *y0, double *y1)
/*
* sleep for the given number of seconds, even if we're interrupted.
*/
-void os_sleep(double seconds)
+void
+os_sleep(double seconds)
{
struct timespec requested;
struct timespec remaining;
@@ -577,7 +578,12 @@ void os_sleep(double seconds)
fractional = modf(seconds, &integral);
requested.tv_sec = (time_t) integral;
- requested.tv_nsec = (long) trunc(fractional * 1e9);
+ /*
+ * Round up just in case; it's probably better to sleep slightly
+ * too long than to sleep for too short a time.
+ */
+ requested.tv_nsec = (long) ceil(fractional * 1e9);
+
while (nanosleep(&requested, &remaining) == -1 && errno == EINTR) {
requested = remaining;
}
=====================================
tests/issues.lisp
=====================================
--- a/tests/issues.lisp
+++ b/tests/issues.lisp
@@ -347,3 +347,14 @@
(assert (null (set-difference directories
'(".dir" "dir")
:test #'string-equal)))))
+
+(define-test issue.26
+ (:tag :issues)
+ (let ((start-time (get-universal-time)))
+ (let ((p (ext:run-program "/usr/bin/env" '("sleep" "1") :wait nil)))
+ (declare (ignore p))
+ (sleep 5)
+ ;; We expect to have slept for at least 5 sec, but since
+ ;; get-universal-time only has an accuracy of 1 sec, just verify
+ ;; more than 3 sec have elapsed.
+ (assert-true (>= (- (get-universal-time) start-time) 3)))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/compare/e5777ecb2f2581f6788f7136…
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
0e172b4b by Raymond Toy at 2016-11-10T19:13:53-08:00
Fix #36: encode-universal-time errors on valid time
Allow 1899 as a year, but also add a check that the resulting time is
a non-negative integer.
Add a test for this too in issues.lisp.
- - - - -
2 changed files:
- src/code/time.lisp
- tests/issues.lisp
Changes:
=====================================
src/code/time.lisp
=====================================
--- a/src/code/time.lisp
+++ b/src/code/time.lisp
@@ -223,8 +223,11 @@
(type (mod 24) hour)
(type (integer 1 31) date)
(type (integer 1 12) month)
- (type (or (integer 0 99) (integer 1900)) year)
- (type (or null rational) time-zone))
+ ;; 1899 to account for time zones that are equivalent to 1900.
+ (type (or (integer 0 99) (integer 1899)) year)
+ (type (or null rational) time-zone)
+ ;; Result must be non-negative integer!
+ (values (integer 0)))
(let* ((year (if (< year 100)
(pick-obvious-year year)
year))
=====================================
tests/issues.lisp
=====================================
--- a/tests/issues.lisp
+++ b/tests/issues.lisp
@@ -347,3 +347,8 @@
(assert (null (set-difference directories
'(".dir" "dir")
:test #'string-equal)))))
+
+(define-test issue.36
+ (:tag :issues)
+ (loop for k from 1 to 24 do
+ (assert-equal 0 (encode-universal-time 0 0 (- 24 k) 31 12 1899 k))))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/0e172b4b2d6dc5a6dd016c080…