X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Ftime.lisp;h=279dee0ff495f4ca27e19c38a76e8662ced9f899;hb=2d3c576c1b75c3b60f19ef508202a46090d25111;hp=2402b429987d54b82730145b0c146f6b625312bf;hpb=65e2a75247b894d1f562102ef1df77c7060b5048;p=uffi.git diff --git a/tests/time.lisp b/tests/time.lisp index 2402b42..279dee0 100644 --- a/tests/time.lisp +++ b/tests/time.lisp @@ -7,7 +7,7 @@ ;;;; Author: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: time.lisp,v 1.2 2003/08/13 18:53:42 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -59,7 +59,34 @@ 1 1 1970 2 3 1) - +(uffi:def-struct timeval + (secs :long) + (usecs :long)) +(uffi:def-struct timezone + (minutes-west :int) + (dsttime :int)) +(uffi:def-function ("gettimeofday" c-gettimeofday) + ((tv (* timeval)) + (tz (* timezone))) + :returning :int) + +(defun get-utime () + (uffi:with-foreign-object (tv 'timeval) + (let ((res (c-gettimeofday tv (uffi:make-null-pointer 'timezone)))) + (values + (+ (* 1000000 (uffi:get-slot-value tv 'timeval 'secs)) + (uffi:get-slot-value tv 'timeval 'usecs)) + res)))) +(deftest timeofday.1 + (multiple-value-bind (t1 res1) (get-utime) + (multiple-value-bind (t2 res2) (get-utime) + (and (or (= t2 t1) (> t2 t1)) + (> t1 1000000000) + (> t2 1000000000) + (zerop res1) + (zerop res2)))) + t) +