Skip to content

Commit

Permalink
Update renode wait-for-shutdown logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Apr 4, 2024
1 parent ed5d993 commit 751fbac
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
9 changes: 6 additions & 3 deletions test_system/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions test_system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ features = ["samd51g-rt", "samd51g", "samd51", "rtic", "defmt", "unproven"]
version = "0.7"
features = ["git2", "chrono"]

[patch.crates-io]
defmt = { git = "https://github.com/knurling-rs/defmt.git", rev = "4db33ca5df8d7a7b5d9036c49b1ea535cc3986c0" }

[profile.release]
codegen-units = 1
debug = 2
Expand All @@ -60,6 +57,20 @@ platform-descriptions = [
->nvic@48
''',
]
variables = [
'''
$hookScript =
"""
self.Pause()
self.Log(LogLevel.Info, "Reached shutdown symbol, flushing RTT")
rtt = self.GetMachine()["sysbus.RttReader"]
rtt.Stop()
# NOTE: this only stops if the GUI/xwt is enabled
#Antmicro.Renode.Emulator.Exit()
emulationManager.CurrentEmulation.AddOrUpdateInBag('status', 'finished')
"""
'''
]
pre-start-commands = [
# NOTE: this is a bit of a hack to speed things up
'sysbus.nvic Frequency 10000000000',
Expand All @@ -79,13 +90,14 @@ pre-start-commands = [
'logLevel -1 RttReader',
'RttReader Start',
]
# Includes the Deviant staged mutation related
# Include the Deviant staged mutation related
#'write_staged_mutation "88b565a8-455b-4993-9779-9f6d4004d6d5" "d135b4b9-64c9-4d0d-b2bb-621e37ca29f7"',
reset = '''
sysbus LoadELF $bin
clear_deviant_noint_vars
cpu0 AddHook `sysbus GetSymbolAddress "wait_forever"` $hookScript
'''
start = 'emulation RunFor "00:00:15"'
post-start-commands = [
'quit'
# Wait for the test to finish, then quit
'wait_for_done',
]
7 changes: 6 additions & 1 deletion test_system/renode/RttReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ public void Start() {
}

public void Stop() {
this.NoisyLog("Stopping RTT reading");
this.NoisyLog("Stopping RTT reading, flushing");
pollTimer.Enabled = false;
if(controlBlockAddress != 0)
{
readRttBuffer();
}
}

private void TimerLimitReachedCallback()
Expand Down Expand Up @@ -157,6 +161,7 @@ private void readRttBuffer()
if(total > 0)
{
machine.SystemBus.WriteDoubleWord(((ulong) chAddr) + ReadOffset, read);
//this.NoisyLog("RTT bytes {0}", total);
}

for(uint i = 0; i < total; i = i + 1)
Expand Down
5 changes: 5 additions & 0 deletions test_system/renode/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ def mc_write_staged_mutation(mutator_uuid_str, mutation_uuid_str):
sysbus.WriteByte(var_mutation_id_addr + offset, val)

sysbus.WriteDoubleWord(var_mutation_staged_addr, 1)

def mc_wait_for_done():
while not emulationManager.CurrentEmulation.TryGetFromBag[str]('status')[0]:
time.sleep(0.1)
monitor.Parse('q')
2 changes: 1 addition & 1 deletion test_system/scripts/run_robot_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -euo pipefail

renode-test --kill-stale-renode-instances tests.robot
renode-test --kill-stale-renode-instances --variable CREATE_SNAPSHOT_ON_FAIL:False tests.robot

exit 0
7 changes: 7 additions & 0 deletions test_system/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ mod panic_impl {
defmt::error!("panic::msg={}", defmt::Display2Format(info));
}

wait_forever();
}

// NOTE: we use this symbol in renode to indicate it's time to shutdown
#[inline(never)]
#[no_mangle]
fn wait_forever() -> ! {
loop {
atomic::compiler_fence(Ordering::SeqCst);
}
Expand Down

0 comments on commit 751fbac

Please sign in to comment.