diff --git a/README.md b/README.md index fa5c706..c7a7708 100644 --- a/README.md +++ b/README.md @@ -773,6 +773,23 @@ dt=2014-12-09|3065252 (2.37%) -------------------------------------------~ dt=2014-12-10|3316703 (2.57%) -----------------------------------------------~ ``` +Running Tests +============= + +The `tests` directory contains sample input and output files, as well as a +script to verify expected output based on the sample inputs. To use it, first +export an environment variable called `distribution` that points to the +location of your distribution executable. The script must be run from the `tests` +directory. For example, the following will run tests against the Perl script +and then against the Python script: + + cd tests/ + distribution=../distribution ./runTests.sh + distribution=../distribution.py ./runTests.sh + +The `runTests.sh` script takes one optional argument, `-v`. This enables +verbose mode, which prints out any differences in the stderr of the test runs, +for comparing diagnostic info. To-Do List ========== diff --git a/tests/runTests.sh b/tests/runTests.sh index 19d2753..63108d0 100755 --- a/tests/runTests.sh +++ b/tests/runTests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # make sure env is setup proper if [ "xxx$distribution" == "xxx" ] ; then @@ -6,58 +6,58 @@ if [ "xxx$distribution" == "xxx" ] ; then exit 255 fi +getopts "v" verbose + # the tests -echo "Test #6 is designed to take several seconds on a modern CPU." echo "" -echo -n "Running test: 1. " -cat input01.txt | $distribution --rcfile=../distributionrc --graph --height=35 --width=120 --char=dt --color --verbose > output001.txt 2> output101.txt - -echo -n "2. " -cat input02.txt | awk '{print $4" "$5}' | $distribution --rcfile=../distributionrc -s=med --width=110 --tokenize=word --match=word -v -c > output002.txt 2> output102.txt +printf "Running test: 1. " +cat stdin.01.txt | $distribution --rcfile=../distributionrc --graph --height=35 --width=120 --char=dt --color --verbose > stdout.01.actual.txt 2> stderr.01.actual.txt -echo -n "3. " -grep modem input02.txt | awk '{print $1}' | $distribution --rcfile=../distributionrc --width=110 -h=15 -c='|' -v -c 2> output103.txt | sort > output003.txt +printf "2. " +cat stdin.02.txt | awk '{print $4" "$5}' | $distribution --rcfile=../distributionrc -s=med --width=110 --tokenize=word --match=word -v -c > stdout.02.actual.txt 2> stderr.02.actual.txt -echo -n "4. " -cat input03.txt | $distribution --rcfile=../distributionrc --size=large --height=8 --width=60 -t=/ --palette=0,31,33,35,37 -c='()' > output004.txt 2> output104.txt +printf "3. " +grep modem stdin.02.txt | awk '{print $1}' | $distribution --rcfile=../distributionrc --width=110 -h=15 -c='|' -v -c 2> stderr.03.actual.txt | sort > stdout.03.actual.txt -echo -n "5. " -cat input03.txt | $distribution --rcfile=../distributionrc -c=pc -w=48 --tokenize=word --match=num --size=large --verbose 2> output105.txt | sort -n > output005.txt +printf "4. " +cat stdin.03.txt | $distribution --rcfile=../distributionrc --size=large --height=8 --width=60 -t=/ --palette=0,31,33,35,37 -c='()' > stdout.04.actual.txt 2> stderr.04.actual.txt -echo -n "6. " -for i in `seq 1 17 3141592` ; do echo $[ $i ^ ($i + 9) ]; done | cut -c 2-6 | $distribution --rcfile=../distributionrc --width=124 --height=29 -p=0,32,34,36,31 -c=^ -v > output006.txt 2> output106.txt +printf "5. " +cat stdin.03.txt | $distribution --rcfile=../distributionrc -c=pc -w=48 --tokenize=word --match=num --size=large --verbose 2> stderr.05.actual.txt | sort -n > stdout.05.actual.txt -echo -n "7. " -cat input04.txt | awk '{print $8}' | $distribution --rcfile=../distributionrc -s=s -w=90 --char=Ξ > output007.txt 2> output107.txt - -# get onto the newline -echo "" +printf "6. " +# generate a large list of deterministic but meaningless numbers +(( i=0 )) ; while [[ $i -lt 3141592 ]] ; do + echo $(( i ^ (i+=17) )) +done | cut -c 2-6 | $distribution --rcfile=../distributionrc --width=124 --height=29 -p=0,32,34,36,31 -c=^ -v > stdout.06.actual.txt 2> stderr.06.actual.txt -echo " -Expected output: - = b2d463a3fb20df2c01fb95b1e2006784 output001.txt - = 6e03fecd199ec6e93540fbd08afe6b94 output002.txt - = 4edb70a142774c686c9268b88a00cb01 output003.txt - = cae71e886be0ff84fe8c887ccff9c636 output004.txt - = 83332608dffc4e6692049931c9c5d5fc output005.txt - = f993d1b611f5d23fde36590717a0cbec output006.txt - = bdf7a31f8b453e9075f63b6280749021 output007.txt +printf "7. " +cat stdin.04.txt | awk '{print $8}' | $distribution --rcfile=../distributionrc -s=s -w=90 --char=Ξ > stdout.07.actual.txt 2> stderr.07.actual.txt -Actual output:" +echo "done." # be sure output is proper -for i in output0*.txt ; do - echo " = `md5sum $i`" - #echo "debug: `cat $i`" +err=0 +printf "Comparing results: " +for i in 01 02 03 04 05 06 07 ; do + printf "$i. " + diff -w stdout.$i.expected.txt stdout.$i.actual.txt + if [ $? -ne 0 ]; then + err=1 + fi + + # when in verbose mode, ignore any "runtime lines, since those may differ by + # milliseconds from machine to machine. Also ignore any lines with "^M" markers, + # which are line-erase signals used for updating the screen interactively, and + # thus don't need to be stored or compared. + if [ "$verbose" = "v" ]; then + diff -w -I "runtime:" -I " " stderr.$i.expected.txt stderr.$i.actual.txt + fi done -## # the problem with output1*.txt is they have millisecond timings which -## # will change from run to run. so filter those out then repeat... -## for i in output1*.txt ; do -## echo " = `md5sum $i`" -## #echo "debug: `cat $i`" -## done +echo "done." # clean up -rm output*.txt +rm stdout.*.actual.txt stderr.*.actual.txt +exit $err diff --git a/tests/stderr.01.expected.txt b/tests/stderr.01.expected.txt new file mode 100644 index 0000000..5e53d6f --- /dev/null +++ b/tests/stderr.01.expected.txt @@ -0,0 +1,5 @@ +tokens/lines examined: 279 + tokens/lines matched: 17,444,532 + histogram keys: 279 + runtime: 1.52ms + Key|Ct (Pct) Histogram diff --git a/tests/stderr.02.expected.txt b/tests/stderr.02.expected.txt new file mode 100644 index 0000000..438dd02 --- /dev/null +++ b/tests/stderr.02.expected.txt @@ -0,0 +1,5 @@ +tokens/lines examined: 5,480 + tokens/lines matched: 1,104 + histogram keys: 144 + runtime: 6.19ms + Key|Ct (Pct) Histogram diff --git a/tests/stderr.03.expected.txt b/tests/stderr.03.expected.txt new file mode 100644 index 0000000..13a50bc --- /dev/null +++ b/tests/stderr.03.expected.txt @@ -0,0 +1,5 @@ +tokens/lines examined: 29 + tokens/lines matched: 29 + histogram keys: 9 + runtime: 0.31ms + Key|Ct (Pct) Histogram diff --git a/tests/stderr.04.expected.txt b/tests/stderr.04.expected.txt new file mode 100644 index 0000000..fed8ee6 --- /dev/null +++ b/tests/stderr.04.expected.txt @@ -0,0 +1 @@ + Key|Ct (Pct) Histogram diff --git a/tests/stderr.05.expected.txt b/tests/stderr.05.expected.txt new file mode 100644 index 0000000..0c02a37 --- /dev/null +++ b/tests/stderr.05.expected.txt @@ -0,0 +1,5 @@ +tokens/lines examined: 1,942 + tokens/lines matched: 191 + histogram keys: 11 + runtime: 2.12ms +Key|Ct (Pct) Histogram diff --git a/tests/stderr.06.expected.txt b/tests/stderr.06.expected.txt new file mode 100644 index 0000000..3b3e503 --- /dev/null +++ b/tests/stderr.06.expected.txt @@ -0,0 +1,5 @@ +tokens/lines examined: 56,960... ; hash prunes: 0 tokens/lines examined: 113,920... ; hash prunes: 0 tokens/lines examined: 171,773... ; hash prunes: 0 tokens/lines examined: 184,800 + tokens/lines matched: 184,800 + histogram keys: 68 + runtime: 3,243.41ms +Key|Ct (Pct) Histogram diff --git a/tests/stderr.07.expected.txt b/tests/stderr.07.expected.txt new file mode 100644 index 0000000..c6f84aa --- /dev/null +++ b/tests/stderr.07.expected.txt @@ -0,0 +1 @@ + Key|Ct (Pct) Histogram diff --git a/tests/input01.txt b/tests/stdin.01.txt similarity index 100% rename from tests/input01.txt rename to tests/stdin.01.txt diff --git a/tests/input02.txt b/tests/stdin.02.txt similarity index 100% rename from tests/input02.txt rename to tests/stdin.02.txt diff --git a/tests/input03.txt b/tests/stdin.03.txt similarity index 100% rename from tests/input03.txt rename to tests/stdin.03.txt diff --git a/tests/input04.txt b/tests/stdin.04.txt similarity index 100% rename from tests/input04.txt rename to tests/stdin.04.txt diff --git a/tests/stdout.01.expected.txt b/tests/stdout.01.expected.txt new file mode 100644 index 0000000..0216b0d --- /dev/null +++ b/tests/stdout.01.expected.txt @@ -0,0 +1,35 @@ + /etc/mateconf|7780758 (44.60%) •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• + /etc/brltty|3143272 (18.02%) •••••••••••••••••••••••••••••••• + /etc/apparmor.d|1597915 (9.16%) ••••••••••••••••• +/etc/bash_completion.d|597836 (3.43%) ••••••• + /etc/mono|535352 (3.07%) •••••• + /etc/ssl|465414 (2.67%) ••••• + /etc/ardour2|362303 (2.08%) •••• + /etc/X11|226309 (1.30%) ••• + /etc/ImageMagick|202358 (1.16%) ••• + /etc/init.d|143281 (0.82%) •• + /etc/ssh|138042 (0.79%) •• + /etc/fonts|119862 (0.69%) •• + /etc/sound|112051 (0.64%) •• + /etc/xdg|111971 (0.64%) •• + /etc/java-7-openjdk|100414 (0.58%) •• + /etc/apache2|95556 (0.55%) • + /etc/ld.so.cache|92934 (0.53%) • + /etc/sane.d|71429 (0.41%) • + /etc/dbus-1|70918 (0.41%) • + /etc/init|58780 (0.34%) • + /etc/bash_completion|58753 (0.34%) • + /etc/console-setup|57645 (0.33%) • +/etc/speech-dispatcher|53500 (0.31%) • + /etc/gimp|41894 (0.24%) • + /etc/ppp|41552 (0.24%) • + /etc/apt|40810 (0.23%) • + /etc/grub.d|40058 (0.23%) • + /etc/xml|35802 (0.21%) • + /etc/gnome|33126 (0.19%) • + /etc/default|32218 (0.18%) • + /etc/wpa_supplicant|31611 (0.18%) • + /etc/cron.daily|30047 (0.17%) • + /etc/acpi|27944 (0.16%) • + /etc/vga|25081 (0.14%) • + /etc/pam.d|24963 (0.14%) • diff --git a/tests/stdout.02.expected.txt b/tests/stdout.02.expected.txt new file mode 100644 index 0000000..9bebd8a --- /dev/null +++ b/tests/stdout.02.expected.txt @@ -0,0 +1,20 @@ + info|229 (20.74%) -----------------------------------------------------------------------------------o + PM|110 (9.96%) ---------------------------------------o + pcieport|78 (7.07%) ----------------------------o + Activation|62 (5.62%) ----------------------o + INFO|44 (3.99%) ---------------o + pci|21 (1.90%) -------o +Initializing|21 (1.90%) -------o + system|16 (1.45%) -----o + fglrx|16 (1.45%) -----o + bcma|16 (1.45%) -----o + smpboot|14 (1.27%) -----o + NMI|14 (1.27%) -----o + Calibrating|14 (1.27%) -----o + CPU|14 (1.27%) -----o + Booting|14 (1.27%) -----o + on|13 (1.18%) ----o + usb|11 (1.00%) ---o + time|10 (0.91%) ---o + sd|10 (0.91%) ---o + nameserver|10 (0.91%) ---o diff --git a/tests/stdout.03.expected.txt b/tests/stdout.03.expected.txt new file mode 100644 index 0000000..9bd8370 --- /dev/null +++ b/tests/stdout.03.expected.txt @@ -0,0 +1,9 @@ +2012-01-01|3 (10.34%) ||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-02|2 (6.90%) ||||||||||||||||||||||||||||||||||| +2012-01-03|3 (10.34%) ||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-04|3 (10.34%) ||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-05|3 (10.34%) ||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-06|3 (10.34%) ||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-07|4 (13.79%) |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-08|3 (10.34%) ||||||||||||||||||||||||||||||||||||||||||||||||||||| +2012-01-09|5 (17.24%) |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| diff --git a/tests/stdout.04.expected.txt b/tests/stdout.04.expected.txt new file mode 100644 index 0000000..6e68524 --- /dev/null +++ b/tests/stdout.04.expected.txt @@ -0,0 +1,8 @@ + var|265 (27.69%) (((((((((((((((((((((((((((((((((((() + log|265 (27.69%) (((((((((((((((((((((((((((((((((((() + upstart|123 (12.85%) (((((((((((((((() + cups|11 (1.15%) () +installer|8 (0.84%) () + lightdm|7 (0.73%) ) + apache2|7 (0.73%) ) + apt|5 (0.52%) ) diff --git a/tests/stdout.05.expected.txt b/tests/stdout.05.expected.txt new file mode 100644 index 0000000..a7af6b7 --- /dev/null +++ b/tests/stdout.05.expected.txt @@ -0,0 +1,11 @@ + 0|6 (3.14%) ppppc + 1|46 (24.08%) ppppppppppppppppppppppppppppppppc + 2|27 (14.14%) ppppppppppppppppppc + 3|24 (12.57%) ppppppppppppppppc + 4|24 (12.57%) ppppppppppppppppc + 5|21 (10.99%) ppppppppppppppc + 6|21 (10.99%) ppppppppppppppc + 7|19 (9.95%) pppppppppppppc + 8|1 (0.52%) c + 9|1 (0.52%) c +10|1 (0.52%) c diff --git a/tests/stdout.06.expected.txt b/tests/stdout.06.expected.txt new file mode 100644 index 0000000..ab22a9e --- /dev/null +++ b/tests/stdout.06.expected.txt @@ -0,0 +1,29 @@ + 7|51975 (28.12%) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 9|46200 (25.00%) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 1|17327 (9.38%) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 3|14437 (7.81%) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 13|11550 (6.25%) ^^^^^^^^^^^^^^^^^^^^^^^^ + 41|5775 (3.12%) ^^^^^^^^^^^^ + 5|5774 (3.12%) ^^^^^^^^^^^^ + 15|5774 (3.12%) ^^^^^^^^^^^^ + 11|3249 (1.76%) ^^^^^^^ + 19|2888 (1.56%) ^^^^^^ + 97|2887 (1.56%) ^^^^^^ + 43|2887 (1.56%) ^^^^^^ + 99|1444 (0.78%) ^^^ + 47|1444 (0.78%) ^^^ + 39|1444 (0.78%) ^^^ + 27|1444 (0.78%) ^^^ +009|1444 (0.78%) ^^^ + 95|722 (0.39%) ^^ + 55|722 (0.39%) ^^ +033|722 (0.39%) ^^ + 03|722 (0.39%) ^^ +011|720 (0.39%) ^^ +035|362 (0.20%) ^ +015|362 (0.20%) ^ +081|361 (0.20%) ^ +007|361 (0.20%) ^ +177|184 (0.10%) ^ +083|181 (0.10%) ^ +023|181 (0.10%) ^ diff --git a/tests/stdout.07.expected.txt b/tests/stdout.07.expected.txt new file mode 100644 index 0000000..4c70f96 --- /dev/null +++ b/tests/stdout.07.expected.txt @@ -0,0 +1,10 @@ + S|113 (41.39%) ΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ + Sl|71 (26.01%) ΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ + S<|25 (9.16%) ΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞΞ + Ss+|21 (7.69%) ΞΞΞΞΞΞΞΞΞΞΞΞΞΞ + Ss|20 (7.33%) ΞΞΞΞΞΞΞΞΞΞΞΞΞ + SN|9 (3.30%) ΞΞΞΞΞΞ + Ssl|6 (2.20%) ΞΞΞΞ + Z|3 (1.10%) ΞΞ +STAT|1 (0.37%) Ξ + SNl|1 (0.37%) Ξ