2015-04-11 07:44:37 +08:00
|
|
|
/* tc_utilities.h - testcase utilities header file */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2012-2015 Wind River Systems, Inc.
|
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TC_UTIL_H__
|
|
|
|
#define __TC_UTIL_H__
|
|
|
|
|
2015-10-21 19:36:59 +08:00
|
|
|
#include <zephyr.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
|
|
|
|
#include <misc/printk.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define PRINT_DATA(fmt, ...) printk(fmt, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define PRINT_LINE \
|
|
|
|
PRINT_DATA( \
|
|
|
|
"============================================================" \
|
|
|
|
"=======\n")
|
|
|
|
|
|
|
|
/* stack size and priority for test suite task */
|
|
|
|
#define TASK_STACK_SIZE (1024 * 2)
|
|
|
|
|
|
|
|
#define FAIL "FAIL"
|
|
|
|
#define PASS "PASS"
|
|
|
|
#define FMT_ERROR "%s - %s@%d. "
|
|
|
|
|
|
|
|
#define TC_PASS 0
|
|
|
|
#define TC_FAIL 1
|
|
|
|
|
|
|
|
#define TC_ERROR(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
PRINT_DATA(FMT_ERROR, FAIL, __func__, __LINE__); \
|
|
|
|
PRINT_DATA(fmt, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define TC_PRINT(fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
|
|
|
|
#define TC_START(name) PRINT_DATA("tc_start() - %s\n", name)
|
|
|
|
#define TC_END(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
/* prints result and the function name */
|
|
|
|
#define TC_END_RESULT(result) \
|
|
|
|
do { \
|
|
|
|
PRINT_LINE; \
|
|
|
|
TC_END(result, "%s - %s.\n", \
|
|
|
|
result == TC_PASS ? PASS : FAIL, __func__); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define TC_END_REPORT(result) \
|
|
|
|
do { \
|
|
|
|
PRINT_LINE; \
|
|
|
|
TC_END(result, \
|
2015-06-05 20:24:47 +08:00
|
|
|
"PROJECT EXECUTION %s\n", \
|
2015-04-11 07:44:37 +08:00
|
|
|
result == TC_PASS ? "SUCCESSFUL" : "FAILED"); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#endif /* __TC_UTIL_H__ */
|