]> granicus.if.org Git - sysstat/commitdiff
Add/update non regression tests
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 2 Jun 2019 14:04:32 +0000 (16:04 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 2 Jun 2019 14:04:32 +0000 (16:04 +0200)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
30 files changed:
.gitignore
Makefile.in
cifsiostat.c
configure
configure.in
iostat.c
mpstat.c
pidstat.c
sadf.c
systest.c
systest.h
tapestat.c
tests/00300 [moved from tests/00300.in with 90% similarity]
tests/00310 [moved from tests/00310.in with 79% similarity]
tests/00320 [moved from tests/00320.in with 80% similarity]
tests/00330 [new file with mode: 0644]
tests/00340 [new file with mode: 0644]
tests/00400 [moved from tests/00400.in with 93% similarity]
tests/00410 [moved from tests/00410.in with 94% similarity]
tests/01130 [moved from tests/01130.in with 81% similarity]
tests/01230 [moved from tests/01230.in with 81% similarity]
tests/01380 [new file with mode: 0644]
tests/01382 [new file with mode: 0644]
tests/01385 [new file with mode: 0644]
tests/TLIST
tests/expected.sar-sigint [new file with mode: 0644]
tests/out.sar-sigint [new file with mode: 0644]
tests/rt00010 [moved from tests/rt00010.in with 87% similarity]
tests/rt00020 [moved from tests/rt00020.in with 86% similarity]
tests/variables.in [new file with mode: 0644]

index f5c0952d3e46d10c2039c9f32b96660e15a49045..42ed56532da641282ec92815ef088032fa06e148 100644 (file)
@@ -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
index 7cb8224bf3cb15f62a93b69ba302d136444804bd..d51a6f84772b7c99554a0b45c7a3d3e8e3d8ab93 100644 (file)
@@ -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
index ccc854c98992ead3262eebabff4986921e1c7c9b..936f95c83ead90e68a571cdbd9a1c6209dc8f059 100644 (file)
 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;
index c10afd6710f503ff1470e1dfbe69c0762da27fc3..630f406152157b7d43ed4725c70930e44eb01b52 100755 (executable)
--- 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;;
index 910828407872db0ffb5c72d86cce5d614273db86..48b9a31687b9f29d47823369cb986815a1ffc800 100644 (file)
@@ -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)
 
index 42353e63b656b4c966d7f7b3a80d42cb275c735e..897104ec3d0dc67fb708fbe930e633382e7e1164 100644 (file)
--- 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 */
index 69f26c145be4793dfe68bd980f1559b6f279189b..163f2bc639364c51fe1db8860ca8533e5e8f58eb 100644 (file)
--- 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 */
index 64e6d9ff3f8b9300122b191b803a15e734321711..04d1d6195fe6d07aa9affc26c1006f9bdb57946f 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
 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 278584669512432807eca6d17c2276da0f573a78..2b35c423e4268a861477222b7abb72a9222a7637 100644 (file)
--- a/sadf.c
+++ b/sadf.c
 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 */
index 974455d0eef5dc3d3bca58c933a1773e74f7d6ab..9b1a6edefedeba9c91b02d26ea3e7f00d7b7764f 100644 (file)
--- 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);
index fd4e70ee98fe1a505a5a70825f31fe9154f17a47..dce18b2eccfa02d3acdb50cf1394bf526660ad1e 100644 (file)
--- 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 */
index a8ea46086928b2a89b0ee6ba35f2532cca35b14c..56620a44b230b2dfe8698e0497c729a51da7127e 100644 (file)
 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 */
 
similarity index 90%
rename from tests/00300.in
rename to tests/00300
index 55bf8bf95a014593d2b61a9b16255fc7ef321740..7338efe6d9c3dd80063e4c580d6e84e2e652c5eb 100644 (file)
@@ -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
similarity index 79%
rename from tests/00310.in
rename to tests/00310
index 3d33e1bda475cd8f3e2599a021b4060f2665c400..392d257256f417ae45ebebcbb1b4503574ee8f57 100644 (file)
@@ -1,4 +1,4 @@
-VER_JSON=@VER_JSON@
+. tests/variables
 if [ ! -z "$VER_JSON" ]; then
        ./mpstat -A -o JSON | $VER_JSON >/dev/null;
 fi
similarity index 80%
rename from tests/00320.in
rename to tests/00320
index be6677172d1bc272bbf8568d66072e626e59a69f..b1430894cb16b604ae3f82100e5b805d9bd7572f 100644 (file)
@@ -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 (file)
index 0000000..8ebccf6
--- /dev/null
@@ -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 (file)
index 0000000..77c75fa
--- /dev/null
@@ -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
similarity index 93%
rename from tests/00400.in
rename to tests/00400
index 5779ca646425903eaccfd57035b046e7fc63ae29..cd1bfae229d4eb27f5911d177c6d2ed7a6c08b35 100644 (file)
@@ -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
similarity index 94%
rename from tests/00410.in
rename to tests/00410
index 2c3b241d6d522c71a24ee33262a445496a6d9311..9ac3ecc41606ef7f840e1c3c4d9895a324ce777e 100644 (file)
@@ -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
similarity index 81%
rename from tests/01130.in
rename to tests/01130
index 1f577ca350ac248070e7c7e8a5b72351992a6b58..60640a4158b05ff09bd55a834312a199631fac32 100644 (file)
@@ -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
similarity index 81%
rename from tests/01230.in
rename to tests/01230
index 1f577ca350ac248070e7c7e8a5b72351992a6b58..60640a4158b05ff09bd55a834312a199631fac32 100644 (file)
@@ -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 (file)
index 0000000..d0f57b1
--- /dev/null
@@ -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 (file)
index 0000000..f5ce0ed
--- /dev/null
@@ -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 (file)
index 0000000..fea0c2a
--- /dev/null
@@ -0,0 +1 @@
+diff -u tests/out.sar-sigint.tmp tests/expected.sar-sigint
index 544597f09aa604ea5e9e594c9f3c481e31211b66..f4acd66ebb04fc222b2ed9d54d42a73d7020df01 100644 (file)
 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
diff --git a/tests/expected.sar-sigint b/tests/expected.sar-sigint
new file mode 100644 (file)
index 0000000..cbb56d8
--- /dev/null
@@ -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 (file)
index 0000000..f6e8909
Binary files /dev/null and b/tests/out.sar-sigint differ
similarity index 87%
rename from tests/rt00010.in
rename to tests/rt00010
index a8adb590750fc52b2d6c3e4389f93742d9f0811a..17f7a78ad74f123fb1cea78022d3ef72a76b82f9 100644 (file)
@@ -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
similarity index 86%
rename from tests/rt00020.in
rename to tests/rt00020
index 5dc0e7d584216bcc30451e106e3d37390be82181..f69f68bcd49749b15064c279ecb3ebf2e383787f 100644 (file)
@@ -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 (file)
index 0000000..a8cf53f
--- /dev/null
@@ -0,0 +1,2 @@
+VER_JSON=@VER_JSON@
+VER_XML=@VER_XML@