Changeset 1665

Show
Ignore:
Timestamp:
09/17/09 13:39:58 (15 years ago)
Author:
arnonym
Message:

Backport r1993 and fix #232.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/support/tools/ffado-diag.in

    r1500 r1665  
    2727sys.path.append( "$PYTHONDIR" ) 
    2828 
    29 import os 
    30 import commands 
    31 import re 
    32 import logging 
    33  
    3429from listirqinfo import IRQ,SoftIRQ,IRQInfo 
    3530from helpstrings import HelpStrings 
     31from ffado_diag_helpers import * 
    3632 
    3733## message strings 
     
    5248 
    5349""" 
    54  
    55 ## logging setup 
    56 logging.basicConfig() 
    57 log = logging.getLogger('diag') 
    58  
    59 ## helper routines 
    60  
    61 # kernel 
    62 def get_kernel_version(): 
    63     (exitstatus, outtext) = commands.getstatusoutput('uname -r') 
    64     log.debug("uname -r outputs: %s" % outtext) 
    65     return outtext 
    66  
    67 def get_kernel_rt_patched(): 
    68     print "FIXME: implement test for RT kernel" 
    69     return False 
    70  
    71 # modules 
    72 def check_for_module_loaded(modulename): 
    73     log.info("Checking if module '%s' is loaded... " % modulename) 
    74     f = open('/proc/modules') 
    75     lines = f.readlines() 
    76     f.close() 
    77     for l in lines: 
    78         mod = l.split()[0] 
    79         if mod == modulename: 
    80             log.info(" found") 
    81             return True 
    82     log.info(" not found") 
    83     return False 
    84      
    85 def check_for_module_present(modulename): 
    86     log.info("Checking if module '%s' is present... " % modulename) 
    87     kver = get_kernel_version() 
    88     (exitstatus, outtext) = commands.getstatusoutput("find \"/lib/modules/%s/\" -name '%s.ko' | grep '%s'" % \ 
    89                                                      (kver, modulename, modulename) ) 
    90     log.debug("find outputs: %s" % outtext) 
    91     if outtext == "": 
    92         log.info(" not found") 
    93         return False 
    94     else: 
    95         log.info(" found") 
    96         return True 
    97  
    98 def check_1394oldstack_loaded(): 
    99     retval = True 
    100     if not check_for_module_loaded('ieee1394'): 
    101         retval = False 
    102     if not check_for_module_loaded('ohci1394'): 
    103         retval = False 
    104     if not check_for_module_loaded('raw1394'): 
    105         retval = False 
    106     return retval 
    107  
    108 def check_1394oldstack_present(): 
    109     retval = True 
    110     if not check_for_module_present('ieee1394'): 
    111         retval = False 
    112     if not check_for_module_present('ohci1394'): 
    113         retval = False 
    114     if not check_for_module_present('raw1394'): 
    115         retval = False 
    116     return retval 
    117  
    118 def check_1394newstack_loaded(): 
    119     retval = True 
    120     if not check_for_module_loaded('fw-core'): 
    121         retval = False 
    122     if not check_for_module_loaded('fw-ohci'): 
    123         retval = False 
    124     return retval 
    125  
    126 def check_1394newstack_present(): 
    127     retval = True 
    128     if not check_for_module_present('fw-core'): 
    129         retval = False 
    130     if not check_for_module_present('fw-ohci'): 
    131         retval = False 
    132     return retval 
    133  
    134 def check_1394oldstack_devnode_present(): 
    135     return os.path.exists('/dev/raw1394') 
    136  
    137 def check_1394oldstack_devnode_permissions(): 
    138     f = open('/dev/raw1394','w') 
    139     if f: 
    140         f.close() 
    141         return True 
    142     else: 
    143         return False 
    144  
    145 def run_command(cmd): 
    146     (exitstatus, outtext) = commands.getstatusoutput(cmd) 
    147     log.debug("%s outputs: %s" % (cmd, outtext)) 
    148     return outtext 
    149  
    150 # package versions 
    151 def get_package_version(name): 
    152     cmd = "pkg-config --modversion %s" % name 
    153     return run_command(cmd) 
    154  
    155 def get_package_flags(name): 
    156     cmd = "pkg-config --cflags --libs %s" % name 
    157     return run_command(cmd) 
    158  
    159 def get_command_path(name): 
    160     cmd = "which %s" % name 
    161     return run_command(cmd) 
    162  
    163 def get_version_first_line(cmd): 
    164     ver = run_command(cmd).split("\n") 
    165     if len(ver) == 0: 
    166         ver = ["None"] 
    167     return ver[0] 
    168  
    169  
    170 def list_host_controllers(): 
    171     cmd = "lspci | grep 1394" 
    172     controllers = run_command(cmd).split("\n") 
    173     log.debug("lspci | grep 1394: %s" % controllers) 
    174     for c in controllers: 
    175         tmp = c.split() 
    176         if len(tmp) > 0: 
    177             tmp 
    178             cmd = "lspci -vv -nn -s %s" % tmp[0] 
    179             print run_command(cmd) 
    18050 
    18151## main program 
     
    22797 
    22898    # check libraries 
    229     print " Prerequisites..." 
     99    print " Prerequisites (dynamic at run-time)..." 
    230100    print "   gcc................ %s" % get_version_first_line('gcc --version') 
    231101    print "   g++................ %s" % get_version_first_line('g++ --version') 
     
    244114    print "   dbus-1............. %s" % get_package_version("dbus-1") 
    245115    print "     flags............ %s" % get_package_flags("dbus-1") 
     116    print " Prerequisites (static at compile-time)..." 
     117    f = open( "$PYTHONDIR/static_info.txt", "r" ) 
     118    for line in f: 
     119        line = line[:-1] 
     120        if line is not "\n" and line.startswith("  "): 
     121            print line 
     122    f.close() 
    246123 
    247124    # libraw 
  • branches/libffado-2.0/support/tools/SConscript

    r1500 r1665  
    3535e['pythondir'] = Template( os.path.join( e['sharedir'], 'python' ) ).safe_substitute( e ) 
    3636 
     37e.Command( "static_info.txt", "#/SConstruct", "python support/tools/ffado-diag-static > $TARGET" ) 
     38 
    3739e.ScanReplace( "ffado-diag.in" ) 
    3840 
     
    4042e.Install( "$pythondir", "helpstrings.py" ) 
    4143e.Install( "$pythondir", "listirqinfo.py" ) 
     44e.Install( "$pythondir", "static_info.txt" ) 
     45e.Install( "$pythondir", "ffado_diag_helpers.py" )