blob: 1b22869141261fe0a2cc20a5d74cd460d26a8d81 [file] [log] [blame]
Frederic Lepiedae55c182017-04-14 08:31:34 +02001#!/bin/sh
2set -e
3
4. `dirname $0`/assert.sh
5
6ORIG_HOST=`cat /etc/hostname`
7echo "original hostname: $ORIG_HOST"
8
9# should activate daemon and work
10STATUS="`hostnamectl`"
11assert_in "Static hostname: $ORIG_HOST" "$STATUS"
12assert_in "Kernel:.* `uname -r`" "$STATUS"
13
14# change hostname
15assert_eq "`hostnamectl set-hostname testhost 2>&1`" ""
16assert_eq "`cat /etc/hostname`" "testhost"
17assert_in "Static hostname: testhost" "`hostnamectl`"
18
19# reset to original
20assert_eq "`hostnamectl set-hostname $ORIG_HOST 2>&1`" ""
21assert_eq "`cat /etc/hostname`" "$ORIG_HOST"
22assert_in "Static hostname: $ORIG_HOST" "`hostnamectl`"