source: rtems-tools/rtemstoolkit/solaris.py @ 6d30de6

5
Last change on this file since 6d30de6 was 7e5cdea, checked in by Chris Johns <chrisj@…>, on 11/23/18 at 04:02:52

rtemstoolkit: Add unit testing for the python modules

  • Add support to run the unit tests for the rtemstoolkit python modules from waf. Enter './waf test' for the tests to be run on python2 and python3.
  • Update the importing of rtemstoolkit modules to the standard method which works on python2 and python3.
  • Update the README.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# This code is based on what ever doco about spec files I could find and
22# RTEMS project's spec files.
23#
24
25import os
26
27from rtemstoolkit import check
28from rtemstoolkit import error
29from rtemstoolkit import execute
30
31def cpus():
32    psrinfo = '/sbin/psrinfo|wc -l'
33    e = execute.capture_execution()
34    exit_code, proc, output = e.shell(psrinfo)
35    if exit_code == 0:
36        ncpus = int(output)
37    else:
38        ncpus = 1
39    return ncpus
40
41def overrides():
42    uname = os.uname()
43    ncpus = '%d' % (cpus())
44    if uname[4] == 'i86pc':
45        cpu = 'i386'
46    else:
47        cpu = uname[4]
48    version = uname[2]
49    if version.find('-') > 0:
50        version = version.split('-')[0]
51    defines = {
52        '_ncpus':           ('none',    'none',     ncpus),
53        '_os':              ('none',    'none',     'solaris'),
54        '_host':            ('triplet', 'required', cpu + '-pc-solaris2'),
55        '_host_vendor':     ('none',    'none',     'pc'),
56        '_host_os':         ('none',    'none',     'solaris'),
57        '_host_os_version': ('none',    'none',     version),
58        '_host_cpu':        ('none',    'none',     cpu),
59        '_host_alias':      ('none',    'none',     '%{nil}'),
60        '_host_arch':       ('none',    'none',     cpu),
61        '_usr':             ('dir',     'required', '/usr'),
62        '_var':             ('dir',     'optional', '/var'),
63        '__bash':           ('exe',     'optional', '/usr/bin/bash'),
64        '__bison':          ('exe',     'required', '/usr/bin/bison'),
65        '__git':            ('exe',     'required', '/usr/bin/git'),
66        '__svn':            ('exe',     'required', '/usr/bin/svn'),
67        '__cvs':            ('exe',     'required', '/usr/bin/cvs'),
68        '__xz':             ('exe',     'optional', '/usr/bin/xz'),
69        '__make':           ('exe',     'required', 'gmake'),
70        '__patch_opts':     ('none',     'none',    '-E'),
71        '__chown':          ('exe',     'required', '/usr/bin/chown'),
72        '__install':        ('exe',     'required', '/usr/bin/ginstall'),
73        '__cc':             ('exe',     'required', '/usr/bin/gcc'),
74        '__cxx':            ('exe',     'required', '/usr/bin/g++'),
75        'with_iconv':       ('none',    'none',     '0')
76        }
77
78    defines['_build']        = defines['_host']
79    defines['_build_vendor'] = defines['_host_vendor']
80    defines['_build_os']     = defines['_host_os']
81    defines['_build_cpu']    = defines['_host_cpu']
82    defines['_build_alias']  = defines['_host_alias']
83    defines['_build_arch']   = defines['_host_arch']
84
85    return defines
86
87if __name__ == '__main__':
88    import pprint
89    pprint.pprint(cpus())
90    pprint.pprint(overrides())
Note: See TracBrowser for help on using the repository browser.