3 # Kernel configration options.
4 OPTIONS=" IPV6 IPV6_ROUTER_PREF IPV6_MULTIPLE_TABLES IPV6_ROUTE_INFO"
5 OPTIONS="$OPTIONS TUN SYN_COOKIES IP_ADVANCED_ROUTER IP_MULTIPLE_TABLES"
6 OPTIONS="$OPTIONS NETFILTER NETFILTER_ADVANCED NETFILTER_XTABLES"
7 OPTIONS="$OPTIONS NETFILTER_XT_MARK NETFILTER_XT_TARGET_MARK"
8 OPTIONS="$OPTIONS IP_NF_IPTABLES IP_NF_MANGLE"
9 OPTIONS="$OPTIONS IP6_NF_IPTABLES IP6_NF_MANGLE INET6_IPCOMP"
10 OPTIONS="$OPTIONS IPV6_PRIVACY IPV6_OPTIMISTIC_DAD"
11 # For 3.1 kernels, where devtmpfs is not on by default.
12 OPTIONS="$OPTIONS DEVTMPFS DEVTMPFS_MOUNT"
14 # How many tap interfaces to create.
17 # The root filesystem disk image we'll use.
18 ROOTFS=net_test.rootfs.20150203
19 COMPRESSED_ROOTFS=$ROOTFS.xz
20 URL=https://dl.google.com/dl/android/$COMPRESSED_ROOTFS
22 # Figure out which test to run.
24 echo "Usage: $0 <test>" >&2
31 # Check if we need to uncompress the disk image.
32 # We use xz because it compresses better: to 42M vs 72M (gzip) / 62M (bzip2).
34 if [ ! -f $ROOTFS ]; then
35 echo "Deleting $COMPRESSED_ROOTFS" >&2
36 rm -f $COMPRESSED_ROOTFS
37 echo "Downloading $URL" >&2
39 echo "Uncompressing $COMPRESSED_ROOTFS" >&2
40 unxz $COMPRESSED_ROOTFS
45 # Create NUMTAPINTERFACES tap interfaces on the host, and prepare UML command
46 # line params to use them. The interfaces are called <user>TAP0, <user>TAP1,
47 # ..., on the host, and eth0, eth1, ..., in the VM.
51 for id in $(seq 0 $(( NUMTAPINTERFACES - 1 )) ); do
53 tapinterfaces="$tapinterfaces $tap"
54 mac=$(printf fe:fd:00:00:00:%02x $id)
55 netconfig="$netconfig eth$id=tuntap,$tap,$mac"
58 for tap in $tapinterfaces; do
59 if ! ip link list $tap > /dev/null; then
60 echo "Creating tap interface $tap" >&2
61 sudo tunctl -u $USER -t $tap
62 sudo ip link set $tap up
66 # Exporting ARCH=um SUBARCH=x86_64 doesn't seem to work, as it "sometimes" (?)
67 # results in a 32-bit kernel.
69 # If there's no kernel config at all, create one or UML won't work.
70 [ -f .config ] || make defconfig ARCH=um SUBARCH=x86_64
72 # Enable the kernel config options listed in $OPTIONS.
73 cmdline=${OPTIONS// / -e }
74 ./scripts/config $cmdline
76 # olddefconfig doesn't work on old kernels.
77 if ! make olddefconfig ARCH=um SUBARCH=x86_64 CROSS_COMPILE= ; then
80 Warning: "make olddefconfig" failed.
81 Perhaps this kernel is too old to support it.
82 You may get asked lots of questions.
83 Keep enter pressed to accept the defaults.
89 make -j12 linux ARCH=um SUBARCH=x86_64 CROSS_COMPILE=
91 # Get the absolute path to the test file that's being run.
92 dir=/host$(dirname $(readlink -f $0))
95 exec ./linux umid=net_test ubda=$(dirname $0)/$ROOTFS \
96 mem=512M init=/sbin/net_test.sh net_test=$dir/$test \