rusage: Fix initialization of rusage->num_processors
Refs: #1064 Change-Id: I4c04127a766b9c71f726113b8b7d6416ff971bff
This commit is contained in:
committed by
Dominique Martinet
parent
8ff754c466
commit
a6ac4acf40
38
test/rusage/rusage104_lin.c
Normal file
38
test/rusage/rusage104_lin.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "ihklib.h"
|
||||
#include "mckernel/ihklib_rusage.h"
|
||||
#include "util.h"
|
||||
|
||||
#define DELAY0 (100UL * 1000 * 1000)
|
||||
#define DELAY1 (200UL * 1000 * 1000)
|
||||
#define SCALE 1.5
|
||||
#define WITHIN_RANGE(x, y, s) (x >= y && x <= y * s)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
struct mckernel_rusage rusage;
|
||||
|
||||
if ((ret = ihk_os_getrusage(0, &rusage, sizeof(rusage)))) {
|
||||
fprintf(stderr, "%s: ihk_os_getrusage failed\n", __func__);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
OKNG(WITHIN_RANGE(rusage.cpuacct_usage_percpu[1], DELAY0, SCALE),
|
||||
"cpu 0: user time: expected: %ld nsec, reported: %ld nsec\n",
|
||||
DELAY0, rusage.cpuacct_usage_percpu[1]);
|
||||
OKNG(WITHIN_RANGE(rusage.cpuacct_usage_percpu[2], DELAY1, SCALE),
|
||||
"cpu 1: user time: expected: %ld nsec, reported: %ld nsec\n",
|
||||
DELAY1, rusage.cpuacct_usage_percpu[2]);
|
||||
|
||||
printf("All tests finished\n");
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user