Hi! <snip> >And this one languished for a week. Unintentional irony, sorry. (I was >debugging sed.) It's okay, I ran into life as well
>My general plan for making "run as root" tests work is to make an >Aboriginal Linux build control image that runs them as root under qemu. > > http://landley.net/aboriginal/control-images I'll have to try this out some time :) <snip> >Ah, I remember why this went on the todo list. This includes 22 test >cases, to be run as root, with no indication of what the actual bug is >or which test case hits it. What does failure look like? What would >success look like? Tried to add more explanatory notes. My concern with ifconfig down is that the interface that is down is still displayed with a call to ifconfig (as opposed to ifconfig -a) My main concern with calling the pointtopoint option is it returns a usage message instead of making the changes to the ifconfig display that nettools makes when given the same command. (I'm not sure what the reference should be, so I went with what Kali does). >This test set relies on modprobing a "dummy" module, and my normal test >environment for this sort of thing is a static kernel built without >module support. Removed the modprob call, and it still seems to work on Kali... <snip> >Running ifconfig tests remotely through the network >is... awkward. Does that mean the overall testing strategy of the testsuite might be good for now? >I can fire up an ubuntu instance under kvm, maybe? Or add the DUMMY >kconfig symbol to the aboriginal kernel I build and modify the test not >to modprobe. Looks like removing modprobe fixed the issue on Kali (it just feels really wrong)... >Let me get back to this after I cut the 0.5.1 release... OK. Looking forward to your feedback on this patch. Thanks, Cindy > Thanks, > Cindy >Sorry this is taking so long, juggling many things. It's okay, this is just a hobby for me. On Wed, Nov 19, 2014 at 5:38 PM, Rob Landley <[email protected]> wrote: > On 11/12/14 20:48, Cynt Rynt wrote: > > Hi, > > Thanks for getting back to me so quickly. > > And this one languished for a week. Unintentional irony, sorry. (I was > debugging sed.) > > > I was trying to figure out > > how to write coverage tests for toybox, and ran into issues using the > > pointtopoint option for ifconfig. > > My general plan for making "run as root" tests work is to make an > Aboriginal Linux build control image that runs them as root under qemu. > > http://landley.net/aboriginal/control-images > > (That's why chgrp.test and losetup.test have the "not root" part at the > beginning.) > > It's on the todo list. :) > > > Before I finished writing the test > > suite, I thought it best to find out if I was calling ifconfig wrong or > > if I found a bug. Attached is the .patch that generated the issue. > > Ah, I remember why this went on the todo list. This includes 22 test > cases, to be run as root, with no indication of what the actual bug is > or which test case hits it. What does failure look like? What would > success look like? > > This test set relies on modprobing a "dummy" module, and my normal test > environment for this sort of thing is a static kernel built without > module support. I'm reluctant to test it on my netbook because according > to uptime the last time I rebooted was August. (I don't care about the > uptime value, I've been meaning to reboot the thing so youtube starts > working again anyway (ubuntu upgraded the video codecs out from under > the browser, and apparently relaunching chrome isn't good enough, it > wants a reboot).) But I have eight desktops full of open windows, most > with multiple tabs, and ps ax | wc -l says 491 processes, so I have to > go through and close a lot of tabs before I can reboot without losing > track of what I'm working on. I'd rather avoid a forced reboot when I'm > not ready to spend the rest of the day doing state cleanup. > > Testing this on the other machine is problematic because although it's > technically a laptop, the battery lasts 15 seconds, so it's on a shelf > and I ssh into it to use it. (ssh -X and x11 forwarding actually work > reasonably well...) Running ifconfig tests remotely through the network > is... awkward. > > I can fire up an ubuntu instance under kvm, maybe? Or add the DUMMY > kconfig symbol to the aboriginal kernel I build and modify the test not > to modprobe. > > Let me get back to this after I cut the 0.5.1 release... > > > Thanks, > > Cindy > > Sorry this is taking so long, juggling many things. > > Rob >
diff -r b5968bffb65c tests/ifconfig.test --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ifconfig.test Wed Nov 26 16:25:03 2014 -0800 @@ -0,0 +1,185 @@ +#!/bin/bash +# Copyright 2014 Cynthia Rempel <[email protected]> +# +# Brief: Some cursery coverage tests of ifconfig... +# Note: requires permissions to run modprobe and all ifconfig options +# Commands used: grep, grep -i, ip link, ip tuntap, wc -l +# +# Possible improvements: +# 1. Verify the dummy interface actually has the modified characteristics +# instead of relying on ifconfig output +# 2. Introduce more error cases, to verify ifconfig fails gracefully +# 3. Do more complex calls to ifconfig, while mixing the order of the +# arguments +# 4. Cover more ifconfig options: +# hw ether|infiniband ADDRESS - set LAN hardware address (AA:BB:CC...) +# txqueuelen LEN - number of buffered packets before output blocks +# Obsolete fields included for historical purposes: +# irq|io_addr|mem_start ADDR - micromanage obsolete hardware +# outfill|keepalive INTEGER - SLIP analog dialup line quality monitoring +# metric INTEGER - added to Linux 0.9.10 with comment "never used", still true + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +# Add a dummy interface to test with +ifconfig dummy0 up + +# Test Description: Disable the dummy0 interface +# Results Expected: After calling ifconfig, no lines with dummy0 are displayed +testing "ifconfig dummy0 down and if config /-only" \ +"ifconfig dummy0 down && ifconfig dummy0 | grep dummy | wc -l" \ +"0\n" "" "" + +# Test Description: Enable the dummy0 interface +# Results Expected: After calling ifconfig, one line with dummy0 is displayed +testing "ifconfig dummy0 up" \ +"ifconfig dummy0 up && ifconfig dummy0 | grep dummy | wc -l" \ +"1\n" "" "" + +# Test Description: Set the ip address of the dummy0 interface +# Results Expected: After calling ifconfig dummy0, one line displays the ip +# address selected +testing "ifconfig dummy0 10.240.240.240" \ +"ifconfig dummy0 10.240.240.240 && ifconfig dummy0 | grep 10\.240\.240\.240 | wc -l" \ +"1\n" "" "" + +# Test Description: Change the netmask to the interface +# Results Expected: After calling ifconfig dummy0, one line displays the +# netmask selected +testing "ifconfig dummy0 netmask 255.255.240.0" \ +"ifconfig dummy0 netmask 255.255.240.0 && ifconfig dummy0 | grep 255\.255\.240\.0 | wc -l" \ +"1\n" "" "" + +# Test Description: Change the broadcast address to the interface +# Results Expected: After calling ifconfig dummy0, one line displays the +# broadcast address selected +testing "ifconfig dummy0 broadcast 10.240.240.255" \ +"ifconfig dummy0 broadcast 10.240.240.255 && ifconfig dummy0 | grep 10\.240\.240\.255 | wc -l" \ +"1\n" "" "" + +# Test Description: Revert to the default ip address +# Results Expected: After calling ifconfig dummy0, there are no lines +# displaying the ip address previously selected +testing "ifconfig dummy0 default" \ +"ifconfig dummy0 default && ifconfig dummy0 | grep 10\.240\.240\.240 | wc -l" \ +"0\n" "" "" + +# Test Description: Change the Maximum transmission unit (MTU) of the interface +# Results Expected: After calling ifconfig dummy0, there is one line with the +# selected MTU +testing "ifconfig dummy0 mtu 1269" \ +"ifconfig dummy0 mtu 1269 && ifconfig dummy0 | grep 1269 | wc -l" \ +"1\n" "" "" + +# Test Description: Verify ifconfig add fails with such a small mtu +# Results Expected: There is one line of error message containing +# "No buffer space available" +testing "ifconfig dummy0 add ::2 -- too small mtu" \ +"ifconfig dummy0 add ::2 2>&1 | grep No\ buffer\ space\ available | wc -l" \ +"1\n" "" "" + +# Test Description: Change the Maximum transmission unit (MTU) of the interface +# Results Expected: After calling ifconfig dummy0, there is one line with the +# selected MTU +testing "ifconfig dummy0 mtu 2000" \ +"ifconfig dummy0 mtu 2000 && ifconfig dummy0 | grep 2000 | wc -l" \ +"1\n" "" "" + +# Test Description: Verify ifconfig add succeeds with a larger mtu +# Results Expected: after calling ifconfig dummy0, there is one line with the +# selected ip address +testing "ifconfig dummy0 add ::2" \ +"ifconfig dummy0 add ::2/126 && ifconfig dummy0 | grep \:\:2\/126 | wc -l" \ +"1\n" "" "" + +# Test Description: Verify ifconfig del removes the selected ip6 address +# Results Expected: after calling ifconfig dummy0, there are no lines with the +# selected ip address +testing "ifconfig dummy0 del ::2" \ +"ifconfig dummy0 del ::2/126 && ifconfig dummy0 | grep \:\:2 | wc -l" \ +"0\n" "" "" + +# Test Description: Remove the noarp flag and bring the interface down in +# preparation for the next test +# Results Expected: After calling ifconfig dummy0, there are no lines with the +# NOARP flag +testing "ifconfig dummy0 arp down" \ +"ifconfig dummy0 arp down && ifconfig dummy0 | grep -i NOARP | wc -l" \ +"0\n" "" "" + +# Test Description: Call the pointtopoint option with no argument +# Results Expected: After calling ifconfig dummy0, there is one line with the +# NOARP and UP flags +testing "ifconfig dummy0 pointtopoint" \ +"ifconfig dummy0 pointtopoint && ifconfig dummy0 | grep -i NOARP | grep -i UP | wc -l" \ +"1\n" "" "" + +# Test Description: Test the pointtopoint option and set the ipaddress +# Results Expected: After calling ifconfig dummy0, there is one line with the +# word inet and the selected ip address +testing "ifconfig dummy0 pointtopoint 127.0.0.2" \ +"ifconfig dummy0 pointtopoint 127.0.0.2 && ifconfig dummy0 | grep -i inet | grep -i 127\.0\.0\.2 | wc -l" \ +"1\n" "" "" + +####### Flags you can set on an interface (or -remove by prefixing with -): ############### + +# Test Description: Enable allmulti mode on the interface +# Results Expected: After calling ifconfig dummy0, there is one line with the +# allmulti flag +testing "ifconfig dummy0 allmulti" \ +"ifconfig dummy0 allmulti && ifconfig dummy0 | grep -i allmulti | wc -l" "1\n" \ +"" "" + +# Test Description: Disable multicast mode the interface +# Results Expected: After calling ifconfig dummy0, there are no lines with the +# allmulti flag +testing "ifconfig dummy0 -allmulti" \ +"ifconfig dummy0 -allmulti && ifconfig dummy0 | grep -i allmulti | wc -l" "0\n" \ +"" "" + +# Test Description: Disable NOARP mode on the interface +# Results Expected: After calling ifconfig dummy0, there are no lines with the +# NOARP flag +testing "ifconfig dummy0 arp" \ +"ifconfig dummy0 arp && ifconfig dummy0 | grep -i NOARP | wc -l" "0\n" \ +"" "" + +# Test Description: Enable NOARP mode on the interface +# Results Expected: After calling ifconfig dummy0, there is one line with the +# NOARP flag +testing "ifconfig dummy0 -arp" \ +"ifconfig dummy0 -arp && ifconfig dummy0 | grep -i NOARP | wc -l" "1\n" \ +"" "" + +# Test Description: Enable multicast mode on the interface +# Results Expected: After calling ifconfig dummy0, there is one line with the +# multicast flag +testing "ifconfig dummy0 multicast" \ +"ifconfig dummy0 multicast && ifconfig dummy0 | grep -i multicast | wc -l" \ +"1\n" "" "" + +# Test Description: Disable multicast mode the interface +# Results Expected: After calling ifconfig dummy0, there are no lines with the +# multicast flag +testing "ifconfig dummy0 -multicast" \ +"ifconfig dummy0 -multicast && ifconfig dummy0 | grep -i multicast | wc -l" \ +"0\n" "" "" + +# Test Description: Enable promiscuous mode the interface +# Results Expected: After calling ifconfig dummy0, there is one line with the +# promisc flag +testing "ifconfig dummy0 promisc" \ +"ifconfig dummy0 promisc && ifconfig dummy0 | grep -i promisc | wc -l" "1\n" \ +"" "" + +# Disable promiscuous mode the interface +# Results Expected: After calling ifconfig dummy0, there are no lines with the +# promisc flag +testing "ifconfig dummy0 -promisc" \ +"ifconfig dummy0 -promisc && ifconfig dummy0 | grep -i promisc | wc -l" "0\n" \ +"" "" + +# Disable the dummy interface +ifconfig dummy0 down
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
