[Toybox] acpi.test, Ifconfig.test fixes

Cynt Rynt cynt1728 at gmail.com
Sun Nov 30 21:49:31 PST 2014


Hi,

Attached is a patch that adds a first stab at a testsuite for the acpi
utility, and a patch that fixes some of the issues with the ifconfig
testsuite.

1. Changed the context again... I tried running the tests on aboriginal
Linux, but it said there was no ip command, nor modprobe, which are two
alternatives to getting the dummy interface running.  I didn't have much
success with the static-tools.hdc, but it said it couldn't find toybox, but
I tested the testsuite on Kali by invoking sudo make tests... hopefully
will work on platforms other than Kali.

2. Corrected the pretext of the pointotpoint tests
3. Corrections to the pointopoint tests -- spelling, intent, etc.
After playing with ifconfig all weekend, I've come to the grand conclusion
I can't find a way to get ifconfig pointopoint to set the POINTOPOINT
flag... The POINTOPOINT flag appears to be treated as an immutable feature
of the interface by ifconfig.

Other people in the past had the same issue.
http://www.linuxmisc.com/2-linux-networking/ccf70d924f2c289c.htm ,
http://www.linuxmisc.com/2-linux-networking/075ce6d1d544e8fb.htm

ifconfig <interface> <localaddress> pointopoint <remoteaddress> can be used
to configure ip address for tunnels (for Kali at least)...

So if ifconfig is changed to match the documentation, it will not match
Kali, and thus probably not Debian.  Another option could be to clarify the
documentation...

Having gone through all that, and becoming slightly disappointed, I've
rewritten the ifconfig tests to reflect the defacto standard, over the
documentation, but the test can always be rewritten to reflect the
documentation over the defacto standard... if that's desired.

ACPI tests: according to Isaac Dunham, the author of the acpi utility,
there is no standard, so I compared the implemented features to their
counterparts implemented in Kali. The results were very satisfactory -- I
could use no options, reversed options, and got help when using illegal
options.

