Debian Codegraph @

tests/ts/utmp/last-ipv6

raw
1 #!/bin/bash
2
3 # This file is part of util-linux.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This file is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 TS_TOPDIR="${0%/*}/../.."
16 TS_DESC="last ipv6"
17
18 . "$TS_TOPDIR"/functions.sh
19 ts_init "$*"
20
21 ts_check_test_command "$TS_CMD_LAST"
22 $TS_CMD_LAST --version 2>&1 | grep -q "invalid option" \
23 && ts_skip "deprecated last"
24
25 . "$TS_SELF/utmp_functions.sh"
26
27 WTMP_FILE=${TS_OUTDIR}/wtmp-ipv6
28 rm -f $WTMP_FILE
29
30 export LANG=C
31 export TZ=GMT
32
33 if [ $SIZEOF_UTMP -eq 384 ]; then
34 ln -s ${TS_SELF}/wtmp-ipv6.${BYTE_ORDER} $WTMP_FILE
35 else
36 $TS_CMD_UTMPDUMP -r ${TS_SELF}/txt-ipv6 > $WTMP_FILE 2>/dev/null \
37 || ts_skip "can't create test data"
38 fi
39
40 # there is no better way yet to skip a subtest
41 if ts_resolve_host "a.root-servers.net" >/dev/null; then
42 ts_init_subtest "dns"
43
44 ts_log "~~~ dns short ~~~"
45 $TS_CMD_LAST -f $WTMP_FILE -d >> $TS_OUTPUT 2>/dev/null
46
47 ts_log "~~~ dns long ~~~"
48 $TS_CMD_LAST -f $WTMP_FILE -d -w >> $TS_OUTPUT 2>/dev/null
49
50 ts_log "~~~ dns host last ~~~"
51 $TS_CMD_LAST -f $WTMP_FILE -d -a >> $TS_OUTPUT 2>/dev/null
52
53 ts_finalize_subtest
54 fi
55
56 ts_init_subtest "nodns"
57 ts_log "~~~ show ip ~~~"
58 $TS_CMD_LAST -f $WTMP_FILE -i >> $TS_OUTPUT 2>/dev/null
59
60 ts_log "~~~ show ip last ~~~"
61 $TS_CMD_LAST -f $WTMP_FILE -i -a >> $TS_OUTPUT 2>/dev/null
62 ts_finalize_subtest
63
64 rm -f $WTMP_FILE
65
66 ts_finalize