tests/01230
tests/rt00010
tests/rt00020
-tests/sa01
+tests/sa0[12]
tests/sa19700101
clean:
rm -f sadc sar sadf iostat tapestat mpstat pidstat cifsiostat *.o *.a core TAGS tests/*.tmp
rm -f nfsiostat* man/nfsiostat*
- rm -f tests/sa01 tests/19700101
+ rm -f tests/sa0[12] tests/19700101
find nls -name "*.gmo" -exec rm -f {} \;
almost-distclean: clean nls/sysstat.pot
#!/bin/sh
+if [ "$1" = "comp" ]
+then
+ make CFLAGS="-D DEBUG -D TEST"
+fi
if [ "$1" = "all" ] || [ "$1" = "simtest" ]
then
make distclean
*/
void alarm_handler(int sig)
{
- alarm(interval);
+ __alarm(interval);
}
/*
if (count) {
/* Wait for a signal (probably SIGALRM or SIGINT) */
- pause();
+ __pause();
}
if (sigint_caught)
memset(&alrm_act, 0, sizeof(alrm_act));
alrm_act.sa_handler = alarm_handler;
sigaction(SIGALRM, &alrm_act, NULL);
- alarm(interval);
+ __alarm(interval);
/* Main loop */
rw_sa_stat_loop(count, stdfd, ofd, ofile, sa_dir);
char *sccsid(void) { return (SCCSID); }
#endif
+#ifdef TEST
+extern time_t __unix_time;
+#endif
+
/* Interval and count parameters */
long interval = -1, count = 0;
}
}
+#ifdef TEST
+ else if (!strncmp(argv[opt], "--unix_time=", 12)) {
+ if (strspn(argv[opt] + 12, DIGITS) != strlen(argv[opt] + 12)) {
+ usage(argv[0]);
+ }
+ __unix_time = atoll(argv[opt++] + 12);
+ }
+#endif
else if ((strlen(argv[opt]) > 1) &&
(strlen(argv[opt]) < 4) &&
!strncmp(argv[opt], "-", 1) &&
#ifdef TEST
+#include <stdio.h>
#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
#include <time.h>
+#include <unistd.h>
#include <sys/utsname.h>
#include <sys/statvfs.h>
#include "systest.h"
time_t __unix_time = 0;
+extern long interval;
/*
***************************************************************************
return NULL;
}
+/*
+ ***************************************************************************
+ * Test mode: Go to next time period.
+ ***************************************************************************
+ */
+
+void next_time_step(void)
+{
+ static int root_nr = 1;
+ char rootf[64];
+
+ __unix_time += interval;
+
+ if ((unlink(ROOTDIR) < 0) && (errno != ENOENT)) {
+ perror("unlink");
+ exit(1);
+ }
+
+ sprintf(rootf, "%s%d", ROOTFILE, ++root_nr);
+ if (symlink(rootf, ROOTDIR) < 0) {
+ perror("link");
+ exit(1);
+ }
+}
+
#endif /* TEST */
#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 ROOTDIR "./tests/root"
+#define ROOTFILE "root"
#else
#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()
#endif
(struct utsname *);
void get_unix_time
(time_t *);
+void next_time_step
+ ();
#endif
#endif /* _SYSTEST_H */
--- /dev/null
+./sadf -d -s 13:20:20 -e 13:20:40 --iface=enp6s1 --dev=sda --fs=/dev/sda6 tests/data.tmp -- -n DEV -Fdp > tests/out.sadf-se.tmp
--- /dev/null
+diff -u tests/out.sadf-se.tmp tests/expected.sadf-se
--- /dev/null
+LC_ALL=C TZ=GMT ./sar -f tests/data-cd -s 23:59:58 -e 00:00:00 > tests/out.sar-cd.tmp
--- /dev/null
+diff -u tests/out.sar-cd.tmp tests/expected.sar-cd
--- /dev/null
+LC_ALL=C TZ=GMT ./sar -f tests/data.tmp -e 13:30 -z -n DEV -dp > tests/out.sar-z.tmp
--- /dev/null
+diff -u tests/out.sar-z.tmp tests/expected.sar-z
--- /dev/null
+rm -f tests/sa01 tests/sa02 tests/root
+ln -s root1 tests/root
+TZ=GMT ./sadc --unix_time=1556755199 - 1 3
--- /dev/null
+LC_ALL=C TZ=GMT ./sar -f tests/sa01 > tests/out33.sar-u.tmp
+LC_ALL=C TZ=GMT ./sar -f tests/sa02 >> tests/out33.sar-u.tmp
--- /dev/null
+diff -u tests/out33.sar-u.tmp tests/expected33.sar-u
--- /dev/null
+LC_ALL=C TZ=GMT ./sar --unix_time=1556755203 -1 > tests/out.sar-1.tmp
--- /dev/null
+diff -u tests/out.sar-1.tmp tests/expected.sar-1
00561 diff -u tests/out.sadf-H.tmp tests/expected.sadf-H
00570 ./sadf -r -O debug tests/data.tmp -C -- -A > tests/out.sadf-r.tmp
00571 diff -u tests/out.sadf-r.tmp tests/expected.sadf-r
+00580 ./sadf -d -s 13:20:20 -e 13:20:40 --iface=enp6s0 --dev=sda --fs=/dev/sda6 tests/data.tmp -- -n DEV -Fdp > tests/out.sadf-se.tmp
+00582 diff -u tests/out.sadf-se.tmp tests/expected.sadf-se
===== Checking sadf conversion
00600 ./sadf -c tests/data-9.1.6 > tests/data-9.1.6.tmp
[WARNING: /proc/uptime files are not consistent with unix_time values used. Don't trust timestamps!]
00900 LC_ALL=C TZ=GMT ./sar -h -j UUID -f tests/data.tmp > tests/out.sar-jUUID.tmp
00902 diff -u tests/out.sar-jUUID.tmp tests/expected.sar-jUUID
+00910 LC_ALL=C TZ=GMT ./sar -f tests/data-cd -s 23:59:58 -e 00:00:00 > tests/out.sar-cd.tmp
+ [Testing options -s/-e on a file contents spanning two consecutive days]
+ [Work only with very simple file contents (no LINUX RESTART or COMMENT records)]
+00912 diff -u tests/out.sar-cd.tmp tests/expected.sar-cd
+00920 LC_ALL=C TZ=GMT ./sar -f tests/data.tmp -e 13:30 -z -n DEV -dp > > tests/out.sar-z.tmp
+00922 diff -u tests/out.sar-z.tmp tests/expected.sar-z
===== Creating data0.tmp with no data inside
01000 ./sadc --unix_time=1555593609 -S A_NULL,A_PCSW tests/data0.tmp >/dev/null
01337 diff -u tests/out33.sar-u.tmp tests/expected32.sar-u
01340 ./sadf > tests/out3.sadf.tmp
01342 diff -u tests/out3.sadf.tmp tests/expected3.sadf
+01350 TZ=GMT ./sadc --unix_time=1556755199 - 1 3
+ [Create sa01 and sa02 - Timestamp can be obtained with: date +%s --date='Wed May 1 23:59:59 CEST 2019']
+01352 LC_ALL=C TZ=GMT ./sar -f tests/sa01 > tests/out33.sar-u.tmp; LC_ALL=C TZ=GMT ./sar -f tests/sa02 >> tests/out33.sar-u.tmp
+01355 diff -u tests/out33.sar-u.tmp tests/expected33.sar-u
+01360 LC_ALL=C TZ=GMT ./sar --unix_time=1556755203 -1 > tests/out.sar-1.tmp
+ [Go to day 02 and try to read sa01]
+01362 diff -u tests/out.sar-1.tmp tests/expected.sar-1
--- /dev/null
+# hostname;interval;timestamp;DEV;tps;rkB/s;wkB/s;dkB/s;areq-sz;aqu-sz;await;%util
+SYSSTAT.TEST;39;2019-04-18 13:20:39 UTC;sda;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
+# hostname;interval;timestamp;IFACE;rxpck/s;txpck/s;rxkB/s;txkB/s;rxcmp/s;txcmp/s;rxmcst/s;%ifutil
+SYSSTAT.TEST;39;2019-04-18 13:20:39 UTC;enp6s1;1.90;1.17;0.23;0.21;0.00;0.00;2.31;0.00
+# hostname;interval;timestamp;FILESYSTEM;MBfsfree;MBfsused;%fsused;%ufsused;Ifree;Iused;%Iused
+SYSSTAT.TEST;39;2019-04-18 13:20:39 UTC;/dev/sda6;85582;7774;8.33;13.45;6008414;102818;1.68
--- /dev/null
+Linux 1.2.3-TEST (SYSSTAT.TEST) 05/01/19 _x86_64_ (8 CPU)
+
+23:59:59 CPU %user %nice %system %iowait %steal %idle
+00:00:00 all 2.15 12.50 2.36 0.12 0.00 82.88
+Average: all 2.15 12.50 2.36 0.12 0.00 82.88
--- /dev/null
+Linux 1.2.3-TEST (SYSSTAT.TEST) 05/01/19 _x86_64_ (8 CPU)
+
+23:59:58 CPU %user %nice %system %iowait %steal %idle
+23:59:59 all 2.28 0.00 1.93 0.50 0.00 95.29
+00:00:00 all 2.66 23.20 2.27 0.16 0.00 71.71
+Average: all 2.52 14.28 2.14 0.29 0.00 80.78
--- /dev/null
+Linux 1.2.3-TEST (SYSSTAT.TEST) 04/18/19 _x86_64_ (8 CPU)
+
+13:20:09 DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util
+
+13:20:19 DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util
+13:20:29 sdb 0.67 22.60 0.00 0.00 33.62 0.10 47.00 0.05
+
+13:20:29 DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util
+13:20:39 sdf 1.22 54.34 0.00 0.00 44.51 0.08 62.51 0.09
+13:20:39 sdg 2.91 114.91 0.31 0.00 39.61 0.07 24.75 0.19
+
+13:20:39 DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util
+13:20:49 sdg 0.94 22.33 0.22 0.00 24.05 0.04 6.19 0.09
+
+Average: DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util
+Average: sdf 0.38 16.97 0.00 0.00 44.51 0.02 62.51 0.03
+Average: sdg 1.08 39.94 0.14 0.00 37.15 0.03 21.82 0.08
+
+13:20:09 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
+
+13:20:19 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
+13:20:29 enp6s0 53.55 17.45 64.37 3.38 0.00 0.00 9.25 0.05
+
+13:20:29 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
+13:20:39 enp6s1 1.90 1.17 0.23 0.21 0.00 0.00 2.31 0.00
+13:20:39 wlp5s1 0.39 0.13 0.03 0.01 0.00 0.00 0.00 0.00
+
+13:20:39 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
+13:20:49 virbr0-nic 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
+13:20:49 enp6s0 7397.68 2412.77 8891.46 466.82 0.00 0.00 116.21 7.28
+
+Average: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil
+Average: enp6s1 0.59 0.36 0.07 0.06 0.00 0.00 0.72 0.00
+Average: wlp5s1 0.12 0.04 0.01 0.00 0.00 0.00 0.00 0.00
--- /dev/null
+Linux 1.2.3-TEST (SYSSTAT.TEST) 05/01/19 _x86_64_ (8 CPU)
+
+23:59:59 CPU %user %nice %system %iowait %steal %idle
+00:00:00 all 2.15 12.50 2.36 0.12 0.00 82.88
+Average: all 2.15 12.50 2.36 0.12 0.00 82.88
+Linux 1.2.3-TEST (SYSSTAT.TEST) 05/02/19 _x86_64_ (8 CPU)
+
+00:00:00 CPU %user %nice %system %iowait %steal %idle
+00:00:01 all 2.28 0.00 1.93 0.50 0.00 95.29
+Average: all 2.28 0.00 1.93 0.50 0.00 95.29