1*** Settings ***
2Documentation      This module is for data collection on test case failure
3...                for openbmc systems. Collects data with default name
4...                ffdc_report.txt under directory logs/testSuite/testName/
5...                on failure.
6...                FFDC logging sample layout:
7...                logs
8...                ├── 20160909102538035251_TestWarmreset
9...                │   └── 20160909102538035251_TestWarmResetviaREST
10...                │       ├── 20160909102538035251_BMC_journalctl.log
11...                │       ├── 20160909102538035251_BMC_proc_list
12...                │       ├── 20160909102538035251_BMC_dmesg
13...                │       ├── 20160909102538035251_BMC_inventory
14...                │       ├── 20160909102538035251_BMC_led
15...                │       ├── 20160909102538035251_BMC_record_log
16...                │       ├── 20160909102538035251_BMC_sensor_list
17...                │       ├── 20160909102538035251_OS_dmesg
18...                │       ├── 20160909102538035251_OS_msglog
19...                │       ├── 20160909102538035251_OS_cpufrequency
20...                │       ├── 20160909102538035251_OS_boot
21...                │       └── 20160909102538035251_ffdc_report.txt
22...                └── test_history.txt
23
24Resource           openbmc_ffdc_methods.robot
25Resource           openbmc_ffdc_utils.robot
26
27*** Keywords ***
28
29Log FFDC
30    [Documentation]   Generic FFDC entry point. Place holder to hook in
31    ...               other data collection methods
32    ...               1. Collect Logs if test fails
33    ...               2. Added Test execution history logging
34    ...                  By default this will log Test status PASS/FAIL format
35    ...                  EX: 20160822041250932049:Test:Test case 1:PASS
36    ...                      20160822041250969913:Test:Test case 2:FAIL
37
38    Run Keyword If  '${TEST_STATUS}' == 'FAIL'
39    ...    Log FFDC If Test Case Failed
40
41    Log Test Case Status
42
43
44Log FFDC If Test Case Failed
45    [Documentation]   Main entry point to gather logs on Test case failure
46    ...               1. Set global FFDC time reference for a failure
47    ...               2. Create FFDC work space directory
48    ...               3. Write test info details
49    ...               4. Calls BMC methods to write/collect FFDC data
50
51    ${cur_time}=      Get Current Time Stamp
52    Set Global Variable    ${FFDC_TIME}     ${cur_time}
53    Log To Console    ${\n}FFDC Collection Started \t: ${cur_time}
54
55    # Log directory setup
56    ${suitename}   ${testname}=    Get Test Dir and Name
57
58    Set Global Variable
59    ...   ${FFDC_DIR_PATH}  ${FFDC_LOG_PATH}${suitename}${/}${testname}
60
61    ${prefix}=   Catenate  SEPARATOR=   ${FFDC_DIR_PATH}${/}   ${FFDC_TIME}_
62    Set Global Variable    ${LOG_PREFIX}    ${prefix}
63
64    Create FFDC Directory
65    Header Message
66
67    # -- FFDC processing entry point --
68    Call FFDC Methods
69
70    ${cur_time}=       Get Current Time Stamp
71    Log To Console     FFDC Collection Completed \t: ${cur_time}
72    Log                ${\n}${FFDC_DIR_PATH}
73