[rtems commit] spconfig02: Check object methods in default config

Sebastian Huber sebh at rtems.org
Wed Nov 7 07:33:54 UTC 2018


Module:    rtems
Branch:    master
Commit:    e71c097ac33bdb20a8121174a6d1d78a720f4ac4
Changeset: http://git.rtems.org/rtems/commit/?id=e71c097ac33bdb20a8121174a6d1d78a720f4ac4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Nov  6 12:57:42 2018 +0100

spconfig02: Check object methods in default config

Ensure that the creation of Classic API objects fails with the expected
status code in the default configuration.

Ensure that the deletion of Classic API objects fails with the expected
status code in the default configuration if the identifier is invalid.

Ensure that only the expected objects are present in the default
configuration via rtems_object_get_classic_name().

---

 testsuites/sptests/Makefile.am               |   9 +
 testsuites/sptests/configure.ac              |   1 +
 testsuites/sptests/spconfig02/init.c         | 279 +++++++++++++++++++++++++++
 testsuites/sptests/spconfig02/spconfig02.doc |  32 +++
 testsuites/sptests/spconfig02/spconfig02.scn |   7 +
 5 files changed, 328 insertions(+)

diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 7a18243..80680df 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -717,6 +717,15 @@ spconfig01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spconfig01) \
 	$(support_includes)
 endif
 
+if TEST_spconfig02
+sp_tests += spconfig02
+sp_screens += spconfig02/spconfig02.scn
+sp_docs += spconfig02/spconfig02.doc
+spconfig02_SOURCES = spconfig02/init.c
+spconfig02_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spconfig02) \
+	$(support_includes)
+endif
+
 if TEST_spconsole01
 sp_tests += spconsole01
 sp_screens += spconsole01/spconsole01.scn
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index 36b3a17..e725b39 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -118,6 +118,7 @@ RTEMS_TEST_CHECK([spchain])
 RTEMS_TEST_CHECK([spclock_err01])
 RTEMS_TEST_CHECK([spclock_err02])
 RTEMS_TEST_CHECK([spconfig01])
+RTEMS_TEST_CHECK([spconfig02])
 RTEMS_TEST_CHECK([spconsole01])
 RTEMS_TEST_CHECK([spcontext01])
 RTEMS_TEST_CHECK([spcoverage])
