1*** Settings ***
2Suite Setup                         Custom Suite Setup
3Suite Teardown                      Custom Suite Teardown
4
5*** Variables ***
6${EXISTING_PLATFORM}                platforms/cpus/miv.repl
7
8*** Keywords ***
9Custom Suite Setup
10    ${dirname}=                     Generate Random String  10  [LETTERS]
11    ${path}=                        Join Path  ${TEMPDIR}  robot-${dirname}
12    Set Suite Variable              ${SUITE_TEMPDIR}  ${path}
13    Create Directory                ${SUITE_TEMPDIR}
14    Setup
15
16Custom Suite Teardown
17    # It seems that on Windows, locks to "logFile"s are still being held after "Clear"
18    # preventing Teardown, so some tests are temporarily marked as "skip_windows" until this issue is resolved
19    Execute Command                 Clear
20    Remove Directory                ${SUITE_TEMPDIR}  true
21    Teardown
22
23Create Machine
24    Execute Command                 using sysbus
25    Execute Command                 mach create
26    Execute Command                 machine LoadPlatformDescriptionFromString "uart: UART.SiFive_UART @ sysbus 0x1000"
27
28Create Temporary REPL File
29    [Arguments]                     ${repl_filename}
30    ${file_path}=                   Join Path  ${SUITE_TEMPDIR}  ${repl_filename}
31    Create File                     ${file_path}
32    RETURN                          ${file_path}
33
34Should Have Loaded REPL
35    ${peripherals}=                 Execute Command  peripherals
36    Should Contain                  ${peripherals}  sysbus
37
38*** Test Cases ***
39Should Create Uart Backend
40    Create Machine
41
42    ${base_file}=                   Join Path  ${SUITE_TEMPDIR}  file
43    Execute Command                 uart CreateFileBackend @${base_file}
44    File Should Exist               ${base_file}
45
46    Execute Command                 uart CloseFileBackend @${base_file}
47
48    ${next_file}=                   Join Path  ${SUITE_TEMPDIR}  file.1
49    Execute Command                 uart CreateFileBackend @${base_file}
50    File Should Exist               ${next_file}
51
52Should Create Subsequent Log Files
53    [Tags]                          skip_windows
54    ${base_file}=                   Join Path  ${SUITE_TEMPDIR}  logfile
55    Execute Command                 logFile @${base_file}
56    File Should Exist               ${base_file}
57
58    ${next_file}=                   Join Path  ${SUITE_TEMPDIR}  logfile.1
59    Execute Command                 logFile @${base_file}
60    File Should Exist               ${next_file}
61
62Should Create Platform Using Command
63    Execute Command                 include @${EXISTING_PLATFORM}
64    Should Have Loaded REPL
65
66Should Create Platform Using Method
67    Execute Command                 mach create
68
69    Execute Command                 machine LoadPlatformDescription @${EXISTING_PLATFORM}
70    Should Have Loaded REPL
71
72Should Create Platform Using Command With String Argument
73    # Using a string argument allows spaces in the file path.
74    Execute Command                 include "${EXISTING_PLATFORM}"
75    ${repl}=                        Create Temporary REPL File  Platform With Spaces.repl
76    Execute Command                 include "${repl}"
77    Should Have Loaded REPL
78
79Should Create Platform Using Method With String Argument
80    Execute Command                 mach create
81
82    Execute Command                 machine LoadPlatformDescription "${EXISTING_PLATFORM}"
83    ${repl}=                        Create Temporary REPL File  Platform With Spaces.repl
84    Execute Command                 machine LoadPlatformDescription "${repl}"
85    Should Have Loaded REPL
86