[rtems commit] fstests/fsbdpart01: New test

Joel Sherrill joel at rtems.org
Thu Mar 29 14:14:30 UTC 2012


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Feb 28 15:37:31 2012 +0100

fstests/fsbdpart01: New test

---

 testsuites/fstests/Makefile.am               |    1 +
 testsuites/fstests/configure.ac              |    1 +
 testsuites/fstests/fsbdpart01/Makefile.am    |   20 +++
 testsuites/fstests/fsbdpart01/fsbdpart01.doc |   11 ++
 testsuites/fstests/fsbdpart01/fsbdpart01.scn |   17 ++
 testsuites/fstests/fsbdpart01/init.c         |  231 ++++++++++++++++++++++++++
 6 files changed, 281 insertions(+), 0 deletions(-)

diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am
index d731eb6..f765a89 100644
--- a/testsuites/fstests/Makefile.am
+++ b/testsuites/fstests/Makefile.am
@@ -32,6 +32,7 @@ SUBDIRS += mrfs_fssymlink
 SUBDIRS += mrfs_fstime
 SUBDIRS += fsnofs01
 SUBDIRS += fsimfsgeneric01
+SUBDIRS += fsbdpart01
 
 EXTRA_DIST =
 EXTRA_DIST += support/ramdisk_support.c
diff --git a/testsuites/fstests/configure.ac b/testsuites/fstests/configure.ac
index f2ca983..833a85c 100644
--- a/testsuites/fstests/configure.ac
+++ b/testsuites/fstests/configure.ac
@@ -106,6 +106,7 @@ mrfs_fssymlink/Makefile
 mrfs_fstime/Makefile
 fsnofs01/Makefile
 fsimfsgeneric01/Makefile
+fsbdpart01/Makefile
 
 ])
 AC_OUTPUT
