testing/drivertest: add drivertest for cmocka driver testcases
Signed-off-by: yintao <yintao@xiaomi.com>
This commit is contained in:
parent
9ccff7b349
commit
0a9b58ff88
26
testing/drivertest/Kconfig
Normal file
26
testing/drivertest/Kconfig
Normal file
@ -0,0 +1,26 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config TESTING_DRIVER_TEST
|
||||
tristate "vela cmocka driver test"
|
||||
default n
|
||||
---help---
|
||||
Enable the cmocka driver test
|
||||
|
||||
if TESTING_DRIVER_TEST
|
||||
|
||||
config TESTING_DRIVER_TEST_PRIORITY
|
||||
int "Task priority"
|
||||
default 100
|
||||
|
||||
config TESTING_DRIVER_TEST_STACKSIZE
|
||||
int "Stack size"
|
||||
default DEFAULT_TASK_STACKSIZE
|
||||
|
||||
config TESTING_DRIVER_TEST_SIMPLE
|
||||
bool "Enable cmocka driver simple test"
|
||||
default n
|
||||
|
||||
endif
|
23
testing/drivertest/Make.defs
Normal file
23
testing/drivertest/Make.defs
Normal file
@ -0,0 +1,23 @@
|
||||
############################################################################
|
||||
# apps/testing/drivertest/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifneq ($(CONFIG_TESTING_DRIVER_TEST),)
|
||||
CONFIGURED_APPS += $(APPDIR)/testing/drivertest
|
||||
endif
|
32
testing/drivertest/Makefile
Normal file
32
testing/drivertest/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
############################################################################
|
||||
# apps/testing/drivertest/Makefile
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you 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
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
PRIORITY = $(CONFIG_TESTING_DRIVER_TEST_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_TESTING_DRIVER_TEST_STACKSIZE)
|
||||
MODULE = $(CONFIG_TESTING_DRIVER_TEST)
|
||||
|
||||
ifneq ($(CONFIG_TESTING_DRIVER_TEST_SIMPLE),)
|
||||
MAINSRC += cmocka_driver_simple.c
|
||||
PROGNAME += cmocka_driver_simple
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
63
testing/drivertest/cmocka_driver_simple.c
Normal file
63
testing/drivertest/cmocka_driver_simple.c
Normal file
@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
* apps/testing/drivertest/cmocka_driver_simple.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdint.h>
|
||||
#include <cmocka.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void test_case_01(void **state)
|
||||
{
|
||||
(void) state;
|
||||
assert_int_equal(0, 0);
|
||||
}
|
||||
|
||||
static void test_case_02(void **state)
|
||||
{
|
||||
(void)state;
|
||||
assert_string_not_equal("hello", "world");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* cmocka_driver_simple_main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
const struct CMUnitTest tests[] =
|
||||
{
|
||||
cmocka_unit_test(test_case_01),
|
||||
cmocka_unit_test(test_case_02),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
Loading…
Reference in New Issue
Block a user