assertSoftware.py 20.4 KB
Newer Older
Łukasz Nowak's avatar
Łukasz Nowak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
##############################################################################
#
# Copyright (c) 2008-2010 Nexedi SA and Contributors. All Rights Reserved.
#                    Lukasz Nowak <luke@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################
28

Łukasz Nowak's avatar
Łukasz Nowak committed
29 30
import os
import subprocess
31 32
import unittest

33 34
def getCleanList(s):
  """Converts free form string separated by whitespaces to python list"""
35 36
  return sorted([q.strip() for q in s.split() if len(q.strip()) > 0])

37 38 39 40 41 42
def readElfAsDict(f):
  """Reads ELF information from file"""
  popen = subprocess.Popen(['readelf', '-d', f], stdout=subprocess.PIPE,
      stderr=subprocess.STDOUT)
  result = popen.communicate()[0]
  if popen.returncode != 0:
Łukasz Nowak's avatar
Łukasz Nowak committed
43
    raise AssertionError(result)
44 45 46
  library_list = []
  for l in result.split('\n'):
    if '(NEEDED)' in l:
Łukasz Nowak's avatar
Łukasz Nowak committed
47
      library_list.append(l.split(':')[1].strip(' []').split('.so')[0])
48
    elif '(RPATH)' in l:
49
      rpath_list = [q.rstrip('/') for q in l.split(':',1)[1].strip(' []').split(':')]
50
    elif '(RUNPATH)' in l:
51
      runpath_list = [q.rstrip('/') for q in l.split(':',1)[1].strip(' []').split(':')]
52
  return dict(
Łukasz Nowak's avatar
Łukasz Nowak committed
53 54 55
    library_list=sorted(library_list),
    rpath_list=sorted(rpath_list),
    runpath_list=sorted(runpath_list)
56 57
  )

58 59 60 61 62 63 64 65 66 67 68 69 70
class AssertSoftwareRunable(unittest.TestCase):
  def test_HaProxy(self):
    stdout, stderr = subprocess.Popen(["parts/haproxy/sbin/haproxy", "-v"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    self.assertEqual(stderr, '')
    self.assertTrue(stdout.startswith('HA-Proxy'))

  def test_Apache(self):
    stdout, stderr = subprocess.Popen(["parts/apache/bin/httpd", "-v"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    self.assertEqual(stderr, '')
    self.assertTrue(stdout.startswith('Server version: Apache'))

Łukasz Nowak's avatar
Łukasz Nowak committed
71 72 73 74 75 76
  def test_Varnish(self):
    stdout, stderr = subprocess.Popen(["parts/varnish/sbin/varnishd", "-V"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    self.assertEqual(stdout, '')
    self.assertTrue(stderr.startswith('varnishd ('))

77 78 79 80 81 82 83 84 85 86 87 88 89
  def test_TokyoCabinet(self):
    stdout, stderr = subprocess.Popen(["parts/tokyocabinet/bin/tcamgr",
      "version"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    self.assertEqual(stderr, '')
    self.assertTrue(stdout.startswith('Tokyo Cabinet'))

  def test_Flare(self):
    stdout, stderr = subprocess.Popen(["parts/flare/bin/flarei", "-v"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    self.assertEqual(stderr, '')
    self.assertTrue(stdout.startswith('flare'))

90
  def test_rdiff_backup(self):
91 92
    stdout, stderr = subprocess.Popen(["bin/rdiff-backup", "-V"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
93 94 95
    self.assertEqual(stderr, '')
    self.assertEqual(stdout.strip(), 'rdiff-backup 1.0.5')

96 97 98 99 100 101 102 103 104 105 106 107
  def test_imagemagick(self):
    binary_list = [ 'animate', 'composite', 'convert', 'identify', 'mogrify',
        'stream', 'compare', 'conjure', 'display', 'import', 'montage']
    base = os.path.join('parts', 'imagemagick', 'bin')
    error_list = []
    for binary in binary_list:
      stdout, stderr = subprocess.Popen([os.path.join(base, binary), "-version"],
          stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
      if 'Version: ImageMagick' not in stdout:
        error_list.append(binary)
    self.assertEqual([], error_list)

108 109 110 111 112 113
  def test_w3m(self):
    stdout, stderr = subprocess.Popen(["parts/w3m/bin/w3m", "-V"],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    self.assertEqual(stderr, '')
    self.assertTrue(stdout.startswith('w3m version w3m/0.5.2'))

114
class AssertMysql50Tritonn(unittest.TestCase):
115 116 117 118 119 120 121
  def test_ld_mysqld(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/libexec/mysqld')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libdl',
      'libgcc_s', 'libm', 'libnsl', 'libpthread', 'librt', 'libsenna',
      'libssl', 'libstdc++', 'libz']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
122
        software in ['ncurses', 'zlib', 'senna', 'readline', 'openssl']]
123 124 125 126 127 128 129 130 131 132
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysqlmanager(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/libexec/mysqlmanager')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libgcc_s',
      'libm', 'libnsl', 'libpthread', 'libssl', 'libstdc++', 'libz']),
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
133
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
134 135
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])
136

137 138 139 140 141 142 143
  def test_ld_libmysqlclient_r(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/lib/mysql/libmysqlclient_r.so')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libm', 'libnsl',
      'libpthread', 'libssl', 'libz']),
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
144
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
145 146 147 148 149 150 151 152 153 154
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_libmysqlclient(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/lib/mysql/libmysqlclient.so')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libm', 'libnsl',
      'libssl', 'libz']),
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
155
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
156 157 158 159 160 161 162 163 164 165
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_sphinx(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/lib/mysql/sphinx.so')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libgcc_s', 'libm', 'libnsl',
      'libpthread', 'libstdc++']),
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
166
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
167 168 169
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

Łukasz Nowak's avatar
Łukasz Nowak committed
170 171 172 173 174 175 176 177 178 179
  def test_ld_mysql(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/bin/mysql')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libgcc_s', 'libm',
      'libmysqlclient', 'libncurses', 'libnsl', 'libreadline', 'libssl', 'libstdc++',
      'libz']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
    expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir),
      'parts', 'mysql-tritonn-5.0', 'lib', 'mysql'))
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysqladmin(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/bin/mysqladmin')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libgcc_s', 'libm',
      'libmysqlclient', 'libnsl', 'libssl', 'libstdc++', 'libz']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
    expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir),
      'parts', 'mysql-tritonn-5.0', 'lib', 'mysql'))
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysqldump(self):
    elf_dict = readElfAsDict('parts/mysql-tritonn-5.0/bin/mysqldump')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libm',
      'libmysqlclient', 'libnsl', 'libssl', 'libz']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline', 'openssl']]
    expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir),
      'parts', 'mysql-tritonn-5.0', 'lib', 'mysql'))
