--- testsuites/smptests/smppflock01/Makefile.am | 19 +++ testsuites/smptests/smppflock01/init.c | 176 +++++++++++++++++++++++ testsuites/smptests/smppflock01/smppflock01.doc | 17 +++ 3 files changed, 212 insertions(+) create mode 100644 testsuites/smptests/smppflock01/Makefile.am create mode 100644 testsuites/smptests/smppflock01/init.c create mode 100644 testsuites/smptests/smppflock01/smppflock01.doc create mode 100644 testsuites/smptests/smppflock01/smppflock01.scn
diff --git a/testsuites/smptests/smppflock01/Makefile.am b/testsuites/smptests/smppflock01/Makefile.am new file mode 100644 index 0000000..74a1810 --- /dev/null +++ b/testsuites/smptests/smppflock01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = smppflock01 +smppflock01_SOURCES = init.c ../../support/src/locked_print.c + +dist_rtems_tests_DATA = smppflock01.scn smppflock01.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(smppflock01_OBJECTS) +LINK_LIBS = $(smppflock01_LDLIBS) + +smppflock01$(EXEEXT): $(smppflock01_OBJECTS) $(smppflock01_DEPENDENCIES) + @rm -f smppflock01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/smptests/smppflock01/init.c b/testsuites/smptests/smppflock01/init.c new file mode 100644 index 0000000..987a200 --- /dev/null +++ b/testsuites/smptests/smppflock01/init.c @@ -0,0 +1,176 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems.h> +#include <rtems/score/smprwlock.h> + +#include "tmacros.h" + +#define TASK_PRIORITY 1 +#define CPU_COUNT 32 +#define TEST_COUNT 10 + +/* + * Keep the names and IDs in global variables so another task can use them. + */ +volatile bool TaskRan[ CPU_COUNT ]; + + +static Atomic_Uint locked; +static SMP_rwlock_Control lock; + +static void task(rtems_task_argument arg) +{ + SMP_rwlock_Control *pflock = (SMP_rwlock_Control *) arg; +// uint32_t cpu_count = rtems_smp_get_processor_count(); + uint32_t cpu_self = rtems_smp_get_current_processor(); + rtems_status_code sc; + uint_fast32_t l; + int i = TEST_COUNT; + + /* XXX - Delay a bit to allow debug messages from + * startup to print. This may need to go away when + * debug messages go away. + */ + locked_print_initialize(); + + while (i--) { + _SMP_rwlock_Acquire_write(pflock); + { + l = _Atomic_Load_uint(&locked, ATOMIC_ORDER_ACQUIRE); + if (l != 0) { + locked_printf("ERROR [WR:%d]: %u != 0\n", __LINE__, l); + } + + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_add_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + + l = _Atomic_Load_uint(&locked, ATOMIC_ORDER_ACQUIRE); + if (l != 8) { + locked_printf("ERROR [WR:%d]: %u != 2\n", __LINE__, l); + } + + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + _Atomic_Fetch_sub_uint(&locked, 1, ATOMIC_ORDER_RELEASE); + + l = _Atomic_Load_uint(&locked, ATOMIC_ORDER_ACQUIRE); + if (l != 0) { + locked_printf("ERROR [WR:%d]: %u != 0\n", __LINE__, l); + } + } + _SMP_rwlock_Release_write(&lock); + + _SMP_rwlock_Acquire_read(&lock); + { + _Atomic_Load_uint(&locked, ATOMIC_ORDER_ACQUIRE); + if (l != 0) { + locked_printf("ERROR [RD:%d]: %u != 0\n", __LINE__, l); + } + } + _SMP_rwlock_Release_read(&lock); + } + + /* Set the flag that the task is up and running */ + TaskRan[cpu_self] = true; + + sc = rtems_task_suspend(RTEMS_SELF); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void test(void) +{ + SMP_rwlock_Control *pflock = &lock; + uint32_t cpu_count = rtems_smp_get_processor_count(); + uint32_t cpu_self = rtems_smp_get_current_processor(); + uint32_t cpu; + int i; + char ch; + rtems_status_code sc; + + _SMP_rwlock_Initialize(pflock); + +/* Initialize the TaskRan array */ + for ( i=0; i<cpu_count; i++ ) { + TaskRan[i] = false; + } + + for (cpu = 0; cpu < cpu_count; ++cpu) { + if (cpu != cpu_self) { + rtems_id task_id; + ch = '0' + cpu; + + sc = rtems_task_create( + rtems_build_name('T', 'A', ch, ' '), + TASK_PRIORITY, + RTEMS_MINIMUM_STACK_SIZE, + RTEMS_DEFAULT_MODES, + RTEMS_DEFAULT_ATTRIBUTES, + &task_id + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_task_start(task_id, task, (rtems_task_argument) pflock); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } + } +} + +static void Init(rtems_task_argument arg) +{ + bool allDone; + uint32_t cpu_count = rtems_smp_get_processor_count(); + int i; + + puts("\n\n*** TEST SMP phase_fair lock 1 ***"); + + test(); + + /* Wait on the all tasks to run */ + while (1) { + allDone = true; + for ( i=1; i<cpu_count; i++ ) { + if (TaskRan[i] == false) + allDone = false; + } + if (allDone) { + locked_printf( "\n\n*** END OF TEST SMP phase_fair lock 1 ***\n" ); + rtems_test_exit( 0 ); + } + } +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_SMP_APPLICATION + +#define CONFIGURE_SMP_MAXIMUM_PROCESSORS CPU_COUNT + +#define CONFIGURE_MAXIMUM_TASKS CPU_COUNT + +#define CONFIGURE_MAXIMUM_SEMAPHORES 1 + +#define CONFIGURE_MAXIMUM_TIMERS 1 + +#define CONFIGURE_INIT_TASK_PRIORITY TASK_PRIORITY +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/smptests/smppflock01/smppflock01.doc b/testsuites/smptests/smppflock01/smppflock01.doc new file mode 100644 index 0000000..b8f74ba --- /dev/null +++ b/testsuites/smptests/smppflock01/smppflock01.doc @@ -0,0 +1,17 @@ +This file describes the directives and concepts tested by this test set. + +test set name: smppflock01 + +The screen file was obtained on a PowerPC QorIQ P1020E target running with a +processor frequency of 800MHz. + +directives: + + - _SMP_rwlock_Acquire_write() + - _SMP_rwlock_Release_write() + - _SMP_rwlock_Acquire_read() + - _SMP_rwlock_Release_read() + +concepts: + + - Valid the SMP rwlock correctness diff --git a/testsuites/smptests/smppflock01/smppflock01.scn b/testsuites/smptests/smppflock01/smppflock01.scn new file mode 100644 index 0000000..e69de29 -- 1.7.9.5 _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel