File: assertion.sh

package info (click to toggle)
dracut 109-6exp2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 4,868 kB
  • sloc: sh: 24,511; ansic: 5,234; makefile: 346; perl: 186; python: 48; javascript: 19
file content (21 lines) | stat: -rwxr-xr-x 714 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash

# Get the output of 'ip addr show eth0'
ip_output=$(ip addr show eth0)

# Extract the line containing "inet"
inet_line="${ip_output##*inet }"
inet_line="${inet_line%% brd*}" # Remove everything after "brd" if it exists

# Extract the IP address by removing the subnet mask
ip_address="${inet_line%%/*}"

# https://www.qemu.org/docs/master/system/devices/net.html#using-the-user-mode-network-stack
# The qemu DHCP server assign addresses to the hosts starting from 10.0.2.15
# We run the VM only with one network interface, so testing for 10.0.2.15 is safe

if [ "$ip_address" != "10.0.2.15" ]; then
    # fail the test
    echo "ip addr show" >> /run/failed
    ip addr show >> /run/failed
fi