]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/lxc-test-usernic
licensing: Add missing headers and FSF address
[mirror_lxc.git] / src / tests / lxc-test-usernic
CommitLineData
20ab58c7
SH
1#!/bin/bash
2
3# lxc: linux Container library
4
5# Authors:
6# Serge Hallyn <serge.hallyn@ubuntu.com>
7#
8# This is a test script for the lxc-user-nic program
9
10# This library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 2.1 of the License, or (at your option) any later version.
14
15# This library is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# Lesser General Public License for more details.
19
20# You should have received a copy of the GNU Lesser General Public
21# License along with this library; if not, write to the Free Software
250b1eec 22# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20ab58c7
SH
23
24conffile="/tmp/lxc-usernet"
25dbfile="/tmp/nics"
26sysfsdir=/tmp/lxcnettest
27
28rm -f $conffile $dbfile
29
30rm -rf $sysfsdir
31mkdir -p $sysfsdir
32
33# there is no conffile, so we have no permissions
34lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1
35if [ $? -eq 0 ]; then
36 echo "Fail: empty conffile should not allow me a nic"
37 exit 1
38fi
39
40cat > $conffile << EOF
41$(id -un) veth lxcbr0 1
42EOF
43
44# Should be allowed one but not two
45lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1
46if [ $? -ne 0 ]; then
47 echo "Failed to get one allowed nic"
48 exit 1
49fi
50
51lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1
52if [ $? -eq 0 ]; then
53 echo "Fail: was able to get a second nic"
54 exit 1
55fi
56
57# now remove the 'existing nic' and make sure we're allowed to create
58# a new one
59lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1
60rm -rf $sysfsdir
61mkdir -p $sysfsdir
62if [ $? -ne 0 ]; then
63 echo "Fail: was unable to get a replacement nic"
64 exit 1
65fi
66
67echo "All tests passed"