2 * sysstat test functions.
3 * (C) 2019 by Sebastien GODARD (sysstat <at> orange.fr)
5 ***************************************************************************
6 * This program is free software; you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation; either version 2 of the License, or (at your *
9 * option) any later version. *
11 * This program is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * You should have received a copy of the GNU General Public License along *
17 * with this program; if not, write to the Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA *
19 ***************************************************************************
30 #include <sys/utsname.h>
31 #include <sys/statvfs.h>
35 time_t __unix_time = 0;
39 ***************************************************************************
40 * Test mode: Instead of reading system time, use time given on the command
44 * @t Number of seconds since the epoch, as given on the command line.
45 ***************************************************************************
48 void get_unix_time(time_t *t)
54 ***************************************************************************
55 * Test mode: Send bogus information about current kernel.
58 * @h Structure with kernel information.
59 ***************************************************************************
62 void get_uname(struct utsname *h)
64 strcpy(h->sysname, "Linux");
65 strcpy(h->nodename, "SYSSTAT.TEST");
66 strcpy(h->release, "1.2.3-TEST");
67 strcpy(h->machine, "x86_64");
71 ***************************************************************************
72 * Test mode: Send bogus information about current filesystem.
75 * @buf Structure with filesystem information.
76 ***************************************************************************
79 int get_fs_stat(char *c, struct statvfs *buf)
82 unsigned long long bfree[4] = {89739427840, 293286670336, 11696156672, 292616732672};
83 unsigned long long blocks[4] = {97891291136, 309502345216, 30829043712, 309502345216};
84 unsigned long long bavail[4] = {84722675712, 277541253120, 10106515456, 276871315456};
85 unsigned long long files[4] = {6111232, 19202048, 1921360, 19202048};
86 unsigned long long ffree[4] = {6008414, 19201593, 1621550, 19051710};
88 buf->f_bfree = bfree[p];
89 buf->f_blocks = blocks[p];
90 buf->f_bavail = bavail[p];
92 buf->f_files = files[p];
93 buf->f_ffree = ffree[p];
101 ***************************************************************************
102 * Test mode: Ignore environment variable value.
103 ***************************************************************************
106 char *get_env_value(char *c)
112 ***************************************************************************
113 * Test mode: Go to next time period.
114 ***************************************************************************
117 void next_time_step(void)
119 static int root_nr = 1;
122 __unix_time += interval;
124 if ((unlink(ROOTDIR) < 0) && (errno != ENOENT)) {
129 sprintf(rootf, "%s%d", ROOTFILE, ++root_nr);
130 if (symlink(rootf, ROOTDIR) < 0) {