What would make the developing the tests much easier is a prebuilt image
with toybox configured with an allyesconfig (without nfs or nsenter, as
they don't seem to build on Kali).

Hope this helps,
Cindy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20141130/fa1ea25b/attachment-0001.htm>
-------------- next part --------------
diff -r 4faace2c5245 tests/acpi.test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/acpi.test	Sun Nov 30 06:46:26 2014 -0800
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Copyright 2014 Cynthia Rempel <cynthia at rtems.org>
+#
+# Purpose: Tests the acpi command.
+# Requires: grep -i, head -n, wc -l
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+# Test Description: Call acpi with no arguments
+# Results Expected: The battery percentage
+testing "acpi no arguments" "acpi | grep -i \"Battery\ *[0-9]:\ *[0-9][0-9]*%\" | head -n 1 | wc -l" \
+	"1\n" "" ""
+
+# Test Description: Get the power adapters' status
+# Results Expected: Whether the adapters were online or offline
+testing "acpi -a" "acpi -a | grep -i \"Adapter\ *[0-9]*:\ *.*\-line\" | head -n 1 | wc -l" \
+	"1\n" "" ""
+
+# Test Description: Get the status of the batteries
+# Results Expected: The battery percentage
+testing "acpi -b" "acpi -b | grep -i \"Battery\ *[0-9]:\ *[0-9][0-9]*%\" | head -n 1 | wc -l" \
+	"1\n" "" ""
+
+# Test Description: Get descriptions of the cooling devices
+# Results Expected: A list of descriptions for cooling devices
+testing "acpi -c" "acpi -c | grep -i \"Cooling\ *[0-9]:\ .*\" | head -n 1 | wc -l" \
+        "1\n" "" ""
+
+# Test Description: Get the temperature
+# Results Expected: A list of readings from temperature sensors
+testing "acpi -t" "acpi -t | grep -i \"Thermal\ *[0-9]:\ .*degrees\" | head -n 1 | wc -l" \
+        "1\n" "" ""
+
+# Test Description: Call acpi verbose
+# Results Expected: The battery percentage
+testing "acpi -V battery percentage" "acpi -V | grep -i \"Battery\ *[0-9]:\ *[0-9][0-9]*%\" | head -n 1 | wc -l" \
+        "1\n" "" ""
+
+# Test Description: Get the power adapters' status
+# Results Expected: Whether the adapters were online or offline
+testing "acpi -ab" "acpi -ab | grep -i \"Adapter\ *[0-9]*:\ *.*\-line\" | head -n 1 | wc -l" \
+        "1\n" "" ""
+
+# Test Description: Get the status of the batteries
+# Results Expected: The battery percentage
+testing "acpi -ba" "acpi -ba | grep -i \"Battery\ *[0-9]:\ *[0-9][0-9]*%\" | head -n 1 | wc -l" \
+        "1\n" "" ""
+
+# Test Description: Call an unknown option
+# Results Expected: The usage sent to standard error
+testing "acpi -bh" "acpi -bh |& grep -i \"usage\" | head -n 1 | wc -l" \
+        "1\n" "" ""
-------------- next part --------------
diff -r 4faace2c5245 tests/ifconfig.test
--- a/tests/ifconfig.test	Thu Nov 27 00:28:13 2014 -0600
+++ b/tests/ifconfig.test	Sun Nov 30 21:02:57 2014 -0800
@@ -2,8 +2,8 @@
 # Copyright 2014 Cynthia Rempel <cynthia at rtems.org>
 #
 # 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
+# Note: requires permissions to run all ifconfig options
+# Commands used: grep, grep -i, ip li add dummy, wc -l
 #
 # Possible improvements:
 # 1. Verify the dummy interface actually has the modified characteristics
@@ -31,12 +31,12 @@
 #testing "name" "command" "result" "infile" "stdin"
 
 # Add a dummy interface to test with
-ifconfig dummy0 up
+ip li add dummy0 type dummy
 
 # 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" \
+"ifconfig dummy0 down && ifconfig | grep dummy | wc -l" \
 "0\n" "" ""
 
 # Test Description: Enable the dummy0 interface
@@ -116,20 +116,37 @@
 "ifconfig dummy0 arp down && ifconfig dummy0 | grep -i NOARP | wc -l" \
 "0\n" "" ""
 
-# Test Description: Call the pointtopoint option with no argument
+# 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 127.0.0.1" \
+"ifconfig dummy0 127.0.0.1 && ifconfig dummy0 | grep 127\.0\.0\.1 | wc -l" \
+"1\n" "" ""
+
+# Test Description: Call the pointopoint 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" \
+testing "ifconfig dummy0 pointopoint" \
+"ifconfig dummy0 pointopoint |& grep -i pointopoint\ needs\ argument | 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" \
+# Test Description: Call the pointopoint option with two arguments
+# Results Expected: After calling ifconfig tunnel0, there is one line with the
+#                   ip addreesses selected
+
+# ifconfig <interface> pointopoint does not set the POINTOPOINT flag.  Start
+# with an interface that's supposed to be set with
+# ifconfig <interface> pointopoint
+ip tunnel add tunnel0 mode ipip ttl 60 remote 127.0.0.3 local 127.0.0.2
+
+testing "ifconfig tunnel0 127.0.0.4 pointopoint 127.0.0.5" \
+"ifconfig tunnel0 127.0.0.4 pointopoint 127.0.0.5 && ifconfig tunnel0 | grep 127\.0\.0\.4 | grep 127\.0\.0\.5 | wc -l" \
 "1\n" "" ""
 
+# remove the tunnel0 interface as it's of no more use
+ip li delete tunnel0
+
 ####### Flags you can set on an interface (or -remove by prefixing with -): ###############
 
 # Test Description: Enable allmulti mode on the interface
@@ -189,4 +206,4 @@
 "" ""
 
 # Disable the dummy interface
-ifconfig dummy0 down
+


More information about the Toybox mailing list