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 15TS_TOPDIR="${0%/*}/../.." 16TS_DESC="last" 17 18. $TS_TOPDIR/functions.sh 19ts_init "$*" 20 21ts_check_test_command "$TS_CMD_LAST" 22ts_check_test_command "$TS_CMD_UTMPDUMP" 23ts_check_prog "ln" 24 25$TS_CMD_LAST --version 2>&1 | grep -q "invalid option" \ 26 && ts_skip "deprecated last" 27 28. "$TS_SELF/utmp_functions.sh" 29 30WTMP_FILE=${TS_OUTDIR}/wtmp-a 31rm -f $WTMP_FILE 32 33export LANG=C 34export TZ=GMT 35 36if [ $SIZEOF_UTMP -eq 384 ]; then 37 ln -s ${TS_SELF}/wtmp-a.${BYTE_ORDER} $WTMP_FILE 38else 39 $TS_CMD_UTMPDUMP -r ${TS_SELF}/txt-a > $WTMP_FILE 2>/dev/null \ 40 || ts_skip "can't create test data" 41fi 42 43# there is no better way yet to skip a subtest 44if ts_resolve_host "a.root-servers.net" >/dev/null; then 45ts_init_subtest "dns" 46 47ts_log "~~~ dns short ~~~" 48$TS_CMD_LAST -f $WTMP_FILE -d root >> $TS_OUTPUT 2>/dev/null 49 50ts_log "~~~ dns long ~~~" 51$TS_CMD_LAST -f $WTMP_FILE -w -d root >> $TS_OUTPUT 2>/dev/null 52 53ts_log "~~~ dns host last ~~~" 54$TS_CMD_LAST -f $WTMP_FILE -a -d root >> $TS_OUTPUT 2>/dev/null 55 56ts_finalize_subtest 57fi 58 59ts_init_subtest "nodns" 60ts_log "~~~ basic output ~~~" 61$TS_CMD_LAST -f $WTMP_FILE >> $TS_OUTPUT 2>/dev/null 62 63ts_log "~~~ include system ~~~" 64$TS_CMD_LAST -f $WTMP_FILE -x >> $TS_OUTPUT 2>/dev/null 65 66ts_log "~~~ show ip ~~~" 67$TS_CMD_LAST -f $WTMP_FILE -i torvalds >> $TS_OUTPUT 2>/dev/null 68 69ts_log "~~~ no host ~~~" 70$TS_CMD_LAST -f $WTMP_FILE -R torvalds >> $TS_OUTPUT 2>/dev/null 71 72ts_log "~~~ full times shortopt ~~~" 73$TS_CMD_LAST -f $WTMP_FILE -F >> $TS_OUTPUT 2>/dev/null 74 75ts_log "~~~ full times longopt ~~~" 76$TS_CMD_LAST -f $WTMP_FILE --time-format=full >> $TS_OUTPUT 2>/dev/null 77 78ts_log "~~~ no time ~~~" 79$TS_CMD_LAST -f $WTMP_FILE --time-format=notime >> $TS_OUTPUT 2>/dev/null 80 81ts_log "~~~ iso-8601 time ~~~" 82$TS_CMD_LAST -f $WTMP_FILE --time-format=iso -w >> $TS_OUTPUT 2>/dev/null 83 84ts_log "~~~ since and until ~~~" 85$TS_CMD_LAST -f $WTMP_FILE -s "2013-08-28 02:20" -t "2013-08-28 08:20" >> $TS_OUTPUT 2>/dev/null 86 87ts_log "~~~ present ~~~" 88$TS_CMD_LAST -f $WTMP_FILE -p "2013-08-28 11:20" >> $TS_OUTPUT 2>/dev/null 89ts_finalize_subtest 90 91rm -f $WTMP_FILE 92 93ts_finalize 94