summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-02-28 15:37:31 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:24:19 +0100
commit113944fa634e792c78bf394989d710197bb722da (patch)
tree8848eba83690026715b603721c4a0cdc15ce4c18 /testsuites
parentlibblock: Use new API for disk media (diff)
downloadrtems-113944fa634e792c78bf394989d710197bb722da.tar.bz2
fstests/fsbdpart01: New test
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/fstests/Makefile.am1
-rw-r--r--testsuites/fstests/configure.ac1
-rw-r--r--testsuites/fstests/fsbdpart01/Makefile.am20
-rw-r--r--testsuites/fstests/fsbdpart01/fsbdpart01.doc11
-rw-r--r--testsuites/fstests/fsbdpart01/fsbdpart01.scn17
-rw-r--r--testsuites/fstests/fsbdpart01/init.c231
6 files changed, 281 insertions, 0 deletions
diff --git a/testsuites/fstests/Makefile.am b/testsuites/fstests/Makefile.am
index d731eb6591..f765a89af4 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 f2ca983699..833a85c21a 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 0000000000..923e98047a
--- /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@.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 0000000000..56da2eb4f0
--- /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 0000000000..33efd2c003
--- /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 0000000000..69fe071ef6
--- /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@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>