[PATCH 1/3 autotest-client-tests] UBUNTU: SAUCE: Add kernel self tests framework

Tim Gardner tim.gardner at canonical.com
Thu Nov 20 17:07:21 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 11/20/2014 09:49 AM, Stefan Bader wrote:
> On 19.11.2014 21:50, tim.gardner at canonical.com wrote:
>> From: Tim Gardner <tim.gardner at canonical.com>
>> 
>> Signed-off-by: Tim Gardner <tim.gardner at canonical.com> --- 
>> ubuntu_kernel_selftests/control                    | 17 +++++ 
>> ubuntu_kernel_selftests/ubuntu_kernel_selftests.py | 82
>> ++++++++++++++++++++++ 2 files changed, 99 insertions(+) create
>> mode 100644 ubuntu_kernel_selftests/control create mode 100644
>> ubuntu_kernel_selftests/ubuntu_kernel_selftests.py
>> 
>> diff --git a/ubuntu_kernel_selftests/control
>> b/ubuntu_kernel_selftests/control new file mode 100644 index
>> 0000000..ca10209 --- /dev/null +++
>> b/ubuntu_kernel_selftests/control @@ -0,0 +1,17 @@ +AUTHOR =
>> "Ubuntu" +NAME = "selftests" +CRITERIA = """ +Uses built-in
>> kernel repository self tests. +""" +SUITE = "None" +TIME =
>> "SHORT" +TEST_CLASS = 'kernel' +TEST_CATEGORY = 'Functional' 
>> +TEST_TYPE = "client" +DOC = "" + +name =
>> 'ubuntu_kernel_selftests' + +results =
>> job.run_test_detail('ubuntu_kernel_selftests',
>> test_name='kernel-selftests', tag='kernel-selftests') + +# vi:set
>> ts=4 sw=4 expandtab syntax=python: diff --git
>> a/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py
>> b/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py new file
>> mode 100644 index 0000000..e8c8ed5 --- /dev/null +++
>> b/ubuntu_kernel_selftests/ubuntu_kernel_selftests.py @@ -0,0
>> +1,82 @@ +# +# +import os +import string +import sys +from
>> subprocess import call +from autotest.client
>> import test, utils +import multiprocessing + +# +# Dictionary of
>> kernel versions and releases for which self tests are supported. 
>> +# +releases = { '3.13':'trusty', '3.16':'utopic',
>> '3.18':'vivid', '3.19':'vivid' }; + +# +# Each release has a
>> unique set of tests that actually work. You can get the list of 
>> +# defined test targets from the TARGET macro of
>> tools/testing/selftests/Makefile. +# +tests = { +
>> '3.2.':[ ], +          '3.13':[ ], +          '3.16':[ ], +
>> '3.18':[ ], +          '3.19':[ ] +        };
> 
> Hm, maybe not really important but why is 3.2 in the tests list but
> not in the releases one?
> 
>> + +TARGETS = 'breakpoints cpu-hotplug efivarfs kcmp memfd
>> memory-hotplug mqueue mount net ptrace timers vm powerpc user
>> sysctl firmware ftrace' + +class
>> ubuntu_kernel_selftests(test.test): +    version = 1 + +    def
>> run_once(self, test_name): +        self.job.require_gcc() + +
>> # +        # Extract the running kernel version and pair it with
>> an Ubuntu release. Knowing +        # that allows us to pull the
>> right repository. +        # +        release = os.uname() +
>> uname = release[2] +        version = uname[0:4] +
>> print(version) + +        # +        # If there is no version in
>> the releases dictionary, then just bail since this kernel +
>> # may not have had self tests (3.2 for example). +        # +
>> if not releases[version]: +            print("There are no self
>> tests defined for kernel version %s" % version) + +        # +
>> # Use a local repo for manual testing. If it does not exist, then
>> clone from the master +        # repository. +        # +
>> repo = os.environ['HOME'] + '/ubuntu/ubuntu-%s' %
>> releases[version] +        if os.path.exists(repo) == True: +
>> cmd = 'git clone -q %s linux' % repo +            print(cmd) +
>> if os.system(cmd) < 0: +                print("FAIL: Could not
>> clone from local %s" % repo) +                return -1 + +
>> # +        # No local repository, so clone from the master repo. 
>> +        # +        if os.path.exists('linux') == False: +
>> cmd = 'git clone -q git://kernel.ubuntu.com/ubuntu/ubuntu-%s.git
>> linux' % releases[version] +            print(cmd) +
>> if os.system(cmd) < 0: +                print("FAIL: Could not
>> clone ubuntu-%s" % releases[version]) +                return -1 
>> + +        for x in tests[version]: +            cmd = "sudo make
>> -C linux/tools/testing/selftests/%s all run_tests" % x +
>> print(cmd) +            if os.system(cmd) < 0: +
>> print("FAIL: kernel self test %s failed" % x) +
>> return -1 + +        return 0 + +# vi:set ts=4 sw=4 expandtab
>> syntax=python:
>> 
> 
> 
> 
> 

Since the dep8 tests get run against all kernels, I wanted to make
sure that a 3.2 based kernel doesn't fail. Hence the empty list of tests.

rtg

- -- 
Tim Gardner tim.gardner at canonical.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJUbh/CAAoJED12yEX6FEfKoBgQAI6lkPDIdg21wml3WRmGTrFK
OpwnVUwu201XzW1qsMn2IAnxYGY3AAUywwx6ooM7W3+t9uB3047IVVWNkTePN+zh
AptvhRRwkBVBbCF4kooZRJbvBzK6NKR/tG/j+yELbskOFrFeQGAu/Y8SWALBXQWA
yw5JYLLH6UyVP/Yk0WKI2AZxBQoCeDI4XSV2B4ibVPANgef6ouLCRbIEQQlornUy
/MvyFdHBIJisOKlKreAd7PA62JQegyQSsJndaLsL5/glFjNmRdut8A70+JdoGUfX
qtQOTx4KORFLa0VujBs1dzANmoCHdVwsTMktRJniLRK/4+LTtfgme2VNBQbWa6OG
WHEYnPji57USBlR+sb/k7RQZ3RFRUR1e4/pgPYqYwI7cAydf/LnRCzEZSypb2/zk
OSG9YzMCgJ2/vR7jgCQbr1rzdQa216wAk+D1zi4bTK2DCzldDw8ZGJaRK6AnjpwL
ew3ez/gMC5MNuvhqkQZXom1K9wS7RPZlNoIeupZwUBp0hazFrnU1L4sARG9u8hGH
gfErLM0P9nBuzxWzcpNblXyyW8H0fkcFnjEcE08ogtgYdNotQ/O+2Rv2UI1lB3cj
3Gukf/1pGwp6bIHeIf8WxidWjSsd+Pm+2pFhdym/MApao7RcHSWw4Xuqr7A3azUA
pFSDzDULS3Nq8yXE+WS8
=v/qJ
-----END PGP SIGNATURE-----




More information about the kernel-team mailing list