author Ehsan Akhgari <>
Wed, 22 Aug 2012 11:56:38 -0400
changeset 102997 a16372ce30b5f6b747246b01fcd215a4bf3b6342
parent 94475 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 134811 1006a2fff3990d3816d198ead213bd6e4354302e
permissions -rw-r--r--
Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

'''A generic script to verify all test files are in the 
corresponding .ini file.

Usage: <directory> [<directory> ...]

import sys
import os
from glob import glob
import manifestparser

class srcManifestParser(manifestparser.ManifestParser):
  def __init__(self, manifests=(), defaults=None, strict=True, testroot=None):
    self.testroot = testroot
    manifestparser.ManifestParser.__init__(self, manifests, defaults, strict)

  def getRelativeRoot(self, here):
    if self.testroot is None:
        return manifestparser.ManifestParser.getRelativeRoot(self, self.rootdir)
    return self.testroot

def getIniTests(testdir):
  mp = manifestparser.ManifestParser(strict=False), 'xpcshell.ini'))
  return mp.tests

def verifyDirectory(initests, directory):
  files = glob(os.path.join(os.path.abspath(directory), "test_*"))
  for f in files:
    if (not os.path.isfile(f)):

    name = os.path.basename(f)
    if name.endswith('.in'):
      name = name[:-3]

    if not name.endswith('.js'):

    found = False
    for test in initests:
      if os.path.join(os.path.abspath(directory), name) == test['path']:
        found = True
    if not found:
      print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini'))

def verifyIniFile(initests, directory):
  files = glob(os.path.join(os.path.abspath(directory), "test_*"))
  for test in initests:
    name = test['path'].split('/')[-1]

    found = False
    for f in files:

      fname = f.split('/')[-1]
      if fname.endswith('.in'):
        fname = '.in'.join(fname.split('.in')[:-1])

      if os.path.join(os.path.abspath(directory), fname) == test['path']:
        found = True

    if not found:
      print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory)

def verifyMasterIni(mastername, topsrcdir, directory):
  mp = srcManifestParser(strict=False, testroot=topsrcdir)
  tests = mp.tests

  found = False
  for test in tests:
    if test['manifest'] == os.path.abspath(os.path.join(directory, 'xpcshell.ini')):
      found = True

  if not found:
    print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | directory %s is missing from master xpcshell.ini file %s" % (directory, mastername)

if __name__ == '__main__':
  if len(sys.argv) < 4:
    print >>sys.stderr, "Usage: <topsrcdir> <path/master.ini> <directory> [<directory> ...]"

  topsrcdir = sys.argv[1]
  for d in sys.argv[3:]:
    # xpcshell-unpack is a copy of xpcshell sibling directory and in the Makefile
    # we copy all files (including xpcshell.ini from the sibling directory.
    if d.endswith('toolkit/mozapps/extensions/test/xpcshell-unpack'):

    initests = getIniTests(d)
    verifyDirectory(initests, d)
    verifyIniFile(initests, d)
    verifyMasterIni(sys.argv[2], topsrcdir, d)