diff --git a/testsuites/fstests/fsbdpart01/Makefile.am b/testsuites/fstests/fsbdpart01/Makefile.am
new file mode 100644
index 0000000..923e980
--- /dev/null
+++ b/testsuites/fstests/fsbdpart01/Makefile.am
@@ -0,0 +1,20 @@
+rtems_tests_PROGRAMS = fsbdpart01
+fsbdpart01_SOURCES = init.c
+
+dist_rtems_tests_DATA = fsbdpart01.scn fsbdpart01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(fsbdpart01_OBJECTS)
+LINK_LIBS = $(fsbdpart01_LDLIBS)
+
+fsbdpart01$(EXEEXT): $(fsbdpart01_OBJECTS) $(fsbdpart01_DEPENDENCIES)
+	@rm -f fsbdpart01$(EXEEXT)
+	$(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/fstests/fsbdpart01/fsbdpart01.doc b/testsuites/fstests/fsbdpart01/fsbdpart01.doc
new file mode 100644
index 0000000..56da2eb
--- /dev/null
+++ b/testsuites/fstests/fsbdpart01/fsbdpart01.doc
@@ -0,0 +1,11 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: fsbdpart01
+
+directives:
+
+  TBD
+
+concepts:
+
+  TBD
diff --git a/testsuites/fstests/fsbdpart01/fsbdpart01.scn b/testsuites/fstests/fsbdpart01/fsbdpart01.scn
new file mode 100644
index 0000000..33efd2c
--- /dev/null
+++ b/testsuites/fstests/fsbdpart01/fsbdpart01.scn
@@ -0,0 +1,17 @@
+*** TEST FSBDPART 1 ***
+-------------------------------------------------------------------------------
+                                PARTITION TABLE
+------------+------------+-----------------------------------------------------
+ BEGIN      | END        | TYPE
+------------+------------+-----------------------------------------------------
+         63 |        126 |                                              FAT 32
+        126 |        189 |                                              FAT 32
+        189 |        252 |                                              FAT 32
+        315 |        378 |                                              FAT 32
+        441 |        504 |                                              FAT 32
+        567 |        630 |                                              FAT 32
+        693 |        756 |                                              FAT 32
+        819 |        882 |                                              FAT 32
+        945 |       1008 |                                              FAT 32
+------------+------------+-----------------------------------------------------
+*** END OF TEST FSBDPART 1 ***
diff --git a/testsuites/fstests/fsbdpart01/init.c b/testsuites/fstests/fsbdpart01/init.c
new file mode 100644
index 0000000..69fe071
--- /dev/null
+++ b/testsuites/fstests/fsbdpart01/init.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  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 "tmacros.h"
+
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <rtems/bdpart.h>
+#include <rtems/blkdev.h>
+#include <rtems/ide_part_table.h>
+#include <rtems/ramdisk.h>
+
+#define ASSERT_SC(sc) rtems_test_assert((sc) == RTEMS_SUCCESSFUL)
+
+#define PARTITION_COUNT 9
+
+static const char rda [] = "/dev/rda";
+
+static const char *const bdpart_rdax [PARTITION_COUNT] = {
+  "/dev/rda1",
+  "/dev/rda2",
+  "/dev/rda3",
+  "/dev/rda4",
+  "/dev/rda5",
+  "/dev/rda6",
+  "/dev/rda7",
+  "/dev/rda8",
+  "/dev/rda9"
+};
+
+static const char *const ide_part_table_rdax [PARTITION_COUNT] = {
+  "/dev/rda1",
+  "/dev/rda2",
+  "/dev/rda3",
+  "/dev/rda5",
+  "/dev/rda6",
+  "/dev/rda7",
+  "/dev/rda8",
+  "/dev/rda9",
+  "/dev/rda10"
+};
+
+static const rtems_blkdev_bnum starts [PARTITION_COUNT] = {
+  63, 126, 189, 315, 441, 567, 693, 819, 945
+};
+
+static const rtems_bdpart_format format = {
+  .mbr = {
+    .type = RTEMS_BDPART_FORMAT_MBR,
+    .disk_id = 0xdeadbeef,
+    .dos_compatibility = true
+  }
+};
+
+static const unsigned distribution [PARTITION_COUNT] = {
+  1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+static void test_logical_disks(const char *const *rdax, bool exists)
+{
+  size_t i = 0;
+
+  for (i = 0; i < PARTITION_COUNT; ++i) {
+    int fd = open(rdax [i], O_RDONLY);
+
+    if (exists) {
+      const rtems_disk_device *dd = NULL;
+      int rv = 0;
+
+      rtems_test_assert(fd >= 0);
+
+      rv = rtems_disk_fd_get_disk_device(fd, &dd);
+      rtems_test_assert(rv == 0);
+
+      rtems_test_assert(dd->start == starts [i]);
+      rtems_test_assert(dd->size == 63);
+
+      rv = close(fd);
+      rtems_test_assert(rv == 0);
+    } else {
+      rtems_test_assert(fd == -1);
+    }
+  }
+}
+
+static void test_bdpart(void)
+{
+  rtems_status_code sc = RTEMS_SUCCESSFUL;
+  rtems_bdpart_partition created_partitions [PARTITION_COUNT];
+  rtems_bdpart_format actual_format;
+  rtems_bdpart_partition actual_partitions [PARTITION_COUNT];
+  size_t actual_count = PARTITION_COUNT;
+  size_t i = 0;
+
+  memset(&created_partitions [0], 0, sizeof(created_partitions));
+  memset(&actual_format, 0, sizeof(actual_format));
+  memset(&actual_partitions [0], 0, sizeof(actual_partitions));
+
+  for (i = 0; i < PARTITION_COUNT; ++i) {
+    rtems_bdpart_to_partition_type(
+      RTEMS_BDPART_MBR_FAT_32,
+      created_partitions [i].type
+    );
+  }
+
+  sc = rtems_bdpart_create(
+    rda,
+    &format,
+    &created_partitions [0],
+    &distribution [0],
+    PARTITION_COUNT
+  );
+  ASSERT_SC(sc);
+
+  sc = rtems_bdpart_write(
+    rda,
+    &format,
+    &created_partitions [0],
+    PARTITION_COUNT
+  );
+  ASSERT_SC(sc);
+
+  sc = rtems_bdpart_read(
+    rda,
+    &actual_format,
+    &actual_partitions [0],
+    &actual_count
+  );
+  ASSERT_SC(sc);
+  rtems_test_assert(actual_format.mbr.disk_id == format.mbr.disk_id);
+  rtems_test_assert(
+    memcmp(
+      &actual_partitions [0],
+      &created_partitions [0],
+      PARTITION_COUNT
+    ) == 0
+  );
+
+  sc = rtems_bdpart_register(
+    rda,
+    actual_partitions,
+    actual_count
+  );
+  ASSERT_SC(sc);
+  test_logical_disks(&bdpart_rdax [0], true);
+
+  sc = rtems_bdpart_unregister(
+    rda,
+    actual_partitions,
+    actual_count
+  );
+  ASSERT_SC(sc);
+  test_logical_disks(&bdpart_rdax [0], false);
+
+  sc = rtems_bdpart_register_from_disk(rda);
+  ASSERT_SC(sc);
+  test_logical_disks(&bdpart_rdax [0], true);
+
+  sc = rtems_bdpart_unregister(
+    rda,
+    actual_partitions,
+    actual_count
+  );
+  ASSERT_SC(sc);
+  test_logical_disks(&bdpart_rdax [0], false);
+
+  rtems_bdpart_dump(&actual_partitions [0], actual_count);
+}
+
+static void test_ide_part_table(void)
+{
+  rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+  test_logical_disks(&ide_part_table_rdax [0], false);
+  sc = rtems_ide_part_table_initialize(rda);
+  ASSERT_SC(sc);
+  test_logical_disks(&ide_part_table_rdax [0], true);
+}
+
+static void Init(rtems_task_argument arg)
+{
+  printf("\n\n*** TEST FSBDPART 1 ***\n");
+
+  test_bdpart();
+  test_ide_part_table();
+
+  printf("*** END OF TEST FSBDPART 1 ***\n");
+
+  rtems_test_exit(0);
+}
+
+rtems_ramdisk_config rtems_ramdisk_configuration [] = {
+  { .block_size = 512, .block_num = 1024 }
+};
+
+size_t rtems_ramdisk_configuration_size = 1;
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_EXTRA_DRIVERS RAMDISK_DRIVER_TABLE_ENTRY
+#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+
+#define CONFIGURE_MAXIMUM_TASKS 2
+
+#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024)
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>




More information about the vc mailing list