You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/03/09 20:04:22 UTC
[2/6] incubator-mynewt-blinky git commit: update structure to
represent blinky
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/os/src/test/mempool_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/mempool_test.c b/libs/os/src/test/mempool_test.c
deleted file mode 100644
index cd17c90..0000000
--- a/libs/os/src/test/mempool_test.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * 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 <stdio.h>
-#include <string.h>
-#include "testutil/testutil.h"
-#include "os/os.h"
-#include "os_test_priv.h"
-
-/* Create a memory pool for testing */
-#define NUM_MEM_BLOCKS (10)
-#define MEM_BLOCK_SIZE (80)
-
-/* Limit max blocks for testing */
-#define MEMPOOL_TEST_MAX_BLOCKS (128)
-
-#if OS_CFG_ALIGNMENT == OS_CFG_ALIGN_4
-int alignment = 4;
-#else
-int alignment = 8;
-#endif
-
-/* Test memory pool structure */
-struct os_mempool g_TstMempool;
-
-/* Test memory pool buffer */
-os_membuf_t TstMembuf[OS_MEMPOOL_SIZE(NUM_MEM_BLOCKS, MEM_BLOCK_SIZE)];
-
-/* Array of block pointers. */
-void *block_array[MEMPOOL_TEST_MAX_BLOCKS];
-
-int verbose = 0;
-
-static int
-mempool_test_get_pool_size(int num_blocks, int block_size)
-{
- int mem_pool_size;
-
-#if OS_CFG_ALIGNMENT == OS_CFG_ALIGN_4
- mem_pool_size = (num_blocks * ((block_size + 3)/4) * sizeof(os_membuf_t));
-#else
- mem_pool_size = (num_blocks * ((block_size + 7)/8) * sizeof(os_membuf_t));
-#endif
-
- return mem_pool_size;
-}
-
-static void
-mempool_test(int num_blocks, int block_size)
-{
- int cnt;
- int true_block_size;
- int mem_pool_size;
- uint32_t test_block;
- uint8_t *tstptr;
- void **free_ptr;
- void *block;
- os_error_t rc;
-
- /* Check for too many blocks */
- TEST_ASSERT(num_blocks <= MEMPOOL_TEST_MAX_BLOCKS);
-
- rc = os_mempool_init(&g_TstMempool, num_blocks, MEM_BLOCK_SIZE,
- &TstMembuf[0], "TestMemPool");
- TEST_ASSERT_FATAL(rc == 0, "Error creating memory pool %d", rc);
-
- TEST_ASSERT(g_TstMempool.mp_num_free == num_blocks,
- "Number of free blocks not equal to total blocks!");
-
- TEST_ASSERT(SLIST_FIRST(&g_TstMempool) == (void *)&TstMembuf[0],
- "Free list pointer does not point to first block!");
-
- mem_pool_size = mempool_test_get_pool_size(num_blocks, block_size);
- TEST_ASSERT(mem_pool_size == sizeof(TstMembuf),
- "Total memory pool size not correct! (%d vs %lu)",
- mem_pool_size, (unsigned long)sizeof(TstMembuf));
-
- /* Get the real block size */
-#if (OS_CFG_ALIGNMENT == OS_CFG_ALIGN_4)
- true_block_size = (g_TstMempool.mp_block_size + 3) & ~3;
-#else
- true_block_size = (g_TstMempool.mp_block_size + 7) & ~7;
-#endif
-
- /* Traverse free list. Better add up to number of blocks! */
- cnt = 0;
- free_ptr = (void **)&TstMembuf;
- tstptr = (uint8_t *)&TstMembuf;
- while (1) {
- /* Increment # of elements by 1 */
- ++cnt;
-
- /* If the free list is NULL, leave */
- if (*free_ptr == NULL) {
- break;
- }
-
- TEST_ASSERT(((uint8_t *)*free_ptr - (uint8_t *)free_ptr) ==
- true_block_size,
- "Free pointers are more than one block apart!");
-
- /* Move to next memory block */
- tstptr += true_block_size;
-
- TEST_ASSERT(*free_ptr == (void *)tstptr,
- "Error: free_ptr=%p testptr=%p\n", *free_ptr, tstptr);
-
- free_ptr = *free_ptr;
- }
-
- /* Last one in list better be NULL */
- TEST_ASSERT(cnt == g_TstMempool.mp_num_blocks,
- "Free list contains too many elements (%u)", cnt);
-
- /* Get a block */
- block = os_memblock_get(&g_TstMempool);
- TEST_ASSERT(block != NULL,
- "Error: get block fails when pool should have elements");
-
- TEST_ASSERT(g_TstMempool.mp_num_free == (num_blocks-1),
- "Number of free blocks incorrect (%u vs %u)",
- g_TstMempool.mp_num_free, (num_blocks-1));
-
- /* Put back the block */
- rc = os_memblock_put(&g_TstMempool, block);
- TEST_ASSERT(rc == 0, "Put block fails with error code=%d\n", rc);
-
- TEST_ASSERT(g_TstMempool.mp_num_free == num_blocks,
- "Number of free blocks incorrect (%u vs %u)",
- g_TstMempool.mp_num_free, num_blocks);
-
- /* remove all the blocks. Make sure we get count. */
- memset(block_array, 0, sizeof(block_array));
- cnt = 0;
- while (1) {
- block = os_memblock_get(&g_TstMempool);
- if (block == NULL) {
- break;
- }
- block_array[cnt] = block;
- ++cnt;
- if (cnt == MEMPOOL_TEST_MAX_BLOCKS) {
- break;
- }
- }
-
- TEST_ASSERT((cnt == g_TstMempool.mp_num_blocks) &&
- (cnt != MEMPOOL_TEST_MAX_BLOCKS),
- "Got more blocks than mempool contains (%d vs %d)",
- cnt, g_TstMempool.mp_num_blocks);
-
- /* Better be no free blocks left! */
- TEST_ASSERT(g_TstMempool.mp_num_free == 0,
- "Got all blocks but number free not zero! (%d)",
- g_TstMempool.mp_num_free);
-
- /* Now put them all back */
- for (cnt = 0; cnt < g_TstMempool.mp_num_blocks; ++cnt) {
- rc = os_memblock_put(&g_TstMempool, block_array[cnt]);
- TEST_ASSERT(rc == 0,
- "Error putting back block %p (cnt=%d err=%d)",
- block_array[cnt], cnt, rc);
- }
-
- /* Better be no free blocks left! */
- TEST_ASSERT(g_TstMempool.mp_num_free == g_TstMempool.mp_num_blocks,
- "Put all blocks but number free not equal to total!");
-
- /* Better get error when we try these things! */
- rc = os_memblock_put(NULL, block_array[0]);
- TEST_ASSERT(rc != 0,
- "Should have got an error trying to put to null pool");
-
- rc = os_memblock_put(&g_TstMempool, NULL);
- TEST_ASSERT(rc != 0, "No error trying to put to NULL block");
-
- TEST_ASSERT(os_memblock_get(NULL) == NULL,
- "No error trying to get a block from NULL pool");
-
- /* Attempt to free a block outside the range of the membuf */
- test_block = g_TstMempool.mp_membuf_addr;
- test_block -= 4;
- rc = os_memblock_put(&g_TstMempool, (void *)test_block);
- TEST_ASSERT(rc == OS_INVALID_PARM, "No error freeing bad block address");
-
- test_block += (true_block_size * g_TstMempool.mp_num_blocks) + 100;
- rc = os_memblock_put(&g_TstMempool, (void *)test_block);
- TEST_ASSERT(rc == OS_INVALID_PARM, "No error freeing bad block address");
-
- /* Attempt to free on bad boundary */
- test_block = g_TstMempool.mp_membuf_addr;
- test_block += (true_block_size / 2);
- rc = os_memblock_put(&g_TstMempool, (void *)test_block);
- TEST_ASSERT(rc == OS_INVALID_PARM, "No error freeing bad block address");
-}
-
-/**
- * os mempool test
- *
- * Main test loop for memory pool testing.
- *
- * @return int
- */
-TEST_CASE(os_mempool_test_case)
-{
- mempool_test(NUM_MEM_BLOCKS, MEM_BLOCK_SIZE);
-}
-
-TEST_SUITE(os_mempool_test_suite)
-{
- os_mempool_test_case();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/os/src/test/mutex_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/mutex_test.c b/libs/os/src/test/mutex_test.c
deleted file mode 100644
index ff5e016..0000000
--- a/libs/os/src/test/mutex_test.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/**
- * 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 <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/time.h>
-#include "testutil/testutil.h"
-#include "os/os.h"
-#include "os/os_test.h"
-#include "os/os_cfg.h"
-#include "os/os_mutex.h"
-#include "os_test_priv.h"
-
-#ifdef ARCH_sim
-#define MUTEX_TEST_STACK_SIZE 1024
-#else
-#define MUTEX_TEST_STACK_SIZE 256
-#endif
-
-struct os_task task14;
-os_stack_t stack14[OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE)];
-
-struct os_task task15;
-os_stack_t stack15[OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE)];
-
-struct os_task task16;
-os_stack_t stack16[OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE)];
-
-struct os_task task17;
-os_stack_t stack17[OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE)];
-
-#define TASK14_PRIO (4)
-#define TASK15_PRIO (5)
-#define TASK16_PRIO (6)
-#define TASK17_PRIO (7)
-
-volatile int g_task14_val;
-volatile int g_task15_val;
-volatile int g_task16_val;
-volatile int g_task17_val;
-struct os_mutex g_mutex1;
-struct os_mutex g_mutex2;
-
-static volatile int g_mutex_test;
-
-/**
- * mutex test basic
- *
- * Basic mutex tests
- *
- * @return int
- */
-static void
-mutex_test_basic_handler(void *arg)
-{
- struct os_mutex *mu;
- struct os_task *t;
- os_error_t err;
-
- mu = &g_mutex1;
- t = os_sched_get_current_task();
-
- /* Test some error cases */
- TEST_ASSERT(os_mutex_init(NULL) == OS_INVALID_PARM);
- TEST_ASSERT(os_mutex_delete(NULL) == OS_INVALID_PARM);
- TEST_ASSERT(os_mutex_release(NULL) == OS_INVALID_PARM);
- TEST_ASSERT(os_mutex_pend(NULL, 0) == OS_INVALID_PARM);
-
- /* Get the mutex */
- err = os_mutex_pend(mu, 0);
- TEST_ASSERT(err == 0,
- "Did not get free mutex immediately (err=%d)", err);
-
- /* Check mutex internals */
- TEST_ASSERT(mu->mu_owner == t && mu->mu_level == 1 &&
- mu->mu_prio == t->t_prio && SLIST_EMPTY(&mu->mu_head),
- "Mutex internals not correct after getting mutex\n"
- "Mutex: owner=%p prio=%u level=%u head=%p\n"
- "Task: task=%p prio=%u",
- mu->mu_owner, mu->mu_prio, mu->mu_level,
- SLIST_FIRST(&mu->mu_head),
- t, t->t_prio);
-
- /* Get the mutex again; should be level 2 */
- err = os_mutex_pend(mu, 0);
- TEST_ASSERT(err == 0, "Did not get my mutex immediately (err=%d)", err);
-
- /* Check mutex internals */
- TEST_ASSERT(mu->mu_owner == t && mu->mu_level == 2 &&
- mu->mu_prio == t->t_prio && SLIST_EMPTY(&mu->mu_head),
- "Mutex internals not correct after getting mutex\n"
- "Mutex: owner=%p prio=%u level=%u head=%p\n"
- "Task: task=%p prio=%u",
- mu->mu_owner, mu->mu_prio, mu->mu_level,
- SLIST_FIRST(&mu->mu_head), t, t->t_prio);
-
- /* Release mutex */
- err = os_mutex_release(mu);
- TEST_ASSERT(err == 0, "Could not release mutex I own (err=%d)", err);
-
- /* Check mutex internals */
- TEST_ASSERT(mu->mu_owner == t && mu->mu_level == 1 &&
- mu->mu_prio == t->t_prio && SLIST_EMPTY(&mu->mu_head),
- "Error: mutex internals not correct after getting mutex\n"
- "Mutex: owner=%p prio=%u level=%u head=%p\n"
- "Task: task=%p prio=%u",
- mu->mu_owner, mu->mu_prio, mu->mu_level,
- SLIST_FIRST(&mu->mu_head), t, t->t_prio);
-
- /* Release it again */
- err = os_mutex_release(mu);
- TEST_ASSERT(err == 0, "Could not release mutex I own (err=%d)", err);
-
- /* Check mutex internals */
- TEST_ASSERT(mu->mu_owner == NULL && mu->mu_level == 0 &&
- mu->mu_prio == t->t_prio && SLIST_EMPTY(&mu->mu_head),
- "Mutex internals not correct after getting mutex\n"
- "Mutex: owner=%p prio=%u level=%u head=%p\n"
- "Task: task=%p prio=%u",
- mu->mu_owner, mu->mu_prio, mu->mu_level,
- SLIST_FIRST(&mu->mu_head), t, t->t_prio);
-
- os_test_restart();
-}
-
-static void
-mutex_test1_task14_handler(void *arg)
-{
- os_error_t err;
- struct os_task *t;
- int iters;
-
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == mutex_test1_task14_handler);
-
- for (iters = 0; iters < 3; iters++) {
- os_time_delay(100);
-
- g_task14_val = 1;
-
- err = os_mutex_pend(&g_mutex1, 100);
- TEST_ASSERT(err == OS_OK);
- TEST_ASSERT(g_task16_val == 1);
-
- os_time_delay(100);
- }
-
- os_test_restart();
-}
-
-static void
-mutex_test2_task14_handler(void *arg)
-{
- os_error_t err;
- struct os_task *t;
- int iters;
-
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == mutex_test2_task14_handler);
-
- for (iters = 0; iters < 3; iters++) {
- err = os_mutex_pend(&g_mutex1, 0);
- TEST_ASSERT(err == OS_OK, "err=%d", err);
-
- g_task14_val = 1;
- os_time_delay(100);
-
- /*
- * Task17 should have its mutex wait flag set; at least the first time
- * through!
- */
- if (iters == 0) {
- TEST_ASSERT(task17.t_flags & OS_TASK_FLAG_MUTEX_WAIT);
- }
-
- if (g_mutex_test == 4) {
- os_mutex_delete(&g_mutex1);
- os_time_delay(150);
- }
-
- os_mutex_release(&g_mutex1);
- os_time_delay(100);
- }
-
- os_test_restart();
-}
-
-static void
-task15_handler(void *arg)
-{
- os_error_t err;
- struct os_task *t;
-
- if (g_mutex_test == 1) {
- while (1) {
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == task15_handler);
-
- os_time_delay(50);
- while (1) {
- /* Wait here forever */
- }
- }
- } else {
- if (g_mutex_test == 2) {
- /* Sleep for 3 seconds */
- t = os_sched_get_current_task();
- os_time_delay(500);
- } else if (g_mutex_test == 3) {
- /* Sleep for 3 seconds */
- t = os_sched_get_current_task();
- os_time_delay(30);
- }
-
- while (1) {
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == task15_handler);
-
- err = os_mutex_pend(&g_mutex1, 10000);
- if (g_mutex_test == 4) {
- TEST_ASSERT(err == OS_TIMEOUT);
- } else {
- TEST_ASSERT(err == OS_OK);
- }
-
- os_time_delay(100);
- }
- }
-}
-
-static void
-task16_handler(void *arg)
-{
- os_error_t err;
- struct os_task *t;
-
- if (g_mutex_test == 1) {
- while (1) {
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == task16_handler);
-
- /* Get mutex 1 */
- err = os_mutex_pend(&g_mutex1, 0xFFFFFFFF);
- TEST_ASSERT(err == OS_OK);
-
- while (g_task14_val != 1) {
- /* Wait till task 1 wakes up and sets val. */
- }
-
- g_task16_val = 1;
-
- err = os_mutex_release(&g_mutex1);
- TEST_ASSERT(err == OS_OK);
- }
- } else {
- if (g_mutex_test == 2) {
- /* Sleep for 3 seconds */
- t = os_sched_get_current_task();
- os_time_delay(30);
- } else if (g_mutex_test == 3) {
- /* Sleep for 3 seconds */
- t = os_sched_get_current_task();
- os_time_delay(50);
- }
-
- while (1) {
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == task16_handler);
-
- err = os_mutex_pend(&g_mutex1, 10000);
- if (g_mutex_test == 4) {
- TEST_ASSERT(err == OS_TIMEOUT);
- } else {
- TEST_ASSERT(err == OS_OK);
- }
-
- if (err == OS_OK) {
- err = os_mutex_release(&g_mutex1);
- TEST_ASSERT(err == OS_OK);
- }
-
- os_time_delay(10000);
- }
- }
-}
-
-static void
-task17_handler(void *arg)
-{
- os_error_t err;
- struct os_task *t;
-
- while (1) {
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == task17_handler);
-
- if (g_mutex_test == 5) {
- err = os_mutex_pend(&g_mutex1, 10);
- } else {
- err = os_mutex_pend(&g_mutex1, 10000);
- TEST_ASSERT((t->t_flags & OS_TASK_FLAG_MUTEX_WAIT) == 0);
- }
-
- if (g_mutex_test == 4 || g_mutex_test == 5) {
- TEST_ASSERT(err == OS_TIMEOUT);
- } else {
- TEST_ASSERT(err == OS_OK);
- }
-
- if (err == OS_OK) {
- err = os_mutex_release(&g_mutex1);
- TEST_ASSERT(err == OS_OK);
- }
-
- os_time_delay(10000);
- }
-}
-
-TEST_CASE(os_mutex_test_basic)
-{
- os_init();
-
- os_mutex_init(&g_mutex1);
-
- os_task_init(&task14, "task14", mutex_test_basic_handler, NULL,
- TASK14_PRIO, OS_WAIT_FOREVER, stack14,
- OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_start();
-}
-
-TEST_CASE(os_mutex_test_case_1)
-{
- int rc;
-
- os_init();
-
- g_mutex_test = 1;
- g_task14_val = 0;
- g_task15_val = 0;
- g_task16_val = 0;
-
- rc = os_mutex_init(&g_mutex1);
- TEST_ASSERT(rc == 0);
- rc = os_mutex_init(&g_mutex2);
- TEST_ASSERT(rc == 0);
-
- os_task_init(&task14, "task14", mutex_test1_task14_handler, NULL,
- TASK14_PRIO, OS_WAIT_FOREVER, stack14,
- OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_task_init(&task15, "task15", task15_handler, NULL, TASK15_PRIO,
- OS_WAIT_FOREVER, stack15, OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_task_init(&task16, "task16", task16_handler, NULL, TASK16_PRIO,
- OS_WAIT_FOREVER, stack16, OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_start();
-}
-
-TEST_CASE(os_mutex_test_case_2)
-{
- os_init();
-
- g_mutex_test = 2;
- g_task14_val = 0;
- g_task15_val = 0;
- g_task16_val = 0;
- os_mutex_init(&g_mutex1);
- os_mutex_init(&g_mutex2);
-
- os_task_init(&task14, "task14", mutex_test2_task14_handler, NULL,
- TASK14_PRIO, OS_WAIT_FOREVER, stack14,
- OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_task_init(&task15, "task15", task15_handler, NULL, TASK15_PRIO,
- OS_WAIT_FOREVER, stack15, OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_task_init(&task16, "task16", task16_handler, NULL, TASK16_PRIO,
- OS_WAIT_FOREVER, stack16, OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_task_init(&task17, "task17", task17_handler, NULL, TASK17_PRIO,
- OS_WAIT_FOREVER, stack17, OS_STACK_ALIGN(MUTEX_TEST_STACK_SIZE));
-
- os_start();
-}
-
-TEST_SUITE(os_mutex_test_suite)
-{
- os_mutex_test_basic();
- os_mutex_test_case_1();
- os_mutex_test_case_2();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/os/src/test/os_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/os_test.c b/libs/os/src/test/os_test.c
deleted file mode 100644
index e4cff6a..0000000
--- a/libs/os/src/test/os_test.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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 <assert.h>
-#include <stddef.h>
-#include "testutil/testutil.h"
-#include "os/os_test.h"
-#include "os_test_priv.h"
-
-int
-os_test_all(void)
-{
- os_mempool_test_suite();
- os_mutex_test_suite();
- os_sem_test_suite();
- os_mbuf_test_suite();
-
- return tu_case_failed;
-}
-
-#ifdef PKG_TEST
-
-int
-main(int argc, char **argv)
-{
- tu_config.tc_print_results = 1;
- tu_init();
-
- os_test_all();
-
- return tu_any_failed;
-}
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/os/src/test/os_test_priv.h
----------------------------------------------------------------------
diff --git a/libs/os/src/test/os_test_priv.h b/libs/os/src/test/os_test_priv.h
deleted file mode 100644
index 7293805..0000000
--- a/libs/os/src/test/os_test_priv.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.
- */
-
-#ifndef H_OS_TEST_PRIV_
-#define H_OS_TEST_PRIV_
-
-void os_test_restart(void);
-
-int os_mempool_test_suite(void);
-int os_mbuf_test_suite(void);
-int os_mutex_test_suite(void);
-int os_sem_test_suite(void);
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/os/src/test/sem_test.c
----------------------------------------------------------------------
diff --git a/libs/os/src/test/sem_test.c b/libs/os/src/test/sem_test.c
deleted file mode 100644
index e0f60b6..0000000
--- a/libs/os/src/test/sem_test.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/**
- * 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 <stdio.h>
-#include <string.h>
-#include "testutil/testutil.h"
-#include "os/os.h"
-#include "os/os_cfg.h"
-#include "os/os_sem.h"
-#include "os_test_priv.h"
-
-#ifdef ARCH_sim
-#define SEM_TEST_STACK_SIZE 1024
-#else
-#define SEM_TEST_STACK_SIZE 512
-#endif
-
-struct os_task task1;
-os_stack_t stack1[OS_STACK_ALIGN(SEM_TEST_STACK_SIZE)];
-
-struct os_task task2;
-os_stack_t stack2[OS_STACK_ALIGN(SEM_TEST_STACK_SIZE)];
-
-struct os_task task3;
-os_stack_t stack3[OS_STACK_ALIGN(SEM_TEST_STACK_SIZE)];
-
-struct os_task task4;
-os_stack_t stack4[OS_STACK_ALIGN(SEM_TEST_STACK_SIZE)];
-
-#define TASK1_PRIO (1)
-#define TASK2_PRIO (2)
-#define TASK3_PRIO (3)
-#define TASK4_PRIO (4)
-
-struct os_sem g_sem1;
-
-/*
- * TEST NUMBERS:
- * 10: In this test we have the highest priority task getting the semaphore
- * then sleeping. Two lower priority tasks then wake up and attempt to get
- * the semaphore. They are blocked until the higher priority task releases
- * the semaphore, at which point the lower priority tasks should wake up in
- * order, get the semaphore, then release it and go back to sleep.
- *
- */
-
-/**
- * sem test disp sem
- *
- * Display semaphore contents
- *
- * @param sem
- */
-static const char *
-sem_test_sem_to_s(const struct os_sem *sem)
-{
- static char buf[128];
-
- snprintf(buf, sizeof buf, "\tSemaphore: tokens=%u head=%p",
- sem->sem_tokens, SLIST_FIRST(&sem->sem_head));
-
- return buf;
-}
-
-static void
-sem_test_sleep_task_handler(void *arg)
-{
- struct os_task *t;
-
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == sem_test_sleep_task_handler);
-
- os_time_delay(2000);
- os_test_restart();
-}
-
-static void
-sem_test_pend_release_loop(int delay, int timeout, int itvl)
-{
- os_error_t err;
-
- os_time_delay(delay);
-
- while (1) {
- err = os_sem_pend(&g_sem1, timeout);
- TEST_ASSERT((err == OS_OK) || (err == OS_TIMEOUT));
-
- err = os_sem_release(&g_sem1);
- TEST_ASSERT(err == OS_OK);
-
- os_time_delay(itvl);
- }
-}
-
-/**
- * sem test basic
- *
- * Basic semaphore tests
- *
- * @return int
- */
-static void
-sem_test_basic_handler(void *arg)
-{
- struct os_task *t;
- struct os_sem *sem;
- os_error_t err;
-
- sem = &g_sem1;
- t = os_sched_get_current_task();
-
- /* Test some error cases */
- TEST_ASSERT(os_sem_init(NULL, 1) == OS_INVALID_PARM);
- TEST_ASSERT(os_sem_delete(NULL) == OS_INVALID_PARM);
- TEST_ASSERT(os_sem_release(NULL) == OS_INVALID_PARM);
- TEST_ASSERT(os_sem_pend(NULL, 1) == OS_INVALID_PARM);
-
- /* Get the semaphore */
- err = os_sem_pend(sem, 0);
- TEST_ASSERT(err == 0,
- "Did not get free semaphore immediately (err=%d)", err);
-
- /* Check semaphore internals */
- TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head),
- "Semaphore internals wrong after getting semaphore\n"
- "%s\n"
- "Task: task=%p prio=%u", sem_test_sem_to_s(sem), t, t->t_prio);
-
- /* Get the semaphore again; should fail */
- err = os_sem_pend(sem, 0);
- TEST_ASSERT(err == OS_TIMEOUT,
- "Did not time out waiting for semaphore (err=%d)", err);
-
- /* Check semaphore internals */
- TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head),
- "Semaphore internals wrong after getting semaphore\n"
- "%s\n"
- "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t,
- t->t_prio);
-
- /* Release semaphore */
- err = os_sem_release(sem);
- TEST_ASSERT(err == 0,
- "Could not release semaphore I own (err=%d)", err);
-
- /* Check semaphore internals */
- TEST_ASSERT(sem->sem_tokens == 1 && SLIST_EMPTY(&sem->sem_head),
- "Semaphore internals wrong after releasing semaphore\n"
- "%s\n"
- "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t,
- t->t_prio);
-
- /* Release it again */
- err = os_sem_release(sem);
- TEST_ASSERT(err == 0,
- "Could not release semaphore again (err=%d)\n", err);
-
- /* Check semaphore internals */
- TEST_ASSERT(sem->sem_tokens == 2 && SLIST_EMPTY(&sem->sem_head),
- "Semaphore internals wrong after releasing semaphore\n"
- "%s\n"
- "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t,
- t->t_prio);
-
- /* "Delete" it */
- err = os_sem_delete(sem);
- TEST_ASSERT(err == 0,
- "Could not delete semaphore (err=%d)", err);
-
- /* Check semaphore internals */
- TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head),
- "Semaphore internals wrong after deleting semaphore\n"
- "%s\n"
- "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t,
- t->t_prio);
-
- os_test_restart();
-}
-
-static void
-sem_test_1_task1_handler(void *arg)
-{
- os_error_t err;
- struct os_task *t;
- int i;;
-
- for (i = 0; i < 3; i++) {
- t = os_sched_get_current_task();
- TEST_ASSERT(t->t_func == sem_test_1_task1_handler);
-
-
- err = os_sem_pend(&g_sem1, 0);
- TEST_ASSERT(err == OS_OK);
-
- /* Sleep to let other tasks run */
- os_time_delay(100);
-
- /* Release the semaphore */
- err = os_sem_release(&g_sem1);
- TEST_ASSERT(err == OS_OK);
-
- /* Sleep to let other tasks run */
- os_time_delay(100);
- }
-
- os_test_restart();
-}
-
-TEST_CASE(os_sem_test_basic)
-{
- os_error_t err;
-
- os_init();
-
- err = os_sem_init(&g_sem1, 1);
- TEST_ASSERT(err == OS_OK);
-
- os_task_init(&task1, "task1", sem_test_basic_handler, NULL, TASK1_PRIO,
- OS_WAIT_FOREVER, stack1, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_start();
-}
-
-static void
-sem_test_1_task2_handler(void *arg)
-{
- sem_test_pend_release_loop(0, 100, 100);
-}
-
-static void
-sem_test_1_task3_handler(void *arg)
-{
- sem_test_pend_release_loop(0, OS_TIMEOUT_NEVER, 2000);
-}
-
-TEST_CASE(os_sem_test_case_1)
-{
- os_error_t err;
-
- os_init();
-
- err = os_sem_init(&g_sem1, 1);
- TEST_ASSERT(err == OS_OK);
-
- os_task_init(&task1, "task1", sem_test_1_task1_handler, NULL,
- TASK1_PRIO, OS_WAIT_FOREVER, stack1,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task2, "task2", sem_test_1_task2_handler, NULL,
- TASK2_PRIO, OS_WAIT_FOREVER, stack2,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task3, "task3", sem_test_1_task3_handler, NULL, TASK3_PRIO,
- OS_WAIT_FOREVER, stack3, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_start();
-}
-
-static void
-sem_test_2_task2_handler(void *arg)
-{
- sem_test_pend_release_loop(0, 2000, 2000);
-}
-
-static void
-sem_test_2_task3_handler(void *arg)
-{
- sem_test_pend_release_loop(0, OS_TIMEOUT_NEVER, 2000);
-}
-
-static void
-sem_test_2_task4_handler(void *arg)
-{
- sem_test_pend_release_loop(0, 2000, 2000);
-}
-
-TEST_CASE(os_sem_test_case_2)
-{
- os_error_t err;
-
- os_init();
-
- err = os_sem_init(&g_sem1, 1);
- TEST_ASSERT(err == OS_OK);
-
- os_task_init(&task1, "task1", sem_test_sleep_task_handler, NULL,
- TASK1_PRIO, OS_WAIT_FOREVER, stack1,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task2, "task2", sem_test_2_task2_handler, NULL,
- TASK2_PRIO, OS_WAIT_FOREVER, stack2,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task3, "task3", sem_test_2_task3_handler, NULL, TASK3_PRIO,
- OS_WAIT_FOREVER, stack3, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task4, "task4", sem_test_2_task4_handler, NULL, TASK4_PRIO,
- OS_WAIT_FOREVER, stack4, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_start();
-}
-
-static void
-sem_test_3_task2_handler(void *arg)
-{
- sem_test_pend_release_loop(100, 2000, 2000);
-}
-
-static void
-sem_test_3_task3_handler(void *arg)
-{
- sem_test_pend_release_loop(150, 2000, 2000);
-}
-
-static void
-sem_test_3_task4_handler(void *arg)
-{
- sem_test_pend_release_loop(0, 2000, 2000);
-}
-
-TEST_CASE(os_sem_test_case_3)
-{
- os_error_t err;
-
- os_init();
-
- err = os_sem_init(&g_sem1, 1);
- TEST_ASSERT(err == OS_OK);
-
- os_task_init(&task1, "task1", sem_test_sleep_task_handler, NULL,
- TASK1_PRIO, OS_WAIT_FOREVER, stack1,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task2, "task2", sem_test_3_task2_handler, NULL,
- TASK2_PRIO, OS_WAIT_FOREVER, stack2,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task3, "task3", sem_test_3_task3_handler, NULL, TASK3_PRIO,
- OS_WAIT_FOREVER, stack3, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task4, "task4", sem_test_3_task4_handler, NULL, TASK4_PRIO,
- OS_WAIT_FOREVER, stack4, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_start();
-}
-
-static void
-sem_test_4_task2_handler(void *arg)
-{
- sem_test_pend_release_loop(60, 2000, 2000);
-}
-
-static void
-sem_test_4_task3_handler(void *arg)
-{
- sem_test_pend_release_loop(60, 2000, 2000);
-}
-
-static void
-sem_test_4_task4_handler(void *arg)
-{
- sem_test_pend_release_loop(0, 2000, 2000);
-}
-
-
-TEST_CASE(os_sem_test_case_4)
-{
- os_error_t err;
-
- os_init();
-
- err = os_sem_init(&g_sem1, 1);
- TEST_ASSERT(err == OS_OK);
-
- os_task_init(&task1, "task1", sem_test_sleep_task_handler, NULL,
- TASK1_PRIO, OS_WAIT_FOREVER, stack1,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task2, "task2", sem_test_4_task2_handler, NULL,
- TASK2_PRIO, OS_WAIT_FOREVER, stack2,
- OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task3, "task3", sem_test_4_task3_handler, NULL, TASK3_PRIO,
- OS_WAIT_FOREVER, stack3, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_task_init(&task4, "task4", sem_test_4_task4_handler, NULL, TASK4_PRIO,
- OS_WAIT_FOREVER, stack4, OS_STACK_ALIGN(SEM_TEST_STACK_SIZE));
-
- os_start();
-}
-
-TEST_SUITE(os_sem_test_suite)
-{
- os_sem_test_basic();
- os_sem_test_case_1();
- os_sem_test_case_2();
- os_sem_test_case_3();
- os_sem_test_case_4();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/README.md
----------------------------------------------------------------------
diff --git a/libs/testutil/README.md b/libs/testutil/README.md
deleted file mode 100644
index 62bac30..0000000
--- a/libs/testutil/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# testutil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/design.txt
----------------------------------------------------------------------
diff --git a/libs/testutil/design.txt b/libs/testutil/design.txt
deleted file mode 100644
index a1dfd9b..0000000
--- a/libs/testutil/design.txt
+++ /dev/null
@@ -1,476 +0,0 @@
-#
-# 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.
-#
-
-****** TEST AUTOMATION
-
-*** HISTORY
-Rev. Date Changes
-2 2015/09/07 Addition of tu_restart(); clarification of exported
- preprocessor symbols.
-1 2015/08/28
-
-
-*** SUMMARY
-
-Automated testing can be done in either of two ways:
- 1. Testing a set of packages on embedded hardware or a simulated
- environment.
- 2. Testing an individual package in a simulated environment.
-
-
-***** PACKAGE SET TESTING
-
-Automated testing of package sets consists of two components:
- 1. "PC software" which administers tests and manages results.
- 2. Test images which run on the units under test (UUTs).
-
-
-**** PC SOFTWARE
-
-The PC software will need to perform the following tasks:
- 1. Connect to UUT (e.g., via JTAG and OpenOCD) (if embedded).
- 2. Upload test image (if embedded).
- 3. Run test image.
- 4. Read test results from UUT.
- 5. Generate test report.
-
-If any of these tasks fail, a fatal error would need to be logged to the test
-report.
-
-The details of the PC software are TBD, and are not discussed further here.
-
-
-**** TEST IMAGES
-
-Test images are build using the stack tool. The user will need to create a
-separate stack tool target for each platform under test. In addition, there
-will be a single stack tool project which contains code to call the appropriate
-test code. Each test image typically consists of the following:
- 1. The test cases from all relevant packages.
- 2. Some "glue code" from a special test project.
-
-
-*** PACKAGE TEST CASES
-
-A package may optionally contain a set of test cases. Test cases are not
-normally compiled and linked when a package is built; they are only included
-when the "test" identity is specified. All of a
-package's test code goes in its 'src/test' directory. For example, the ffs
-package's test code is located in the following directory:
-
- libs/ffs/src/test/
-
-This directory contains the source and header files that implement the ffs test
-code.
-
-The test code has access to all the header files in the following directories:
- * src
- * src/arch/<target-arch>
- * include
- * src/test
- * src/test/arch/<target-arch>
- * include directories of all package dependencies
-
-Package test code typically depends on the testutil package, described later in
-this document. If a package's test code uses testutil, then the package itself
-needs to have testutil in its dependency list.
-
-Some test cases or test initialization code may be platform-specific. In such
-cases, the platform-specific function definitions are placed in arch
-subdirectories within the package test directory.
-
-When test code is built (i.e., when the "test" identity is specified), the
-stack tool defines the "TEST" macro. This macro is defined during complilation
-of all C source files in all projects and packages..
-
-
-***** TESTUTIL
-
-The testutil package is a test framework that provides facilities for
-specifying test cases and recording test results.
-
-
-*** TEST STRUCTURE
-
-Tests are structures according to the following hierarchy:
-
- [test]
- / \
- [suite] [suite]
- / \ / \
- [case] [case] [case] [case]
-
-
-I.e., a test consists of test suites, and a test suite consits of test cases.
-
-The test code uses testutil to define test suites and test cases.
-
-
-*** TESTUTIL EXAMPLE
-
-The following example demonstrates how to create a simple test suite.
-
- TEST_CASE(test_addition)
- {
- int sum;
-
- sum = 5 + 10;
- TEST_ASSERT(sum == 15, "actual value: %d", sum);
- }
-
- TEST_CASE(test_times_0)
- {
- TEST_ASSERT(3 * 0 == 0);
- TEST_ASSERT(4 * 0 == 0);
- TEST_ASSERT(712 * 0 == 0);
- }
-
- TEST_SUITE(test_suite_arithmetic)
- {
- test_addition();
- test_times_0();
- }
-
-The test suite would then be executed via a call to test_suite_arithmetic().
-
-
-*** TEST RESULTS
-
-The testutil package optionally writes test results to a file system residing
-on the UUT. The contents of the file system can then be retrieved from the UUT
-by the PC software. When run in an embedded environment, the results are
-written to an ffs file system. When run in a simulated environment, the
-results are written to the native file system.
-
-Results directory structure:
- /
- └── test-results
- ├── <test-suite-1>
- | ├── <test-case-1>
- | │ ├── <result-1>.txt
- | │ ├── [<result-2>.txt]
- | │ ├── [...]
- | │ └── [other-data-files]
- | ├── <test-case-2>
- | │ ├── <result-1>.txt
- | │ ├── [<result-2>.txt]
- | │ ├── [...]
- | │ └── [other-data-files]
- | └── [...]
- ├── <test-suite-2>
- | └── [...]
- └── [...]
-
-The name of the top-level directory is configurable. This document uses
-'test-results' in its examples.
-
-Each test case directory contains a set of result files, and optionally
-contains data files containing information collected during the test. Result
-files are named according to one of the following templates:
-
- * pass.txt
- * fail-xxxx.txt
-
-Where "xxxx" is a numeric index automatically generated by testutil. If a test
-passes, its results directory is populated with a single 'pass' file and no
-'fail' files. If a test fails, its results directory is populated with one or
-more 'fail' files and no 'pass' files. A result file (pass or fail) optionally
-contains a text string.
-
-In addition, a results directory can contains data files containing information
-collected during the test. For example, a test case may record timing
-information or statistics. Test case code specifies the name and contents of a
-data file when it writes one. Data files can be written during a test case
-regardless of the test outcome. There are no restrictions on the size or
-contents of data files, but their filenames should be distinct from the test
-result naming scheme described above. There is no limit to the number of data
-files that a particular test case can write.
-
-Returning to the earlier arithmetic test suite example, suppose the test suite
-completed with the following results:
-
- * test_addition: 1 assertion success, 0 assertion failures
- * test_times_0: 1 assertion success, 2 assertion failures
-
-Such a test run would produce the following directory tree:
-
- /
- └── test-results
- └── test_suite_arithmetic
- ├── test_addition
- │ └── pass.txt
- └── test_times_0
- ├── fail-0000.txt
- └── fail-0001.txt
-
-Each 'fail' file would contain a string describing the failure.
-
-
-*** TESTUTIL API
-
-struct tu_config {
- /** If nonzero, test results are printed to stdout. */
- int tc_print_results;
-
- /**
- * Name of the base results directory (e.g., "test-results"). If null,
- * results are not written to disk.
- */
- const char *tc_results_path;
-
- /**
- * Array of flash areas where an ffs file system should be located. Unused
- * if run in a simulated environment. This array must be terminated with a
- * zero-length area.
- */
- const struct ffs_area_desc *tc_area_descs;
-};
-extern struct tu_config tu_config;
-
-Description:
- The global tu_config struct contains all the testutil package's settings.
- The struct must be populated before tu_init() is called.
-
--
-
-int tu_init(void)
-
-Description:
- Initializes the test framework according to the contents of the tu_config
- struct. If run in an embedded environment and the
- tu_config.tc_results_path and tu_config.tc_area_descs fields are non-null,
- this function ensures an ffs file system is present within the specified
- flash areas. If testutil is using an ffs file system, and no valid ffs
- file system is detected in the specified region of flash, the region is
- formatted with a new file system. This function must be called before any
- tests are run.
-
- If, immediately prior to a call to tu_init(), the UUT was restarted via a
- call to tu_restart(), this function skips all the test cases that have
- already been executed. See tu_restart() for details.
-
- Returns 0 on success; nonzero on failure.
-
--
-
-TEST_ASSERT(expression)
-TEST_ASSERT(expression, fail_msg, ...)
-
-Description:
- Asserts that the specified condition is true. If the expression is true,
- nothing gets reported. The expression argument is mandatory; the rest are
- optional. The fail_msg argument is a printf format string which specifies
- how the remaining arguments are parsed.
-
- If the expression is false, testutil reports the following message:
-
- |<file>:<line-number>| failed assertion: <expression>
- <fail_msg>
-
- If no fail_msg is specified, only the first line gets reported.
-
- The test case proceeds as normal after this macro is invoked.
-
-Example:
- TEST_ASSERT(num_blocks == 1024,
- "expected: 1024 blocks; got: %d", num_blocks);
-
- On failure, the above assertion would result in a report like the
- following:
-
- |ffs_test.c:426| failed assertion: num_blocks == 1024
- expected: 1024 blocks; got 12
-
--
-
-TEST_ASSERT_FATAL(expression)
-TEST_ASSERT_FATAL(expression, fail_msg, ...)
-
-Description:
- These are identical to their TEST_ASSERT counterparts, except that a
- failure causes the current test case to be aborted.
-
--
-
-TEST_PASS(msg, ...)
-
-Description:
- Reports a success result for the current test. This function is not
- normally needed, as all successful tests automatically write an empty pass
- result at completion. This function is only needed when the success result
- report should contain text. The msg argument is a printf format string
- which specifies how the remaining arguments are parsed. The result file
- produced by this function contains the following text:
-
- |<file>:<line-number>| manual pass
- <msg>
-
- After this function is called, the remainder of the test case is not
- executed. If the current test has already failed when this macro is
- invoked, the macro has no effect.
-
--
-
-testutil_write_data(const char *filename, const uint8_t *data, size_t data_len)
-
-Description:
- Writes a data file to the current test results directory. The file's
- contents are fully specified by the data and data_len arguments. If a file
- with the specified name already exists, it is overwritten. After this
- function is called, the test case proceeds as normal.
-
- Data does not get written to stdout; it only gets written to disk. This
- function has no effect if testutil is configured to not write results to
- disk.
-
--
-
-TEST_CASE(test_case_name) { /* test case code */ }
-
-Description:
- Defines a test case function with the following type:
-
- int test_case_name(void)
-
- The return value is 0 if the test case passed; nonzero if it failed.
- Generally, the return code is not used.
-
-
--
-
-TEST_SUITE(test_suite_name) { /* test suite code */ }
-
-Description:
- Defines a test suite function with the following type:
-
- int test_suite_name(void)
-
- The return value is 0 if the test suite passed; nonzero if it failed.
- Generally, the return code is not used.
-
--
-
-void tu_restart(void)
-
-Description:
- This function is used when a system reset is necessary to proceed with
- testing. For example, the OS is designed to run forever once started, so a
- test which creates several OS tasks and then starts the OS has no means of
- completing. This function, when called from such a test, gracefully ends
- the current test case and proceeds to the next test case.
-
- The particulars of this function depend on whether it is called from a
- simulated environment. In a simulated environment, this function uses a
- longjmp() call to break out of the current test case.
-
- In a non-simulated environment, this function performs the following
- procedure:
-
- 1. Record the current test status to the file system.
- 2. Perform a software reset of the UUT.
- 3. Read test status and delete it from the file system.
- 4. Skip all previously completed test cases.
-
- If this function is called before any results have been reported for the
- current test case, a "pass" result gets reported.
-
- Note: after this function performs a software reset, the UUT may not be
- fully initialized, depending on the test environment. For example, if the
- UUT has been set up to run the test image from RAM via JTAG, variables in
- the .data section will not get properly initialized by the software reset.
- Proper initialization in this case would require that data be re-read from
- the image file via an additional run of the JTAG script.
-
--
-
-ASSERT_IF_TEST(cond)
-
-Description:
- The effect of this macro depends on whether the TEST macro is defined:
-
- If defined: expands to assert().
- If not defined: expands to nothing.
-
- This macro is not intended for use within test cases. Instead, it should
- be used in normal non-test code to perform computationally-expensive
- checks. In non-test builds, the checks do not get performed.
-
-
-***** INDIVIDUAL PACKAGE TESTING
-
-Testing individual packages is performed via the "target test" stack tool
-command. When testing is done in this manner, the stack tool automatically
-runs the test code on the host machine. There is no need for an extra stack
-project for producing a test image.
-
-Testing a package in this manner requires a special target that is specific to
-the package. The target specifies the package to test via the "pkg"
-configuration variable. The target must not specify a project, or the test
-command will fail.
-
-Below is an example target called testffs that tests the ffs package:
-
- testffs
- compiler: sim
- compiler_def: debug
- pkg: libs/ffs
- bsp: hw/bsp/native
- arch: sim
- name: testffs
-
-The target specifies the "native" bsp. This is necessary so that the ffs test
-code can link with the appropriate implementations of the hal functions that it
-depends on.
-
-The test is run by specifying the following stack arguments:
-
- target test testffs
-
-When the "target test" command is used, the PKG_TEST macro is defined during
-compilation of the package under test. This is in addition to the TEST macro,
-which is defined during compilation of all packages.
-
-
-***** ISSUES / QUESTIONS
-
-* For individual package tests, the requirement for a separate target for each
- package may become unwieldy. Perhaps the stack tool should be modified to
- allow arbitrary key-value pairs to be specified on the command line. That
- way, the target's "pkg" variable could be unset, and the user would specify
- the package to test when he executes the test command. This would allow the
- same target to be used for all packages, e.g.,
-
- target test testtarget pkg=libs/ffs
- target test testtarget pkg=libs/os
-
-* Most test frameworks define a lot of extra assertions (e.g., assert_equal(),
- assert_not_null(), assert_false(), etc). These don't seem particularly
- useful to me, so I did not add them. Typing TEST_ASSERT(x == 5) is no more
- difficult than TEST_ASSERT_EQUAL(x, 5). The benefit of the more specific
- assertions is that they can automatically produce more helpful failure
- messages. For example, if TEST_ASSERT_EQUAL(x, 5) fails, the failure message
- can contain the actual value of x in most cases, whereas a plain
- TEST_ASSERT() won't automatically log that information. This didn't seem
- useful enough to me to justify growing the interface, but I am interested in
- hearing what others think.
-
-* During testing on embedded devices, the PC software will need some
- notification when testing is complete, so that it knows when to retrieve the
- test results. The testutil package should expose some state that the PC
- software can poll for this purpose.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/include/testutil/testutil.h
----------------------------------------------------------------------
diff --git a/libs/testutil/include/testutil/testutil.h b/libs/testutil/include/testutil/testutil.h
deleted file mode 100644
index f3243f4..0000000
--- a/libs/testutil/include/testutil/testutil.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * 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.
- */
-
-#ifndef H_TESTUTIL_
-#define H_TESTUTIL_
-
-#include <inttypes.h>
-#include <setjmp.h>
-
-/*****************************************************************************
- * Public declarations *
- *****************************************************************************/
-
-typedef void tu_case_init_fn_t(void *arg);
-typedef void tu_case_report_fn_t(char *msg, int msg_len, void *arg);
-typedef void tu_suite_init_fn_t(void *arg);
-typedef void tu_restart_fn_t(void *arg);
-
-struct tu_config {
- int tc_print_results;
- int tc_system_assert;
-
- tu_case_init_fn_t *tc_case_init_cb;
- void *tc_case_init_arg;
-
- tu_case_report_fn_t *tc_case_fail_cb;
- void *tc_case_fail_arg;
-
- tu_case_report_fn_t *tc_case_pass_cb;
- void *tc_case_pass_arg;
-
- tu_suite_init_fn_t *tc_suite_init_cb;
- void *tc_suite_init_arg;
-
- tu_restart_fn_t *tc_restart_cb;
- void *tc_restart_arg;
-};
-
-extern struct tu_config tu_config;
-extern const char *tu_suite_name;
-extern const char *tu_case_name;
-extern int tu_first_idx;
-
-int tu_init(void);
-void tu_restart(void);
-
-
-/*****************************************************************************
- * Private declarations *
- *****************************************************************************/
-
-void tu_suite_init(const char *name);
-
-void tu_case_init(const char *name);
-void tu_case_complete(void);
-void tu_case_fail_assert(int fatal, const char *file, int line,
- const char *expr, const char *format, ...);
-void tu_case_write_pass_auto(void);
-void tu_case_pass_manual(const char *file, int line,
- const char *format, ...);
-
-
-extern int tu_any_failed;
-extern int tu_suite_failed;
-extern int tu_case_reported;
-extern int tu_case_failed;
-extern int tu_case_idx;
-extern jmp_buf tu_case_jb;
-
-#define TEST_SUITE(suite_name) \
- static void TEST_SUITE_##suite_name(void); \
- \
- int \
- suite_name(void) \
- { \
- tu_suite_init(#suite_name); \
- TEST_SUITE_##suite_name(); \
- \
- return tu_suite_failed; \
- } \
- \
- static void \
- TEST_SUITE_##suite_name(void)
-
-#define TEST_CASE(case_name) \
- static void TEST_CASE_##case_name(void); \
- \
- int \
- case_name(void) \
- { \
- if (tu_case_idx >= tu_first_idx) { \
- tu_case_init(#case_name); \
- \
- if (setjmp(tu_case_jb) == 0) { \
- TEST_CASE_##case_name(); \
- tu_case_write_pass_auto(); \
- } \
- } \
- \
- tu_case_complete(); \
- \
- return tu_case_failed; \
- } \
- \
- static void \
- TEST_CASE_##case_name(void)
-
-#define FIRST_AUX(first, ...) first
-#define FIRST(...) FIRST_AUX(__VA_ARGS__, _)
-
-#define NUM(...) ARG10(__VA_ARGS__, N, N, N, N, N, N, N, N, 1, _)
-#define ARG10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10
-
-#define REST_OR_0(...) REST_OR_0_AUX(NUM(__VA_ARGS__), __VA_ARGS__)
-#define REST_OR_0_AUX(qty, ...) REST_OR_0_AUX_INNER(qty, __VA_ARGS__)
-#define REST_OR_0_AUX_INNER(qty, ...) REST_OR_0_AUX_##qty(__VA_ARGS__)
-#define REST_OR_0_AUX_1(first) 0
-#define REST_OR_0_AUX_N(first, ...) __VA_ARGS__
-
-#define XSTR(s) STR(s)
-#define STR(s) #s
-
-#define TEST_ASSERT_FULL(fatal, expr, ...) do \
-{ \
- if (!(expr)) { \
- tu_case_fail_assert((fatal), __FILE__, __LINE__, XSTR(expr), \
- __VA_ARGS__); \
- } \
-} while (0)
-
-#define TEST_ASSERT(...) \
- TEST_ASSERT_FULL(0, FIRST(__VA_ARGS__), REST_OR_0(__VA_ARGS__))
-
-#define TEST_ASSERT_FATAL(...) \
- TEST_ASSERT_FULL(1, FIRST(__VA_ARGS__), REST_OR_0(__VA_ARGS__))
-
-#define TEST_PASS(...) \
- tu_case_pass_manual(__FILE__, __LINE__, __VA_ARGS__);
-
-#ifdef TEST
-#define ASSERT_IF_TEST(expr) assert(expr)
-#else
-#define ASSERT_IF_TEST(expr)
-#endif
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/testutil/pkg.yml b/libs/testutil/pkg.yml
deleted file mode 100644
index f64e6c9..0000000
--- a/libs/testutil/pkg.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# 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.
-#
-
-pkg.name: libs/testutil
-pkg.vers: 0.8.0
-pkg.deps:
- - hw/hal
- - libs/os
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/src/arch/cortex_m4/testutil_arch_arm.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/arch/cortex_m4/testutil_arch_arm.c b/libs/testutil/src/arch/cortex_m4/testutil_arch_arm.c
deleted file mode 100644
index 52ace63..0000000
--- a/libs/testutil/src/arch/cortex_m4/testutil_arch_arm.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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 "hal/hal_system.h"
-#include "testutil_priv.h"
-
-void
-tu_arch_restart(void)
-{
- system_reset();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/src/arch/sim/testutil_arch_sim.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/arch/sim/testutil_arch_sim.c b/libs/testutil/src/arch/sim/testutil_arch_sim.c
deleted file mode 100644
index 2d90501..0000000
--- a/libs/testutil/src/arch/sim/testutil_arch_sim.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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 "os/os.h"
-#include "os/os_arch.h"
-#include "os/os_test.h"
-#include "testutil_priv.h"
-
-void
-tu_arch_restart(void)
-{
- os_arch_os_stop();
- tu_case_abort();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/src/case.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/case.c b/libs/testutil/src/case.c
deleted file mode 100644
index a2d78ef..0000000
--- a/libs/testutil/src/case.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/**
- * 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 <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include "testutil/testutil.h"
-#include "testutil_priv.h"
-
-jmp_buf tu_case_jb;
-int tu_case_reported;
-int tu_case_failed;
-int tu_case_idx;
-
-const char *tu_case_name;
-
-#define TU_CASE_BUF_SZ 1024
-
-static char tu_case_buf[TU_CASE_BUF_SZ];
-static int tu_case_buf_len;
-
-void
-tu_case_abort(void)
-{
- tu_case_write_pass_auto();
- longjmp(tu_case_jb, 1);
-}
-
-static int
-tu_case_vappend_buf(const char *format, va_list ap)
-{
- char *dst;
- int maxlen;
- int rc;
-
- dst = tu_case_buf + tu_case_buf_len;
- maxlen = TU_CASE_BUF_SZ - tu_case_buf_len;
-
- rc = vsnprintf(dst, maxlen, format, ap);
- tu_case_buf_len += rc;
- if (tu_case_buf_len >= TU_CASE_BUF_SZ) {
- tu_case_buf_len = TU_CASE_BUF_SZ - 1;
- return -1;
- }
-
- return 0;
-}
-
-static int
-tu_case_append_buf(const char *format, ...)
-{
- va_list ap;
- int rc;
-
- va_start(ap, format);
- rc = tu_case_vappend_buf(format, ap);
- va_end(ap);
-
- return rc;
-}
-
-static void
-tu_case_set_name(const char *name)
-{
- tu_case_name = name;
-}
-
-void
-tu_case_init(const char *name)
-{
- tu_case_reported = 0;
- tu_case_failed = 0;
-
- tu_case_set_name(name);
-
- if (tu_config.tc_case_init_cb != NULL) {
- tu_config.tc_case_init_cb(tu_config.tc_case_init_arg);
- }
-}
-
-void
-tu_case_complete(void)
-{
- tu_case_idx++;
-}
-
-static void
-tu_case_write_fail_buf(void)
-{
- tu_case_reported = 1;
- tu_case_failed = 1;
- tu_suite_failed = 1;
- tu_any_failed = 1;
-
- if (tu_config.tc_print_results) {
- printf("[FAIL] %s/%s %s", tu_suite_name, tu_case_name, tu_case_buf);
- }
-
- if (tu_config.tc_case_fail_cb != NULL) {
- tu_config.tc_case_fail_cb(tu_case_buf, tu_case_buf_len,
- tu_config.tc_case_fail_arg);
- }
-}
-
-static void
-tu_case_append_file_info(const char *file, int line)
-{
- int rc;
-
- rc = tu_case_append_buf("|%s:%d| ", file, line);
- assert(rc == 0);
-}
-
-static void
-tu_case_append_assert_msg(const char *expr)
-{
- int rc;
-
- rc = tu_case_append_buf("failed assertion: %s", expr);
- assert(rc == 0);
-}
-
-static void
-tu_case_write_pass_buf(void)
-{
- if (tu_config.tc_print_results) {
- printf("[pass] %s/%s\n", tu_suite_name, tu_case_name);
- if (tu_case_buf_len > 0) {
- printf("%s", tu_case_buf);
- }
- }
-
- tu_case_reported = 1;
-
- if (tu_config.tc_case_pass_cb != NULL) {
- tu_config.tc_case_pass_cb(tu_case_buf, tu_case_buf_len,
- tu_config.tc_case_pass_arg);
- }
-}
-
-static void
-tu_case_append_manual_pass_msg(void)
-{
- int rc;
-
- rc = tu_case_append_buf("manual pass");
- assert(rc == 0);
-}
-
-void
-tu_case_write_pass_auto(void)
-{
- if (!tu_case_reported) {
- tu_case_buf_len = 0;
- tu_case_write_pass_buf();
- }
-}
-
-void
-tu_case_fail_assert(int fatal, const char *file, int line,
- const char *expr, const char *format, ...)
-{
- va_list ap;
- int rc;
-
- if (tu_config.tc_system_assert) {
- assert(0);
- }
-
- tu_case_buf_len = 0;
-
- tu_case_append_file_info(file, line);
- tu_case_append_assert_msg(expr);
-
- if (format != NULL) {
- rc = tu_case_append_buf("\n");
- assert(rc == 0);
-
- va_start(ap, format);
- rc = tu_case_vappend_buf(format, ap);
- assert(rc == 0);
- va_end(ap);
- }
-
- rc = tu_case_append_buf("\n");
- assert(rc == 0);
-
- tu_case_write_fail_buf();
-
- if (fatal) {
- tu_case_abort();
- }
-}
-
-void
-tu_case_pass_manual(const char *file, int line, const char *format, ...)
-{
- va_list ap;
- int rc;
-
- if (tu_case_reported) {
- return;
- }
-
- tu_case_buf_len = 0;
-
- tu_case_append_file_info(file, line);
- tu_case_append_manual_pass_msg();
-
- if (format != NULL) {
- rc = tu_case_append_buf("\n");
- assert(rc == 0);
-
- va_start(ap, format);
- rc = tu_case_vappend_buf(format, ap);
- assert(rc == 0);
- va_end(ap);
- }
-
- rc = tu_case_append_buf("\n");
- assert(rc == 0);
-
- tu_case_write_pass_buf();
-
- tu_case_abort();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/src/suite.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/suite.c b/libs/testutil/src/suite.c
deleted file mode 100644
index 5c2e5cb..0000000
--- a/libs/testutil/src/suite.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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 <assert.h>
-#include "testutil/testutil.h"
-#include "testutil_priv.h"
-
-const char *tu_suite_name = 0;
-int tu_suite_failed = 0;
-
-static void
-tu_suite_set_name(const char *name)
-{
- tu_suite_name = name;
-}
-
-void
-tu_suite_init(const char *name)
-{
- tu_suite_failed = 0;
-
- tu_suite_set_name(name);
-
- if (tu_config.tc_suite_init_cb != NULL) {
- tu_config.tc_suite_init_cb(tu_config.tc_suite_init_arg);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/src/testutil.c
----------------------------------------------------------------------
diff --git a/libs/testutil/src/testutil.c b/libs/testutil/src/testutil.c
deleted file mode 100644
index 09842c5..0000000
--- a/libs/testutil/src/testutil.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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 <assert.h>
-#include "hal/hal_flash.h"
-#include "testutil/testutil.h"
-#include "testutil_priv.h"
-
-struct tu_config tu_config;
-int tu_any_failed;
-int tu_first_idx;
-
-int
-tu_init(void)
-{
- tu_any_failed = 0;
-
- return 0;
-}
-
-void
-tu_restart(void)
-{
- tu_case_write_pass_auto();
-
- tu_first_idx = tu_case_idx + 1;
-
- if (tu_config.tc_restart_cb != NULL) {
- tu_config.tc_restart_cb(tu_config.tc_restart_arg);
- }
-
- tu_arch_restart();
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/testutil/src/testutil_priv.h
----------------------------------------------------------------------
diff --git a/libs/testutil/src/testutil_priv.h b/libs/testutil/src/testutil_priv.h
deleted file mode 100644
index 0047874..0000000
--- a/libs/testutil/src/testutil_priv.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.
- */
-
-#ifndef H_TESTUTIL_PRIV_
-#define H_TESTUTIL_PRIV_
-
-#include <stddef.h>
-#include <inttypes.h>
-
-void tu_arch_restart(void);
-void tu_case_abort(void);
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/util/include/util/base64.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/base64.h b/libs/util/include/util/base64.h
deleted file mode 100644
index 4428fa9..0000000
--- a/libs/util/include/util/base64.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.
- */
-#ifndef __UTIL_BASE64_H
-#define __UTIL_BASE64_H
-
-#include <stdint.h>
-
-int base64_encode(const void *, int, char *, uint8_t);
-int base64_decode(const char *, void *buf);
-int base64_pad(char *, int);
-
-#define BASE64_ENCODE_SIZE(__size) (((__size) * (4 / 3)) + 4)
-
-#endif /* __UTIL_BASE64_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/util/include/util/cbmem.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/cbmem.h b/libs/util/include/util/cbmem.h
deleted file mode 100644
index 6948fb4..0000000
--- a/libs/util/include/util/cbmem.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.
- */
-#ifndef __UTIL_CBMEM_H__
-#define __UTIL_CBMEM_H__
-
-#include <os/os.h>
-
-struct cbmem_entry_hdr {
- uint16_t ceh_len;
- uint16_t ceh_flags;
-};
-
-struct cbmem {
- struct os_mutex c_lock;
-
- struct cbmem_entry_hdr *c_entry_start;
- struct cbmem_entry_hdr *c_entry_end;
- uint8_t *c_buf;
- uint8_t *c_buf_end;
- uint8_t *c_buf_cur_end;
-};
-
-struct cbmem_iter {
- struct cbmem_entry_hdr *ci_start;
- struct cbmem_entry_hdr *ci_cur;
- struct cbmem_entry_hdr *ci_end;
-};
-
-#define CBMEM_ENTRY_SIZE(__p) (sizeof(struct cbmem_entry_hdr) \
- + ((struct cbmem_entry_hdr *) (__p))->ceh_len)
-#define CBMEM_ENTRY_NEXT(__p) ((struct cbmem_entry_hdr *) \
- ((uint8_t *) (__p) + CBMEM_ENTRY_SIZE(__p)))
-
-typedef int (*cbmem_walk_func_t)(struct cbmem *, struct cbmem_entry_hdr *,
- void *arg);
-
-int cbmem_lock_acquire(struct cbmem *cbmem);
-int cbmem_lock_release(struct cbmem *cbmem);
-int cbmem_init(struct cbmem *cbmem, void *buf, uint32_t buf_len);
-int cbmem_append(struct cbmem *cbmem, void *data, uint16_t len);
-void cbmem_iter_start(struct cbmem *cbmem, struct cbmem_iter *iter);
-struct cbmem_entry_hdr *cbmem_iter_next(struct cbmem *cbmem,
- struct cbmem_iter *iter);
-int cbmem_read(struct cbmem *cbmem, struct cbmem_entry_hdr *hdr, void *buf,
- uint16_t off, uint16_t len);
-int cbmem_walk(struct cbmem *cbmem, cbmem_walk_func_t walk_func, void *arg);
-
-int cbmem_flush(struct cbmem *);
-
-#endif /* __UTIL_CBMEM_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/util/include/util/tpq.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/tpq.h b/libs/util/include/util/tpq.h
deleted file mode 100644
index 9e2b8a5..0000000
--- a/libs/util/include/util/tpq.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.
- */
-#ifndef __UTIL_TPQ_H__
-#define __UTIL_TPQ_H__
-
-#include <os/queue.h>
-#include <os/os_eventq.h>
-
-/* A task packet queue element */
-struct tpq_elem {
- STAILQ_ENTRY(tpq_elem) tpq_next;
-};
-
-/* The task packet queue object */
-struct tpq
-{
- STAILQ_HEAD(, tpq_elem) tpq_head;
- struct os_event tpq_ev;
-};
-
-/**
- * Put an element on a task packet queue and post an event to an event queue.
- *
- * @param evq Pointer to event queue
- * @param tpq Pointer to task packet queue
- * @param elem Pointer to element to enqueue
- */
-void tpq_put(struct os_eventq *evq, struct tpq *tpq, struct tpq_elem *elem);
-
-/**
- * Retrieve an element from a task packet queue. This removes the element at
- * the head of the queue.
- *
- * @param head
- *
- * @return struct tpq_elem*
- */
-struct tpq_elem *tpq_get(struct tpq *tpq);
-
-/**
- * Initialize a task packet queue
- *
- * @param tpq Pointer to task packet queue
- * @param ev_type Type of event.
- * @param ev_arg Argument of event
- *
- * @return int
- */
-void tpq_init(struct tpq *tpq, uint8_t ev_type, void *ev_arg);
-
-#endif /* __UTIL_TPQ_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/util/include/util/util.h
----------------------------------------------------------------------
diff --git a/libs/util/include/util/util.h b/libs/util/include/util/util.h
deleted file mode 100644
index 6b3dd8b..0000000
--- a/libs/util/include/util/util.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * 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.
- */
-#ifndef __UTIL_H__
-#define __UTIL_H__
-
-#endif /* __UTIL_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/util/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/util/pkg.yml b/libs/util/pkg.yml
deleted file mode 100644
index cdd7f4b..0000000
--- a/libs/util/pkg.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# 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.
-#
-
-pkg.name: libs/util
-pkg.vers: 0.8.0
-pkg.deps:
- - hw/hal
- - libs/os
- - libs/testutil
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-blinky/blob/8878610e/libs/util/src/base64.c
----------------------------------------------------------------------
diff --git a/libs/util/src/base64.c b/libs/util/src/base64.c
deleted file mode 100644
index d7a79c0..0000000
--- a/libs/util/src/base64.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * This file is based on roken from the FreeBSD source. It has been modified
- * to not use malloc() and instead expect static buffers, and tabs have been
- * replaced with spaces. Also, instead of strlen() on the resulting string,
- * pointer arithmitic is done, as p represents the end of the buffer.
- */
-
-/*
- * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <stdio.h>
-
-#include <util/base64.h>
-
-static const char base64_chars[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-static int
-pos(char c)
-{
- const char *p;
- for (p = base64_chars; *p; p++)
- if (*p == c)
- return p - base64_chars;
- return -1;
-}
-
-int
-base64_encode(const void *data, int size, char *s, uint8_t should_pad)
-{
- char *p;
- int i;
- int c;
- const unsigned char *q;
- char *last;
- int diff;
-
- p = s;
-
- q = (const unsigned char *) data;
- last = NULL;
- i = 0;
- while (i < size) {
- c = q[i++];
- c *= 256;
- if (i < size)
- c += q[i];
- i++;
- c *= 256;
- if (i < size)
- c += q[i];
- i++;
- p[0] = base64_chars[(c & 0x00fc0000) >> 18];
- p[1] = base64_chars[(c & 0x0003f000) >> 12];
- p[2] = base64_chars[(c & 0x00000fc0) >> 6];
- p[3] = base64_chars[(c & 0x0000003f) >> 0];
- last = p;
- p += 4;
- }
-
- if (last) {
- diff = i - size;
- if (diff > 0) {
- if (should_pad) {
- memset(last + (4 - diff), '=', diff);
- } else {
- p = last + (4 - diff);
- }
- }
- }
-
- *p = 0;
-
- return (p - s);
-}
-
-int
-base64_pad(char *buf, int len)
-{
- int remainder;
-
- remainder = len % 4;
- if (remainder == 0) {
- return (0);
- }
-
- memset(buf, '=', 4 - remainder);
-
- return (4 - remainder);
-}
-
-#define DECODE_ERROR -1
-
-static unsigned int
-token_decode(const char *token)
-{
- int i;
- unsigned int val = 0;
- int marker = 0;
- if (strlen(token) < 4)
- return DECODE_ERROR;
- for (i = 0; i < 4; i++) {
- val *= 64;
- if (token[i] == '=')
- marker++;
- else if (marker > 0)
- return DECODE_ERROR;
- else
- val += pos(token[i]);
- }
- if (marker > 2)
- return DECODE_ERROR;
- return (marker << 24) | val;
-}
-
-int
-base64_decode(const char *str, void *data)
-{
- const char *p;
- unsigned char *q;
-
- q = data;
- for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) {
- unsigned int val = token_decode(p);
- unsigned int marker = (val >> 24) & 0xff;
- if (val == DECODE_ERROR)
- return -1;
- *q++ = (val >> 16) & 0xff;
- if (marker < 2)
- *q++ = (val >> 8) & 0xff;
- if (marker < 1)
- *q++ = val & 0xff;
- }
- return q - (unsigned char *) data;
-}