Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 39681 invoked from network); 7 Aug 2006 10:07:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Aug 2006 10:07:40 -0000 Received: (qmail 72751 invoked by uid 500); 7 Aug 2006 10:07:38 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 72198 invoked by uid 500); 7 Aug 2006 10:07:35 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 72187 invoked by uid 99); 7 Aug 2006 10:07:35 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2006 03:07:35 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 202.81.18.155 is neither permitted nor denied by domain of firepure@gmail.com) Received: from [202.81.18.155] (HELO ausmtp06) (202.81.18.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Aug 2006 03:07:24 -0700 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp06 (8.13.6/8.13.6) with ESMTP id k77A0gTV7704824 for ; Mon, 7 Aug 2006 20:00:42 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.250.242]) by sd0208e0.au.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id k77A2TAw240788 for ; Mon, 7 Aug 2006 20:02:30 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k779x5IL015643 for ; Mon, 7 Aug 2006 19:59:05 +1000 Received: from d23m0011.cn.ibm.com (d23m0011.cn.ibm.com [9.181.32.74]) by d23av01.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k779x3p6015606 for ; Mon, 7 Aug 2006 19:59:04 +1000 Received: from [9.181.107.166] ([9.181.107.166]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006080717553832-4295 ; Mon, 7 Aug 2006 17:55:38 +0800 Message-ID: <44D70E1A.3090104@gmail.com> Date: Mon, 07 Aug 2006 17:55:38 +0800 From: "Jimmy, Jing Lv" User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib][Instrument] Documents for non-unit-tests (was Re:[classlib] Plan on work on java.lang.instrument) References: <44D01E9A.30800@gmail.com> <6e47b64f0608012144i52262bcdjc7b41c21a02fbd39@mail.gmail.com> <44D031E8.2000602@pobox.com> <6e47b64f0608012205t2275cf58q5c1e03d106033d99@mail.gmail.com> <44D03412.4080506@pobox.com> <44D1AE24.8000202@gmail.com> <44D2DDD8.8060107@gmail.com> <44D696E6.2040103@gmail.com> <44D6A3CA.5040602@pobox.com> <44D6AC2E.4000603@gmail.com> In-Reply-To: X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 07/08/2006 17:55:38, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 07/08/2006 17:59:03, Serialize complete at 07/08/2006 17:59:03 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Leo Li wrote: > Hi, all: > I have some idea to test instrument. > For example, if we would like to test > Instrumentation.addTransformerwill throw NullPointerException if the > argument is null, > we can first write a TestInstrument with premain function. > > import java.lang.instrument.Instrumentation; > public class TestInstrument { > > public static void premain(String agentArgs, Instrumentation inst) > { > try > { > inst.addTransformer(null); > } > catch(NullPointerException e) > { > //failed, we set error code > System.exit(1); > } > } > } > Normally, the VM will exit with zero as it return value if there is no > exception occurs in main class. > > then, we might write an JUnit Test: > public void test() throws Exception > { > Process process = Runtime.getRuntime().exec("java -javaagent > Test.jarTest"); > //if premain runs as we expected, the exit code is zero. > assertEquals(0,process.waitFor()); > } > > (Besides,Test is an ordinary class with a main function that will not throw > error. Test.jar with the manifest to denote the class of TestInstrument as > the premain class.} > > Is it all right? :) > Sounds pretty good :) "exec" do helps, it can check simple situations. What I'm concern is that if the return code is not enough for some situations, e.g, what exception is thrown exactly, or what cause VM exit abnormally. IMHO, it is still necessary for us. > On 8/7/06, Jimmy, Jing Lv wrote: >> >> Geir Magnusson Jr wrote: >> > >> > Jimmy, Jing Lv wrote: >> >> Richard Liang wrote: >> >>> >> >>> Jimmy, Jing Lv wrote: >> >>>> Hi, >> >>>> >> >>>> As it is hard to write unit test for package instrument, I now >> >>>> have an idea: write down some documents for details of non-unit test >> >>>> cases for instrument. The detail of such test cases contain: >> >>> Do you mean it's hard to *write* unit test or it's hard to integrate >> >>> the tests with Harmony build system? >> >>> >> >> Hard to write unit test, so record them in some document may be a >> better >> >> way :) >> > >> > Why is it hard to create unit tests? >> > >> >> To test java.lang.instrument, mostly we need to start up a new VM to see >> its behavior. Its function(premain, etc) may be run before most classes >> loaded, and almost all exceptions will cause VM abort. And the result is >> hard to be checked automatic. What's more, extra java/c code is needed >> for the test. >> >> One thought was that we can use exec("java commands") in junit(is that >> OK to run exec in tests?), but how to check its output is still a >> problem. >> >> I'll put unit test if any, but I believe most necessary and important >> tests are non-unit tests. >> >> >>>> 1. The test run on which platform, including special environment; >> >>>> 2. The test description; >> >>>> 3. How to run test (command line, etc.); >> >>>> 4. test result; >> >>>> 5. resource (or links) for tests, including c/java code for test if >> any. >> >>>> >> >>>> I hope ensure the code quality in this way. Like unit test, such >> >>>> tests can be checked and re-run for regression, though >> un-automatically. >> >>>> >> >>>> And I'll put them in Harmony-wiki[1], and any >> test-description is >> >>>> welcome!. (Geir, I've found an advancement of wiki :) ) >> >>>> >> >>>> Any suggestions? :) >> >>>> >> >>>> [1]http://wiki.apache.org/harmony/INSTRUMENT >> >>>> >> >>>>> Geir Magnusson Jr wrote: >> >>>>> Never appeal to me using a Wiki as an authority :) It's like >> finding >> >>>>> something written in chalk on the sidewalk. >> >>>>> >> >>>>> However, if you had pointed out >> >>>>> >> >>>>> http://incubator.apache.org/harmony/auth_cont_quest.html >> >>>>> >> >>>>> I'd have agreed w/o having the opportunity to make fun of the Wiki. >> >>>>> >> >>>>> So I agree :) >> >>>>> >> >>>>> geir >> >>>> >> >> >> > >> > --------------------------------------------------------------------- >> > Terms of use : http://incubator.apache.org/harmony/mailing.html >> > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org >> > For additional commands, e-mail: harmony-dev-help@incubator.apache.org >> > >> > >> >> >> -- >> >> Best Regards! >> >> Jimmy, Jing Lv >> China Software Development Lab, IBM >> >> --------------------------------------------------------------------- >> Terms of use : http://incubator.apache.org/harmony/mailing.html >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org >> >> > > -- Best Regards! Jimmy, Jing Lv China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org