Skip to content
Snippets Groups Projects
Unverified Commit e8af06fe authored by Martine Lenders's avatar Martine Lenders Committed by GitHub
Browse files

Merge pull request #9346 from haukepetersen/add_bench_sizeofcoretypes

tests: initial include of tests/bench_sizeof_coretypes
parents f1a5b08d 4abe8d59
Branches
No related tags found
No related merge requests found
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
# 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.
/*
* 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;
}
#!/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))
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
/*
* 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;
}
#!/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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment