其他分享
首页 > 其他分享> > ltp-ddt wdt_test

ltp-ddt wdt_test

作者:互联网

# @name Watchdog Timer getsupport,settimeout,getstatus,keepalive ioctl and write test
# @desc Watchdog Timer getsupport,settimeout,getstatus,keepalive ioctl and write test
# @requires watchdog

WDT_S_FUNC_GETSUPORT source 'common.sh'; do_cmd install_modules.sh 'wdt' ; DEV_NODE=`get_devnode.sh "wdt"` || die "error getting devnode for wdt"; do_cmd wdt_tests -device $DEV_NODE -ioctl getsupport     wdt_tests -device /dev/watchdog -ioctl getsupport   wdt_tests是c代码   SOURCES := \
        ../utils/user/st_fileapi.c \
        src/interface/common/st_wdt_common.c \
        src/parser/st_wdt_parser.c \
        src/testcases/st_wdt_ioctl.c \
        src/testcases/st_wdt_open_close.c \
        src/testcases/st_wdt_write.c

MAKE_TARGETS            := wdt_tests

wdt_tests:
    $(CC) $(CFLAGS) $(LDFLAGS) -o wdt_tests ${INCLUDES} ${SOURCES}   main函数位于: st_wdt_parser.c   /****************************************************************************
 * Function        - Main function
 * Functionality    - This is where the execution begins
 * Input Params        - argc,argv
 * Return Value        - None
 * Note            - None
 ****************************************************************************/
int main(int argc, char *argv[])
{

    int retval;
    /* Initialize options with default vales */
    st_init_wdt_test_params();

    /* Invoke the parser function to process the command line options */
    retval = st_process_wdt_test_options(argc, argv);
    return retval;
}   1. st_init_wdt_test_params(); //初始化 in  st_wdt_common.c void st_init_wdt_test_params(void)
{
    strcpy(testoptions.device , DEFAULT_DEVICE);
    testoptions.ioctl = DEFAULT_IOCTL;
    testoptions.loop = DEFAULT_LOOP_COUNT;
    testoptions.ioctl_arg = DEFAULT_IOCTL_ARG;
    testoptions.iomode = DEFAULT_IOMODE;
}   #define DEFAULT_IOMODE        ST_WDT_IOMODE_NONE
#define DEFAULT_DEVICE        "/dev/watchdog"
#define DEFAULT_IOCTL         ST_WDT_IOCTL_NONE
#define DEFAULT_LOOP_COUNT    1
#define DEFAULT_IOCTL_ARG     0   2. retval = st_process_wdt_test_options(argc, argv); //in st_wdt_parser.c     int c = getopt_long_only(argc, argv, "vh", long_options,
                     &option_index); //获取参数 TEST_PRINT_TST_START(testcaseid);  //打印start st_print_wdt_test_params(&testoptions, testcaseid);  //打印参数 fileDesc = st_wdt_open(&testoptions);  //open wdt ret_val2 = st_wdt_ioctl_test(&testoptions, testcaseid, fileDesc);  // TEST_PRINT_TST_RESULT(result, testcaseid);  //打印result
TEST_PRINT_TST_END(testcaseid);  //打印end ioctl(fileDesc, WDIOC_GETTIMEOUT, &timeout); //取超时时间   一旦/dev/watchdog被打开,则watchdog激活,并且除非喂狗,否则将在一段时间之后重启。              

标签:ltp,DEFAULT,st,ioctl,wdt,testoptions,test
来源: https://www.cnblogs.com/idyllcheung/p/10910065.html