mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-02 03:17:57 +00:00
UT for ocmp_fe
This commit is contained in:
@@ -51,7 +51,7 @@ bool rffe_ctrl_get_band(rffeChannel channel, rffeBand *band)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool static _get_config(void *driver, unsigned int param_id, void *return_buf)
|
||||
static bool _get_config(void *driver, unsigned int param_id, void *return_buf)
|
||||
{
|
||||
bool ret = false;
|
||||
FE_Ch_Band_cfg *driverCfg = driver;
|
||||
@@ -68,7 +68,7 @@ bool static _get_config(void *driver, unsigned int param_id, void *return_buf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool static _set_config(void *driver, unsigned int param_id,
|
||||
static bool _set_config(void *driver, unsigned int param_id,
|
||||
const void *return_buf)
|
||||
{
|
||||
bool ret = false;
|
||||
@@ -87,6 +87,8 @@ bool static _set_config(void *driver, unsigned int param_id,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
static ePostCode _probe(void *driver, POSTData *postData)
|
||||
{
|
||||
return POST_DEV_FOUND;
|
||||
@@ -100,6 +102,7 @@ static ePostCode _init(void *driver, const void *config,
|
||||
rffe_ctrl_set_band(driverCfg->channel, cfg->band);
|
||||
return POST_DEV_FOUND;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
const Driver_fxnTable FE_PARAM_fxnTable = {
|
||||
/* Message handlers */
|
||||
|
||||
@@ -187,6 +187,9 @@ $(PATHB)Test_ocmp_debugi2c$(TARGET_EXTENSION): $(STD_FILES) $(TEST_OCMP_DEBUGI2C
|
||||
TEST_OCMP_RFWATCHDOG_SRC=$(OCWARE_ROOT)/src/devices/ocmp_wrappers/ocmp_rfwatchdog.c $(OCWARE_ROOT)/src/devices/i2cbus.c $(OCWARE_ROOT)/src/helpers/memory.c fake/fake_GPIO.c fake/fake_I2C.c fake/fake_ThreadedISR.c fake/fake_PCA9557.c fake/fake_rfwatchdog.c stub/stub_GateMutex.c $(OCWARE_ROOT)/src/drivers/GpioPCA9557.c $(OCWARE_ROOT)/src/devices/pca9557.c $(OCWARE_ROOT)/platform/oc-sdr/cfg/OC_CONNECT_FE.c
|
||||
$(PATHB)Test_ocmp_rfwatchdog$(TARGET_EXTENSION): $(STD_FILES) $(TEST_OCMP_RFWATCHDOG_SRC)
|
||||
|
||||
TEST_OCMP_FE_SRC=$(OCWARE_ROOT)/src/devices/ocmp_wrappers/ocmp_fe.c $(OCWARE_ROOT)/platform/oc-sdr/cfg/OC_CONNECT_FE.c
|
||||
$(PATHB)Test_ocmp_fe$(TARGET_EXTENSION): $(STD_FILES) $(TEST_OCMP_FE_SRC)
|
||||
|
||||
$(PATHB)%$(TARGET_EXTENSION):
|
||||
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $^ -o $@
|
||||
$(COV_CMDS)
|
||||
|
||||
21
firmware/ec/test/include/test_fe.h
Normal file
21
firmware/ec/test/include/test_fe.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
#ifndef _TEST_OCMP_FE_H
|
||||
#define _TEST_OCMP_FE_H
|
||||
|
||||
#include "common/inc/global/Framework.h"
|
||||
#include "common/inc/ocmp_wrappers/ocmp_fe-param.h"
|
||||
#include "inc/subsystem/rffe/rffe_ctrl.h"
|
||||
#include <string.h>
|
||||
#include <ti/sysbios/knl/Task.h>
|
||||
#include "unity.h"
|
||||
|
||||
#define FE_DEFAULT_VALUE 0x00
|
||||
#define FE_INVALID_PARAM 0xFF
|
||||
#endif
|
||||
Binary file not shown.
91
firmware/ec/test/suites/Test_ocmp_fe.c
Normal file
91
firmware/ec/test/suites/Test_ocmp_fe.c
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#include "include/test_fe.h"
|
||||
|
||||
extern const FE_Band_Cfg fact_ch1_band_cfg;
|
||||
extern const FE_Band_Cfg fact_ch2_band_cfg;
|
||||
extern FE_Ch_Band_cfg fe_ch1_bandcfg;
|
||||
extern FE_Ch_Band_cfg fe_ch2_bandcfg;
|
||||
/* ============================= Fake Functions ============================= */
|
||||
unsigned int s_task_sleep_ticks;
|
||||
xdc_Void ti_sysbios_knl_Task_sleep__E(xdc_UInt32 nticks)
|
||||
{
|
||||
s_task_sleep_ticks += nticks;
|
||||
}
|
||||
|
||||
void test_alert(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* ============================= Boilerplate ================================ */
|
||||
void suite_setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void suite_tearDown(void)
|
||||
{
|
||||
}
|
||||
/* ================================ Tests =================================== */
|
||||
void test_ocmp_fe_init(void)
|
||||
{
|
||||
/* For ch1 */
|
||||
TEST_ASSERT_EQUAL(
|
||||
POST_DEV_FOUND,
|
||||
FE_PARAM_fxnTable.cb_init(&fe_ch1_bandcfg, &fact_ch1_band_cfg, NULL));
|
||||
|
||||
/* For ch2 */
|
||||
TEST_ASSERT_EQUAL(
|
||||
POST_DEV_FOUND,
|
||||
FE_PARAM_fxnTable.cb_init(&fe_ch2_bandcfg, &fact_ch2_band_cfg, NULL));
|
||||
}
|
||||
|
||||
void test_ocmp_fe_get_config(void)
|
||||
{
|
||||
rffeBand returnVal = FE_DEFAULT_VALUE;
|
||||
/* For ch1 */
|
||||
TEST_ASSERT_EQUAL(true, FE_PARAM_fxnTable.cb_get_config(
|
||||
&fe_ch1_bandcfg, FE_CFG_BAND, &returnVal));
|
||||
|
||||
/* For ch2 */
|
||||
TEST_ASSERT_EQUAL(true, FE_PARAM_fxnTable.cb_get_config(
|
||||
&fe_ch2_bandcfg, FE_CFG_BAND, &returnVal));
|
||||
|
||||
/* Invalid Param */
|
||||
TEST_ASSERT_EQUAL(false, FE_PARAM_fxnTable.cb_get_config(&fe_ch2_bandcfg,
|
||||
FE_INVALID_PARAM,
|
||||
&returnVal));
|
||||
}
|
||||
|
||||
void test_ocmp_fe_set_config(void)
|
||||
{
|
||||
rffeBand value = FE_DEFAULT_VALUE;
|
||||
/* For ch1 */
|
||||
TEST_ASSERT_EQUAL(true, FE_PARAM_fxnTable.cb_set_config(
|
||||
&fe_ch1_bandcfg, FE_CFG_BAND, &value));
|
||||
|
||||
/* For ch2 */
|
||||
TEST_ASSERT_EQUAL(true, FE_PARAM_fxnTable.cb_set_config(
|
||||
&fe_ch2_bandcfg, FE_CFG_BAND, &value));
|
||||
|
||||
/* Invalid Param */
|
||||
TEST_ASSERT_EQUAL(false, FE_PARAM_fxnTable.cb_set_config(
|
||||
&fe_ch2_bandcfg, FE_INVALID_PARAM, &value));
|
||||
}
|
||||
/* probe function is stack holder only. No need to create test for it */
|
||||
/* rrfe_ctrl_set_band and rffe_ctrl_get_band are using static structure. No test
|
||||
* case are needed for them */
|
||||
Reference in New Issue
Block a user