From: Martin Quinson Date: Wed, 30 Sep 2015 19:21:12 +0000 (+0200) Subject: [tesh] greatly normalize the self-tests X-Git-Tag: v3_12~93 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fc241a7adb2fd271db60b7aba6c94ea863eb3c34 [tesh] greatly normalize the self-tests Things should remain unsurprizing when there is no need for a surprise --- diff --git a/tools/cmake/AddTests.cmake b/tools/cmake/AddTests.cmake index 166aec8046..1679d57d6c 100644 --- a/tools/cmake/AddTests.cmake +++ b/tools/cmake/AddTests.cmake @@ -65,23 +65,23 @@ ENABLE_TESTING() IF(NOT enable_memcheck) ## CORE ## ### TESH ### - ADD_TESH(tesh-self-basic --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/basic.tesh) - ADD_TESH(tesh-self-cd --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/cd.tesh) - ADD_TESH(tesh-self-setenv --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/setenv.tesh) - ADD_TESH(tesh-self-IO-broken-pipe --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-broken-pipe.tesh) - ADD_TESH(tesh-self-IO-orders --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-orders.tesh) - ADD_TESH(tesh-self-IO-bigsize --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-bigsize.tesh) - ADD_TESH(tesh-self-set-return --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-return.tesh) - ADD_TESH(tesh-self-set-timeout --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-timeout.tesh) - ADD_TESH(tesh-self-set-output-ignore --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-output-ignore.tesh) - ADD_TESH(tesh-self-set-output-sort --setenv bindir=${CMAKE_BINARY_DIR}/bin --cd "${CMAKE_HOME_DIRECTORY}/tools/tesh" set-output-sort.tesh) - ADD_TESH(tesh-self-catch-return --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-return.tesh) - ADD_TESH(tesh-self-catch-timeout --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-timeout.tesh) - ADD_TESH(tesh-self-catch-wrong-output --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-wrong-output.tesh) - ADD_TESH(tesh-self-bg-basic --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/bg-basic.tesh) - ADD_TESH(tesh-self-background --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/background.tesh) - ADD_TESH(tesh-self-bg-set-signal --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/bg-set-signal.tesh) - ADD_TESH(tesh-self-catch-signal --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-signal.tesh) + ADD_TESH(tesh-self-basic --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/basic.tesh) + ADD_TESH(tesh-self-cd --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/cd.tesh) + ADD_TESH(tesh-self-setenv --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/setenv.tesh) + ADD_TESH(tesh-self-IO-broken-pipe --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-broken-pipe.tesh) + ADD_TESH(tesh-self-IO-orders --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-orders.tesh) + ADD_TESH(tesh-self-IO-bigsize --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/IO-bigsize.tesh) + ADD_TESH(tesh-self-set-return --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-return.tesh) + ADD_TESH(tesh-self-set-timeout --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-timeout.tesh) + ADD_TESH(tesh-self-set-output-ignore --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-output-ignore.tesh) + ADD_TESH(tesh-self-set-output-sort --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/set-output-sort.tesh) + ADD_TESH(tesh-self-catch-return --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-return.tesh) + ADD_TESH(tesh-self-catch-timeout --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-timeout.tesh) + ADD_TESH(tesh-self-catch-wrong-output --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-wrong-output.tesh) + ADD_TESH(tesh-self-bg-basic --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/bg-basic.tesh) + ADD_TESH(tesh-self-background --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/background.tesh) + ADD_TESH(tesh-self-bg-set-signal --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/bg-set-signal.tesh) + ADD_TESH(tesh-self-catch-signal --setenv bindir=${CMAKE_BINARY_DIR}/bin ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-signal.tesh) ### GENERIC ### # BEGIN TESH TESTS diff --git a/tools/tesh/IO-orders.tesh b/tools/tesh/IO-orders.tesh index 2b30132e57..e2c0a25d71 100644 --- a/tools/tesh/IO-orders.tesh +++ b/tools/tesh/IO-orders.tesh @@ -5,58 +5,52 @@ p Order: in, out, cmd < < TOTO < > TOTO < $ cat -> Enable coverage > Test suite from stdin > [(stdin):3] cat > Test suite from stdin OK -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh p Order: out, in, cmd < > TOTO < < TOTO < $ cat -> Enable coverage > Test suite from stdin > [(stdin):3] cat > Test suite from stdin OK -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh p Order: out, cmd, in < > TOTO < $ cat < < TOTO -> Enable coverage > Test suite from stdin > [(stdin):2] cat > Test suite from stdin OK -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh p Order: in, cmd, out < < TOTO < $ cat < > TOTO -> Enable coverage > Test suite from stdin > [(stdin):2] cat > Test suite from stdin OK -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh p Order: cmd, out, in < $ cat < > TOTO < < TOTO -> Enable coverage > Test suite from stdin > [(stdin):1] cat > Test suite from stdin OK -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh p Order: cmd, in, out < $ cat < < TOTO < > TOTO -> Enable coverage > Test suite from stdin > [(stdin):1] cat > Test suite from stdin OK -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh diff --git a/tools/tesh/basic.tesh b/tools/tesh/basic.tesh index 32289af536..db3d8f7e1e 100644 --- a/tools/tesh/basic.tesh +++ b/tools/tesh/basic.tesh @@ -13,7 +13,7 @@ $ cat tmp_fich ! output ignore < $ cat tmp_fich < > TUTU TOTO -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh $ rm tmp_fich @@ -77,14 +77,14 @@ $ sed 's/_/ /' < < _x < $ sed 's/_/ /' < > x -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh ! expect return 2 ! output ignore < < x < $ cat < > x -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh p * trailing spaces... < x_ @@ -96,14 +96,14 @@ $ sed 's/_/ /' < < x_ < $ sed 's/_/ /' < > x -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh ! expect return 2 ! output ignore < < x < $ cat < > x -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh p * empty lines... < a @@ -122,7 +122,7 @@ $ cat < $ cat < > a < > c -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh ! expect return 2 ! output ignore @@ -132,7 +132,7 @@ $ ${bindir:=.}/tesh --enable-coverage < > a < > < > c -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh < < b @@ -150,7 +150,7 @@ $ cat < $ cat < > b < > c -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh ! expect return 2 ! output ignore @@ -160,4 +160,4 @@ $ ${bindir:=.}/tesh --enable-coverage < > < > b < > c -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh diff --git a/tools/tesh/catch-return.tesh b/tools/tesh/catch-return.tesh index 210d6607a7..f14d15bc16 100644 --- a/tools/tesh/catch-return.tesh +++ b/tools/tesh/catch-return.tesh @@ -4,7 +4,7 @@ ! expect return 41 < $ perl -e "exit 1" -$ ./tesh +$ ${bindir:=.}/tesh > Test suite from stdin > [(stdin):1] perl -e "exit 1" > Test suite `(stdin)': NOK (<(stdin):1> returned code 1) diff --git a/tools/tesh/catch-signal.tesh b/tools/tesh/catch-signal.tesh index 8229a7a377..552c580445 100644 --- a/tools/tesh/catch-signal.tesh +++ b/tools/tesh/catch-signal.tesh @@ -16,8 +16,7 @@ $ perl segfault.pl p Check that we return the expected return value on SEGV ! expect return 15 < $ perl segfault.pl -$ ../tesh --enable-coverage -> Enable coverage +$ ${bindir:=.}/tesh > Test suite from stdin > [(stdin):1] perl segfault.pl > Test suite `(stdin)': NOK (<(stdin):1> got signal SIGSEGV) diff --git a/tools/tesh/catch-timeout.tesh b/tools/tesh/catch-timeout.tesh index ace1b5017d..305997eb2d 100644 --- a/tools/tesh/catch-timeout.tesh +++ b/tools/tesh/catch-timeout.tesh @@ -6,10 +6,9 @@ ! expect return 3 < ! timeout 1 < $ sleep 6 -> Enable coverage > Test suite from stdin > [(stdin):2] sleep 6 > <(stdin):2> timeouted. Kill the process. > Test suite `(stdin)': NOK (<(stdin):2> timeout after 1 sec) > <(stdin):2> No output so far. -$ ./tesh --enable-coverage +$ ${bindir:=.}/tesh diff --git a/tools/tesh/catch-wrong-output.tesh b/tools/tesh/catch-wrong-output.tesh index aa57175b32..6273a9b828 100644 --- a/tools/tesh/catch-wrong-output.tesh +++ b/tools/tesh/catch-wrong-output.tesh @@ -6,8 +6,7 @@ p This tests whether TESH detects wrong outputs < > TOTO < < TUTU < $ cat -$ ./tesh --enable-coverage -> Enable coverage +$ ${bindir:=.}/tesh > Test suite from stdin > [(stdin):3] cat > Output of <(stdin):3> mismatch: diff --git a/tools/tesh/cd.tesh b/tools/tesh/cd.tesh index eccf0b605d..6a9ce2dacd 100644 --- a/tools/tesh/cd.tesh +++ b/tools/tesh/cd.tesh @@ -12,11 +12,10 @@ $ ls # Check that tesh detects properly cd to non-existing directories ! expect return 4 < $ cd toto -> Enable coverage > Test suite from stdin > Chdir to toto failed: No such file or directory > Test suite `(stdin)': NOK (system error) -$ ../tesh --enable-coverage +$ ${bindir:=.}/tesh # The next command checks that there is a testdir_temp-cd in the upper directory, # ie that mkdir and cd both worked. diff --git a/tools/tesh/set-output-ignore.tesh b/tools/tesh/set-output-ignore.tesh index 492d963834..04da086a7a 100644 --- a/tools/tesh/set-output-ignore.tesh +++ b/tools/tesh/set-output-ignore.tesh @@ -6,8 +6,7 @@ p This tests whether TESH accepts to ignore command output < > TOTO < < TUTU < $ cat -$ ./tesh --enable-coverage -> Enable coverage +$ ${bindir:=.}/tesh > Test suite from stdin > [(stdin):4] cat > (ignoring the output of <(stdin):4> as requested) diff --git a/tools/tesh/set-output-sort-1.tesh b/tools/tesh/set-output-sort-1.tesh deleted file mode 100644 index c009b4a718..0000000000 --- a/tools/tesh/set-output-sort-1.tesh +++ /dev/null @@ -1,68 +0,0 @@ -p Test sorting and filtering of output - -$ true - -! output sort -$ true - -$ printf 'profiling: foo\\n' - -$ printf 'profiling: foo' - -! output sort -$ printf 'profiling: foo\\n' - -! output sort -$ printf 'profiling: foo' - -$ printf 'a\\nb\\nc\\nd\\n' -> a -> b -> c -> d - -$ printf 'a\\nb\\nc\\nd' -> a -> b -> c -> d - -! output sort -$ printf 'c\\nd\\nb\\na\\n' -> a -> b -> c -> d - -! output sort -$ printf 'c\\nd\\nb\\na' -> a -> b -> c -> d - -$ printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz\\n' -> a -> b -> c -> d - -$ printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz' -> a -> b -> c -> d - -! output sort -$ printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz\\n' -> a -> b -> c -> d - -! output sort -$ printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz' -> a -> b -> c -> d diff --git a/tools/tesh/set-output-sort.tesh b/tools/tesh/set-output-sort.tesh index f459286681..d5888ad142 100644 --- a/tools/tesh/set-output-sort.tesh +++ b/tools/tesh/set-output-sort.tesh @@ -2,25 +2,93 @@ p This tests whether TESH correctly sorts command output -$ ${bindir:=.}/tesh --enable-coverage set-output-sort-1.tesh +< p Test sorting and filtering of output +< +< $ true +< +< ! output sort +< $ true +< +< $ printf 'profiling: foo\\n' +< +< $ printf 'profiling: foo' +< +< ! output sort +< $ printf 'profiling: foo\\n' +< +< ! output sort +< $ printf 'profiling: foo' +< +< $ printf 'a\\nb\\nc\\nd\\n' +< > a +< > b +< > c +< > d +< +< $ printf 'a\\nb\\nc\\nd' +< > a +< > b +< > c +< > d +< +< ! output sort +< $ printf 'c\\nd\\nb\\na\\n' +< > a +< > b +< > c +< > d +< +< ! output sort +< $ printf 'c\\nd\\nb\\na' +< > a +< > b +< > c +< > d +< +< $ printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz\\n' +< > a +< > b +< > c +< > d +< +< $ printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz' +< > a +< > b +< > c +< > d +< +< ! output sort +< $ printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz\\n' +< > a +< > b +< > c +< > d +< +< ! output sort +< $ printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz' +< > a +< > b +< > c +< > d +$ ${bindir:=.}/tesh --enable-coverage > Enable coverage -> Test suite `set-output-sort-1' -> [set-output-sort-1:1] Test sorting and filtering of output -> [set-output-sort-1:3] true -> [set-output-sort-1:6] true -> [set-output-sort-1:8] printf 'profiling: foo\\n' -> [set-output-sort-1:10] printf 'profiling: foo' -> [set-output-sort-1:13] printf 'profiling: foo\\n' -> [set-output-sort-1:16] printf 'profiling: foo' -> [set-output-sort-1:18] printf 'a\\nb\\nc\\nd\\n' -> [set-output-sort-1:24] printf 'a\\nb\\nc\\nd' -> [set-output-sort-1:31] printf 'c\\nd\\nb\\na\\n' -> [set-output-sort-1:38] printf 'c\\nd\\nb\\na' -> [set-output-sort-1:44] printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz\\n' -> [set-output-sort-1:50] printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz' -> [set-output-sort-1:57] printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz\\n' -> [set-output-sort-1:64] printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz' -> Test suite `set-output-sort-1' OK +> Test suite from stdin +> [(stdin):1] Test sorting and filtering of output +> [(stdin):3] true +> [(stdin):6] true +> [(stdin):8] printf 'profiling: foo\\n' +> [(stdin):10] printf 'profiling: foo' +> [(stdin):13] printf 'profiling: foo\\n' +> [(stdin):16] printf 'profiling: foo' +> [(stdin):18] printf 'a\\nb\\nc\\nd\\n' +> [(stdin):24] printf 'a\\nb\\nc\\nd' +> [(stdin):31] printf 'c\\nd\\nb\\na\\n' +> [(stdin):38] printf 'c\\nd\\nb\\na' +> [(stdin):44] printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz\\n' +> [(stdin):50] printf 'a\\nprofiling: foo\\nprofiling: bar\\nb\\nc\\nd\\nprofiling: baz' +> [(stdin):57] printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz\\n' +> [(stdin):64] printf 'c\\nprofiling: foo\\nprofiling: bar\\nd\\nb\\na\\nprofiling: baz' +> Test suite from stdin OK p Check the Right Prefix Length (19) for "output sort" ! output sort 19 @@ -45,7 +113,7 @@ $ cat < $ cat < > 123456789012345678 A line < > 123456789012345678 B line -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh p Check user-defined prefix length for "output sort" ! output sort 5 @@ -70,4 +138,4 @@ $ cat < $ cat < > 000 A line < > 000 B line -$ ${bindir:=.}/tesh --enable-coverage +$ ${bindir:=.}/tesh