1*** Settings ***
2Library                       DateTime
3
4*** Variables ***
5${AUTOCOMPLETION_RESC}        scripts/single-node/sam4s.resc
6
7*** Keywords ***
8Test Autocompletion
9    [Arguments]             ${suggestion}
10    Execute Command         include @${AUTOCOMPLETION_RESC}
11    Execute Command         py "monitor.SuggestionNeeded('${suggestion}')"
12
13*** Test Cases ***
14Should Pause Renode
15    # we test if pausing can interrupt the execution before the end of the quantum (hence testing against a value lower than 10)
16    ${pause_limit}=           Convert Time           9
17                              Execute Command        i @scripts/single-node/miv.resc
18                              Execute Command        cpu PerformanceInMips 1
19    # treat WFI as NOP because WFI might make virtual time advance too far if it has fallen behind host time
20                              Execute Command        cpu WfiAsNop true
21                              Execute Command        emulation SetGlobalQuantum "10"
22    # we assume that starting/pausing of the simulation happens during the same quantum;
23    # it seems to be a resonable expectation for the quantum value of 10 virtual seconds
24                              Execute Command        s
25                              Execute Command        p
26    ${time_source_info}=      Execute Command        emulation GetTimeSourceInfo
27    ${elapsed_matches}=       Get Regexp Matches     ${time_source_info}    Elapsed Virtual Time: ([0-9:.]+)    1
28    ${elapsed}=               Convert Time           ${elapsed_matches[0]}
29
30    Should Be True            ${elapsed} < ${pause_limit}
31
32Should Print Last Logs
33    Execute Command           i @scripts/single-node/miv.resc
34    ${logs} =                 Execute Command  lastLog
35    Should Contain            ${logs}  [INFO] cpu: Setting PC value to 0x80000000.
36
37Should Overflow Buffer
38    FOR    ${i}    IN RANGE    1000
39        Execute Command  log "Test-${i}-Log"
40    END
41    ${logs} =                 Execute Command  lastLog 1000
42    Should Contain            ${logs}  Test-0-Log
43    Should Contain            ${logs}  Test-999-Log
44    Should Not Contain        ${logs}  Test-1000-Log
45    Execute Command           log "Test-1000-Log"
46    ${logs} =                 Execute Command  lastLog 1000
47    Should Not Contain        ${logs}  Test-0-Log
48    Should Contain            ${logs}  Test-1-Log
49    Should Contain            ${logs}  Test-1000-Log
50
51Should Load Python Standard Library
52    ${result} =               Execute Command  python "import SimpleHTTPServer"
53    Should Not Contain        ${result}  No module named
54
55Should Set Proper Types To Variables
56
57    Execute Command           \$var1=1234
58    Execute Command           set var2 2345
59
60    Execute Command           emulation SetSeed $var1
61    Execute Command           emulation SetSeed $var2
62
63Should Not Call Conditional Set
64
65    Execute Command           \$var1=1234
66    Execute Command           \$var1?=5678
67
68    ${res}=  Execute Command  echo $\var1
69    Should Be Equal           ${res.strip()}   1234
70
71Should Call Conditional Set
72
73    Execute Command           \$var1?=5678
74
75    ${res}=  Execute Command  echo $\var1
76    Should Be Equal           ${res.strip()}   5678
77
78Should Call GPIO Set
79    Execute Command           i @scripts/single-node/nrf52840.resc
80    ${gpioState}=             Execute Command   uart0 IRQ
81    Should Contain            ${gpioState}  GPIO: unset
82    Execute Command           uart0 IRQ Set true
83    ${gpioState}=             Execute Command   uart0 IRQ
84    Should Contain            ${gpioState}  GPIO: set
85
86Should Not Crash On Bool Autocompletion
87    Test Autocompletion     cpu IsHalted
88
89Should Not Crash On Int Autocompletion
90    Test Autocompletion     cpu MaximumBlockSize
91
92Should Not Crash On String Autocompletion
93    Test Autocompletion     cpu LogFile
94