issue/863/CT300x: add timestamp and check
This commit is contained in:
@@ -7,10 +7,37 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
char *
|
||||||
|
gettime(char *buf, struct timeval *tv)
|
||||||
|
{
|
||||||
|
struct tm *tm;
|
||||||
|
|
||||||
|
gettimeofday(tv, NULL);
|
||||||
|
tm = localtime(&tv->tv_sec);
|
||||||
|
sprintf(buf, "%02d:%02d:%02d.%06d", tm->tm_hour, tm->tm_min, tm->tm_sec, tv->tv_usec);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tv_sub(struct timeval *tv1, const struct timeval *tv2)
|
||||||
|
{
|
||||||
|
tv1->tv_sec -= tv2->tv_sec;
|
||||||
|
tv1->tv_usec -= tv2->tv_usec;
|
||||||
|
if (tv1->tv_usec < 0) {
|
||||||
|
tv1->tv_sec--;
|
||||||
|
tv1->tv_usec += 1000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct timeval tv1;
|
||||||
|
struct timeval tv2;
|
||||||
|
|
||||||
void
|
void
|
||||||
sig(int s)
|
sig(int s)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "signal hanlder is called\n");
|
char buf[16];
|
||||||
|
|
||||||
|
fprintf(stderr, "%s signal hanlder is called\n", gettime(buf, &tv2));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -20,10 +47,12 @@ main(int argc, char **argv)
|
|||||||
int fds[2];
|
int fds[2];
|
||||||
char c;
|
char c;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
memset(&act, '\0', sizeof act);
|
memset(&act, '\0', sizeof act);
|
||||||
act.sa_handler = sig;
|
act.sa_handler = sig;
|
||||||
sigaction(SIGALRM, &act, NULL);
|
sigaction(SIGALRM, &act, NULL);
|
||||||
|
fprintf(stderr, "%s test start, kill after 3 seconds\n", gettime(buf, &tv1));
|
||||||
alarm(3);
|
alarm(3);
|
||||||
pipe(fds);
|
pipe(fds);
|
||||||
rc = read(fds[0], &c, 1);
|
rc = read(fds[0], &c, 1);
|
||||||
@@ -35,6 +64,10 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "CT3001 NG BAD error errno=%d\n", errno);
|
fprintf(stderr, "CT3001 NG BAD error errno=%d\n", errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "CT3001 OK\n");
|
tv_sub(&tv2, &tv1);
|
||||||
|
if (tv2.tv_sec != 3)
|
||||||
|
fprintf(stderr, "CT3001 NG signal delayed (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "CT3001 OK\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,31 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
char *
|
||||||
|
gettime(char *buf, struct timeval *tv)
|
||||||
|
{
|
||||||
|
struct tm *tm;
|
||||||
|
|
||||||
|
gettimeofday(tv, NULL);
|
||||||
|
tm = localtime(&tv->tv_sec);
|
||||||
|
sprintf(buf, "%02d:%02d:%02d.%06d", tm->tm_hour, tm->tm_min, tm->tm_sec, tv->tv_usec);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tv_sub(struct timeval *tv1, const struct timeval *tv2)
|
||||||
|
{
|
||||||
|
tv1->tv_sec -= tv2->tv_sec;
|
||||||
|
tv1->tv_usec -= tv2->tv_usec;
|
||||||
|
if (tv1->tv_usec < 0) {
|
||||||
|
tv1->tv_sec--;
|
||||||
|
tv1->tv_usec += 1000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct timeval tv1;
|
||||||
|
struct timeval tv2;
|
||||||
|
|
||||||
void
|
void
|
||||||
child()
|
child()
|
||||||
{
|
{
|
||||||
@@ -27,13 +52,16 @@ main(int argc, char **argv)
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
int st;
|
int st;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
|
fprintf(stderr, "%s test start, kill after 3 seconds\n", gettime(buf, &tv1));
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
child();
|
child();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
|
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
|
||||||
|
fprintf(stderr, "%s child process terminated\n", gettime(buf, &tv2));
|
||||||
if (rc != pid) {
|
if (rc != pid) {
|
||||||
fprintf(stderr, "CT3003 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
fprintf(stderr, "CT3003 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -46,6 +74,10 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "CT3003 NG BAD signal sig=%d\n", WTERMSIG(st));
|
fprintf(stderr, "CT3003 NG BAD signal sig=%d\n", WTERMSIG(st));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "CT3003 OK\n");
|
tv_sub(&tv2, &tv1);
|
||||||
|
if (tv2.tv_sec != 3)
|
||||||
|
fprintf(stderr, "CT3003 NG signal delayed (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "CT3003 OK\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,31 @@
|
|||||||
|
|
||||||
#define FILESIZE (2L * 1024 * 1024 * 1024)
|
#define FILESIZE (2L * 1024 * 1024 * 1024)
|
||||||
|
|
||||||
|
char *
|
||||||
|
gettime(char *buf, struct timeval *tv)
|
||||||
|
{
|
||||||
|
struct tm *tm;
|
||||||
|
|
||||||
|
gettimeofday(tv, NULL);
|
||||||
|
tm = localtime(&tv->tv_sec);
|
||||||
|
sprintf(buf, "%02d:%02d:%02d.%06d", tm->tm_hour, tm->tm_min, tm->tm_sec, tv->tv_usec);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tv_sub(struct timeval *tv1, const struct timeval *tv2)
|
||||||
|
{
|
||||||
|
tv1->tv_sec -= tv2->tv_sec;
|
||||||
|
tv1->tv_usec -= tv2->tv_usec;
|
||||||
|
if (tv1->tv_usec < 0) {
|
||||||
|
tv1->tv_sec--;
|
||||||
|
tv1->tv_usec += 1000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct timeval tv1;
|
||||||
|
struct timeval tv2;
|
||||||
|
|
||||||
void
|
void
|
||||||
child()
|
child()
|
||||||
{
|
{
|
||||||
@@ -38,13 +63,16 @@ main(int argc, char **argv)
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
int st;
|
int st;
|
||||||
int rc;
|
int rc;
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
|
fprintf(stderr, "%s test start, kill after 1 seconds\n", gettime(buf, &tv1));
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
child();
|
child();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
|
while ((rc = waitpid(pid, &st, 0)) == -1 && errno == EINTR);
|
||||||
|
fprintf(stderr, "%s child process terminated\n", gettime(buf, &tv2));
|
||||||
if (rc != pid) {
|
if (rc != pid) {
|
||||||
fprintf(stderr, "CT3004 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
fprintf(stderr, "CT3004 NG BAD wait rc=%d errno=%d\n", rc, errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -57,6 +85,10 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "CT3004 NG BAD signal sig=%d\n", WTERMSIG(st));
|
fprintf(stderr, "CT3004 NG BAD signal sig=%d\n", WTERMSIG(st));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "CT3004 OK\n");
|
tv_sub(&tv2, &tv1);
|
||||||
|
if (tv2.tv_sec != 1)
|
||||||
|
fprintf(stderr, "CT3004 OK (%d.%06d)\n", tv2.tv_sec, tv2.tv_usec);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "CT3004 OK\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,31 @@
|
|||||||
スクリプトは Mon Feb 5 16:00:07 2018
|
スクリプトは Fri Mar 23 13:25:09 2018
|
||||||
に開始しました[?1034hbash-4.2$ make test
|
に開始しました[?1034hbash-4.2$ make test
|
||||||
./CT300x.sh
|
./CT300x.sh
|
||||||
signal hanlder is called
|
13:25:13.087171 test start, kill after 3 seconds
|
||||||
|
13:25:16.087626 signal hanlder is called
|
||||||
CT3001 OK
|
CT3001 OK
|
||||||
2048+0 レコード入力
|
2048+0 レコード入力
|
||||||
2048+0 レコード出力
|
2048+0 レコード出力
|
||||||
2147483648 バイト (2.1 GB) コピーされました、 19.5651 秒、 110 MB/秒
|
2147483648 バイト (2.1 GB) コピーされました、 19.5143 秒、 110 MB/秒
|
||||||
vm.drop_caches = 3
|
vm.drop_caches = 3
|
||||||
signal hanlder is called
|
signal hanlder is called
|
||||||
CT3002 OK
|
CT3002 OK
|
||||||
|
13:26:00.218056 test start, kill after 3 seconds
|
||||||
|
13:26:03.230253 child process terminated
|
||||||
CT3003 OK
|
CT3003 OK
|
||||||
2048+0 レコード入力
|
2048+0 レコード入力
|
||||||
2048+0 レコード出力
|
2048+0 レコード出力
|
||||||
2147483648 バイト (2.1 GB) コピーされました、 19.5383 秒、 110 MB/秒
|
2147483648 バイト (2.1 GB) コピーされました、 19.5203 秒、 110 MB/秒
|
||||||
vm.drop_caches = 3
|
vm.drop_caches = 3
|
||||||
|
13:26:23.478328 test start, kill after 1 seconds
|
||||||
|
13:26:24.836362 child process terminated
|
||||||
CT3004 OK
|
CT3004 OK
|
||||||
kill SIGURG
|
kill SIGURG
|
||||||
kill SIGINT
|
kill SIGINT
|
||||||
CT3005 OK
|
CT3005 OK
|
||||||
2048+0 レコード入力
|
2048+0 レコード入力
|
||||||
2048+0 レコード出力
|
2048+0 レコード出力
|
||||||
2147483648 バイト (2.1 GB) コピーされました、 19.5148 秒、 110 MB/秒
|
2147483648 バイト (2.1 GB) コピーされました、 19.4966 秒、 110 MB/秒
|
||||||
vm.drop_caches = 3
|
vm.drop_caches = 3
|
||||||
kill SIGURG
|
kill SIGURG
|
||||||
CT3006 OK
|
CT3006 OK
|
||||||
@@ -29,12 +34,12 @@ kill SIGINT
|
|||||||
CT3007 OK
|
CT3007 OK
|
||||||
2048+0 レコード入力
|
2048+0 レコード入力
|
||||||
2048+0 レコード出力
|
2048+0 レコード出力
|
||||||
2147483648 バイト (2.1 GB) コピーされました、 19.5614 秒、 110 MB/秒
|
2147483648 バイト (2.1 GB) コピーされました、 19.4999 秒、 110 MB/秒
|
||||||
vm.drop_caches = 3
|
vm.drop_caches = 3
|
||||||
kill SIGTERM (ignored)
|
kill SIGTERM (ignored)
|
||||||
CT3008 OK
|
CT3008 OK
|
||||||
bash-4.2$ exit
|
bash-4.2$ exit
|
||||||
exit
|
exit
|
||||||
|
|
||||||
スクリプトは Mon Feb 5 16:03:02 2018
|
スクリプトは Fri Mar 23 13:28:04 2018
|
||||||
に終了しました
|
に終了しました
|
||||||
Reference in New Issue
Block a user