From: Sebastien GODARD Date: Sun, 2 Jun 2019 14:04:32 +0000 (+0200) Subject: Add/update non regression tests X-Git-Tag: v12.1.6~45 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce1d2a57de01b999663d9503a75ae041d9b038ff;p=sysstat Add/update non regression tests Signed-off-by: Sebastien GODARD --- diff --git a/.gitignore b/.gitignore index f5c0952..42ed565 100644 --- a/.gitignore +++ b/.gitignore @@ -49,13 +49,5 @@ core 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 diff --git a/Makefile.in b/Makefile.in index 7cb8224..d51a6f8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -624,8 +624,7 @@ almost-distclean: clean nls/sysstat.pot 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 diff --git a/cifsiostat.c b/cifsiostat.c index ccc854c..936f95c 100644 --- a/cifsiostat.c +++ b/cifsiostat.c @@ -46,6 +46,10 @@ 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; diff --git a/configure b/configure index c10afd6..630f406 100755 --- a/configure +++ b/configure @@ -5600,23 +5600,7 @@ ac_config_files="$ac_config_files man/iostat.1:man/iostat.in" # 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" @@ -6350,15 +6334,7 @@ do "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;; diff --git a/configure.in b/configure.in index 9108284..48b9a31 100644 --- a/configure.in +++ b/configure.in @@ -635,15 +635,7 @@ AC_CONFIG_FILES([man/sar.1:man/sar.in]) # File must be renamed 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) diff --git a/iostat.c b/iostat.c index 42353e6..897104e 100644 --- a/iostat.c +++ b/iostat.c @@ -1921,7 +1921,7 @@ void rw_io_stat_loop(long int count, struct tm *rectime, int iodev_nr, int dlist if (count) { curr ^= 1; - pause(); + __pause(); if (sigint_caught) { /* SIGINT signal caught => Terminate JSON output properly */ diff --git a/mpstat.c b/mpstat.c index 69f26c1..163f2bc 100644 --- a/mpstat.c +++ b/mpstat.c @@ -1884,7 +1884,7 @@ void rw_mpstat_loop(int dis_hdr, int rows) int_act.sa_handler = int_handler; sigaction(SIGINT, &int_act, NULL); - pause(); + __pause(); if (sigint_caught) /* SIGINT signal caught during first interval: Exit immediately */ @@ -1938,7 +1938,7 @@ void rw_mpstat_loop(int dis_hdr, int rows) if (count) { - pause(); + __pause(); if (sigint_caught) { /* SIGINT signal caught => Display average stats */ diff --git a/pidstat.c b/pidstat.c index 64e6d9f..04d1d61 100644 --- a/pidstat.c +++ b/pidstat.c @@ -52,6 +52,10 @@ 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}; diff --git a/sadf.c b/sadf.c index 2785846..2b35c42 100644 --- a/sadf.c +++ b/sadf.c @@ -48,6 +48,10 @@ 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 */ diff --git a/systest.c b/systest.c index 974455d..9b1a6ed 100644 --- a/systest.c +++ b/systest.c @@ -34,6 +34,7 @@ time_t __unix_time = 0; extern long interval; +extern int sigint_caught; /* *************************************************************************** @@ -117,7 +118,7 @@ char *get_env_value(char *c) void next_time_step(void) { static int root_nr = 1; - char rootf[64]; + char rootf[64], testf[64]; __unix_time += interval; @@ -127,6 +128,15 @@ void next_time_step(void) } 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); diff --git a/systest.h b/systest.h index fd4e70e..dce18b2 100644 --- a/systest.h +++ b/systest.h @@ -23,6 +23,7 @@ #define ROOTDIR "./tests/root" #define ROOTFILE "root" +#define TESTDIR "./tests" #else @@ -54,6 +55,9 @@ void get_unix_time (time_t *); void next_time_step (); + +void int_handler + (int); #endif #endif /* _SYSTEST_H */ diff --git a/tapestat.c b/tapestat.c index a8ea460..56620a4 100644 --- a/tapestat.c +++ b/tapestat.c @@ -64,6 +64,10 @@ 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 */ diff --git a/tests/00300.in b/tests/00300 similarity index 90% rename from tests/00300.in rename to tests/00300 index 55bf8bf..7338efe 100644 --- a/tests/00300.in +++ b/tests/00300 @@ -1,4 +1,4 @@ -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 diff --git a/tests/00310.in b/tests/00310 similarity index 79% rename from tests/00310.in rename to tests/00310 index 3d33e1b..392d257 100644 --- a/tests/00310.in +++ b/tests/00310 @@ -1,4 +1,4 @@ -VER_JSON=@VER_JSON@ +. tests/variables if [ ! -z "$VER_JSON" ]; then ./mpstat -A -o JSON | $VER_JSON >/dev/null; fi diff --git a/tests/00320.in b/tests/00320 similarity index 80% rename from tests/00320.in rename to tests/00320 index be66771..b143089 100644 --- a/tests/00320.in +++ b/tests/00320 @@ -1,4 +1,4 @@ -VER_JSON=@VER_JSON@ +. tests/variables if [ ! -z "$VER_JSON" ]; then ./iostat -t -p ALL -o JSON | $VER_JSON >/dev/null; fi diff --git a/tests/00330 b/tests/00330 new file mode 100644 index 0000000..8ebccf6 --- /dev/null +++ b/tests/00330 @@ -0,0 +1,8 @@ +. 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 diff --git a/tests/00340 b/tests/00340 new file mode 100644 index 0000000..77c75fa --- /dev/null +++ b/tests/00340 @@ -0,0 +1,8 @@ +. 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 diff --git a/tests/00400.in b/tests/00400 similarity index 93% rename from tests/00400.in rename to tests/00400 index 5779ca6..cd1bfae 100644 --- a/tests/00400.in +++ b/tests/00400 @@ -1,4 +1,4 @@ -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 diff --git a/tests/00410.in b/tests/00410 similarity index 94% rename from tests/00410.in rename to tests/00410 index 2c3b241..9ac3ecc 100644 --- a/tests/00410.in +++ b/tests/00410 @@ -1,4 +1,4 @@ -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 diff --git a/tests/01130.in b/tests/01130 similarity index 81% rename from tests/01130.in rename to tests/01130 index 1f577ca..60640a4 100644 --- a/tests/01130.in +++ b/tests/01130 @@ -1,4 +1,4 @@ -VER_JSON=@VER_JSON@ +. tests/variables if [ ! -z "$VER_JSON" ]; then ./sadf -j tests/data0.tmp -- -A | $VER_JSON >/dev/null; fi diff --git a/tests/01230.in b/tests/01230 similarity index 81% rename from tests/01230.in rename to tests/01230 index 1f577ca..60640a4 100644 --- a/tests/01230.in +++ b/tests/01230 @@ -1,4 +1,4 @@ -VER_JSON=@VER_JSON@ +. tests/variables if [ ! -z "$VER_JSON" ]; then ./sadf -j tests/data0.tmp -- -A | $VER_JSON >/dev/null; fi diff --git a/tests/01380 b/tests/01380 new file mode 100644 index 0000000..d0f57b1 --- /dev/null +++ b/tests/01380 @@ -0,0 +1,5 @@ +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 diff --git a/tests/01382 b/tests/01382 new file mode 100644 index 0000000..f5ce0ed --- /dev/null +++ b/tests/01382 @@ -0,0 +1 @@ +LC_ALL=C TZ=GMT ./sar -f tests/sa-sigint.tmp -m CPU > tests/out.sar-sigint.tmp diff --git a/tests/01385 b/tests/01385 new file mode 100644 index 0000000..fea0c2a --- /dev/null +++ b/tests/01385 @@ -0,0 +1 @@ +diff -u tests/out.sar-sigint.tmp tests/expected.sar-sigint diff --git a/tests/TLIST b/tests/TLIST index 544597f..f4acd66 100644 --- a/tests/TLIST +++ b/tests/TLIST @@ -34,6 +34,10 @@ 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 @@ -162,6 +166,10 @@ [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 diff --git a/tests/expected.sar-sigint b/tests/expected.sar-sigint new file mode 100644 index 0000000..cbb56d8 --- /dev/null +++ b/tests/expected.sar-sigint @@ -0,0 +1,10 @@ +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 diff --git a/tests/out.sar-sigint b/tests/out.sar-sigint new file mode 100644 index 0000000..f6e8909 Binary files /dev/null and b/tests/out.sar-sigint differ diff --git a/tests/rt00010.in b/tests/rt00010 similarity index 87% rename from tests/rt00010.in rename to tests/rt00010 index a8adb59..17f7a78 100644 --- a/tests/rt00010.in +++ b/tests/rt00010 @@ -1,4 +1,4 @@ -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 diff --git a/tests/rt00020.in b/tests/rt00020 similarity index 86% rename from tests/rt00020.in rename to tests/rt00020 index 5dc0e7d..f69f68b 100644 --- a/tests/rt00020.in +++ b/tests/rt00020 @@ -1,4 +1,4 @@ -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 diff --git a/tests/variables.in b/tests/variables.in new file mode 100644 index 0000000..a8cf53f --- /dev/null +++ b/tests/variables.in @@ -0,0 +1,2 @@ +VER_JSON=@VER_JSON@ +VER_XML=@VER_XML@