]>
Commit | Line | Data |
---|---|---|
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 | |
24 | conffile="/tmp/lxc-usernet" | |
25 | dbfile="/tmp/nics" | |
26 | sysfsdir=/tmp/lxcnettest | |
27 | ||
28 | rm -f $conffile $dbfile | |
29 | ||
30 | rm -rf $sysfsdir | |
31 | mkdir -p $sysfsdir | |
32 | ||
33 | # there is no conffile, so we have no permissions | |
34 | lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1 | |
35 | if [ $? -eq 0 ]; then | |
36 | echo "Fail: empty conffile should not allow me a nic" | |
37 | exit 1 | |
38 | fi | |
39 | ||
40 | cat > $conffile << EOF | |
41 | $(id -un) veth lxcbr0 1 | |
42 | EOF | |
43 | ||
44 | # Should be allowed one but not two | |
45 | lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1 | |
46 | if [ $? -ne 0 ]; then | |
47 | echo "Failed to get one allowed nic" | |
48 | exit 1 | |
49 | fi | |
50 | ||
51 | lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1 | |
52 | if [ $? -eq 0 ]; then | |
53 | echo "Fail: was able to get a second nic" | |
54 | exit 1 | |
55 | fi | |
56 | ||
57 | # now remove the 'existing nic' and make sure we're allowed to create | |
58 | # a new one | |
59 | lxc-usernic-test 1111 veth lxcbr0 > /dev/null 2>&1 | |
60 | rm -rf $sysfsdir | |
61 | mkdir -p $sysfsdir | |
62 | if [ $? -ne 0 ]; then | |
63 | echo "Fail: was unable to get a replacement nic" | |
64 | exit 1 | |
65 | fi | |
66 | ||
67 | echo "All tests passed" |