![]() |
|
|||
0001 /* 0002 * Copyright © 2018 Alexey Dobriyan <adobriyan@gmail.com> 0003 * 0004 * Permission to use, copy, modify, and distribute this software for any 0005 * purpose with or without fee is hereby granted, provided that the above 0006 * copyright notice and this permission notice appear in all copies. 0007 * 0008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 0009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 0010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 0011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 0012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 0013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 0014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 0015 */ 0016 // Test that values in /proc/uptime increment monotonically. 0017 #undef NDEBUG 0018 #include <assert.h> 0019 #include <stdint.h> 0020 #include <sys/types.h> 0021 #include <sys/stat.h> 0022 #include <fcntl.h> 0023 0024 #include "proc-uptime.h" 0025 0026 int main(void) 0027 { 0028 uint64_t start, u0, u1, i0, i1; 0029 int fd; 0030 0031 fd = open("/proc/uptime", O_RDONLY); 0032 assert(fd >= 0); 0033 0034 proc_uptime(fd, &u0, &i0); 0035 start = u0; 0036 do { 0037 proc_uptime(fd, &u1, &i1); 0038 assert(u1 >= u0); 0039 assert(i1 >= i0); 0040 u0 = u1; 0041 i0 = i1; 0042 } while (u1 - start < 100); 0043 0044 return 0; 0045 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |