File: 047

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (88 lines) | stat: -rwxr-xr-x 2,147 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
# PCP QA Test No. 047
# Exercise fix for a containers networking issue.
#
# Copyright (c) 2015 Red Hat.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

. ./common.containers

_check_containers
_check_docker_binary
_check_docker_images busybox

_cleanup()
{
    if [ -n "$container" ]
    then
        echo "== removing container" | tee -a $seq_full
	_remove_docker_containers $container
	container=""
    fi
    rm -rf $tmp.*
}

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_pminfo_value()
{
    inst="$1"

    grep -F " or \"$inst\"" | \
    sed \
	-e "s/^ *inst .* or \"$inst\". value //g" \
    #end
}

_compare_value()
{
    label=$1
    if_value=$2
    pcp_value=$3

    echo "$label - ifconfig=\"$if_value\" pcp=\"$pcp_value\"" >>$seq_full

    if [ "$pcp_value" = "$if_value" ]
    then
	echo "$label matches"
    else
	echo "$label mismatch - ifconfig=\"$if_value\" pcp=\"$pcp_value\""
	status=1
    fi
}

# real QA test starts here
container=`$docker run -d busybox sleep 15`
echo "== container: $container" >> $seq_full

echo "== extract values from pmdalinux"
metrics="network.interface.hw_addr network.interface.inet_addr"
pminfo --fetch --container=$container network.interface.hw_addr >$tmp.pcp_hw
pminfo --fetch --container=$container network.interface.inet_addr >$tmp.pcp_inet

eval pcp_hw_addr=`cat $tmp.pcp_hw | _pminfo_value eth0`
eval pcp_inet_addr=`cat $tmp.pcp_inet | _pminfo_value eth0`
echo "== pcp values:" >> $seq_full
cat $tmp.pcp_hw $tmp.pcp_inet >> $seq_full
echo "hw_addr:" >> $seq_full
echo "inet_addr:" >> $seq_full

echo "== extract values from docker" | tee -a $seq_full
$docker exec $container ifconfig eth0 | tee -a $seq_full >$tmp.ifconfig

eval if_inet_addr=`cat $tmp.ifconfig | grep 'inet addr' \
	| sed -e 's/.*inet addr://g' -e 's/ .*//g'`
eval if_hw_addr=`cat $tmp.ifconfig | grep 'HWaddr' \
	| sed -e 's/.*HWaddr //g' -e 's/ .*//g' -e 's/.*/\L&/'`

echo "== comparing values" | tee -a $seq_full
_compare_value hw_addr $if_hw_addr $pcp_hw_addr
_compare_value inet_addr $if_inet_addr $pcp_inet_addr

# success, all done
status=0
exit