t_elf.py revision 3402
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import unittest
import os
import re
# If something in this list does not exist, the test_valid_elf
# tests may fail. At some point if someone moves paths around in
# ON, this might fail. Sorry!
elf_paths = [
]
def test_non_elf(self):
"""Test that elf routines gracefully handle non-elf objects."""
p = "this-is-not-an-elf-file.so"
def test_non_existent(self):
"""Test that elf routines gracefully handle ENOENT."""
def test_valid_elf(self):
"""Test that elf routines work on a small set of objects."""
elf.get_dynamic(p)
elf.get_hashes(p)
def test_get_hashes_params(self):
"""Test that get_hashes(..) returns checksums according to the
parameters passed to the method."""
# Check that the hashes generated have the correct length
# depending on the algorithm used to generated.
sha1_len = 40
sha256_len = 64
# the default is to return both the SHA-1 elfhash and
# the SHA-256 pkg.content-hash
for h in range(2):
sha256_count = 0
unsigned_count = 0
for h in range(4):
unsigned_count += 1
if v[1] == "sha256":
sha256_count += 1
elif v[1] == "sha512t_256":
sha512t_256_count += 1
if __name__ == "__main__":