summaryrefslogtreecommitdiffstats
path: root/tests/ts
diff options
context:
space:
mode:
authorKarel Zak2018-01-22 17:09:25 +0100
committerKarel Zak2018-01-22 17:09:25 +0100
commitc0b340bc9972c9484e2cfa13054c9fe0f9925931 (patch)
tree645e5616a0e3c15e91d460ae0d483b83116798de /tests/ts
parenttests: use subtests for weekarg cal(1) tests (diff)
downloadkernel-qcow2-util-linux-c0b340bc9972c9484e2cfa13054c9fe0f9925931.tar.gz
kernel-qcow2-util-linux-c0b340bc9972c9484e2cfa13054c9fe0f9925931.tar.xz
kernel-qcow2-util-linux-c0b340bc9972c9484e2cfa13054c9fe0f9925931.zip
tests: use subtests for weeknum cal(1) tests
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/ts')
-rwxr-xr-xtests/ts/cal/weeknum78
1 files changed, 23 insertions, 55 deletions
diff --git a/tests/ts/cal/weeknum b/tests/ts/cal/weeknum
index 3a8f376e6..f2aec9474 100755
--- a/tests/ts/cal/weeknum
+++ b/tests/ts/cal/weeknum
@@ -28,62 +28,30 @@ export TERM=linux
USETERM=$( ts_has_option "useterm" "$*" )
[ "$USETERM" == "yes" ] && TS_VERBOSE="yes"
-ts_log ""
-for x in 2001 2002 2003 2009 2010 2011 2012 ; do
-MYTIME="1 $x"
-
-ts_log "Gregorian - Monday-based week with week numbers - year $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -ymw $MYTIME
-fi
-$TS_CMD_CAL -ymw $MYTIME >> $TS_OUTPUT
-
-ts_log "Gregorian - Sunday-based week with week numbers - year $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -ysw $MYTIME
-fi
-$TS_CMD_CAL -ysw $MYTIME >> $TS_OUTPUT
-
-
-ts_log "Julian - Monday-based week with week numbers - year $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -ymjw $MYTIME
-fi
-$TS_CMD_CAL -ymjw $MYTIME >> $TS_OUTPUT
-
-ts_log "Julian - Sunday-based week with week numbers - year $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -ysjw $MYTIME
-fi
-$TS_CMD_CAL -ysjw $MYTIME >> $TS_OUTPUT
-
-ts_log "Gregorian - Monday-based week with week numbers - 3 month $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -3mw $MYTIME
-fi
-$TS_CMD_CAL -3mw $MYTIME >> $TS_OUTPUT
-
-ts_log "Gregorian - Sunday-based week with week numbers - 3 month $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -3sw $MYTIME
-fi
-$TS_CMD_CAL -3sw $MYTIME >> $TS_OUTPUT
-
-
-ts_log "Julian - Monday-based week with week numbers - 3 month $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -3mjw $MYTIME
-fi
-$TS_CMD_CAL -3mjw $MYTIME >> $TS_OUTPUT
-
-ts_log "Julian - Sunday-based week with week numbers - 3 month $x"
-if [ "$USETERM" == "yes" ]; then
- $TS_CMD_CAL -3sjw $MYTIME
-fi
-$TS_CMD_CAL -3sjw $MYTIME >> $TS_OUTPUT
-
-done
+function call_cal {
+ local testname=$(echo "$2" | sed 's/-//g')
+
+ ts_init_subtest "$testname"
+ ts_log "$1"
+ shift
+ for x in 2001 2002 2003 2009 2010 2011 2012 ; do
+ if [ "$USETERM" == "yes" ]; then
+ $TS_CMD_CAL "$@" 1 $x
+ fi
+ $TS_CMD_CAL "$@" 1 $x >> $TS_OUTPUT
+ done
+ ts_finalize_subtest
+}
+
+call_cal "Gregorian - Monday-based week with week numbers" -ymw
+call_cal "Gregorian - Sunday-based week with week numbers" -ysw
+call_cal "Julian - Monday-based week with week numbers" -ymjw
+call_cal "Julian - Sunday-based week with week numbers" -ysjw
+call_cal "Gregorian - Monday-based week with week number" -3mw
+call_cal "Gregorian - Sunday-based week with week numbers - 3 month" -3sw
+call_cal "Julian - Monday-based week with week numbers - 3 month" -3mjw
+call_cal "Julian - Sunday-based week with week numbers - 3 month" -3sjw
ts_finalize