TAGS
nls/*.gmo
tests/*.tmp
-tests/00300
-tests/00310
-tests/00320
-tests/00400
-tests/00410
-tests/01130
-tests/01230
-tests/rt00010
-tests/rt00020
tests/sa[012]*
+tests/variables
rm -f cron/sysstat-collect.service cron/sysstat-collect.timer cron/sysstat-summary.service cron/sysstat-summary.timer
rm -f cron/sysstat.cron.hourly cron/sysstat.crond.sample cron/sysstat.crond.sample.in
rm -f man/sa1.8 man/sa2.8 man/sadc.8 man/sadf.1 man/sar.1 man/iostat.1 man/sysstat.5
- rm -f tests/00300 tests/00310 tests/00320 tests/00400 tests/00410 tests/01130 tests/01230
- rm -f tests/rt00010 tests/rt00020
+ rm -f tests/variables
rm -f man/cifsiostat.1
rm -f *.log config.status
rm -rf autom4te.cache
char *sccsid(void) { return (SCCSID); }
#endif
+#ifdef TEST
+void int_handler(int n) { return; }
+#endif
+
unsigned long long uptime_cs[2] = {0, 0};
struct cifs_stats *st_cifs[2];
struct io_hdr_stats *st_hdr_cifs;
# File must be renamed
ac_config_files="$ac_config_files man/cifsiostat.1:man/cifsiostat.in"
# File must be renamed
-ac_config_files="$ac_config_files tests/00300"
-
-ac_config_files="$ac_config_files tests/00310"
-
-ac_config_files="$ac_config_files tests/00320"
-
-ac_config_files="$ac_config_files tests/00400"
-
-ac_config_files="$ac_config_files tests/00410"
-
-ac_config_files="$ac_config_files tests/01130"
-
-ac_config_files="$ac_config_files tests/01230"
-
-ac_config_files="$ac_config_files tests/rt00010"
-
-ac_config_files="$ac_config_files tests/rt00020"
+ac_config_files="$ac_config_files tests/variables"
ac_config_files="$ac_config_files Makefile"
"man/sysstat.5") CONFIG_FILES="$CONFIG_FILES man/sysstat.5:man/sysstat.in" ;;
"man/iostat.1") CONFIG_FILES="$CONFIG_FILES man/iostat.1:man/iostat.in" ;;
"man/cifsiostat.1") CONFIG_FILES="$CONFIG_FILES man/cifsiostat.1:man/cifsiostat.in" ;;
- "tests/00300") CONFIG_FILES="$CONFIG_FILES tests/00300" ;;
- "tests/00310") CONFIG_FILES="$CONFIG_FILES tests/00310" ;;
- "tests/00320") CONFIG_FILES="$CONFIG_FILES tests/00320" ;;
- "tests/00400") CONFIG_FILES="$CONFIG_FILES tests/00400" ;;
- "tests/00410") CONFIG_FILES="$CONFIG_FILES tests/00410" ;;
- "tests/01130") CONFIG_FILES="$CONFIG_FILES tests/01130" ;;
- "tests/01230") CONFIG_FILES="$CONFIG_FILES tests/01230" ;;
- "tests/rt00010") CONFIG_FILES="$CONFIG_FILES tests/rt00010" ;;
- "tests/rt00020") CONFIG_FILES="$CONFIG_FILES tests/rt00020" ;;
+ "tests/variables") CONFIG_FILES="$CONFIG_FILES tests/variables" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
AC_CONFIG_FILES([man/sysstat.5:man/sysstat.in]) # File must be renamed
AC_CONFIG_FILES([man/iostat.1:man/iostat.in]) # File must be renamed
AC_CONFIG_FILES([man/cifsiostat.1:man/cifsiostat.in]) # File must be renamed
-AC_CONFIG_FILES([tests/00300])
-AC_CONFIG_FILES([tests/00310])
-AC_CONFIG_FILES([tests/00320])
-AC_CONFIG_FILES([tests/00400])
-AC_CONFIG_FILES([tests/00410])
-AC_CONFIG_FILES([tests/01130])
-AC_CONFIG_FILES([tests/01230])
-AC_CONFIG_FILES([tests/rt00010])
-AC_CONFIG_FILES([tests/rt00020])
+AC_CONFIG_FILES([tests/variables])
AC_OUTPUT(Makefile)
if (count) {
curr ^= 1;
- pause();
+ __pause();
if (sigint_caught) {
/* SIGINT signal caught => Terminate JSON output properly */
int_act.sa_handler = int_handler;
sigaction(SIGINT, &int_act, NULL);
- pause();
+ __pause();
if (sigint_caught)
/* SIGINT signal caught during first interval: Exit immediately */
if (count) {
- pause();
+ __pause();
if (sigint_caught) {
/* SIGINT signal caught => Display average stats */
char *sccsid(void) { return (SCCSID); }
#endif
+#ifdef TEST
+void int_handler(int n) { return; }
+#endif
+
unsigned long long tot_jiffies[3] = {0, 0, 0};
unsigned long long uptime_cs[3] = {0, 0, 0};
struct pid_stats *st_pid_list[3] = {NULL, NULL, NULL};
char *sccsid(void) { return (SCCSID); }
#endif
+#ifdef TEST
+void int_handler(int n) { return; }
+#endif
+
long interval = -1, count = 0;
/* TRUE if data read from file don't match current machine's endianness */
time_t __unix_time = 0;
extern long interval;
+extern int sigint_caught;
/*
***************************************************************************
void next_time_step(void)
{
static int root_nr = 1;
- char rootf[64];
+ char rootf[64], testf[64];
__unix_time += interval;
}
sprintf(rootf, "%s%d", ROOTFILE, ++root_nr);
+ sprintf(testf, "%s/%s", TESTDIR, rootf);
+ if (access(testf, F_OK) < 0) {
+ if (errno = ENOENT) {
+ /* No more kernel directories: Simulate a Ctrl/C */
+ int_handler(0);
+ return ;
+ }
+ }
+
if (symlink(rootf, ROOTDIR) < 0) {
perror("link");
exit(1);
#define ROOTDIR "./tests/root"
#define ROOTFILE "root"
+#define TESTDIR "./tests"
#else
(time_t *);
void next_time_step
();
+
+void int_handler
+ (int);
#endif
#endif /* _SYSTEST_H */
char *sccsid(void) { return (SCCSID); }
#endif
+#ifdef TEST
+void int_handler(int n) { return; }
+#endif
+
int cpu_nr = 0; /* Nb of processors on the machine */
int flags = 0; /* Flag for common options and system state */
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./sadf -j tests/data.tmp -C -- -A | $VER_JSON >/dev/null && ./sadf -j tests/data.tmp | $VER_JSON >/dev/null && ./sadf -t -j tests/data.tmp | $VER_JSON >/dev/null;
fi
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./mpstat -A -o JSON | $VER_JSON >/dev/null;
fi
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./iostat -t -p ALL -o JSON | $VER_JSON >/dev/null;
fi
--- /dev/null
+. tests/variables
+if [ ! -z "$VER_JSON" ]; then
+ rm -f tests/root
+ ln -s root1 tests/root
+ ./mpstat -o JSON 1 10 | $VER_JSON >/dev/null;
+fi
+rm -f tests/root
+ln -s root1 tests/root
--- /dev/null
+. tests/variables
+if [ ! -z "$VER_JSON" ]; then
+ rm -f tests/root
+ ln -s root1 tests/root
+ ./iostat -p ALL -o JSON 1 10 | $VER_JSON >/dev/null;
+fi
+rm -f tests/root
+ln -s root1 tests/root
-VER_XML=@VER_XML@
+. tests/variables
if [ ! -z "$VER_XML" ]; then
./sadf -x tests/data.tmp -C -- -A | $VER_XML --schema xml/sysstat.xsd - >/dev/null && ./sadf -x tests/data.tmp | $VER_XML --schema xml/sysstat.xsd - >/dev/null && ./sadf -T -x tests/data.tmp | $VER_XML --schema xml/sysstat.xsd - >/dev/null;
fi
-VER_XML=@VER_XML@
+. tests/variables
if [ ! -z "$VER_XML" ]; then
./sadf -x tests/data.tmp -C -- -A | $VER_XML --dtdvalid xml/sysstat-*.dtd - >/dev/null && ./sadf -x tests/data.tmp | $VER_XML --dtdvalid xml/sysstat-*.dtd - >/dev/null && ./sadf -t -x tests/data.tmp | $VER_XML --dtdvalid xml/sysstat-*.dtd - >/dev/null;
fi
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./sadf -j tests/data0.tmp -- -A | $VER_JSON >/dev/null;
fi
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./sadf -j tests/data0.tmp -- -A | $VER_JSON >/dev/null;
fi
--- /dev/null
+rm -f tests/root
+ln -s root1 tests/root
+LC_ALL=C TZ=GMT ./sar --unix_time=1556755203 -o tests/sa-sigint.tmp 1 10 > /dev/null
+rm -f tests/root
+ln -s root1 tests/root
--- /dev/null
+LC_ALL=C TZ=GMT ./sar -f tests/sa-sigint.tmp -m CPU > tests/out.sar-sigint.tmp
--- /dev/null
+diff -u tests/out.sar-sigint.tmp tests/expected.sar-sigint
00300 ./sadf -j tests/data.tmp -C -- -A | $VER_JSON >/dev/null && ./sadf -j tests/data.tmp | $VER_JSON >/dev/null && ./sadf -t -j tests/data.tmp | $VER_JSON >/dev/null
00310 ./mpstat -A -o JSON | $VER_JSON >/dev/null
00320 ./iostat -t -p ALL -o JSON | $VER_JSON >/dev/null
+00330 ./mpstat -o JSON 1 10 | $VER_JSON >/dev/null;
+ [Simulate a Ctrl/C within mpstat]
+00340 ./iostat -p ALL -o JSON 1 10 | $VER_JSON >/dev/null;
+ [Simulate a Ctrl/C within iostat]
===== Checking XML output validity
00400 ./sadf -x tests/data.tmp -C -- -A | $VER_XML --schema xml/sysstat.xsd - >/dev/null && ./sadf -x tests/data.tmp | $VER_XML --schema xml/sysstat.xsd - >/dev/null && ./sadf -T -x tests/data.tmp | $VER_XML --schema xml/sysstat.xsd - >/dev/null
[Create datafile sa20190502]
01372 LC_ALL=C TZ=GMT ./sar -f tests/sa20190502 > tests/out.sar-D.tmp
01375 diff -u tests/out.sar-D.tmp tests/expected.sar-D
+01380 LC_ALL=C TZ=GMT ./sar --unix_time=1556755203 -o tests/sa-sigint.tmp 1 10 > /dev/null
+ [Create binary datafile sa-sigint.tmp. Stop with a simulated Ctrl/C]
+01382 LC_ALL=C TZ=GMT ./sar -f tests/sa-sigint.tmp -m CPU > tests/out.sar-sigint.tmp
+01385 diff -u tests/out.sar-sigint.tmp tests/expected.sar-sigint
===== Testing error cases
01400 LC_ALL=C TZ=GMT ./sar -f tests/data-trunc 2>&1 | grep "End of system activity file unexpected" >/dev/null
--- /dev/null
+Linux 1.2.3-TEST (SYSSTAT.TEST) 05/02/19 _x86_64_ (8 CPU)
+
+00:00:03 CPU MHz
+00:00:04 all 3522.54
+00:00:05 all 3522.54
+00:00:06 all 3522.54
+00:00:07 all 3522.54
+00:00:08 all 3517.54
+00:00:09 all 3517.54
+Average: all 3520.87
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./iostat -y 1 1 -o JSON -p ALL ALL -xt | $VER_JSON >/dev/null && ./iostat 1 1 -o JSON | $VER_JSON >/dev/null;
fi
-VER_JSON=@VER_JSON@
+. tests/variables
if [ ! -z "$VER_JSON" ]; then
./mpstat 1 1 -o JSON | $VER_JSON >/dev/null && ./mpstat -A 1 1 -o JSON | $VER_JSON >/dev/null;
fi
--- /dev/null
+VER_JSON=@VER_JSON@
+VER_XML=@VER_XML@