diff options
author | Karel Zak | 2014-06-16 14:37:39 +0200 |
---|---|---|
committer | Karel Zak | 2014-06-16 14:37:39 +0200 |
commit | 9123621450b4e16a3a5e3e2c94692d41c6b8e856 (patch) | |
tree | 79d66630172930413684f2118ec22d634dc378c3 | |
parent | Merge branch 'gettext-version' of https://github.com/rudimeier/util-linux (diff) | |
parent | tests: skip some last tests if no dns support (diff) | |
download | kernel-qcow2-util-linux-9123621450b4e16a3a5e3e2c94692d41c6b8e856.tar.gz kernel-qcow2-util-linux-9123621450b4e16a3a5e3e2c94692d41c6b8e856.tar.xz kernel-qcow2-util-linux-9123621450b4e16a3a5e3e2c94692d41c6b8e856.zip |
Merge branch 'tests-utmp' of https://github.com/rudimeier/util-linux
* 'tests-utmp' of https://github.com/rudimeier/util-linux:
tests: skip some last tests if no dns support
tests: split last into dns and nodns subtests
tests: add utmpdump-circle test (arch independent)
tests: provide missing test data for "last" on exotic archs
tests: skip utmpdump tests for exotic archs
tests: merge last/ and utmpdump/ into new utmp/ dir
utmpdump: fix localtime() error handling
-rw-r--r-- | login-utils/utmpdump.c | 5 | ||||
-rw-r--r-- | tests/expected/last/ipv6 | 20 | ||||
-rw-r--r-- | tests/expected/utmp/last-dns | 12 | ||||
-rw-r--r-- | tests/expected/utmp/last-ipv6-dns | 12 | ||||
-rw-r--r-- | tests/expected/utmp/last-ipv6-nodns | 8 | ||||
-rw-r--r-- | tests/expected/utmp/last-nodns (renamed from tests/expected/last/last) | 32 | ||||
-rw-r--r-- | tests/expected/utmp/utmpdump-circle | 1 | ||||
-rw-r--r-- | tests/expected/utmp/utmpdump-tobin (renamed from tests/expected/utmpdump/ipv6tobin) | 0 | ||||
-rw-r--r-- | tests/expected/utmp/utmpdump-tobin-ipv6 (renamed from tests/expected/utmpdump/to-binary) | 0 | ||||
-rw-r--r-- | tests/expected/utmp/utmpdump-totxt (renamed from tests/expected/utmpdump/to-text) | 0 | ||||
-rw-r--r-- | tests/expected/utmp/utmpdump-totxt-ipv6 (renamed from tests/expected/utmpdump/ipv6totxt) | 0 | ||||
-rw-r--r-- | tests/functions.sh | 17 | ||||
-rwxr-xr-x | tests/ts/hwclock/systohc | 20 | ||||
-rwxr-xr-x | tests/ts/utmp/last (renamed from tests/ts/last/last) | 32 | ||||
-rwxr-xr-x | tests/ts/utmp/last-ipv6 (renamed from tests/ts/last/ipv6) | 22 | ||||
-rw-r--r-- | tests/ts/utmp/txt-a | 19 | ||||
-rw-r--r-- | tests/ts/utmp/txt-b (renamed from tests/ts/utmpdump/text) | 0 | ||||
-rw-r--r-- | tests/ts/utmp/txt-ipv6 (renamed from tests/ts/utmpdump/ipv6txt) | 4 | ||||
-rw-r--r-- | tests/ts/utmp/utmp_functions.sh | 18 | ||||
-rwxr-xr-x | tests/ts/utmp/utmpdump-circle | 42 | ||||
-rwxr-xr-x | tests/ts/utmp/utmpdump-tobin (renamed from tests/ts/utmpdump/to-binary) | 11 | ||||
-rwxr-xr-x | tests/ts/utmp/utmpdump-tobin-ipv6 (renamed from tests/ts/utmpdump/ipv6tobin) | 9 | ||||
-rwxr-xr-x | tests/ts/utmp/utmpdump-totxt (renamed from tests/ts/utmpdump/to-text) | 9 | ||||
-rwxr-xr-x | tests/ts/utmp/utmpdump-totxt-ipv6 (renamed from tests/ts/utmpdump/ipv6totxt) | 7 | ||||
-rw-r--r-- | tests/ts/utmp/wtmp-a.BE (renamed from tests/ts/last/wtmp.BE) | bin | 7296 -> 7296 bytes | |||
-rw-r--r-- | tests/ts/utmp/wtmp-a.LE (renamed from tests/ts/last/wtmp.LE) | bin | 7296 -> 7296 bytes | |||
-rw-r--r-- | tests/ts/utmp/wtmp-b.BE (renamed from tests/ts/utmpdump/binary.BE) | bin | 3840 -> 3840 bytes | |||
-rw-r--r-- | tests/ts/utmp/wtmp-b.LE (renamed from tests/ts/utmpdump/binary.LE) | bin | 3840 -> 3840 bytes | |||
-rw-r--r-- | tests/ts/utmp/wtmp-ipv6.BE (renamed from tests/ts/last/ipv6-input.BE) | bin | 768 -> 768 bytes | |||
-rw-r--r-- | tests/ts/utmp/wtmp-ipv6.LE (renamed from tests/ts/last/ipv6-input.LE) | bin | 768 -> 768 bytes | |||
-rw-r--r-- | tests/ts/utmpdump/ipv6bin.BE | bin | 768 -> 0 bytes | |||
-rw-r--r-- | tests/ts/utmpdump/ipv6bin.LE | bin | 768 -> 0 bytes |
32 files changed, 202 insertions, 98 deletions
diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index 7611c9f0a..e1fefc63e 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -48,9 +48,10 @@ static char *timetostr(const time_t time) { static char s[29]; /* [Sun Sep 01 00:00:00 1998 PST] */ + struct tm *tmp; - if (time != 0) - strftime(s, 29, "%a %b %d %T %Y %Z", localtime(&time)); + if (time != 0 && (tmp = localtime(&time))) + strftime(s, 29, "%a %b %d %T %Y %Z", tmp); else s[0] = '\0'; diff --git a/tests/expected/last/ipv6 b/tests/expected/last/ipv6 deleted file mode 100644 index 0fa234c1f..000000000 --- a/tests/expected/last/ipv6 +++ /dev/null @@ -1,20 +0,0 @@ -~~~ dns short ~~~ -IPv6 root a.root-servers.n Wed Aug 28 20:30 - 20:40 (00:10) - -ipv6-input begins Wed Aug 28 20:30:40 2013 -~~~ dns long ~~~ -IPv6 root a.root-servers.net Wed Aug 28 20:30 - 20:40 (00:10) - -ipv6-input begins Wed Aug 28 20:30:40 2013 -~~~ dns host last ~~~ -IPv6 root Wed Aug 28 20:30 - 20:40 (00:10) a.root-servers.net - -ipv6-input begins Wed Aug 28 20:30:40 2013 -~~~ show ip ~~~ -IPv6 root 2001:503:ba3e::2 Wed Aug 28 20:30 - 20:40 (00:10) - -ipv6-input begins Wed Aug 28 20:30:40 2013 -~~~ show ip last ~~~ -IPv6 root Wed Aug 28 20:30 - 20:40 (00:10) 2001:503:ba3e::2:30 - -ipv6-input begins Wed Aug 28 20:30:40 2013 diff --git a/tests/expected/utmp/last-dns b/tests/expected/utmp/last-dns new file mode 100644 index 000000000..34012c7f1 --- /dev/null +++ b/tests/expected/utmp/last-dns @@ -0,0 +1,12 @@ +~~~ dns short ~~~ +IPv4 root a.root-servers.n Wed Aug 28 13:00 - 14:00 (01:00) + +wtmp-a begins Wed Aug 28 03:00:00 2013 +~~~ dns long ~~~ +IPv4 root a.root-servers.net Wed Aug 28 13:00 - 14:00 (01:00) + +wtmp-a begins Wed Aug 28 03:00:00 2013 +~~~ dns host last ~~~ +IPv4 root Wed Aug 28 13:00 - 14:00 (01:00) a.root-servers.net + +wtmp-a begins Wed Aug 28 03:00:00 2013 diff --git a/tests/expected/utmp/last-ipv6-dns b/tests/expected/utmp/last-ipv6-dns new file mode 100644 index 000000000..aa53a6451 --- /dev/null +++ b/tests/expected/utmp/last-ipv6-dns @@ -0,0 +1,12 @@ +~~~ dns short ~~~ +IPv6 root a.root-servers.n Wed Aug 28 20:30 - 20:40 (00:10) + +wtmp-ipv6 begins Wed Aug 28 20:30:40 2013 +~~~ dns long ~~~ +IPv6 root a.root-servers.net Wed Aug 28 20:30 - 20:40 (00:10) + +wtmp-ipv6 begins Wed Aug 28 20:30:40 2013 +~~~ dns host last ~~~ +IPv6 root Wed Aug 28 20:30 - 20:40 (00:10) a.root-servers.net + +wtmp-ipv6 begins Wed Aug 28 20:30:40 2013 diff --git a/tests/expected/utmp/last-ipv6-nodns b/tests/expected/utmp/last-ipv6-nodns new file mode 100644 index 000000000..65d422a45 --- /dev/null +++ b/tests/expected/utmp/last-ipv6-nodns @@ -0,0 +1,8 @@ +~~~ show ip ~~~ +IPv6 root 2001:503:ba3e::2 Wed Aug 28 20:30 - 20:40 (00:10) + +wtmp-ipv6 begins Wed Aug 28 20:30:40 2013 +~~~ show ip last ~~~ +IPv6 root Wed Aug 28 20:30 - 20:40 (00:10) 2001:503:ba3e::2:30 + +wtmp-ipv6 begins Wed Aug 28 20:30:40 2013 diff --git a/tests/expected/last/last b/tests/expected/utmp/last-nodns index 4172e8697..cb7cfde09 100644 --- a/tests/expected/last/last +++ b/tests/expected/utmp/last-nodns @@ -14,7 +14,7 @@ login foo six Wed Aug 28 06:00 - 07:00 (01:00) user_pro foo seven Wed Aug 28 05:00 - 06:00 (01:00) accounti foo nine Wed Aug 28 03:00 - 04:00 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ include system ~~~ rick long never-gonna-logo Thu Jan 1 00:00 - 03:14 (24855+03:14) torvalds linux hobby Mon Aug 26 00:57 gone - no logout @@ -33,27 +33,15 @@ login foo six Wed Aug 28 06:00 - 07:00 (01:00) user_pro foo seven Wed Aug 28 05:00 - 06:00 (01:00) accounti foo nine Wed Aug 28 03:00 - 04:00 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 -~~~ dns short ~~~ -IPv4 root a.root-servers.n Wed Aug 28 13:00 - 14:00 (01:00) - -wtmp begins Wed Aug 28 03:00:00 2013 -~~~ dns long ~~~ -IPv4 root a.root-servers.net Wed Aug 28 13:00 - 14:00 (01:00) - -wtmp begins Wed Aug 28 03:00:00 2013 -~~~ dns host last ~~~ -IPv4 root Wed Aug 28 13:00 - 14:00 (01:00) a.root-servers.net - -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ show ip ~~~ torvalds linux 128.214.205.14 Mon Aug 26 00:57 gone - no logout -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ no host ~~~ torvalds linux Mon Aug 26 00:57 gone - no logout -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ full times shortopt ~~~ rick long never-gonna-logo Thu Jan 1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14) torvalds linux hobby Mon Aug 26 00:57:08 1991 gone - no logout @@ -70,7 +58,7 @@ login foo six Wed Aug 28 06:00:00 2013 - Wed Aug 28 07: user_pro foo seven Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013 (01:00) accounti foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ full times longopt ~~~ rick long never-gonna-logo Thu Jan 1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14) torvalds linux hobby Mon Aug 26 00:57:08 1991 gone - no logout @@ -87,7 +75,7 @@ login foo six Wed Aug 28 06:00:00 2013 - Wed Aug 28 07: user_pro foo seven Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013 (01:00) accounti foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ no time ~~~ rick long never-gonna-logo (24855+03:14) torvalds linux hobby no logout @@ -104,7 +92,7 @@ login foo six (01:00) user_pro foo seven (01:00) accounti foo nine (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ iso-8601 time ~~~ rick long never-gonna-logout 1970-01-01T00:00:00+0000 - 2038-01-19T03:14:07+0000 (24855+03:14) torvalds linux hobby 1991-08-26T00:57:08+0000 gone - no logout @@ -121,7 +109,7 @@ login foo six 2013-08-28T06:00:00+0000 - 2013-08-28T07: user_process foo seven 2013-08-28T05:00:00+0000 - 2013-08-28T06:00:00+0000 (01:00) accounting foo nine 2013-08-28T03:00:00+0000 - 2013-08-28T04:00:00+0000 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ since and until ~~~ oldtime foo four Wed Aug 28 08:00 gone - no logout init foo five Wed Aug 28 07:00 - 08:00 (01:00) @@ -129,10 +117,10 @@ login foo six Wed Aug 28 06:00 - 07:00 (01:00) user_pro foo seven Wed Aug 28 05:00 - 06:00 (01:00) accounti foo nine Wed Aug 28 03:00 - 04:00 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 ~~~ present ~~~ rick long never-gonna-logo Thu Jan 1 00:00 - 03:14 (24855+03:14) torvalds linux hobby Mon Aug 26 00:57 gone - no logout runlevel foo one Wed Aug 28 11:00 - 12:00 (01:00) -wtmp begins Wed Aug 28 03:00:00 2013 +wtmp-a begins Wed Aug 28 03:00:00 2013 diff --git a/tests/expected/utmp/utmpdump-circle b/tests/expected/utmp/utmpdump-circle new file mode 100644 index 000000000..96fd2a9a7 --- /dev/null +++ b/tests/expected/utmp/utmpdump-circle @@ -0,0 +1 @@ +no output expected diff --git a/tests/expected/utmpdump/ipv6tobin b/tests/expected/utmp/utmpdump-tobin index d0f1b61c2..d0f1b61c2 100644 --- a/tests/expected/utmpdump/ipv6tobin +++ b/tests/expected/utmp/utmpdump-tobin diff --git a/tests/expected/utmpdump/to-binary b/tests/expected/utmp/utmpdump-tobin-ipv6 index d0f1b61c2..d0f1b61c2 100644 --- a/tests/expected/utmpdump/to-binary +++ b/tests/expected/utmp/utmpdump-tobin-ipv6 diff --git a/tests/expected/utmpdump/to-text b/tests/expected/utmp/utmpdump-totxt index 02fb22d5f..02fb22d5f 100644 --- a/tests/expected/utmpdump/to-text +++ b/tests/expected/utmp/utmpdump-totxt diff --git a/tests/expected/utmpdump/ipv6totxt b/tests/expected/utmp/utmpdump-totxt-ipv6 index 5cce1506b..5cce1506b 100644 --- a/tests/expected/utmpdump/ipv6totxt +++ b/tests/expected/utmp/utmpdump-totxt-ipv6 diff --git a/tests/functions.sh b/tests/functions.sh index 31ad481f4..2a50de721 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -610,3 +610,20 @@ function ts_scsi_debug_init { TS_DEVICE="/dev/${devname}" } + +function ts_resolve_host { + local host="$1" + local tmp + + # currently we just resolve default records (might be "A", ipv4 only) + if type "dig" >/dev/null 2>&1; then + tmp=$(dig "$host" +short 2>/dev/null) || return 1 + elif type "nslookup" >/dev/null 2>&1; then + tmp=$(nslookup "$host" 2>/dev/null) || return 1 + tmp=$(echo "$tmp"| grep -A1 "^Name:"| grep "^Address:"| cut -d" " -f2) + fi + + # we return 1 if tmp is empty + test -n "$tmp" || return 1 + echo "$tmp" | sort -R | head -n 1 +} diff --git a/tests/ts/hwclock/systohc b/tests/ts/hwclock/systohc index ba97ef780..fa7868fc7 100755 --- a/tests/ts/hwclock/systohc +++ b/tests/ts/hwclock/systohc @@ -29,24 +29,6 @@ ts_skip_nonroot ts_check_prog "bc" ts_check_prog "sntp" -function resolve_host -{ - local host="$1" - local tmp - - # currently we just resolve default records (might be "A", ipv4 only) - if type "dig" >/dev/null 2>&1; then - tmp=$(dig "$host" +short 2>/dev/null) || return 1 - elif type "nslookup" >/dev/null 2>&1; then - tmp=$(nslookup "$host" 2>/dev/null) || return 1 - tmp=$(echo "$tmp"| grep -A1 "^Name:"| grep "^Address:"| cut -d" " -f2) - fi - - # we return 1 if tmp is empty - test -n "$tmp" || return 1 - echo "$tmp" | sort -R | head -n 1 -} - function get_offset_sys_ntp { local ip="$@" @@ -79,7 +61,7 @@ function check_diff_offset # we need fixed ntp IP to get comparable offsets -NTP_IP=$(resolve_host "$NTP_SERVER") \ +NTP_IP=$(ts_resolve_host "$NTP_SERVER") \ || ts_skip "can't resolve hostname $NTP_SERVER" OFFSET_A=$(get_offset_sys_ntp "$NTP_IP") \ diff --git a/tests/ts/last/last b/tests/ts/utmp/last index 241915a7f..64b9b8c20 100755 --- a/tests/ts/last/last +++ b/tests/ts/utmp/last @@ -22,21 +22,24 @@ ts_check_test_command "$TS_CMD_LAST" $TS_CMD_LAST --version 2>&1 | grep -q "invalid option" \ && ts_skip "deprecated last" -WTMP_FILE=${TS_OUTDIR}/wtmp +. "$TS_SELF/utmp_functions.sh" + +WTMP_FILE=${TS_OUTDIR}/wtmp-a rm -f $WTMP_FILE -BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) -ln -s ${TS_SELF}/wtmp.${BYTE_ORDER} $WTMP_FILE export LANG=C export TZ=GMT ->| $TS_OUTPUT +if [ $SIZEOF_UTMP -eq 384 ]; then + ln -s ${TS_SELF}/wtmp-a.${BYTE_ORDER} $WTMP_FILE +else + $TS_CMD_UTMPDUMP -r ${TS_SELF}/txt-a > $WTMP_FILE 2>/dev/null \ + || ts_skip "can't create test data" +fi -ts_log "~~~ basic output ~~~" -$TS_CMD_LAST -f $WTMP_FILE >> $TS_OUTPUT 2>/dev/null - -ts_log "~~~ include system ~~~" -$TS_CMD_LAST -f $WTMP_FILE -x >> $TS_OUTPUT 2>/dev/null +# there is no better way yet to skip a subtest +if ts_resolve_host "a.root-servers.net" >/dev/null; then +ts_init_subtest "dns" ts_log "~~~ dns short ~~~" $TS_CMD_LAST -f $WTMP_FILE -d root >> $TS_OUTPUT 2>/dev/null @@ -47,6 +50,16 @@ $TS_CMD_LAST -f $WTMP_FILE -w -d root >> $TS_OUTPUT 2>/dev/null ts_log "~~~ dns host last ~~~" $TS_CMD_LAST -f $WTMP_FILE -a -d root >> $TS_OUTPUT 2>/dev/null +ts_finalize_subtest +fi + +ts_init_subtest "nodns" +ts_log "~~~ basic output ~~~" +$TS_CMD_LAST -f $WTMP_FILE >> $TS_OUTPUT 2>/dev/null + +ts_log "~~~ include system ~~~" +$TS_CMD_LAST -f $WTMP_FILE -x >> $TS_OUTPUT 2>/dev/null + ts_log "~~~ show ip ~~~" $TS_CMD_LAST -f $WTMP_FILE -i torvalds >> $TS_OUTPUT 2>/dev/null @@ -70,6 +83,7 @@ $TS_CMD_LAST -f $WTMP_FILE -s "2013-08-28 02:20" -t "2013-08-28 08:20" >> $TS_OU ts_log "~~~ present ~~~" $TS_CMD_LAST -f $WTMP_FILE -p "2013-08-28 11:20" >> $TS_OUTPUT 2>/dev/null +ts_finalize_subtest rm -f $WTMP_FILE diff --git a/tests/ts/last/ipv6 b/tests/ts/utmp/last-ipv6 index e3e7dd1b3..d4a96457e 100755 --- a/tests/ts/last/ipv6 +++ b/tests/ts/utmp/last-ipv6 @@ -22,15 +22,24 @@ ts_check_test_command "$TS_CMD_LAST" $TS_CMD_LAST --version 2>&1 | grep -q "invalid option" \ && ts_skip "deprecated last" -WTMP_FILE=${TS_OUTDIR}/ipv6-input +. "$TS_SELF/utmp_functions.sh" + +WTMP_FILE=${TS_OUTDIR}/wtmp-ipv6 rm -f $WTMP_FILE -BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) -ln -s ${TS_SELF}/ipv6-input.${BYTE_ORDER} $WTMP_FILE export LANG=C export TZ=GMT ->| $TS_OUTPUT +if [ $SIZEOF_UTMP -eq 384 ]; then + ln -s ${TS_SELF}/wtmp-ipv6.${BYTE_ORDER} $WTMP_FILE +else + $TS_CMD_UTMPDUMP -r ${TS_SELF}/txt-ipv6 > $WTMP_FILE 2>/dev/null \ + || ts_skip "can't create test data" +fi + +# there is no better way yet to skip a subtest +if ts_resolve_host "a.root-servers.net" >/dev/null; then +ts_init_subtest "dns" ts_log "~~~ dns short ~~~" $TS_CMD_LAST -f $WTMP_FILE -d >> $TS_OUTPUT 2>/dev/null @@ -41,11 +50,16 @@ $TS_CMD_LAST -f $WTMP_FILE -d -w >> $TS_OUTPUT 2>/dev/null ts_log "~~~ dns host last ~~~" $TS_CMD_LAST -f $WTMP_FILE -d -a >> $TS_OUTPUT 2>/dev/null +ts_finalize_subtest +fi + +ts_init_subtest "nodns" ts_log "~~~ show ip ~~~" $TS_CMD_LAST -f $WTMP_FILE -i >> $TS_OUTPUT 2>/dev/null ts_log "~~~ show ip last ~~~" $TS_CMD_LAST -f $WTMP_FILE -i -a >> $TS_OUTPUT 2>/dev/null +ts_finalize_subtest rm -f $WTMP_FILE diff --git a/tests/ts/utmp/txt-a b/tests/ts/utmp/txt-a new file mode 100644 index 000000000..bc91d1983 --- /dev/null +++ b/tests/ts/utmp/txt-a @@ -0,0 +1,19 @@ +[9] [00009] [ts/9] [accounting] [foo ] [nine ] [0.0.0.0 ] [Wed Aug 28 03:00:00 2013 GMT] +[8] [00008] [ts/8] [dead_process] [foo ] [eight ] [0.0.0.0 ] [Wed Aug 28 04:00:00 2013 GMT] +[7] [00007] [ts/7] [user_process] [foo ] [seven ] [0.0.0.0 ] [Wed Aug 28 05:00:00 2013 GMT] +[6] [00006] [ts/6] [login ] [foo ] [six ] [0.0.0.0 ] [Wed Aug 28 06:00:00 2013 GMT] +[5] [00005] [ts/5] [init ] [foo ] [five ] [0.0.0.0 ] [Wed Aug 28 07:00:00 2013 GMT] +[4] [00004] [ts/4] [oldtime ] [foo ] [four ] [0.0.0.0 ] [Wed Aug 28 08:00:00 2013 GMT] +[3] [00003] [ts/3] [newtime ] [foo ] [three ] [0.0.0.0 ] [Wed Aug 28 09:00:00 2013 GMT] +[2] [00002] [ts/2] [sysboot ] [foo ] [two ] [0.0.0.0 ] [Wed Aug 28 10:00:00 2013 GMT] +[1] [00001] [ts/1] [runlevel] [foo ] [one ] [0.0.0.0 ] [Wed Aug 28 11:00:00 2013 GMT] +[0] [00000] [ts/0] [nonvalid] [foo ] [zero ] [0.0.0.0 ] [Wed Aug 28 12:00:00 2013 GMT] +[7] [00010] [ipv4] [IPv4 ] [root ] [dns-server ] [198.41.0.4 ] [Wed Aug 28 13:00:00 2013 GMT] +[8] [00011] [ipv4] [IPv4 ] [root ] [dns-server ] [198.41.0.4 ] [Wed Aug 28 14:00:00 2013 GMT] +[1] [00012] [~~ ] [shutdown] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 15:00:00 2013 GMT] +[2] [00012] [~~ ] [reboot ] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 16:00:00 2013 GMT] +[1] [00012] [~~ ] [shutdown] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 17:00:00 2013 GMT] +[2] [00012] [~~ ] [reboot ] [~ ] [system-name ] [0.0.0.0 ] [Wed Aug 28 18:00:00 2013 GMT] +[7] [00013] [ts/1] [torvalds] [linux ] [hobby ] [128.214.205.14 ] [Mon Aug 26 00:57:08 1991 GMT] +[7] [00014] [long] [rick ] [long ] [never-gonna-logout ] [0.0.0.0 ] [ ] +[8] [00014] [long] [rick ] [long ] [never-gonna-logout ] [0.0.0.0 ] [Tue Jan 19 03:14:07 2038 GMT] diff --git a/tests/ts/utmpdump/text b/tests/ts/utmp/txt-b index 02fb22d5f..02fb22d5f 100644 --- a/tests/ts/utmpdump/text +++ b/tests/ts/utmp/txt-b diff --git a/tests/ts/utmpdump/ipv6txt b/tests/ts/utmp/txt-ipv6 index fb428d5e0..5cce1506b 100644 --- a/tests/ts/utmpdump/ipv6txt +++ b/tests/ts/utmp/txt-ipv6 @@ -1,2 +1,2 @@ -[7] [00010] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30 ] [Wed Aug 28 20:30:40 2013 BST] -[8] [00011] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30 ] [Wed Aug 28 20:40:50 2013 BST] +[7] [00010] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [Wed Aug 28 20:30:40 2013 GMT] +[8] [00011] [ipv6] [IPv6 ] [root ] [dns-server ] [2001:503:ba3e::2:30] [Wed Aug 28 20:40:50 2013 GMT] diff --git a/tests/ts/utmp/utmp_functions.sh b/tests/ts/utmp/utmp_functions.sh new file mode 100644 index 000000000..74a100ce8 --- /dev/null +++ b/tests/ts/utmp/utmp_functions.sh @@ -0,0 +1,18 @@ +ts_check_test_command "$TS_CMD_UTMPDUMP" +ts_check_test_command "$TS_HELPER_SYSINFO" + +function utmp_struct_size { + local size + # probably "utmpdump -r" could be improved regarding white spaces ... + local txt="[0] [00000] [ ] [ ] [ ] [ ] [0.0.0.0 ] [ ]" + + size=$(echo "$txt" | "$TS_CMD_UTMPDUMP" -r 2>/dev/null | wc -c \ + && exit ${PIPESTATUS[1]}) + ret=$? + [ $ret -eq 0 ] || size="0" + echo "$size" + return $ret +} + +BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) || ts_failed "byte-order failed" +SIZEOF_UTMP=$(utmp_struct_size) || ts_failed "utmp_struct_size failed" diff --git a/tests/ts/utmp/utmpdump-circle b/tests/ts/utmp/utmpdump-circle new file mode 100755 index 000000000..cae29953e --- /dev/null +++ b/tests/ts/utmp/utmpdump-circle @@ -0,0 +1,42 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="circle" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +# this test is arch independent, no need for utmp_functions.sh +ts_check_test_command "$TS_CMD_UTMPDUMP" + +export LANG=C +export TZ=GMT +OUT_BIN1=${TS_OUTDIR}/${TS_TESTNAME}.bin1 +OUT_BIN2=${TS_OUTDIR}/${TS_TESTNAME}.bin2 +OUT_TXT=${TS_OUTDIR}/${TS_TESTNAME}.txt + +echo "no output expected" > $TS_OUTPUT +for f in txt-a txt-b txt-ipv6; do + $TS_CMD_UTMPDUMP -r $TS_SELF/$f > $OUT_BIN1 2>/dev/null && + $TS_CMD_UTMPDUMP $OUT_BIN1 > $OUT_TXT 2>/dev/null && + diff -u $TS_SELF/$f $OUT_TXT && + $TS_CMD_UTMPDUMP -r $OUT_TXT > $OUT_BIN2 2>/dev/null && + diff -q $OUT_BIN1 $OUT_BIN2 || + echo "circle failed for $f" +done >> $TS_OUTPUT 2>&1 + +rm -f "$OUT_BIN1" "$OUT_BIN2" "$OUT_TXT" + +ts_finalize diff --git a/tests/ts/utmpdump/to-binary b/tests/ts/utmp/utmpdump-tobin index ecda0cca0..2f14bfc14 100755 --- a/tests/ts/utmpdump/to-binary +++ b/tests/ts/utmp/utmpdump-tobin @@ -13,20 +13,19 @@ # GNU General Public License for more details. TS_TOPDIR="${0%/*}/../.." -TS_DESC="to-binary" +TS_DESC="to binary" . $TS_TOPDIR/functions.sh ts_init "$*" -ts_check_test_command "$TS_CMD_UTMPDUMP" - -BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" export LANG=C export TZ=GMT OUTFILE=${TS_OUTDIR}/${TS_TESTNAME}.file -$TS_CMD_UTMPDUMP -r $TS_SELF/text >| $OUTFILE 2>/dev/null -if diff -q $TS_SELF/binary.$BYTE_ORDER $OUTFILE; then +$TS_CMD_UTMPDUMP -r $TS_SELF/txt-b >| $OUTFILE 2>/dev/null +if diff -q $TS_SELF/wtmp-b.$BYTE_ORDER $OUTFILE; then echo "no diff" fi > $TS_OUTPUT 2>&1 diff --git a/tests/ts/utmpdump/ipv6tobin b/tests/ts/utmp/utmpdump-tobin-ipv6 index c7b354a0c..e0b19cd13 100755 --- a/tests/ts/utmpdump/ipv6tobin +++ b/tests/ts/utmp/utmpdump-tobin-ipv6 @@ -18,15 +18,14 @@ TS_DESC="IPv6 to binary" . $TS_TOPDIR/functions.sh ts_init "$*" -ts_check_test_command "$TS_CMD_UTMPDUMP" - -BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" export LANG=C export TZ=GMT OUTFILE=${TS_OUTDIR}/${TS_TESTNAME}.file -$TS_CMD_UTMPDUMP -r $TS_SELF/ipv6txt >| $OUTFILE 2>/dev/null -if diff -q $TS_SELF/ipv6bin.$BYTE_ORDER $OUTFILE; then +$TS_CMD_UTMPDUMP -r $TS_SELF/txt-ipv6 >| $OUTFILE 2>/dev/null +if diff -q $TS_SELF/wtmp-ipv6.$BYTE_ORDER $OUTFILE; then echo "no diff" fi > $TS_OUTPUT 2>&1 diff --git a/tests/ts/utmpdump/to-text b/tests/ts/utmp/utmpdump-totxt index e36d325fb..37d376a8b 100755 --- a/tests/ts/utmpdump/to-text +++ b/tests/ts/utmp/utmpdump-totxt @@ -13,17 +13,16 @@ # GNU General Public License for more details. TS_TOPDIR="${0%/*}/../.." -TS_DESC="to-text" +TS_DESC="to text" . $TS_TOPDIR/functions.sh ts_init "$*" -ts_check_test_command "$TS_CMD_UTMPDUMP" - -BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" export LANG=C export TZ=GMT -$TS_CMD_UTMPDUMP $TS_SELF/binary.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null +$TS_CMD_UTMPDUMP $TS_SELF/wtmp-b.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null ts_finalize diff --git a/tests/ts/utmpdump/ipv6totxt b/tests/ts/utmp/utmpdump-totxt-ipv6 index e329b1318..1b2178386 100755 --- a/tests/ts/utmpdump/ipv6totxt +++ b/tests/ts/utmp/utmpdump-totxt-ipv6 @@ -18,12 +18,11 @@ TS_DESC="IPv6 to text" . $TS_TOPDIR/functions.sh ts_init "$*" -ts_check_test_command "$TS_CMD_UTMPDUMP" - -BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order) +. "$TS_SELF/utmp_functions.sh" +[ $SIZEOF_UTMP -eq 384 ] || ts_skip "utmp struct size $SIZEOF_UTMP" export LANG=C export TZ=GMT -$TS_CMD_UTMPDUMP $TS_SELF/ipv6bin.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null +$TS_CMD_UTMPDUMP $TS_SELF/wtmp-ipv6.$BYTE_ORDER >| $TS_OUTPUT 2>/dev/null ts_finalize diff --git a/tests/ts/last/wtmp.BE b/tests/ts/utmp/wtmp-a.BE Binary files differindex 5015f8eb1..5015f8eb1 100644 --- a/tests/ts/last/wtmp.BE +++ b/tests/ts/utmp/wtmp-a.BE diff --git a/tests/ts/last/wtmp.LE b/tests/ts/utmp/wtmp-a.LE Binary files differindex f66bb20a1..f66bb20a1 100644 --- a/tests/ts/last/wtmp.LE +++ b/tests/ts/utmp/wtmp-a.LE diff --git a/tests/ts/utmpdump/binary.BE b/tests/ts/utmp/wtmp-b.BE Binary files differindex fb09a0c71..fb09a0c71 100644 --- a/tests/ts/utmpdump/binary.BE +++ b/tests/ts/utmp/wtmp-b.BE diff --git a/tests/ts/utmpdump/binary.LE b/tests/ts/utmp/wtmp-b.LE Binary files differindex 45d35bbb0..45d35bbb0 100644 --- a/tests/ts/utmpdump/binary.LE +++ b/tests/ts/utmp/wtmp-b.LE diff --git a/tests/ts/last/ipv6-input.BE b/tests/ts/utmp/wtmp-ipv6.BE Binary files differindex 8cf7d3965..8cf7d3965 100644 --- a/tests/ts/last/ipv6-input.BE +++ b/tests/ts/utmp/wtmp-ipv6.BE diff --git a/tests/ts/last/ipv6-input.LE b/tests/ts/utmp/wtmp-ipv6.LE Binary files differindex 342553bb9..342553bb9 100644 --- a/tests/ts/last/ipv6-input.LE +++ b/tests/ts/utmp/wtmp-ipv6.LE diff --git a/tests/ts/utmpdump/ipv6bin.BE b/tests/ts/utmpdump/ipv6bin.BE Binary files differdeleted file mode 100644 index 8cf7d3965..000000000 --- a/tests/ts/utmpdump/ipv6bin.BE +++ /dev/null diff --git a/tests/ts/utmpdump/ipv6bin.LE b/tests/ts/utmpdump/ipv6bin.LE Binary files differdeleted file mode 100644 index 342553bb9..000000000 --- a/tests/ts/utmpdump/ipv6bin.LE +++ /dev/null |