Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 78206 invoked from network); 7 Jul 2006 19:40:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jul 2006 19:40:55 -0000 Received: (qmail 6834 invoked by uid 500); 7 Jul 2006 19:40:55 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 6816 invoked by uid 500); 7 Jul 2006 19:40:54 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 6805 invoked by uid 99); 7 Jul 2006 19:40:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jul 2006 12:40:54 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jul 2006 12:40:46 -0700 Received: from qxvcexch01.ad.quovadx.com (qxvcexch01.ad.quovadx.com [192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.4) with ESMTP id k67JdXpk028250 for ; Fri, 7 Jul 2006 19:39:33 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 7 Jul 2006 13:39:44 -0600 Message-ID: <44AEB895.8060100@roguewave.com> Date: Fri, 07 Jul 2006 13:40:05 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: design of testuite exceptions (was: Re: svn commit: r418319 - /incubator/stdcxx/trunk/tests/strings/21.string.io.cpp) References: <4D6A8407B7AC6F4D95B0E55C4E7C4C6204805F7D@exmsk.moscow.vdiweb.com> In-Reply-To: <4D6A8407B7AC6F4D95B0E55C4E7C4C6204805F7D@exmsk.moscow.vdiweb.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 07 Jul 2006 19:39:44.0294 (UTC) FILETIME=[18E29C60:01C6A1FD] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Anton Pevtsov wrote: > Martin, I implemented the exception throwing function and updated the > test driver (except alg_test.h) to use it. > The new files (rw_exception.h and exception.cpp) and diff to updated > files are here: > http://people.apache.org/~antonp/stdcxx07072006/ Great! A few (rather lengthy) comments: Let's try harder not to #include any headers in rw_exception.h or other test suite headers (ideally, we'd include and nothing else). In rw_exception.h we don't need and we shouldn't need (there's no need to make BadAlloc visible, it's an implementation class that exists for the sole purpose of overriding std::bad_alloc::what(); no tests should need to know about it; they should catch the base class by reference instead). The character buffer in the RwTestExceptionBase class is way too big (as is/was the one in BadAlloc in new.cpp). I would probably go with no more than 256 bytes and either dynamically allocate more if needed or truncate excess characters. (I would also suggest renaming the class to just ExceptionBase for brevity). We should also drop the _THROWS() clauses (only bad_alloc and derived class might need to make use of exception specification). No virtual functions (in fact none but the most trivial functions) defined by the test suite should be inline (to avoid making the compiler and inliner working too hard. They should be defined in a .cpp file instead. (FYI: there is rarely any point in defining any virtual functions inline since even modern C++ compilers are only exceedingly rarely able to inline them.) Since _rw_throw_exception() is a public testsuite helper (i.e., one that's exposed to the tests by a declaration in a header) its name should not be decorated with the leading underscore (only private/hidden testsuite helper functions should be). I would also suggest to rename the function to simply rw_throw() (since nothing but an exception can be thrown in C++ ;-) In exception.cpp (and the rest of the test driver's .cpp files) we should #include only the headers, not their counterparts (i.e., instead of ). The latter sometimes define only symbols specified by the C++ standard while the former usually defined other names as well (e.g., POSIX or C99 names). Going forward, I would prefer to use the driver's notification facilities to "log" noteworthy events rather than writing text messages to stderr. I realize that new.cpp does use stderr for logging I'd just as soon not make it a generally available feature exposed in a new API (i.e., via the logtostderr argument). Let's keep the stderr logging in new.cpp for now and decide how to deal with it later (ideally it would be controlled via one of the driver's existing command line options such as -v, --trace, or a new one such as --log). In rw_allocator.h I don't think it's appropriate to be relying on a library class (__rw_synchronized) for any essential test suite functionality. If we need to make a piece of the driver thread-safe we should implement it independently of the library. (Out of curiosity, why does SharedAlloc need to be thread-safe?) Finally, remember to decorate exported names with the _TEST_EXPORT macro. Martin