diff --git a/tests/bench_sizeof_coretypes/Makefile b/tests/bench_sizeof_coretypes/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..c3cb1b3e017b8c0f5c71f05aef1075789001bd72 --- /dev/null +++ b/tests/bench_sizeof_coretypes/Makefile @@ -0,0 +1,17 @@ +include ../Makefile.tests_common + +# Modules that will have an impact on the size of the TCB (thread_t): +# +# disabled by default, enable on demand: +ifneq (,$(USE_FLAGS)) + USEMODULE += core_thread_flags +endif +# +# enabled by default, disable on demand: +ifneq (,$(NO_MSG)) + DISABLE_MODULE += core_msg +endif + +TEST_ON_CI_WHITELIST += all + +include $(RIOTBASE)/Makefile.include diff --git a/tests/bench_sizeof_coretypes/README.md b/tests/bench_sizeof_coretypes/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6e921bb70f208e425f4388a65d3b476c5a5326e8 --- /dev/null +++ b/tests/bench_sizeof_coretypes/README.md @@ -0,0 +1,6 @@ +# Measure Size of Core Types + +This application simply list the size of all significant types defined by the +RIOT core. Its purpose is to provide a base for tracking the memory requirements +of those types over time and to provide a simple way to judge the impacts of +future core changes on memory usage. diff --git a/tests/bench_sizeof_coretypes/main.c b/tests/bench_sizeof_coretypes/main.c new file mode 100644 index 0000000000000000000000000000000000000000..eaf5f07b0d4d8a7b0c311db85dde576d4af08f1a --- /dev/null +++ b/tests/bench_sizeof_coretypes/main.c @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de> + * 2018 Freie Universität Berlin + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief Print size of core types + * + * @author René Kijewski <rene.kijewski@fu-berlin.de> + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * + * @} + */ + +#include <stdio.h> + +#include "cib.h" +#include "clist.h" +#include "panic.h" +#include "kernel_types.h" +#include "list.h" +#include "mbox.h" +#include "msg.h" +#include "mutex.h" +#include "priority_queue.h" +#include "ringbuffer.h" +#include "rmutex.h" +#ifdef MODULE_CORE_THREAD_FLAGS +#include "thread_flags.h" +#endif +#include "thread.h" + + +#define P(NAME) printf(" tcb->%-11s %3u %3u\n", #NAME, \ + (unsigned)sizeof(((thread_t *) 0)->NAME), \ + (unsigned)offsetof(thread_t, NAME)) + +int main(void) +{ + puts("Sizeof RIOT core types\n"); + + puts(" size"); + + printf("sizeof(cib_t): %3u\n", + (unsigned)sizeof(cib_t)); + printf("sizeof(clist_node_t): %3u\n", + (unsigned)sizeof(clist_node_t)); + printf("sizeof(core_panic_t): %3u\n", + (unsigned)sizeof(core_panic_t)); + printf("sizeof(kernel_pid_t): %3u\n", + (unsigned)sizeof(kernel_pid_t)); + printf("sizeof(list_node_t): %3u\n", + (unsigned)sizeof(list_node_t)); + printf("sizeof(mbox_t): %3u\n", + (unsigned)sizeof(mbox_t)); +#ifdef MODULE_CORE_MSG + printf("sizeof(msg_t): %3u\n", + (unsigned)sizeof(msg_t)); +#else + puts("sizeof(msg_t): 0 (not enabled)"); +#endif + printf("sizeof(mutex_t): %3u\n", + (unsigned)sizeof(mutex_t)); + printf("sizeof(priority_queue_node_t): %3u\n", + (unsigned)sizeof(priority_queue_node_t)); + printf("sizeof(priority_queue_t): %3u\n", + (unsigned)sizeof(priority_queue_t)); + printf("sizeof(ringbuffer_t): %3u\n", + (unsigned)sizeof(ringbuffer_t)); + printf("sizeof(rmutex_t): %3u\n", + (unsigned)sizeof(rmutex_t)); +#ifdef MODULE_CORE_THREAD_FLAGS + printf("sizeof(thread_flags_t): %3u\n", + (unsigned)sizeof(thread_flags_t)); +#else + puts("sizeof(thread_flags_t): 0 (not enabled)"); +#endif + printf("\nTCB (thread_t) details: size offset\n"); + printf("sizeof(thread_t): %3u -\n", + (unsigned)sizeof(thread_t)); + P(sp); + P(status); + P(priority); + P(pid); +#ifdef MODULE_CORE_THREAD_FLAGS + P(flags); +#endif + P(rq_entry); +#ifdef MODULE_CORE_MSG + P(wait_data); + P(msg_waiters); + P(msg_queue); + P(msg_array); +#endif +#ifdef DEVELHELP + P(name); +#endif +#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD) + P(stack_start); +#endif + + puts("\n[SUCCESS]"); + return 0; +} diff --git a/tests/bench_sizeof_coretypes/tests/01-run.py b/tests/bench_sizeof_coretypes/tests/01-run.py new file mode 100755 index 0000000000000000000000000000000000000000..b6b4d4d3672940d0ebd6cea386a779a2f167654a --- /dev/null +++ b/tests/bench_sizeof_coretypes/tests/01-run.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2018 Freie Universität Berlin +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import os +import sys + + +def testfunc(child): + child.expect_exact('[SUCCESS]') + + +if __name__ == "__main__": + sys.path.append(os.path.join(os.environ['RIOTTOOLS'], 'testrunner')) + from testrunner import run + sys.exit(run(testfunc)) diff --git a/tests/sizeof_tcb/Makefile b/tests/sizeof_tcb/Makefile deleted file mode 100644 index 032fb617dd80cf1ca487c11a2fc2276afbf82fb5..0000000000000000000000000000000000000000 --- a/tests/sizeof_tcb/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -include ../Makefile.tests_common - -# othread_t modifying modules: -# -# disabled by default: -# USEMODULE += core_thread_flags -# -# enabled by default: -# DISABLE_MODULE += core_msg - -TEST_ON_CI_WHITELIST += all - -include $(RIOTBASE)/Makefile.include diff --git a/tests/sizeof_tcb/main.c b/tests/sizeof_tcb/main.c deleted file mode 100644 index 3ea2f4ea866feb928698c6cad119d424ea505b38..0000000000000000000000000000000000000000 --- a/tests/sizeof_tcb/main.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de> - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup tests - * @{ - * - * @file - * @brief Print the size of thread_t. - * - * @author René Kijewski <rene.kijewski@fu-berlin.de> - * - * @} - */ - -#include <stdio.h> -#include <stddef.h> - -#include "thread.h" - -#define P(NAME) printf("\t%-11s%4u%4u\n", #NAME, \ - (unsigned)sizeof(((thread_t *) 0)->NAME), \ - (unsigned)offsetof(thread_t, NAME)); - -int main(void) -{ - puts("\tmember, sizeof, offsetof"); - - printf("sizeof(thread_t): %u\n", (unsigned)sizeof(thread_t)); - - P(sp); - P(status); - P(priority); - P(pid); -#ifdef MODULE_CORE_THREAD_FLAGS - P(flags); -#endif - P(rq_entry); -#ifdef MODULE_CORE_MSG - P(wait_data); - P(msg_waiters); - P(msg_queue); - P(msg_array); -#endif -#ifdef DEVELHELP - P(name); -#endif -#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD) - P(stack_start); -#endif - -#ifdef DEVELHELP - P(stack_size); -#endif - - puts("SUCCESS"); - return 0; -} diff --git a/tests/sizeof_tcb/tests/01-run.py b/tests/sizeof_tcb/tests/01-run.py deleted file mode 100755 index d36f4af0d4f1d31cc4f87032cd8b09a790bd88c3..0000000000000000000000000000000000000000 --- a/tests/sizeof_tcb/tests/01-run.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (C) 2017 Inria -# -# This file is subject to the terms and conditions of the GNU Lesser -# General Public License v2.1. See the file LICENSE in the top level -# directory for more details. - -import sys -from testrunner import run - - -def testfunc(child): - child.expect_exact('\tmember, sizeof, offsetof') - ret = child.expect([r'sizeof\(thread_t\): [36, 48]', - r'sizeof\(thread_t\): [20, 26]']) - if ret == 0: - child.expect_exact('\tsp 4 0') - child.expect_exact('\tstatus 1 4') - child.expect_exact('\tpriority 1 5') - child.expect_exact('\tpid 2 6') - child.expect_exact('\trq_entry 4 8') - child.expect_exact('\twait_data 4 12') - child.expect_exact('\tmsg_waiters 4 16') - child.expect_exact('\tmsg_queue 12 20') - child.expect_exact('\tmsg_array 4 32') - else: - # 16 bit platform (wsn430) - child.expect_exact('\tsp 2 0') - child.expect_exact('\tstatus 1 2') - child.expect_exact('\tpriority 1 3') - child.expect_exact('\tpid 2 4') - child.expect_exact('\trq_entry 2 6') - child.expect_exact('\twait_data 2 8') - child.expect_exact('\tmsg_waiters 2 10') - child.expect_exact('\tmsg_queue 6 12') - child.expect_exact('\tmsg_array 2 18') - child.expect_exact('SUCCESS') - - -if __name__ == "__main__": - sys.exit(run(testfunc))