qpcpp/examples/qutest/dpp/test_philo.tcl

113 lines
4.8 KiB
Tcl
Raw Normal View History

2017-05-17 13:15:09 -04:00
#-----------------------------------------------------------------------------
# Product: QSPY -- test-script example for qutest.tcl
2018-05-25 12:24:18 -04:00
# Last updated for version 6.3.1
# Last updated on 2018-05-24
2017-05-17 13:15:09 -04:00
#
# Q u a n t u m L e a P s
# ---------------------------
# innovating embedded systems
#
2018-03-19 14:51:26 -04:00
# Copyright (C) 20017-2018 Quantum Leaps, LLC, All rights reserved.
2017-05-17 13:15:09 -04:00
#
# This program is open source software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, this program may be distributed and modified under the
# terms of Quantum Leaps commercial licenses, which expressly supersede
# the GNU General Public License and are specifically designed for
# licensees interested in retaining the proprietary status of their code.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact information:
2018-03-19 14:51:26 -04:00
# https://www.state-machine.com
2017-05-17 13:15:09 -04:00
# mailto:info@state-machine.com
#-----------------------------------------------------------------------------
# preamble...
proc on_reset {} {
expect_pause
continue
2018-05-25 12:24:18 -04:00
glb_filter SM AO UA
2018-03-19 14:51:26 -04:00
current_obj SM_AO l_philo<2>
2017-05-17 13:15:09 -04:00
}
# tests...
2018-03-19 14:51:26 -04:00
test "TIMEOUT->Philo (post)"
post TIMEOUT_SIG
expect "%timestamp AO-Post Sdr=QS_RX,Obj=l_philo<2>,Evt<Sig=TIMEOUT_SIG,*"
expect "%timestamp AO-GetL Obj=l_philo<2>,Evt<Sig=TIMEOUT_SIG,*"
2018-05-22 15:32:27 -04:00
expect "%timestamp Disp===> Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=thinking"
expect "===RTC===> St-Exit Obj=l_philo<2>,State=thinking"
2018-03-19 14:51:26 -04:00
expect "%timestamp AO-Post Sdr=l_philo<2>,Obj=l_table,Evt<Sig=HUNGRY_SIG,*"
2018-05-22 15:32:27 -04:00
expect "===RTC===> St-Entry Obj=l_philo<2>,State=hungry"
expect "%timestamp ===>Tran Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=thinking->hungry"
2017-05-17 13:15:09 -04:00
expect "%timestamp Trg-Done QS_RX_EVENT"
2018-03-19 14:51:26 -04:00
test "publish EAT(2)" -noreset
loc_filter SM_AO l_philo<2>
publish EAT_SIG [binary format c 2]
expect "%timestamp AO-Post Sdr=QS_RX,Obj=l_philo<2>,Evt<Sig=EAT_SIG,*"
expect "%timestamp Trg-Done QS_RX_EVENT"
expect "%timestamp AO-GetL Obj=l_philo<2>,Evt<Sig=EAT_SIG,*"
2018-05-22 15:32:27 -04:00
expect "%timestamp Disp===> Obj=l_philo<2>,Sig=EAT_SIG,State=hungry"
2018-05-25 12:24:18 -04:00
expect "%timestamp BSP_CALL BSP::random 123"
2018-05-22 15:32:27 -04:00
expect "===RTC===> St-Entry Obj=l_philo<2>,State=eating"
expect "%timestamp ===>Tran Obj=l_philo<2>,Sig=EAT_SIG,State=hungry->eating"
2018-03-19 14:51:26 -04:00
expect "%timestamp Trg-Done QS_RX_EVENT"
2018-05-22 15:32:27 -04:00
test "TIMEOUT->thinking (ASSERT)"
2017-05-17 13:15:09 -04:00
probe QActive::post_ 1
dispatch TIMEOUT_SIG
2018-05-22 15:32:27 -04:00
expect "%timestamp Disp===> Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=thinking"
expect "===RTC===> St-Exit Obj=l_philo<2>,State=thinking"
2017-05-17 13:15:09 -04:00
expect "%timestamp TstProbe Fun=QActive::post_,Data=1"
2018-03-19 14:51:26 -04:00
expect "%timestamp =ASSERT= Mod=qf_actq,Loc=110"
2018-05-22 15:32:27 -04:00
test "TIMEOUT->eating (PUBLISH from AO)"
2018-03-19 14:51:26 -04:00
glb_filter OFF
dispatch TIMEOUT_SIG
expect "%timestamp Trg-Done QS_RX_EVENT"
dispatch EAT_SIG [binary format c 2]
expect "%timestamp Trg-Done QS_RX_EVENT"
glb_filter SM AO QF
dispatch TIMEOUT_SIG
expect "%timestamp QF-New Sig=TIMEOUT_SIG,*"
2018-05-22 15:32:27 -04:00
expect "%timestamp Disp===> Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=eating"
2018-03-19 14:51:26 -04:00
expect "%timestamp QF-New Sig=DONE_SIG,*"
expect "%timestamp QF-Pub Sdr=l_philo<2>,Evt<Sig=DONE_SIG,Pool=1,Ref=0>"
expect "%timestamp AO-Post Sdr=l_philo<2>,Obj=l_table,Evt<Sig=DONE_SIG,Pool=1,Ref=2>,*"
expect "%timestamp QF-gcA Evt<Sig=DONE_SIG,Pool=1,Ref=2>"
2018-05-22 15:32:27 -04:00
expect "===RTC===> St-Exit Obj=l_philo<2>,State=eating"
expect "===RTC===> St-Entry Obj=l_philo<2>,State=thinking"
expect "%timestamp ===>Tran Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=eating->thinking"
2018-03-19 14:51:26 -04:00
expect "%timestamp QF-gc Evt<Sig=TIMEOUT_SIG,Pool=1,Ref=1>"
expect "%timestamp Trg-Done QS_RX_EVENT"
2017-05-17 13:15:09 -04:00
test "timeEvt->Philo (tick)"
glb_filter SM AO TE
current_obj TE l_philo<2>.m_timeEvt
tick
2018-03-19 14:51:26 -04:00
expect " TE0-ADis Obj=l_philo<2>.m_timeEvt,AO=l_philo<2>"
expect "%timestamp TE0-Post Obj=l_philo<2>.m_timeEvt,Sig=TIMEOUT_SIG,AO=l_philo<2>"
expect "%timestamp AO-Post Sdr=QS_RX,Obj=l_philo<2>,Evt<Sig=TIMEOUT_SIG*"
expect "%timestamp AO-GetL Obj=l_philo<2>,Evt<Sig=TIMEOUT_SIG*"
2018-05-22 15:32:27 -04:00
expect "%timestamp Disp===> Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=thinking"
2018-03-19 14:51:26 -04:00
expect "%timestamp TE0-DisA Obj=l_philo<2>.m_timeEvt,AO=l_philo<2>"
2018-05-22 15:32:27 -04:00
expect "===RTC===> St-Exit Obj=l_philo<2>,State=thinking"
2018-03-19 14:51:26 -04:00
expect "%timestamp AO-Post Sdr=l_philo<2>,Obj=l_table,Evt<Sig=HUNGRY_SIG*"
2018-05-22 15:32:27 -04:00
expect "===RTC===> St-Entry Obj=l_philo<2>,State=hungry"
expect "%timestamp ===>Tran Obj=l_philo<2>,Sig=TIMEOUT_SIG,State=thinking->hungry"
2017-05-17 13:15:09 -04:00
expect "%timestamp Trg-Done QS_RX_TICK"
# the end
end