Łukasz Nowak's avatar
Łukasz Nowak committed
204 205 206
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

Łukasz Nowak's avatar
Łukasz Nowak committed
207 208 209
class AssertMysql51(unittest.TestCase):
  def test_ld_mysqld(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/libexec/mysqld')
210 211
    self.assertEqual(sorted(['libc', 'libcrypt', 'libdl', 'libgcc_s', 'libm', 'libnsl',
      'libpthread', 'libstdc++', 'libz']), elf_dict['library_list'])
Łukasz Nowak's avatar
Łukasz Nowak committed
212 213 214 215 216 217 218 219 220
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysqlmanager(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/libexec/mysqlmanager')
    self.assertEqual(sorted(['libc', 'libcrypt', 'libgcc_s', 'libm', 'libnsl',
221
      'libpthread', 'libstdc++', 'libz']), elf_dict['library_list'])
Łukasz Nowak's avatar
Łukasz Nowak committed
222 223 224 225 226 227 228 229
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_libmysqlclient_r(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/lib/mysql/libmysqlclient_r.so')
230
    self.assertEqual(sorted(['libc', 'libz', 'libcrypt', 'libm', 'libnsl', 'libpthread']),
Łukasz Nowak's avatar
Łukasz Nowak committed
231 232 233
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
234
        software in ['ncurses', 'zlib', 'readline']]
Łukasz Nowak's avatar
Łukasz Nowak committed
235 236 237 238 239
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_libmysqlclient(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/lib/mysql/libmysqlclient.so')
240
    self.assertEqual(sorted(['libc', 'libz', 'libcrypt', 'libm', 'libnsl', 'libpthread']),
Łukasz Nowak's avatar
Łukasz Nowak committed
241 242 243
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
244 245 246 247 248 249 250
        software in ['ncurses', 'readline', 'zlib']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysql(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/bin/mysql')
    self.assertEqual(sorted(['libc', 'libz', 'libcrypt', 'libgcc_s', 'libm',
251
      'libmysqlclient', 'libncurses', 'libnsl', 'libpthread', 'libreadline',
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
      'libstdc++']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline']]
    expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir),
      'parts', 'mysql-5.1', 'lib', 'mysql'))
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysqladmin(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/bin/mysqladmin')
    self.assertEqual(sorted(['libc', 'libz', 'libcrypt', 'libgcc_s', 'libm',
      'libmysqlclient', 'libnsl', 'libpthread', 'libstdc++']),
      elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline']]
    expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir),
      'parts', 'mysql-5.1', 'lib', 'mysql'))
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_mysqldump(self):
    elf_dict = readElfAsDict('parts/mysql-5.1/bin/mysqldump')
    self.assertEqual(sorted(['libc', 'libz', 'libcrypt', 'libm', 'libmysqlclient',
      'libnsl', 'libpthread']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['ncurses', 'zlib', 'readline']]
    expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir),
      'parts', 'mysql-5.1', 'lib', 'mysql'))
Łukasz Nowak's avatar
Łukasz Nowak committed
283 284 285
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

286 287 288 289 290 291 292 293 294 295 296 297 298
class AssertMemcached(unittest.TestCase):
  """Tests for built memcached"""

  def test_ld_memcached(self):
    """Checks proper liunking to libevent from memcached"""
    elf_dict = readElfAsDict('parts/memcached/bin/memcached')
    self.assertEqual(sorted(['libpthread', 'libevent-1.4', 'libc']),
        elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['libevent']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])
Łukasz Nowak's avatar
Łukasz Nowak committed
299 300 301 302 303 304 305 306 307 308 309 310

class AssertPythonMysql(unittest.TestCase):
  def test_ld_mysqlso(self):
    for d in os.listdir('develop-eggs'):
      if d.startswith('MySQL_python'):
        path = os.path.join('develop-eggs', d, '_mysql.so')
        elf_dict = readElfAsDict(path)
        self.assertEqual(sorted(['libc', 'libcrypt', 'libcrypto', 'libm',
          'libmysqlclient_r', 'libnsl', 'libpthread', 'libssl', 'libz']),
          elf_dict['library_list'])
        soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
        expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
311 312
            software in ['zlib', 'openssl']]
        expected_rpath_list.append(os.path.join(os.path.abspath(os.curdir), 'parts', 'mysql-tritonn-5.0', 'lib', 'mysql'))
