Changeset 1663

Show
Ignore:
Timestamp:
09/16/09 14:06:12 (15 years ago)
Author:
arnonym
Message:

Try to fix the problem of #232 by compiling a static file of pkg-config output during compile-time to be included in the ffado-diag output.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/tools/ffado-diag-static

    • Property svn:mergeinfo set
    r1630 r1663  
    44# 
    55# Copyright (C) 2008 Pieter Palmers 
     6#               2009 Arnold Krilles 
    67# 
    78# This program is free software: you can redistribute it and/or modify 
     
    2526 
    2627# Add the path of the installed dependent files 
    27 sys.path.append( "$PYTHONDIR" ) 
    28  
    2928import os 
    3029import commands 
     
    3231import logging 
    3332 
    34 from listirqinfo import IRQ,SoftIRQ,IRQInfo 
    35 from helpstrings import HelpStrings 
    36  
    37 ## message strings 
    38 FFADODIAG_VERSION = "$VERSION-$REVISION" 
     33from ffado_diag_helpers import * 
    3934 
    4035welcome_msg = """ 
    4136 
    42 FFADO diagnostic utility """ + FFADODIAG_VERSION + """ 
     37FFADO static diagnostic utility 
    4338============================ 
    4439(C) 2008 Pieter Palmers 
     40(C) 2009 Arnold Krille 
    4541 
    4642""" 
     
    5551## logging setup 
    5652logging.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 or mod == modulename.replace('-', '_'): 
    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('firewire-core'): 
    121         retval = False 
    122     if not check_for_module_loaded('firewire-ohci'): 
    123         retval = False 
    124     return retval 
    125  
    126 def check_1394newstack_present(): 
    127     retval = True 
    128     if not check_for_module_present('firewire-core'): 
    129         retval = False 
    130     if not check_for_module_present('firewire-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) 
     53log = logging.getLogger('staticdiag') 
    18054 
    18155## main program 
     
    19266        loglevel = eval(sys.argv[1]) 
    19367        if loglevel == 1: 
    194             logging.getLogger('diag').setLevel(logging.INFO) 
     68            logging.getLogger('staticdiag').setLevel(logging.INFO) 
    19569        elif loglevel == 2: 
    196             logging.getLogger('diag').setLevel(logging.DEBUG) 
     70            logging.getLogger('staticdiag').setLevel(logging.DEBUG) 
    19771 
    19872    print "=== CHECK ===" 
    199     print " Base system..." 
    200      
    201     # check kernel 
    202     kernel_version = get_kernel_version() 
    203     print "  kernel version............ " + str(kernel_version) 
    204     kernel_is_rt_patched = get_kernel_rt_patched() 
    205     print "   RT patched............... " + str(kernel_is_rt_patched) 
    206      
    207     # check modules 
    208     oldstack_present = check_1394oldstack_present() 
    209     oldstack_loaded = check_1394oldstack_loaded() 
    210     newstack_present = check_1394newstack_present() 
    211     newstack_loaded = check_1394newstack_loaded() 
    212      
    213     print "  old 1394 stack present.... " + str(oldstack_present) 
    214     print "  old 1394 stack loaded..... " + str(oldstack_loaded) 
    215     print "  new 1394 stack present.... " + str(newstack_present) 
    216     print "  new 1394 stack loaded..... " + str(newstack_loaded) 
    217      
    218     # check /dev/raw1394 node presence 
    219     devnode_present = check_1394oldstack_devnode_present() 
    220     print "  /dev/raw1394 node present. " + str(devnode_present) 
    221     if devnode_present: 
    222         # check /dev/raw1394 access permissions 
    223         devnode_permissions = check_1394oldstack_devnode_permissions() 
    224         print "  /dev/raw1394 permissions.. " + str(devnode_permissions) 
    225     else: 
    226         devnode_permissions = None 
    22773 
    22874    # check libraries 
    229     print " Prerequisites..." 
    23075    print "   gcc................ %s" % get_version_first_line('gcc --version') 
    23176    print "   g++................ %s" % get_version_first_line('g++ --version') 
     
    24590    print "     flags............ %s" % get_package_flags("dbus-1") 
    24691 
    247     # libraw 
    248      
    249     print " Hardware..." 
    250     # check host controller 
    251     print "   Host controllers:" 
    252     list_host_controllers() 
    253     print "   CPU info:" 
    254     print run_command("cat /proc/cpuinfo") 
    255  
    256     print " Configuration..." 
    257     # check RT settings 
    258      
    259     # check IRQ settings  
    260     print "  IRQ information" 
    261     info = IRQInfo() 
    262  
    263     info.load() 
    264     print str(info) 
    265  
    266     print "" 
    267     print "=== REPORT ===" 
    268      
    269     help = HelpStrings() 
    270      
    271     # do the interpretation of the tests 
    272     print "FireWire kernel drivers:" 
    273     ## FIXME: what about in-kernel firewire? (i.e. no modules) 
    274     if not oldstack_present: 
    275         help.show('MODULES_OLD_STACK_NOT_INSTALLED') 
    276         sys.exit(-1) 
    277     else: 
    278         if newstack_loaded and oldstack_loaded: 
    279             help.show('MODULES_BOTH_STACKS_LOADED') 
    280             sys.exit(-1) 
    281         elif newstack_loaded: 
    282             help.show('MODULES_NEW_STACK_LOADED') 
    283             sys.exit(-1) 
    284         elif not oldstack_loaded: 
    285             help.show('MODULES_OLD_STACK_NOT_LOADED') 
    286             sys.exit(-1) 
    287         else: 
    288             print "[PASS] Kernel modules present and correctly loaded." 
    289  
    290     if not devnode_present: 
    291         help.show('DEVNODE_OLD_STACK_NOT_PRESENT') 
    292         sys.exit(-1) 
    293     else: 
    294         if not devnode_permissions: 
    295             help.show('DEVNODE_OLD_STACK_NO_PERMISSION') 
    296             sys.exit(-1) 
    297         else: 
    298             print "[PASS] /dev/raw1394 node present and accessible." 
    299      
    300      
    301      
  • trunk/libffado/support/tools/ffado-diag.in

    r1630 r1663  
    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 or mod == modulename.replace('-', '_'): 
    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('firewire-core'): 
    121         retval = False 
    122     if not check_for_module_loaded('firewire-ohci'): 
    123         retval = False 
    124     return retval 
    125  
    126 def check_1394newstack_present(): 
    127     retval = True 
    128     if not check_for_module_present('firewire-core'): 
    129         retval = False 
    130     if not check_for_module_present('firewire-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 
  • trunk/libffado/support/tools/ffado_diag_helpers.py

    • Property svn:mergeinfo set
    • Property svn:executable deleted
    r1630 r1663  
    2424import sys 
    2525 
    26 # Add the path of the installed dependent files 
    27 sys.path.append( "$PYTHONDIR" ) 
    28  
    2926import os 
    3027import commands 
    3128import re 
    3229import logging 
    33  
    34 from listirqinfo import IRQ,SoftIRQ,IRQInfo 
    35 from helpstrings import HelpStrings 
    36  
    37 ## message strings 
    38 FFADODIAG_VERSION = "$VERSION-$REVISION" 
    39  
    40 welcome_msg = """ 
    41  
    42 FFADO diagnostic utility """ + FFADODIAG_VERSION + """ 
    43 ============================ 
    44 (C) 2008 Pieter Palmers 
    45  
    46 """ 
    47  
    48 help_msg = """ 
    49 Usage: ffado-diag [verboselevel] 
    50  
    51   verboselevel : verbosity level. (optional) 
    52  
    53 """ 
    5430 
    5531## logging setup 
     
    179155            print run_command(cmd) 
    180156 
    181 ## main program 
    182 if __name__== '__main__': 
    183  
    184     print welcome_msg 
    185  
    186     num_args = len(sys.argv) 
    187     if num_args not in [1,2]: 
    188         print help 
    189         sys.exit(0) 
    190  
    191     if num_args == 2: 
    192         loglevel = eval(sys.argv[1]) 
    193         if loglevel == 1: 
    194             logging.getLogger('diag').setLevel(logging.INFO) 
    195         elif loglevel == 2: 
    196             logging.getLogger('diag').setLevel(logging.DEBUG) 
    197  
    198     print "=== CHECK ===" 
    199     print " Base system..." 
    200      
    201     # check kernel 
    202     kernel_version = get_kernel_version() 
    203     print "  kernel version............ " + str(kernel_version) 
    204     kernel_is_rt_patched = get_kernel_rt_patched() 
    205     print "   RT patched............... " + str(kernel_is_rt_patched) 
    206      
    207     # check modules 
    208     oldstack_present = check_1394oldstack_present() 
    209     oldstack_loaded = check_1394oldstack_loaded() 
    210     newstack_present = check_1394newstack_present() 
    211     newstack_loaded = check_1394newstack_loaded() 
    212      
    213     print "  old 1394 stack present.... " + str(oldstack_present) 
    214     print "  old 1394 stack loaded..... " + str(oldstack_loaded) 
    215     print "  new 1394 stack present.... " + str(newstack_present) 
    216     print "  new 1394 stack loaded..... " + str(newstack_loaded) 
    217      
    218     # check /dev/raw1394 node presence 
    219     devnode_present = check_1394oldstack_devnode_present() 
    220     print "  /dev/raw1394 node present. " + str(devnode_present) 
    221     if devnode_present: 
    222         # check /dev/raw1394 access permissions 
    223         devnode_permissions = check_1394oldstack_devnode_permissions() 
    224         print "  /dev/raw1394 permissions.. " + str(devnode_permissions) 
    225     else: 
    226         devnode_permissions = None 
    227  
    228     # check libraries 
    229     print " Prerequisites..." 
    230     print "   gcc................ %s" % get_version_first_line('gcc --version') 
    231     print "   g++................ %s" % get_version_first_line('g++ --version') 
    232     print "   PyQt............... %s" % get_version_first_line('pyuic -version') 
    233     print "   jackd.............. %s" % get_version_first_line('jackd --version') 
    234     print "     path............. %s" % get_command_path('jackd') 
    235     print "     flags............ %s" % get_package_flags("jack") 
    236     print "   libraw1394......... %s" % get_package_version("libraw1394") 
    237     print "     flags............ %s" % get_package_flags("libraw1394") 
    238     print "   libavc1394......... %s" % get_package_version("libavc1394") 
    239     print "     flags............ %s" % get_package_flags("libavc1394") 
    240     print "   libiec61883........ %s" % get_package_version("libiec61883") 
    241     print "     flags............ %s" % get_package_flags("libiec61883") 
    242     print "   libxml++-2.6....... %s" % get_package_version("libxml++-2.6") 
    243     print "     flags............ %s" % get_package_flags("libxml++-2.6") 
    244     print "   dbus-1............. %s" % get_package_version("dbus-1") 
    245     print "     flags............ %s" % get_package_flags("dbus-1") 
    246  
    247     # libraw 
    248      
    249     print " Hardware..." 
    250     # check host controller 
    251     print "   Host controllers:" 
    252     list_host_controllers() 
    253     print "   CPU info:" 
    254     print run_command("cat /proc/cpuinfo") 
    255  
    256     print " Configuration..." 
    257     # check RT settings 
    258      
    259     # check IRQ settings  
    260     print "  IRQ information" 
    261     info = IRQInfo() 
    262  
    263     info.load() 
    264     print str(info) 
    265  
    266     print "" 
    267     print "=== REPORT ===" 
    268      
    269     help = HelpStrings() 
    270      
    271     # do the interpretation of the tests 
    272     print "FireWire kernel drivers:" 
    273     ## FIXME: what about in-kernel firewire? (i.e. no modules) 
    274     if not oldstack_present: 
    275         help.show('MODULES_OLD_STACK_NOT_INSTALLED') 
    276         sys.exit(-1) 
    277     else: 
    278         if newstack_loaded and oldstack_loaded: 
    279             help.show('MODULES_BOTH_STACKS_LOADED') 
    280             sys.exit(-1) 
    281         elif newstack_loaded: 
    282             help.show('MODULES_NEW_STACK_LOADED') 
    283             sys.exit(-1) 
    284         elif not oldstack_loaded: 
    285             help.show('MODULES_OLD_STACK_NOT_LOADED') 
    286             sys.exit(-1) 
    287         else: 
    288             print "[PASS] Kernel modules present and correctly loaded." 
    289  
    290     if not devnode_present: 
    291         help.show('DEVNODE_OLD_STACK_NOT_PRESENT') 
    292         sys.exit(-1) 
    293     else: 
    294         if not devnode_permissions: 
    295             help.show('DEVNODE_OLD_STACK_NO_PERMISSION') 
    296             sys.exit(-1) 
    297         else: 
    298             print "[PASS] /dev/raw1394 node present and accessible." 
    299      
    300      
    301      
  • trunk/libffado/support/tools/SConscript

    r1501 r1663  
    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" )