Files
mckernel/test/issues/1036/CT_001.c
Ken Sato c23bc8d401 syscall_time: Handle by McKernel
refs: #1036
Change-Id: Ifa81b613c7ee8d95ae7cdf3dd54643f60526fa73
2018-09-13 07:44:02 +00:00

48 lines
879 B
C

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/syscall.h>
#include "./test_chk.h"
#define TEST_NAME "CT_001"
int main(int argc, char *argv[])
{
time_t now;
long sys_ret;
int ng_flag = 0;
printf("*** %s start *******************************\n", TEST_NAME);
/* get seconds since the Epoch by glibc time() */
now = time(NULL);
/* get seconds since the Epoch by syscall_time */
sys_ret = syscall(__NR_time, NULL);
if (now != sys_ret) {
/* check again only once */
now = time(NULL);
if (now != sys_ret) {
ng_flag = 1;
}
}
printf("glibc time(): %ld seconds\n", now);
printf("sys_time : %ld seconds\n", sys_ret);
OKNG(ng_flag != 0, "check seconds since the Epoch");
printf("*** %s PASSED\n\n", TEST_NAME);
return 0;
fn_fail:
printf("*** %s FAILED\n\n", TEST_NAME);
return -1;
}