3 # Kernel configuration 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 # These two break the flo kernel due to differences in -Werror on recent GCC.
15 DISABLE_OPTIONS=" CONFIG_REISERFS_FS CONFIG_ANDROID_PMEM"
17 # How many tap interfaces to create.
20 # The root filesystem disk image we'll use.
21 ROOTFS=net_test.rootfs.20150203
22 COMPRESSED_ROOTFS=$ROOTFS.xz
23 URL=https://dl.google.com/dl/android/$COMPRESSED_ROOTFS
25 # Figure out which test to run.
27 echo "Usage: $0 <test>" >&2
34 # Check if we need to uncompress the disk image.
35 # We use xz because it compresses better: to 42M vs 72M (gzip) / 62M (bzip2).
37 if [ ! -f $ROOTFS ]; then
38 echo "Deleting $COMPRESSED_ROOTFS" >&2
39 rm -f $COMPRESSED_ROOTFS
40 echo "Downloading $URL" >&2
42 echo "Uncompressing $COMPRESSED_ROOTFS" >&2
43 unxz $COMPRESSED_ROOTFS
48 # Create NUMTAPINTERFACES tap interfaces on the host, and prepare UML command
49 # line params to use them. The interfaces are called <user>TAP0, <user>TAP1,
50 # ..., on the host, and eth0, eth1, ..., in the VM.
54 for id in $(seq 0 $(( NUMTAPINTERFACES - 1 )) ); do
56 tapinterfaces="$tapinterfaces $tap"
57 mac=$(printf fe:fd:00:00:00:%02x $id)
58 netconfig="$netconfig eth$id=tuntap,$tap,$mac"
61 for tap in $tapinterfaces; do
62 if ! ip link list $tap > /dev/null; then
63 echo "Creating tap interface $tap" >&2
64 sudo tunctl -u $USER -t $tap
65 sudo ip link set $tap up
69 # Exporting ARCH=um SUBARCH=x86_64 doesn't seem to work, as it "sometimes" (?)
70 # results in a 32-bit kernel.
72 # If there's no kernel config at all, create one or UML won't work.
73 [ -f .config ] || make defconfig ARCH=um SUBARCH=x86_64
75 # Enable the kernel config options listed in $OPTIONS.
76 cmdline=${OPTIONS// / -e }
77 ./scripts/config $cmdline
79 # Disable the kernel config options listed in $DISABLE_OPTIONS.
80 cmdline=${DISABLE_OPTIONS// / -d }
81 ./scripts/config $cmdline
83 # olddefconfig doesn't work on old kernels.
84 if ! make olddefconfig ARCH=um SUBARCH=x86_64 CROSS_COMPILE= ; then
87 Warning: "make olddefconfig" failed.
88 Perhaps this kernel is too old to support it.
89 You may get asked lots of questions.
90 Keep enter pressed to accept the defaults.
96 make -j12 linux ARCH=um SUBARCH=x86_64 CROSS_COMPILE=
98 # Get the absolute path to the test file that's being run.
99 dir=/host$(dirname $(readlink -f $0))
102 exec ./linux umid=net_test ubda=$(dirname $0)/$ROOTFS \
103 mem=512M init=/sbin/net_test.sh net_test=$dir/$test \