Skip to content

Commit

Permalink
test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
attdona committed Oct 1, 2017
1 parent 12e6074 commit 0534e4b
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 168 deletions.
25 changes: 24 additions & 1 deletion burba/tests/bocia/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# name of your application
APPLICATION = test_bocia

include ../Makefile.include
# If no BOARD is found in the environment, use this default:
BOARD ?= cc3200-launchxl

BURBA ?= $(CURDIR)/../..
RIOTBASE ?= $(BURBA)/RIOT

DIRS += $(BURBA)/sys


# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
CFLAGS += -g -DDEVELHELP -DCPUID_ID_LEN=1
CFLAGS_OPT = -O0


# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

USEMODULE += bocia

include $(BURBA)/Makefile.include
112 changes: 112 additions & 0 deletions burba/tests/bocia/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include "bocia_uart.h"
#include "unity.h"
#include "xtimer.h"

#define ENABLE_DEBUG (1)
#include "debug.h"

#define LEDS_COMMAND 10

// bit associated with led in Command ivals registers and in related Ack status
#define LED_RED_BIT 0
#define LED_YELLOW_BIT 1
#define LED_GREEN_BIT 2

#define RETRY_TO_CONNECT 9000

struct timer_msg {
xtimer_t timer;
uint32_t interval;
msg_t msg;
};

struct timer_msg retry = {.interval = 2 * (1000000),
.msg = {.type = RETRY_TO_CONNECT}};

int8_t run_test;

uint32_t handle_command(uint8_t type, Command *command) {
uint32_t sts = -1;
switch (type) {
case LEDS_COMMAND: {
int32_t mask, values;
if (command->n_ivals == 2) {
mask = command->ivals[0];
values = command->ivals[1];

if (mask & 1 << LED_RED_BIT) {
if (values & 1 << LED_RED_BIT) {
gpio_set(LED_RED);
} else {
gpio_clear(LED_RED);
}
}
if (mask & 1 << LED_YELLOW_BIT) {
if (values & 1 << LED_YELLOW_BIT) {
gpio_set(LED_YELLOW);
} else {
gpio_clear(LED_YELLOW);
}
}
if (mask & 1 << LED_GREEN_BIT) {
if (values & 1 << LED_GREEN_BIT) {
gpio_set(LED_GREEN);
} else {
gpio_clear(LED_GREEN);
}
}
}
sts = gpio_read(LED_RED) | gpio_read(LED_YELLOW) << LED_YELLOW_BIT |
gpio_read(LED_GREEN) << LED_GREEN_BIT;

break;
}
}

return sts;
}

void app_init(void) {
if (!bocia_init(0)) {
DEBUG("connection failed, scheduling retry ...\n");
xtimer_set_msg(&retry.timer, retry.interval, &retry.msg,
thread_getpid());
}
}

int main(void) {
msg_t msg;
msg_t msg_queue[SBAPI_MSG_QUEUE_SIZE];

/* initialize message queue */
msg_init_queue(msg_queue, SBAPI_MSG_QUEUE_SIZE);

// start uart monitor
bocia_uart_init();
bocia_delete_file(BOCIA_CFG_FILE);
// test event
printf("board ready\n");

sbapi_init(SBAPI_DEFAULT_CFG);
sbapi_set_mode(ROLE_STA);

run_test = 1;
while (run_test) {
msg_receive(&msg);
switch (msg.type) {
case SBAPI_IP_ACQUIRED:
// test event
printf("IP acquired\n");

app_init();

break;
case BOCIA_CONFIG_OK:
DEBUG("configuration success\n");
app_init();
}
break;
}

return 0;
}
164 changes: 0 additions & 164 deletions burba/tests/bocia/test_cases.c

This file was deleted.

2 changes: 1 addition & 1 deletion burba/tests/nais/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# name of your application
APPLICATION = test_bocia
APPLICATION = test_nais

# If no BOARD is found in the environment, use this default:
BOARD ?= cc3200-launchxl
Expand Down
3 changes: 1 addition & 2 deletions burba/tests/test_cc3200_bocia.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def get_ip_address():
s.connect(("8.8.8.8", 80))
return s.getsockname()[0]

iot.init(tc.fw_build)

events = (
('IP acquired', 'IP_ACQUIRED'),
Expand Down Expand Up @@ -59,5 +58,5 @@ def handle_event(event, uart):
def test_init_board():
tc.check_test_requirements()

iot.run('bocia', events=events, handler=handle_event, timeout=20)
iot.run('bocia', tc.fw_deploy_ctx, events=events, handler=handle_event, timeout=20)

0 comments on commit 0534e4b

Please sign in to comment.