Finished cleaning up the TimerNsec naming wonk.

This commit is contained in:
Pietro Gagliardi 2019-04-28 13:19:04 -04:00
parent 1bc2297597
commit 64478bd5b0
6 changed files with 17 additions and 17 deletions

View File

@ -59,7 +59,7 @@ testingTest(QueueMain)
int flag = 0; int flag = 0;
uiQueueMain(queued, &flag); uiQueueMain(queued, &flag);
timeout_uiMain(t, 5 * testingTimerNsecPerSec, 0); timeout_uiMain(t, 5 * testingNsecPerSec, 0);
if (flag != 1) if (flag != 1)
testingTErrorf(t, "uiQueueMain didn't set flag properly: got %d, want 1", flag); testingTErrorf(t, "uiQueueMain didn't set flag properly: got %d, want 1", flag);
} }

View File

@ -148,9 +148,9 @@ static void testsetRun(struct testset *set, int *anyFailed)
} else if (t->skipped) } else if (t->skipped)
// note that failed overrides skipped // note that failed overrides skipped
status = "SKIP"; status = "SKIP";
timerstr = testingTimerNsecString(testingTimerNsec(timer)); timerstr = testingNsecString(testingTimerNsec(timer));
printf("--- %s: %s (%s)\n", status, t->name, timerstr); printf("--- %s: %s (%s)\n", status, t->name, timerstr);
testingFreeTimerNsecString(timerstr); testingFreeNsecString(timerstr);
t++; t++;
} }
testingFreeTimer(timer); testingFreeTimer(timer);
@ -306,7 +306,7 @@ static void fillIntPart(char *s, int *start, uint64_t unsec)
} }
} }
char *testingTimerNsecString(int64_t nsec) char *testingNsecString(int64_t nsec)
{ {
uint64_t unsec; uint64_t unsec;
int neg; int neg;
@ -366,7 +366,7 @@ char *testingTimerNsecString(int64_t nsec)
return s; return s;
} }
void testingFreeTimerNsecString(char *s) void testingFreeNsecString(char *s)
{ {
free(s); free(s);
} }

View File

@ -66,8 +66,8 @@ extern void testingTDefer(testingT *t, void (*f)(testingT *t, void *data), void
typedef struct testingTimer testingTimer; typedef struct testingTimer testingTimer;
#define testingTimerNsecPerUsec ((int64_t) 1000) #define testingNsecPerUsec ((int64_t) 1000)
#define testingTimerNsecPerSec ((int64_t) 1000000000) #define testingNsecPerSec ((int64_t) 1000000000)
extern testingTimer *testingNewTimer(void); extern testingTimer *testingNewTimer(void);
extern void testingFreeTimer(testingTimer *t); extern void testingFreeTimer(testingTimer *t);
@ -75,8 +75,8 @@ extern void testingTimerStart(testingTimer *t);
extern void testingTimerEnd(testingTimer *t); extern void testingTimerEnd(testingTimer *t);
extern int64_t testingTimerNsec(testingTimer *t); extern int64_t testingTimerNsec(testingTimer *t);
extern char *testingTimerNsecString(int64_t nsec); extern char *testingNsecString(int64_t nsec);
extern void testingFreeTimerNsecString(char *s); extern void testingFreeNsecString(char *s);
extern void testingRunWithTimeout(testingT *t, int64_t timeout, void (*f)(testingT *t, void *data), void *data, const char *comment, int failNowOnError); extern void testingRunWithTimeout(testingT *t, int64_t timeout, void (*f)(testingT *t, void *data), void *data, const char *comment, int failNowOnError);

View File

@ -21,13 +21,13 @@ void testingRunWithTimeout(testingT *t, int64_t timeout, void (*f)(testingT *t,
struct itimerval timer, prevtimer; struct itimerval timer, prevtimer;
int setitimerError = 0; int setitimerError = 0;
timeoutstr = testingTimerNsecString(timeout); timeoutstr = testingNsecString(timeout);
prevsig = signal(SIGALRM, onTimeout); prevsig = signal(SIGALRM, onTimeout);
timer.it_interval.tv_sec = 0; timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 0; timer.it_interval.tv_usec = 0;
timer.it_value.tv_sec = timeout / testingTimerNsecPerSec; timer.it_value.tv_sec = timeout / testingNsecPerSec;
timer.it_value.tv_usec = (timeout % testingTimerNsecPerSec) / testingTimerNsecPerUsec; timer.it_value.tv_usec = (timeout % testingNsecPerSec) / testingNsecPerUsec;
if (setitimer(ITIMER_REAL, &timer, &prevtimer) != 0) { if (setitimer(ITIMER_REAL, &timer, &prevtimer) != 0) {
setitimerError = errno; setitimerError = errno;
testingTErrorf(t, "error applying %s timeout: %s", comment, strerror(setitimerError)); testingTErrorf(t, "error applying %s timeout: %s", comment, strerror(setitimerError));
@ -44,7 +44,7 @@ out:
if (setitimerError == 0) if (setitimerError == 0)
setitimer(ITIMER_REAL, &prevtimer, NULL); setitimer(ITIMER_REAL, &prevtimer, NULL);
signal(SIGALRM, prevsig); signal(SIGALRM, prevsig);
testingFreeTimerNsecString(timeoutstr); testingFreeNsecString(timeoutstr);
if (failNowOnError) if (failNowOnError)
testingTFailNow(t); testingTFailNow(t);
} }

View File

@ -47,12 +47,12 @@ int64_t testingTimerNsec(testingTimer *t)
sec = c / CLOCKS_PER_SEC; sec = c / CLOCKS_PER_SEC;
sec64 = (int64_t) sec; sec64 = (int64_t) sec;
sec64 *= testingTimerNsecPerSec; sec64 *= testingNsecPerSec;
subsec = c % CLOCKS_PER_SEC; subsec = c % CLOCKS_PER_SEC;
subsecf = (double) subsec; subsecf = (double) subsec;
subsecf /= CLOCKS_PER_SEC; subsecf /= CLOCKS_PER_SEC;
subsecf *= testingTimerNsecPerSec; subsecf *= testingNsecPerSec;
subsec64 = (int64_t) subsecf; subsec64 = (int64_t) subsecf;
return sec64 + subsec64; return sec64 + subsec64;

View File

@ -55,12 +55,12 @@ int64_t testingTimerNsec(testingTimer *t)
c = t->end.QuadPart - t->start.QuadPart; c = t->end.QuadPart - t->start.QuadPart;
sec = c / qpf.QuadPart; sec = c / qpf.QuadPart;
sec *= testingTimerNsecPerSec; sec *= testingNsecPerSec;
subsec = c % qpf.QuadPart; subsec = c % qpf.QuadPart;
subsecf = (double) subsec; subsecf = (double) subsec;
subsecf /= qpf.QuadPart; subsecf /= qpf.QuadPart;
subsecf *= testingTimerNsecPerSec; subsecf *= testingNsecPerSec;
subsec = (int64_t) subsecf; subsec = (int64_t) subsecf;
return sec + subsec; return sec + subsec;