diff --git a/testsuites/sptests/spconfig02/init.c b/testsuites/sptests/spconfig02/init.c
new file mode 100644
index 0000000..34631fe
--- /dev/null
+++ b/testsuites/sptests/spconfig02/init.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/score/objectimpl.h>
+
+#include <tmacros.h>
+
+const char rtems_test_name[] = "SPCONFIG 2";
+
+static const rtems_name name = rtems_build_name('N', 'A', 'M', 'E');
+
+static void test_barrier(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_barrier_create(name, RTEMS_DEFAULT_ATTRIBUTES, 1, &id);
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+}
+
+static void test_message_queue(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_message_queue_create(
+    name,
+    1,
+    1,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &id
+  );
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_message_queue_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_MESSAGE_QUEUES, 1, 0);
+  sc = rtems_message_queue_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_partition(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+  long buf[32];
+
+  sc = rtems_partition_create(
+    name,
+    buf,
+    sizeof(buf),
+    sizeof(buf),
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &id
+  );
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_partition_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PARTITIONS, 1, 0);
+  sc = rtems_partition_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_rate_monotonic(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_rate_monotonic_create(name, &id);
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_rate_monotonic_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_PERIODS, 1, 0);
+  sc = rtems_rate_monotonic_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_region(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+  long buf[32];
+
+  sc = rtems_region_create(
+    name,
+    buf,
+    sizeof(buf),
+    1,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &id
+  );
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_region_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_REGIONS, 1, 0);
+  sc = rtems_region_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_semaphore(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_semaphore_create(
+    name,
+    0,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    0,
+    &id
+  );
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_semaphore_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_SEMAPHORES, 1, 0);
+  sc = rtems_semaphore_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_task(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_task_create(
+    name,
+    1,
+    RTEMS_MINIMUM_STACK_SIZE,
+    RTEMS_DEFAULT_MODES,
+    RTEMS_DEFAULT_ATTRIBUTES,
+    &id
+  );
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TASKS, 1, 0);
+  sc = rtems_task_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_timer(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+
+  sc = rtems_timer_create(name, &id);
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_timer_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_TIMERS, 1, 0);
+  sc = rtems_timer_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_user_extensions(void)
+{
+  rtems_status_code sc;
+  rtems_id id;
+  rtems_extensions_table table;
+
+  memset(&table, 0, sizeof(table));
+  sc = rtems_extension_create(name, &table, &id);
+  rtems_test_assert(sc == RTEMS_TOO_MANY);
+
+  sc = rtems_extension_delete(0);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+
+  id = rtems_build_id(OBJECTS_CLASSIC_API, OBJECTS_RTEMS_EXTENSIONS, 1, 0);
+  sc = rtems_extension_delete(id);
+  rtems_test_assert(sc == RTEMS_INVALID_ID);
+}
+
+static void test_id_to_name(rtems_id api, rtems_id cls, rtems_id idx, bool *found)
+{
+  rtems_status_code sc;
+  rtems_id id;
+  rtems_name name_of_id;
+
+  id = rtems_build_id(api, cls, 1, idx);
+  sc = rtems_object_get_classic_name(id, &name_of_id);
+
+  if (sc == RTEMS_SUCCESSFUL) {
+    if (name_of_id == rtems_build_name('U', 'I', '1', ' ')) {
+      rtems_test_assert(id == rtems_task_self());
+      rtems_test_assert(!found[0]);
+      found[0] = true;
+    } else {
+      rtems_test_assert(name_of_id == rtems_build_name('I', 'D', 'L', 'E'));
+      rtems_test_assert(!found[1]);
+      found[1] = true;
+    }
+  } else {
+    rtems_test_assert(sc == RTEMS_INVALID_ID);
+  }
+}
+
+static void test_some_id_to_name(void)
+{
+  rtems_id api;
+  bool found[2];
+
+  found[0] = false;
+  found[1] = false;
+
+  for (api = 0; api < 8; ++api) {
+    rtems_id cls;
+
+    for (cls = 0; cls < 32; ++cls) {
+      test_id_to_name(api, cls, 0, found);
+      test_id_to_name(api, cls, 1, found);
+      test_id_to_name(api, cls, 2, found);
+      test_id_to_name(api, cls, 65534, found);
+      test_id_to_name(api, cls, 65535, found);
+    }
+  }
+
+  rtems_test_assert(found[0]);
+  rtems_test_assert(found[1]);
+}
+
+static void Init(rtems_task_argument arg)
+{
+  rtems_print_printer_printk(&rtems_test_printer);
+  TEST_BEGIN();
+  test_barrier();
+  test_message_queue();
+  test_partition();
+  test_rate_monotonic();
+  test_region();
+  test_semaphore();
+  test_task();
+  test_timer();
+  test_user_extensions();
+  test_some_id_to_name();
+  TEST_END();
+  rtems_test_exit(0);
+}
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+
+#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/spconfig02/spconfig02.doc b/testsuites/sptests/spconfig02/spconfig02.doc
new file mode 100644
index 0000000..c6e1c8b
--- /dev/null
+++ b/testsuites/sptests/spconfig02/spconfig02.doc
@@ -0,0 +1,32 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: spconfig02
+
+directives:
+
+  - rtems_barrier_create()
+  - rtems_extension_create()
+  - rtems_extension_delete()
+  - rtems_message_queue_create()
+  - rtems_message_queue_delete()
+  - rtems_object_get_classic_name()
+  - rtems_partition_create()
+  - rtems_partition_delete()
+  - rtems_rate_monotonic_create()
+  - rtems_rate_monotonic_delete()
+  - rtems_region_create()
+  - rtems_region_delete()
+  - rtems_semaphore_create()
+  - rtems_semaphore_delete()
+  - rtems_task_create()
+  - rtems_timer_create()
+  - rtems_timer_delete()
+
+concepts:
+
+  - Ensure that the creation of Classic API objects fails with the expected
+    status code in the default configuration.
+  - Ensure that the deletion of Classic API objects fails with the expected
+    status code in the default configuration if the identifier is invalid.
+  - Ensure that only the expected objects are present in the default
+    configuration via rtems_object_get_classic_name().
diff --git a/testsuites/sptests/spconfig02/spconfig02.scn b/testsuites/sptests/spconfig02/spconfig02.scn
new file mode 100644
index 0000000..39628a8
--- /dev/null
+++ b/testsuites/sptests/spconfig02/spconfig02.scn
@@ -0,0 +1,7 @@
+*** BEGIN OF TEST SPCONFIG 2 ***
+*** TEST VERSION: 5.0.0.5f0d0d2d272bebb13f63efe70cb186bbf7715a89
+*** TEST STATE: EXPECTED-PASS
+*** TEST BUILD:
+*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 279e47eab88299b0123be5a1e4446fe4a9329a54, Newlib 08eab6396f678cf5e5968acaed0bae9fd129983b)
+
+*** END OF TEST SPCONFIG 2 ***




More information about the vc mailing list