Skip to content

Commit 1f7ce31

Browse files
committed
Add header files to fpga tests, update test names
1 parent 991e1d3 commit 1f7ce31

File tree

14 files changed

+591
-122
lines changed

14 files changed

+591
-122
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/** \addtogroup hal_analogin_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_ANALOG_IN_TEST_H
22+
#define MBED_FPGA_ANALOG_IN_TEST_H
23+
24+
#if DEVICE_ANALOGIN
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/** Test that the alalogin can be initialized using all possible analogin pins.
31+
*
32+
* Given board provides analogin support.
33+
* When analogin is initialized using valid analogin pin.
34+
* Then the operation is successfull.
35+
*
36+
*/
37+
void fpga_analogin_init_test(PinName pin);
38+
39+
/** Test that analogin correctly interprets given input voltage.
40+
*
41+
* Given board provides analogin support.
42+
* When 0.0/3.3 V is provided to analogin pin.
43+
* Then analogin_read returns 0.0/1.0,
44+
* analogin_read_u16 returns 0/65535.
45+
*
46+
*/
47+
void fpga_analogin_test(PinName pin);
48+
49+
50+
/**@}*/
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif
55+
56+
#endif
57+
58+
#endif
59+
60+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/analogin/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
#include "utest/utest.h"
2727
#include "unity/unity.h"
2828
#include "greentea-client/test_env.h"
29-
3029
#include "mbed.h"
3130
#include "pinmap.h"
3231
#include "test_utils.h"
3332
#include "MbedTester.h"
33+
#include "analogin_fpga_test.h"
3434

3535
using namespace utest::v1;
3636

@@ -44,14 +44,14 @@ const PinList *restricted = pinmap_restricted_pins();
4444

4545
MbedTester tester(form_factor, restricted);
4646

47-
void analogin_init(PinName pin)
47+
void fpga_analogin_init_test(PinName pin)
4848
{
4949
analogin_t analogin;
5050

5151
analogin_init(&analogin, pin);
5252
}
5353

