diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2012-07-11 21:31:58 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-09-10 16:12:28 -0500 |
commit | 4f234f1bb43d2be3b84e71504474f97fedbb1826 (patch) | |
tree | 90c6a5dd191039cfc2d9f1b5ef07dcc62537cda1 /src/usr/diag/attn/test/attntestsvc.H | |
parent | 4e5c9ec9784fd33d9ea10dee94fac197ec90527b (diff) | |
download | talos-hostboot-4f234f1bb43d2be3b84e71504474f97fedbb1826.tar.gz talos-hostboot-4f234f1bb43d2be3b84e71504474f97fedbb1826.zip |
Refactor unit test for attnsvc module.
RTC: 40441
Change-Id: Id65e4241d3f9afcb142a910980c525b41186bc19
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1364
Tested-by: Jenkins Server
Reviewed-by: Zane Shelley <zshelle@us.ibm.com>
Reviewed-by: LARINA M. DSOUZA <larsouza@in.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/diag/attn/test/attntestsvc.H')
-rw-r--r-- | src/usr/diag/attn/test/attntestsvc.H | 169 |
1 files changed, 133 insertions, 36 deletions
diff --git a/src/usr/diag/attn/test/attntestsvc.H b/src/usr/diag/attn/test/attntestsvc.H index baac17321..452a6f91a 100644 --- a/src/usr/diag/attn/test/attntestsvc.H +++ b/src/usr/diag/attn/test/attntestsvc.H @@ -1,25 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/usr/diag/attn/test/attntestsvc.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2012 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attntestsvc.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2012 + * + * p1 + * + * Object Code Only (OCO) source materials + * Licensed Internal Code Source Materials + * IBM HostBoot Licensed Internal Code + * + * The source code for this program is not published or other- + * wise divested of its trade secrets, irrespective of what has + * been deposited with the U.S. Copyright Office. + * + * Origin: 30 + * + * IBM_PROLOG_END_TAG + */ #ifndef __TEST_ATTNTESTSVC_H #define __TEST_ATTNTESTSVC_H @@ -29,7 +30,6 @@ * @brief Unit test for the attnsvc module. */ -#include "../attnfwd.H" #include "../attnsvc.H" #include "attnfakesys.H" #include "attntest.H" @@ -185,14 +185,76 @@ class AttnSvcTest: public CxxTest::TestSuite */ void testAttentions() { + static const uint64_t targetPoolSize = 8; + static const uint64_t iterations = 5; + static const uint64_t maxAttnsPerIteration = 5; + TS_TRACE(ENTER_MRK "testAttentions"); errlHndl_t err = 0; - FakeSystem hooks; Service svc; - hooks.install(); + FakePresenter presenter; + FakeSystem system; + + FakeGfir xstpGfir(CHECK_STOP), + spclGfir(SPECIAL), + recGfir(RECOVERABLE); + + xstpGfir.install(system); + spclGfir.install(system); + recGfir.install(system); + + FakeMcs rec(RECOVERABLE), xstp(CHECK_STOP), special(SPECIAL); + FakeGp1 gp1; + + xstp.install(system); + special.install(system); + rec.install(system); + gp1.install(system); + + FakeIpoll xstpIpoll(CHECK_STOP, presenter), + spclIpoll(SPECIAL, presenter), + recIpoll(RECOVERABLE, presenter), + hostIpoll(HOST, presenter); + + xstpIpoll.install(system); + spclIpoll.install(system); + recIpoll.install(system); + hostIpoll.install(system); + + Validator v; + + v.install(system); + + system.installScomImpl(); + + FakeMemTargetService targetSvc(targetPoolSize); + + TargetHandleList membufs, procs; + + targetSvc.getAllChips(procs, TYPE_PROC); + targetSvc.getAllChips(membufs, TYPE_MEMBUF); + + RandSource procSource(iterations, + maxAttnsPerIteration, + system, + &procs[0], + &procs[0] + procs.size()); + + RandSource memSource( + iterations, + maxAttnsPerIteration, + system, + &membufs[0], + &membufs[0] + membufs.size()); + + targetSvc.installTargetService(); + + FakePrd prd(system); + + prd.installPrd(); do { @@ -204,33 +266,68 @@ class AttnSvcTest: public CxxTest::TestSuite break; } - static const int64_t iterations = 20; - - for(int64_t it = 0; it < iterations; ++it) + if(!presenter.start(svc.iv_intrTaskQ)) { - int64_t count = randint(1, 10); + TS_FAIL("unexpected error starting fake presenter"); + break; + } - TS_TRACE("raising %d attentions", count); + if(!memSource.start()) + { + TS_FAIL("unexpected error starting source"); + break; + } - hooks.raiseAttentions(svc.iv_intrTaskQ, count); + if(!procSource.start()) + { + TS_FAIL("unexpected error starting source"); + break; } - err = svc.stop(); + // wait for the testcase to finish injecting attentions - if(err) + if(!memSource.wait()) { - TS_FAIL("unexpected error stopping service"); + TS_FAIL("unexpected error waiting for source"); break; } - if(!hooks.validate()) + if(!procSource.wait()) { - TS_FAIL("unexpected result after injecting attentions"); + TS_FAIL("unexpected error waiting for source"); + break; + } + + // wait for the the service to handle all the attentions + TS_TRACE("Waiting for attentions to be cleared."); + + if(!system.wait(TEN_CTX_SWITCHES_NS * iterations * 100)) + { + TS_FAIL("Attentions still present on system."); + + system.dump(); break; } } while(0); + err = svc.stop(); + + if(err) + { + TS_FAIL("unexpected error stopping service"); + delete err; + } + + presenter.stop(); + + if(!v.empty()) + { + TS_FAIL("unexpected result after injecting attentions"); + + v.dump(); + } + TS_TRACE(EXIT_MRK "testAttentions"); } }; |