Testing LibElf

LibElf development is proceeding side-by-side with that of a test suite.

The test suite needs the following tools:

  • The py-yaml port in /usr/ports/devel/py-yaml. Version 3.04 or later.
  • TET from the OpenGroup. See /usr/ports/misc/tet. The 'lite' version of TET is recommended.

This script in ts/tset/bin/elfc converts a textual (YAML) description of an ELF file to an equivalent binary file of the appropriate class and endianness. It offers nearly complete control over the contents of the generated ELF file.

It is used by the test suite to generate both well-formed and malformed ELF files for use by test cases.

For example:

% cat t.yaml
ehdr: !Ehdr
  e_ident: !Ident
   ei_data: ELFDATA2MSB
  e_machine: EM_SPARCV9
  e_type: ET_REL
% ./tset/bin/elfc t.yaml
% file a.out
ELF 32-bit MSB relocatable, SPARC V9, version 1 (SYSV)

Most fields of the YAML file can be defaulted, allowing the YAML descriptions to be reasonably succinct.

  • Edit the top-level ./Makefile and set the TET_ROOT variable to the path where the TET test suite is installed.
  • Subsequently, a make all at the top level will build the test suite under $OBJDIRPREFIX.
  • A make execute will run tcc, leaving a log in a results/NNNNe/ directory under the top-level.
  • Specific tests can be run as follows:
make execute TET_USER='-y REGEX'
  • libelf/testsuite.txt
  • Last modified: 2008/06/17 21:37
  • by 127.0.0.1