Łukasz Nowak's avatar
Łukasz Nowak committed
313 314
        self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
        self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])
315

316
class AssertApache(unittest.TestCase):
Łukasz Nowak's avatar
Łukasz Nowak committed
317
  """Tests for built apache"""
318

319
  def test_ld_libaprutil1(self):
320
    """Checks proper linking of libaprutil-1.so"""
321
    elf_dict = readElfAsDict('parts/apache/lib/libaprutil-1.so')
Łukasz Nowak's avatar
Łukasz Nowak committed
322 323 324 325 326 327 328
    self.assertEqual(sorted(['libexpat', 'libapr-1', 'librt', 'libcrypt',
      'libpthread', 'libdl', 'libc']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['apache', 'zlib', 'openssl']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])
329

330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
  def test_ld_libapr1(self):
    """Checks proper linking of libapr-1.so"""
    elf_dict = readElfAsDict('parts/apache/lib/libapr-1.so')
    self.assertEqual(sorted(['librt', 'libcrypt',
      'libpthread', 'libdl', 'libc']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['zlib', 'openssl']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

  def test_ld_libexpat(self):
    """Checks proper linking of libexpat.so"""
    elf_dict = readElfAsDict('parts/apache/lib/libexpat.so')
    self.assertEqual(sorted(['libc']), elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['zlib', 'openssl']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

351
  def test_modules(self):
Łukasz Nowak's avatar
Łukasz Nowak committed
352
    """Checks for availability of apache modules"""
353
    required_module_list = getCleanList("""
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
      authn_default_module
      log_config_module
      proxy_http_module
      authn_alias_module
      authz_dbm_module
      case_filter_in_module
      imagemap_module
      setenvif_module
      include_module
      charset_lite_module
      info_module
      cache_module
      actions_module
      proxy_connect_module
      auth_digest_module
      unique_id_module
      mime_magic_module
      disk_cache_module
      mime_module
      usertrack_module
      asis_module
      optional_hook_import_module
      negotiation_module
      proxy_module
      authz_default_module
      ext_filter_module
      auth_basic_module
      authz_owner_module
      authn_anon_module
      rewrite_module
      proxy_balancer_module
      substitute_module
      filter_module
      expires_module
      autoindex_module
      status_module
      cgid_module
      version_module
      echo_module
      optional_fn_export_module
      optional_fn_import_module
      ident_module
      cgi_module
      bucketeer_module
      optional_hook_export_module
      vhost_alias_module
      ssl_module
      authz_user_module
      env_module
      logio_module
      proxy_ftp_module
      cern_meta_module
      authz_groupfile_module
      dir_module
      log_forensic_module
      alias_module
      deflate_module
      authn_dbm_module
      case_filter_module
      authz_host_module
      headers_module
      dumpio_module
      speling_module
      authn_file_module
418
    """)
419 420 421 422 423
    parts_path_prefix = os.path.join(os.path.dirname(__file__), '../parts')
    result = os.popen("%s/apache/bin/httpd -M" % parts_path_prefix)
    loaded_module_list = [module_name for module_name in result.read().split() 
                          if module_name.endswith('module')]
    result.close()
424 425
    failed_module_list = []
    for module in required_module_list:
426
      if module not in loaded_module_list:
427 428
        failed_module_list.append(module)
    self.assertEqual([], failed_module_list,
Łukasz Nowak's avatar
Łukasz Nowak committed
429
        'Apache modules not found:\n'+'\n'.join(failed_module_list))
430

431 432 433 434 435 436 437 438 439 440 441
class AssertItools(unittest.TestCase):
  def test_ld_parserso(self):
    elf_dict = readElfAsDict('parts/itools/lib/itools/xml/parser.so')
    self.assertEqual(sorted(['libc', 'libglib-2.0', 'libpthread']),
        elf_dict['library_list'])
    soft_dir = os.path.join(os.path.abspath(os.curdir), 'parts')
    expected_rpath_list = [os.path.join(soft_dir, software, 'lib') for
        software in ['glib']]
    self.assertEqual(sorted(expected_rpath_list), elf_dict['rpath_list'])
    self.assertEqual(sorted(expected_rpath_list), elf_dict['runpath_list'])

442 443
if __name__ == '__main__':
  unittest.main()