summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNélio Laranjeiro2012-08-22 10:02:10 +0200
committerNélio Laranjeiro2012-09-06 09:47:27 +0200
commit5349983a49216d4d99b4f5b82ced100698fdef81 (patch)
tree5ff579009f66a95a183445d5f5daa49dbd84d9a4
parent059b998a12ae2a254390b5f577ef3e4884d8a109 (diff)
cleo/devkit/tests: add test to verify busybox applets order, refs #3304
Applets in applets.h file must be ASCII ordered.
-rw-r--r--cleopatre/devkit/tests/busybox/busybox_applets_order.py46
-rw-r--r--common/tests/tests3
2 files changed, 49 insertions, 0 deletions
diff --git a/cleopatre/devkit/tests/busybox/busybox_applets_order.py b/cleopatre/devkit/tests/busybox/busybox_applets_order.py
new file mode 100644
index 0000000000..17259508fe
--- /dev/null
+++ b/cleopatre/devkit/tests/busybox/busybox_applets_order.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+#############################################################################
+
+import sys
+import re
+import unittest
+
+class TestVerifyAppletsOrder (unittest.TestCase):
+ """Verifies the Applets ascii order in applets.h file"""
+
+ def setUp (self):
+ pass
+
+ def tearDown (self):
+ pass
+
+ def testOrder (self):
+ """Read each line of the file and get the applet name to store it in a
+ list.
+ This list is copied into an other one to sort it.
+ The two lists are compared and the status is tested.
+ """
+ applet_line = re.compile (r'^USE_[A-Z_]+\(APPLET[A-Z_]*\((.*)\)\)$')
+ applets_list = list ()
+ for line in file ('../../../busybox-1.11.1-spc300/include/applets.h'):
+ match = applet_line.match (line)
+ if match:
+ applet = match.group (1)
+ applets_list.append (applet.split (',')[0])
+
+ # Verify the order.
+ applets_sorted_list = applets_list[:]
+ applets_sorted_list.sort ()
+
+ for i in range (len (applets_list)):
+ self.failUnless (applets_sorted_list[i] == applets_list[i],
+ "Expecting \"%s\" got \"%s\"" \
+ % (applets_sorted_list[i],
+ applets_list[i]))
+
+if __name__ == '__main__':
+ suite = unittest.TestLoader().\
+ loadTestsFromTestCase(TestVerifyAppletsOrder)
+ testResult = unittest.TextTestRunner(verbosity=2).run(suite)
+ sys.exit ((1, 0)[testResult.wasSuccessful ()])
diff --git a/common/tests/tests b/common/tests/tests
index cbabc0aea3..9a94179eef 100644
--- a/common/tests/tests
+++ b/common/tests/tests
@@ -38,6 +38,9 @@ vs_mme: ./obj/vs_mme_utests
cleopatre/devkit/tests/bundle-delivery:
bundle-delivery: python test-bundle-delivery.py
+cleopatre/devkit/tests/busybox:
+busybox-applet-order: python busybox_applets_order.py
+
cesar/hal/arch/test/atomic:
make: make COV=y
cov test_atomic: ./obj/test_atomic