Skip to content

Commit

Permalink
Add/update non regression tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien GODARD <[email protected]>
  • Loading branch information
sysstat committed Jun 2, 2019
1 parent 1d636d5 commit ce1d2a5
Show file tree
Hide file tree
Showing 30 changed files with 91 additions and 59 deletions.
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cifsiostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 2 additions & 26 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;;
Expand Down
10 changes: 1 addition & 9 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion iostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions mpstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 4 additions & 0 deletions pidstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 4 additions & 0 deletions sadf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 11 additions & 1 deletion systest.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

time_t __unix_time = 0;
extern long interval;
extern int sigint_caught;

/*
***************************************************************************
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions systest.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#define ROOTDIR "./tests/root"
#define ROOTFILE "root"
#define TESTDIR "./tests"

#else

Expand Down Expand Up @@ -54,6 +55,9 @@ void get_unix_time
(time_t *);
void next_time_step
();

void int_handler
(int);
#endif

#endif /* _SYSTEST_H */
4 changes: 4 additions & 0 deletions tapestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion tests/00300.in → tests/00300
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/00310.in → tests/00310
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VER_JSON=@VER_JSON@
. tests/variables
if [ ! -z "$VER_JSON" ]; then
./mpstat -A -o JSON | $VER_JSON >/dev/null;
fi
2 changes: 1 addition & 1 deletion tests/00320.in → tests/00320
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/00330
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/00340
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/00400.in → tests/00400
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/00410.in → tests/00410
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/01130.in → tests/01130
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/01230.in → tests/01230
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/01380
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/01382
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LC_ALL=C TZ=GMT ./sar -f tests/sa-sigint.tmp -m CPU > tests/out.sar-sigint.tmp
1 change: 1 addition & 0 deletions tests/01385
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
diff -u tests/out.sar-sigint.tmp tests/expected.sar-sigint
8 changes: 8 additions & 0 deletions tests/TLIST
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/expected.sar-sigint
Original file line number Diff line number Diff line change
@@ -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
Binary file added tests/out.sar-sigint
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/rt00010.in → tests/rt00010
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/rt00020.in → tests/rt00020
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions tests/variables.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VER_JSON=@VER_JSON@
VER_XML=@VER_XML@

0 comments on commit ce1d2a5

Please sign in to comment.