forked from sysstat/sysstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
systest.h
108 lines (95 loc) · 2.48 KB
/
systest.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* sysstat: System performance tools for Linux
* (C) 1999-2021 by Sebastien Godard (sysstat <at> orange.fr)
*/
#ifndef _SYSTEST_H
#define _SYSTEST_H
#include <time.h>
#include <dirent.h>
#include <sys/utsname.h>
#include <sys/statvfs.h>
#include <sys/stat.h>
#ifndef MINORBITS
#define MINORBITS 20
#endif
#define S_MAXMINOR ((1U << MINORBITS) - 1)
#define S_MAXMAJOR ((1U << (32 - MINORBITS)) - 1)
/* Test mode: Use alternate files and syscalls */
#ifdef TEST
#define PRE "./tests/root"
#define __time(m) get_unix_time(m)
#define __uname(m) get_uname(m)
#define __statvfs(m,n) get_fs_stat(m,n)
#define __getenv(m) get_env_value(m)
#define __alarm(m)
#define __pause() next_time_step()
#define __stat(m,n) virtual_stat(m,n)
#define __opendir(m) open_list(m)
#define __readdir(m) read_list(m)
#define __closedir(m) close_list(m)
#define __realpath(m,n) get_realname(m,n)
#define __gettimeofday(m,n) get_day_time(m)
#define __getpwuid(m) get_usrname(m)
#define __fork(m) get_known_pid(m)
#define __major(m) (m >> MINORBITS)
#define __minor(m) (m & S_MAXMINOR)
#define ROOTDIR "./tests/root"
#define ROOTFILE "root"
#define TESTDIR "./tests"
#define VIRTUALHD "./tests/root/dev/mapper/virtualhd"
#define _LIST "_list"
#else
#define PRE ""
#define __time(m) time(m)
#define __uname(m) uname(m)
#define __statvfs(m,n) statvfs(m,n)
#define __getenv(m) getenv(m)
#define __alarm(m) alarm(m)
#define __pause() pause()
#define __stat(m,n) stat(m,n)
#define __opendir(m) opendir(m)
#define __readdir(m) readdir(m)
#define __closedir(m) closedir(m)
#define __realpath(m,n) realpath(m,n)
#define __gettimeofday(m,n) gettimeofday(m,n)
#define __getpwuid(m) getpwuid(m)
#define __fork(m) fork(m)
#define __major(m) major(m)
#define __minor(m) minor(m)
#endif /* TEST */
/*
***************************************************************************
* Functions prototypes
***************************************************************************
*/
#ifdef TEST
void close_list
(DIR *);
void get_day_time
(struct timeval *);
char *get_env_value
(const char *);
int get_fs_stat
(char *, struct statvfs *);
pid_t get_known_pid
(void);
char *get_realname
(char *, char *);
void get_uname
(struct utsname *);
time_t get_unix_time
(time_t *);
struct passwd *get_usrname
(uid_t);
void next_time_step
(void);
DIR *open_list
(const char *);
struct dirent *read_list
(DIR *);
int virtual_stat
(const char *, struct stat *);
void int_handler
(int);
#endif /* TEST */
#endif /* _SYSTEST_H */