54-
void analogin_test(PinName pin)
54+
void fpga_analogin_test(PinName pin)
5555
{
5656
tester.reset();
5757
tester.pin_map_set(pin, MbedTester::LogicalPinGPIO0);
@@ -76,9 +76,9 @@ void analogin_test(PinName pin)
7676

7777
Case cases[] = {
7878
// This will be run for all pins
79-
Case("AnalogIn - init test", all_ports<AnaloginPort, DefaultFormFactor, analogin_init>),
79+
Case("AnalogIn - init test", all_ports<AnaloginPort, DefaultFormFactor, fpga_analogin_init_test>),
8080
// This will be run for single pin
81-
Case("AnalogIn - read test", all_ports<AnaloginPort, DefaultFormFactor, analogin_test>),
81+
Case("AnalogIn - read test", all_ports<AnaloginPort, DefaultFormFactor, fpga_analogin_test>),
8282
};
8383

8484
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/** \addtogroup hal_gpio_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_GPIO_TEST_H
22+
#define MBED_FPGA_GPIO_TEST_H
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/* Test basic input & output operations.
29+
*
30+
* Given a GPIO instance initialized with a generic gpio_init() function,
31+
* when basic input and output operations are performed,
32+
* then all operations succeed.
33+
*/
34+
void fpga_test_basic_input_output(PinName pin);
35+
36+
/* Test explicit input initialization.
37+
*
38+
* Given a GPIO instance,
39+
* when additional parameters are passed to the input init function,
40+
* then the GPIO is correctly initialized as an input.
41+
*/
42+
void fpga_test_explicit_input(PinName pin);
43+
44+
/* Test explicit output initialization.
45+
*
46+
* Given a GPIO instance,
47+
* when additional parameters are passed to the output init function,
48+
* then the GPIO is correctly initialized as an output.
49+
*/
50+
void fpga_test_explicit_output(PinName pin);
51+
52+
/**@}*/
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif
59+
60+
61+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/gpio/main.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
#include "unity/unity.h"
2626
#include "greentea-client/test_env.h"
2727
#include "mbed.h"
28-
29-
using namespace utest::v1;
30-
3128
#include "MbedTester.h"
3229
#include "pinmap.h"
3330
#include "test_utils.h"
31+
#include "gpio_fpga_test.h"
32+
33+
using namespace utest::v1;
3434

3535
// This delay is used when reading a floating input that has an internal pull-up
3636
// or pull-down resistor. The voltage response is much slower when the input
@@ -45,7 +45,7 @@ MbedTester tester(DefaultFormFactor::pins(), DefaultFormFactor::restricted_pins(
4545
* when basic input and output operations are performed,
4646
* then all operations succeed.
4747
*/
48-
void test_basic_input_output(PinName pin)
48+
void fpga_test_basic_input_output(PinName pin)
4949
{
5050
// Reset everything and set all tester pins to hi-Z.
5151
tester.reset();
@@ -123,7 +123,7 @@ void test_basic_input_output(PinName pin)
123123
* when additional parameters are passed to the input init function,
124124
* then the GPIO is correctly initialized as an input.
125125
*/
126-
void test_explicit_input(PinName pin)
126+
void fpga_test_explicit_input(PinName pin)
127127
{
128128
// Reset everything and set all tester pins to hi-Z.
129129
tester.reset();
@@ -175,7 +175,7 @@ void test_explicit_input(PinName pin)
175175
* when additional parameters are passed to the output init function,
176176
* then the GPIO is correctly initialized as an output.
177177
*/
178-
void test_explicit_output(PinName pin)
178+
void fpga_test_explicit_output(PinName pin)
179179
{
180180
// Reset everything and set all tester pins to hi-Z.
181181
tester.reset();
@@ -220,9 +220,9 @@ void test_explicit_output(PinName pin)
220220
}
221221

222222
Case cases[] = {
223-
Case("generic init, input & output", all_ports<GPIOPort, DefaultFormFactor, test_basic_input_output>),
224-
Case("explicit init, input", all_ports<GPIOPort, DefaultFormFactor, test_explicit_input>),
225-
Case("explicit init, output", all_ports<GPIOPort, DefaultFormFactor, test_explicit_output>),
223+
Case("generic init, input & output", all_ports<GPIOPort, DefaultFormFactor, fpga_test_basic_input_output>),
224+
Case("explicit init, input", all_ports<GPIOPort, DefaultFormFactor, fpga_test_explicit_input>),
225+
Case("explicit init, output", all_ports<GPIOPort, DefaultFormFactor, fpga_test_explicit_output>),
226226
};
227227

228228
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/** \addtogroup hal_gpioirq_tests */
19+
/** @{*/
20+
21+
#ifndef MBED_FPGA_GPIO_IRQ_TEST_H
22+
#define MBED_FPGA_GPIO_IRQ_TEST_H
23+
24+
#if DEVICE_INTERRUPTIN
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/** Test that the GPIO IRQ can be initialized/de-initialized using all possible
31+
* GPIO IRQ pins.
32+
*
33+
* Given board provides GPIO IRQ support.
34+
* When GPIO IRQ is initialized (and then de-initialized) using valid GPIO IRQ pin.
35+
* Then the operation is successfull.
36+
*
37+
*/
38+
void fpga_gpio_irq_test(PinName pin);
39+
40+
/** Test that the gpio interrupt is generated correctly.
41+
*
42+
* Given board provides interrupt-in feature.
43+
* When gpio interrupt is configured to fire on rasing/falling/both edge(s).
44+
* Then on rasing/falling/any edge registered interrupt handler is called.
45+
*
46+
*/
47+
void fpga_gpio_irq_init_free_test(PinName pin);
48+
49+
/**@}*/
50+
51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
55+
#endif
56+
57+
#endif
58+
/**@}*/

TESTS/mbed_hal_fpga_ci_test_shield/gpio_irq/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include "unity/unity.h"
2828
#include "greentea-client/test_env.h"
2929
#include "mbed.h"
30+
#include "MbedTester.h"
31+
#include "pinmap.h"
32+
#include "gpio_irq_fpga_test.h"
3033

3134
using namespace utest::v1;
3235

@@ -44,7 +47,7 @@ void test_gpio_irq_handler(uint32_t id, gpio_irq_event event)
4447

4548
#define WAIT() wait_us(10)
4649

47-
void gpio_irq_test(PinName pin)
50+
void fpga_gpio_irq_test(PinName pin)
4851
{
4952
// Reset everything and set all tester pins to hi-Z.
5053
tester.reset();
@@ -250,7 +253,7 @@ void gpio_irq_test(PinName pin)
250253
gpio_irq_free(&gpio_irq);
251254
}
252255

253-
void init_free_test(PinName pin)
256+
void fpga_gpio_irq_init_free_test(PinName pin)
254257
{
255258
gpio_t gpio;
256259
gpio_irq_t gpio_irq;
@@ -260,8 +263,8 @@ void init_free_test(PinName pin)
260263
}
261264

262265
Case cases[] = {
263-
Case("init/free", all_ports<GPIOIRQPort, DefaultFormFactor, init_free_test>),
264-
Case("rising & falling edge", all_ports<GPIOIRQPort, DefaultFormFactor, gpio_irq_test>),
266+
Case("init/free", all_ports<GPIOIRQPort, DefaultFormFactor, fpga_gpio_irq_init_free_test>),
267+
Case("rising & falling edge", all_ports<GPIOIRQPort, DefaultFormFactor, fpga_gpio_irq_test>),
265268
};
266269

267270
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)

0 commit comments

Comments
 (0)