Exception Handling Test Suite for STLport

by Dave Abrahams, Boris Fomitchev

Synopsis

eh_test [-n <iterations>] [-s <size>] [-l] [-e] [-q]/[-v] [-t]

Options:

  • [-n <iterations>] : number of test iterations, default==100;
  • [-s <size>] : base value for random container sizes, default==1000;
  • [-e] : don't throw exceptions, test for leak in normal conditions;
  • [-q] : quiet mode;
  • [-v] : verbose mode (default);
  • [-t] : track each allocation;
  • [test_name [test_name...]] : run test_name tests (default==all).
    Names are : algo, vector, bit_vector, list, slist, deque, set, map, hash_set, hash_map, rope, string, bitset.

The Story

The testsuite was written by Dave Abrahams for testing of proposed EH for SGI STL . Shortly, EH was merged into STLport v1.0. That wasn't long until EH was introduced in  SGI STL distribution, too (a bit different approach was used). This test helped to locate and fix some EH bugs in 2.0-2.02 releases of SGI STL. As a side effect, it reveals problems in some compiler's EH implementation (typically they show up when you are trying turning on some optimizations).

Portability

EH testsuite can be compiled and run with the following compilers :

  • SunPro CC 4.1-4.2 (passed OK)
  • Metrowerks CodeWarrior Pro 1 (passed OK)
  • Visual C++ 4.1 (hashed container tests won't compile, compiler bug produce false alarms for list test, other passed.)
  • Visual C++ 5.0 (passed OK).
  • Borland C++ 5.0 (passed OK).
  • gcc-2.7.2 (without EH, actually ;))
  • egcs-970922 (fails to run, dumps core in __throw implemetation).

Makefiles for gcc, SUNPro, Visual C++ compilers are provided with the suite. Look for .mak files in the distribution. It should be not difficult to adjust one of them to your compiler.

How To

EH testsuite comes in directory test/eh with your STLport distribution. Edit appropriate makefile to fit your compiler and include directories . After you've done, try "make check". That should build test executable and run it with default options (see Synopsis). If writing your own makefile or working from within some IDE, you should specify the following switches to get proper testing :

_STLP_USE_NEWALLOC - use new-based allocator (that will promptly throw on common test scheme). Otherwise, only assignment/comparison will throw,

_STLP_USE_DEBUG_ALLOC - to catch other potential memory problems.

EH_NEW_HEADERS - if you wish to use new-style C++ headers. This option may be useful to test some other STL implementation.

For Borland C++ 5.x , you have to #define _STLP_NO_NAMESPACES to compile.

For 16-bit platforms, you have to #define NO_FAST_ALLOCATOR to compile.

The testsuite may be used to test not only STLport adaptation against particular compiler. It does not contain any adaptation-specific code, so it may be used with regular SGI release (note _STLP_USE_NEWALLOC has no effect then) or with other STL implementation (hash containers and rope may not work).

Copyright

This software is
Copyright (c) 1997 Mark of the Unicorn, Inc.

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Mark of the Unicorn makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.


Table of Contents

News  Company  Product  Services  Community  Forum  Download  Home  


Copyright 2001 by STLport