<div dir="auto">Does this close the ticket? Or just update it?<div dir="auto"><br></div><div dir="auto">Should we have info in the POSIX guide for these calls?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Jul 14, 2017 3:08 PM, "Gedare Bloom" <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I checked these in. Thanks!<br>
<br>
On Thu, Jun 29, 2017 at 10:36 AM, Kevin Kirspel <<a href="mailto:kevin-kirspel@idexx.com">kevin-kirspel@idexx.com</a>> wrote:<br>
> Updates #2859<br>
> ---<br>
> testsuites/psxtests/Makefile.<wbr>am | 1 +<br>
> testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.<wbr>ac</a> | 1 +<br>
> testsuites/psxtests/psxmmap01/<wbr>Makefile.am | 22 ++<br>
> testsuites/psxtests/psxmmap01/<wbr>init.c | 352 ++++++++++++++++++++++++++++<br>
> testsuites/psxtests/psxmmap01/<wbr>psxmmap01.scn | 0<br>
> testsuites/psxtests/psxmmap01/<wbr>system.h | 31 +++<br>
> testsuites/psxtests/psxmmap01/<wbr>test_driver.c | 67 ++++++<br>
> testsuites/psxtests/psxmmap01/<wbr>test_driver.h | 14 ++<br>
> testsuites/psxtests/psxmmap01/<wbr>test_helper.c | 32 +++<br>
> testsuites/psxtests/psxmmap01/<wbr>test_helper.h | 41 ++++<br>
> 10 files changed, 561 insertions(+)<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>Makefile.am<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>init.c<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>psxmmap01.scn<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>system.h<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>test_driver.c<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>test_driver.h<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>test_helper.c<br>
> create mode 100644 testsuites/psxtests/psxmmap01/<wbr>test_helper.h<br>
><br>
> diff --git a/testsuites/psxtests/<wbr>Makefile.am b/testsuites/psxtests/<wbr>Makefile.am<br>
> index 7bcea46..cccdb39 100644<br>
> --- a/testsuites/psxtests/<wbr>Makefile.am<br>
> +++ b/testsuites/psxtests/<wbr>Makefile.am<br>
> @@ -85,6 +85,7 @@ _SUBDIRS += psxrwlock01<br>
> _SUBDIRS += psxsem01<br>
> _SUBDIRS += psxshm01<br>
> _SUBDIRS += psxshm02<br>
> +_SUBDIRS += psxmmap01<br>
> _SUBDIRS += psxsignal01<br>
> _SUBDIRS += psxsignal02<br>
> _SUBDIRS += psxsignal03<br>
> diff --git a/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configur<wbr>e.ac</a> b/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configur<wbr>e.ac</a><br>
> index 1de1312..96a0149 100644<br>
> --- a/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configur<wbr>e.ac</a><br>
> +++ b/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configur<wbr>e.ac</a><br>
> @@ -190,6 +190,7 @@ psxrwlock01/Makefile<br>
> psxsem01/Makefile<br>
> psxshm01/Makefile<br>
> psxshm02/Makefile<br>
> +psxmmap01/Makefile<br>
> psxsignal01/Makefile<br>
> psxsignal02/Makefile<br>
> psxsignal03/Makefile<br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/Makefile.am b/testsuites/psxtests/<wbr>psxmmap01/Makefile.am<br>
> new file mode 100644<br>
> index 0000000..57b0087<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/Makefile.am<br>
> @@ -0,0 +1,22 @@<br>
> +<br>
> +rtems_tests_PROGRAMS = psxmmap01<br>
> +psxmmap01_SOURCES = init.c test_helper.c test_driver.c system.h<br>
> +<br>
> +dist_rtems_tests_DATA = psxmmap01.scn<br>
> +<br>
> +include $(RTEMS_ROOT)/make/custom/@<wbr>RTEMS_BSP@.cfg<br>
> +include $(top_srcdir)/../automake/<a href="http://compile.am" rel="noreferrer" target="_blank">comp<wbr>ile.am</a><br>
> +include $(top_srcdir)/../automake/<a href="http://leaf.am" rel="noreferrer" target="_blank">leaf<wbr>.am</a><br>
> +<br>
> +<br>
> +AM_CPPFLAGS += -I$(top_srcdir)/include<br>
> +AM_CPPFLAGS += -I$(top_srcdir)/../support/<wbr>include<br>
> +<br>
> +LINK_OBJS = $(psxmmap01_OBJECTS)<br>
> +LINK_LIBS = $(psxmmap01_LDLIBS)<br>
> +<br>
> +psxmmap01$(EXEEXT): $(psxmmap01_OBJECTS) $(psxmmap01_DEPENDENCIES)<br>
> + @rm -f psxmmap01$(EXEEXT)<br>
> + $(make-exe)<br>
> +<br>
> +include $(top_srcdir)/../automake/<a href="http://local.am" rel="noreferrer" target="_blank">loca<wbr>l.am</a><br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/init.c b/testsuites/psxtests/<wbr>psxmmap01/init.c<br>
> new file mode 100644<br>
> index 0000000..eb1c747<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/init.c<br>
> @@ -0,0 +1,344 @@<br>
> +/*-<br>
> + * Copyright (c) 2009 Simon L. Nielsen <simon@FreeBSD.org>,<br>
> + * Bjoern A. Zeeb <bz@FreeBSD.org><br>
> + *<br>
> + * Redistribution and use in source and binary forms, with or without<br>
> + * modification, are permitted provided that the following conditions<br>
> + * are met:<br>
> + * 1. Redistributions of source code must retain the above copyright<br>
> + * notice, this list of conditions and the following disclaimer.<br>
> + * 2. Redistributions in binary form must reproduce the above copyright<br>
> + * notice, this list of conditions and the following disclaimer in the<br>
> + * documentation and/or other materials provided with the distribution.<br>
> + *<br>
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND<br>
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE<br>
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
> + * SUCH DAMAGE.<br>
> + *<br>
> + * $FreeBSD$<br>
> + */<br>
> +<br>
> +#ifdef HAVE_CONFIG_H<br>
> +#include "config.h"<br>
> +#endif<br>
> +<br>
> +#define CONFIGURE_INIT<br>
> +#include "system.h"<br>
> +#include "pritime.h"<br>
> +#include "test_helper.h"<br>
> +#include "test_driver.h"<br>
> +<br>
> +#include <sys/mman.h><br>
> +<br>
> +#include <errno.h><br>
> +#include <fcntl.h><br>
> +#include <string.h><br>
> +<br>
> +const char rtems_test_name[] = "PSX MMAP01";<br>
> +const char test_driver_name[] = "/dev/test_driver";<br>
> +<br>
> +static const struct {<br>
> + void *addr;<br>
> + int ok;<br>
> +} map_at_zero_tests[] = {<br>
> + { (void *)0, 0 },<br>
> + { (void *)1, 0 },<br>
> + { (void *)(PAGE_SIZE - 1), 0 },<br>
> + { (void *)PAGE_SIZE, 1 },<br>
> + { (void *)-1, 0 },<br>
> + { (void *)(-PAGE_SIZE), 0 },<br>
> + { (void *)(-1 - PAGE_SIZE), 0 },<br>
> + { (void *)(-1 - PAGE_SIZE - 1), 0 },<br>
> + { (void *)(0x1000 * PAGE_SIZE), 1 },<br>
> +};<br>
> +<br>
> +#define MAP_AT_ZERO_NITEMS (sizeof(map_at_zero_tests) / sizeof(map_at_zero_tests[0]))<br>
> +<br>
> +static void* checked_mmap(<br>
> + int prot,<br>
> + int flags,<br>
> + int fd,<br>
> + int error,<br>
> + const char *msg<br>
> +)<br>
> +{<br>
> + void *p;<br>
> + int pagesize, err;<br>
> +<br>
> + rtems_test_assert((pagesize = getpagesize()) > 0);<br>
> + p = mmap(NULL, pagesize, prot, flags, fd, 0);<br>
> + if (p == MAP_FAILED) {<br>
> + if (error == 0)<br>
> + mmap_test_assert(0, "%s failed with errno %d\n", msg, errno);<br>
> + else {<br>
> + err = errno;<br>
> + mmap_test_assert_equal(error, err,<br>
> + "%s failed with wrong errno %d (expected %d)\n", msg,<br>
> + errno, error);<br>
> + }<br>
> + } else {<br>
> + mmap_test_check(error == 0, "%s succeeded\n", msg);<br>
> + munmap(p, pagesize);<br>
> + }<br>
> + return p;<br>
> +}<br>
> +<br>
> +static void mmap_map_at_zero( void )<br>
> +{<br>
> + void *p;<br>
> + unsigned int i;<br>
> +<br>
> + for (i = 0; i < MAP_AT_ZERO_NITEMS; i++) {<br>
> + p = mmap((void *)map_at_zero_tests[i].addr, PAGE_SIZE,<br>
> + PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED | MAP_PRIVATE,<br>
> + -1, 0);<br>
> + if (p == MAP_FAILED) {<br>
> + mmap_test_assert( map_at_zero_tests[i].ok == 0,<br>
> + "mmap(%08lX, ...) failed\n", (uint32_t)map_at_zero_tests[i]<wbr>.addr );<br>
> + } else {<br>
> + mmap_test_check( map_at_zero_tests[i].ok == 1,<br>
> + "mmap(%p, ...) succeeded: p=%p\n",<br>
> + map_at_zero_tests[i].addr, p );<br>
> + }<br>
> + }<br>
> +}<br>
> +<br>
> +static void mmap_bad_arguments( void )<br>
> +{<br>
> + int devfd, pagesize, shmfd, zerofd;<br>
> + void* p;<br>
> +<br>
> + rtems_test_assert((pagesize = getpagesize()) > 0);<br>
> + rtems_test_assert((devfd = open(&test_driver_name[0], O_RDONLY)) >= 0);<br>
> + rtems_test_assert((shmfd = shm_open("/shm", O_CREAT | O_RDWR, 0644)) >= 0);<br>
> + rtems_test_assert(ftruncate(<wbr>shmfd, pagesize) == 0);<br>
> + rtems_test_assert((zerofd = open("/dev/zero", O_RDONLY)) >= 0);<br>
> +<br>
> + /*<br>
> + * These should normally work on FREEBSD. Test cases below that fail are<br>
> + * due to unsupported features in RTEMS.<br>
> + */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON, -1, 0,<br>
> + "simple MAP_ANON");<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0,<br>
> + "simple shm fd shared");<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, shmfd, 0,<br>
> + "simple shm fd private");<br>
> + /* RTEMS cannot protect against writes so this will fail */<br>
> + checked_mmap(PROT_READ, MAP_SHARED, zerofd, ENOTSUP,<br>
> + "simple /dev/zero shared");<br>
> + /*<br>
> + * Repeat with no write protection. Will fail because of unimplemented<br>
> + * mmap handler in /dev/zero.<br>
> + */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, zerofd, ENOTSUP,<br>
> + "simple /dev/zero shared");<br>
> + /* RTEMS /dev/zero is a character device so this will fail */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, zerofd, EINVAL,<br>
> + "simple /dev/zero private");<br>
> + /* RTEMS cannot protect against writes so this will fail */<br>
> + checked_mmap(PROT_READ, MAP_SHARED, devfd, ENOTSUP,<br>
> + "simple test driver shared");<br>
> + /*<br>
> + * Repeat with no write protection. Should fail because of unimplemented<br>
> + * mmap handler in /dev/null.<br>
> + */<br>
> + p = checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, devfd, 0,<br>
> + "simple test driver shared");<br>
> + rtems_test_assert(p == &test_data[0]);<br>
> +<br>
> + /* Extra PROT flags. */<br>
> + checked_mmap(PROT_READ | PROT_WRITE | 0x100000, MAP_ANON, -1, EINVAL,<br>
> + "MAP_ANON with extra PROT flags");<br>
> + checked_mmap(0xffff, MAP_SHARED, shmfd, EINVAL,<br>
> + "shm fd with garbage PROT");<br>
> +<br>
> + /* Undefined flag. */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_RESERVED0080, -1,<br>
> + EINVAL, "Undefined flag");<br>
> +<br>
> + /* Both MAP_SHARED and MAP_PRIVATE */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE |<br>
> + MAP_SHARED, -1, EINVAL, "MAP_ANON with both SHARED and PRIVATE");<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_SHARED, shmfd,<br>
> + EINVAL, "shm fd with both SHARED and PRIVATE");<br>
> +<br>
> + /* At least one of MAP_SHARED or MAP_PRIVATE without ANON */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, 0, shmfd, EINVAL,<br>
> + "shm fd without sharing flag");<br>
> +<br>
> + /* MAP_ANON with sharing flag. Will fail on RTEMS*/<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, EINVAL,<br>
> + "shared MAP_ANON");<br>
> + /* MAP_ANON with private flag*/<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0,<br>
> + "private MAP_ANON");<br>
> +<br>
> + /* MAP_ANON should require an fd of -1. */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, EINVAL,<br>
> + "MAP_ANON with fd != -1");<br>
> +<br>
> + /*<br>
> + * Writable MAP_SHARED should fail on read-only descriptors. Will fail<br>
> + * on RTEMS because of unimplemented mmap handler in /dev/null and the fact<br>
> + * that there is no read only protection.<br>
> + */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, zerofd, ENOTSUP,<br>
> + "MAP_SHARED of read-only /dev/zero");<br>
> +<br>
> + /*<br>
> + * Character devices other than /dev/zero do not support private<br>
> + * mappings. RTEMS cannot protect against writes so this will fail with<br>
> + * ENOTSUP<br>
> + */<br>
> + checked_mmap(PROT_READ, MAP_PRIVATE, devfd, ENOTSUP,<br>
> + "MAP_PRIVATE of test driver");<br>
> +<br>
> + /*<br>
> + * Repeat with no write protection.<br>
> + */<br>
> + checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, devfd, EINVAL,<br>
> + "MAP_PRIVATE of test driver");<br>
> +<br>
> + close(devfd);<br>
> + close(shmfd);<br>
> + close(zerofd);<br>
> +}<br>
> +<br>
> +static void mmap_dev_zero_private( void )<br>
> +{<br>
> + char *p1, *p2, *p3;<br>
> + int fd, pagesize;<br>
> + /*int i*/<br>
> +<br>
> + rtems_test_assert((pagesize = getpagesize()) > 0);<br>
> + rtems_test_assert((fd = open("/dev/zero", O_RDONLY)) >= 0);<br>
> +<br>
> + /* This should not return MAP_FAILED but does on RTEMS */<br>
> + p1 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);<br>
> + /*rtems_test_assert(p1 != MAP_FAILED);*/<br>
> + rtems_test_assert(p1 == MAP_FAILED);<br>
> +<br>
> + /* This should not return MAP_FAILED but does on RTEMS */<br>
> + p2 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);<br>
> + /*rtems_test_assert(p2 != MAP_FAILED);*/<br>
> + rtems_test_assert(p2 == MAP_FAILED);<br>
> +<br>
> + /* These tests can not run due to failures above */<br>
> + /*for (i = 0; i < pagesize; i++)<br>
> + mmap_test_assert_equal(0, p1[i], "byte at p1[%d] is %x", i, p1[i]);<br>
> +<br>
> + rtems_test_assert(memcmp(p1, p2, pagesize) == 0);<br>
> +<br>
> + p1[0] = 1;<br>
> +<br>
> + rtems_test_assert(p2[0] == 0);<br>
> +<br>
> + p2[0] = 2;<br>
> +<br>
> + rtems_test_assert(p1[0] == 1);*/<br>
> +<br>
> + /* This should not return MAP_FAILED but does on RTEMS */<br>
> + p3 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);<br>
> + /*rtems_test_assert(p3 != MAP_FAILED);*/<br>
> + rtems_test_assert(p3 == MAP_FAILED);<br>
> +<br>
> + /*rtems_test_assert(p3[0] == 0);<br>
> +<br>
> + munmap(p1, pagesize);<br>
> + munmap(p2, pagesize);<br>
> + munmap(p3, pagesize);*/<br>
> + close(fd);<br>
> +}<br>
> +<br>
> +static void mmap_dev_zero_shared( void )<br>
> +{<br>
> + char *p1, *p2, *p3;<br>
> + int fd, pagesize;<br>
> + /*int i*/<br>
> +<br>
> + rtems_test_assert((pagesize = getpagesize()) > 0);<br>
> + rtems_test_assert((fd = open("/dev/zero", O_RDWR)) >= 0);<br>
> +<br>
> + /* This should not return MAP_FAILED but does on RTEMS */<br>
> + p1 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);<br>
> + /*rtems_test_assert(p1 != MAP_FAILED);*/<br>
> + rtems_test_assert(p1 == MAP_FAILED);<br>
> +<br>
> + /* This should not return MAP_FAILED but does on RTEMS */<br>
> + p2 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);<br>
> + /*rtems_test_assert(p2 != MAP_FAILED);*/<br>
> + rtems_test_assert(p2 == MAP_FAILED);<br>
> +<br>
> + /* These tests can not run due to failures above */<br>
> + /*for (i = 0; i < pagesize; i++)<br>
> + mmap_test_assert_equal(0, p1[i], "byte at p1[%d] is %x", i, p1[i]);<br>
> +<br>
> + rtems_test_assert(memcmp(p1, p2, pagesize) == 0);<br>
> +<br>
> + p1[0] = 1;<br>
> +<br>
> + rtems_test_assert(p2[0] == 0);<br>
> +<br>
> + p2[0] = 2;<br>
> +<br>
> + rtems_test_assert(p1[0] == 1);*/<br>
> +<br>
> + p3 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);<br>
> + /*rtems_test_assert(p3 != MAP_FAILED);*/<br>
> + rtems_test_assert(p3 == MAP_FAILED);<br>
> +<br>
> + /*rtems_test_assert(p3[0] == 0);<br>
> +<br>
> + munmap(p1, pagesize);<br>
> + munmap(p2, pagesize);<br>
> + munmap(p3, pagesize);*/<br>
> + close(fd);<br>
> +}<br>
> +<br>
> +void *POSIX_Init(<br>
> + void *argument<br>
> +)<br>
> +{<br>
> + int rv;<br>
> +<br>
> + TEST_BEGIN();<br>
> +<br>
> + rv = IMFS_make_generic_node(<br>
> + &test_driver_name[0],<br>
> + S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,<br>
> + &node_control,<br>
> + NULL<br>
> + );<br>
> + rtems_test_assert(rv == 0);<br>
> +<br>
> + puts( "Init: mmap - map at zero" );<br>
> + mmap_map_at_zero();<br>
> + puts( "Init: mmap - bad arguments" );<br>
> + mmap_bad_arguments();<br>
> + /*<br>
> + * The following test does not work on RTEMS because /dev/zero is<br>
> + * implemented as a character device which does not support MAP_PRIVATE.<br>
> + */<br>
> + puts( "Init: mmap - /dev/zero private" );<br>
> + mmap_dev_zero_private();<br>
> + /*<br>
> + * The following test does not work on RTEMS because /dev/zero does not<br>
> + * implemented the mmap handler.<br>
> + */<br>
> + puts( "Init: mmap - /dev/zero shared" );<br>
> + mmap_dev_zero_shared();<br>
> +<br>
> + TEST_END();<br>
> +<br>
> + rtems_test_exit(0);<br>
> + return 0;<br>
> +}<br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/psxmmap01.scn b/testsuites/psxtests/<wbr>psxmmap01/psxmmap01.scn<br>
> new file mode 100644<br>
> index 0000000..e69de29<br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/system.h b/testsuites/psxtests/<wbr>psxmmap01/system.h<br>
> new file mode 100644<br>
> index 0000000..2241f88<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/system.h<br>
> @@ -0,0 +1,31 @@<br>
> +/*<br>
> + * Copyright (c) 2017 Kevin Kirspel.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/<wbr>LICENSE</a>.<br>
> + */<br>
> +<br>
> +#include <pmacros.h><br>
> +#include <unistd.h><br>
> +#include <errno.h><br>
> +<br>
> +void *POSIX_Init(<br>
> + void *argument<br>
> +);<br>
> +<br>
> +#define CONFIGURE_APPLICATION_NEEDS_<wbr>CLOCK_DRIVER<br>
> +#define CONFIGURE_APPLICATION_NEEDS_<wbr>CONSOLE_DRIVER<br>
> +#define CONFIGURE_APPLICATION_NEEDS_<wbr>ZERO_DRIVER<br>
> +#define CONFIGURE_APPLICATION_NEEDS_<wbr>STUB_DRIVER<br>
> +<br>
> +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION<br>
> +<br>
> +#define CONFIGURE_MAXIMUM_POSIX_<wbr>THREADS 1<br>
> +#define CONFIGURE_LIBIO_MAXIMUM_FILE_<wbr>DESCRIPTORS 10<br>
> +#define CONFIGURE_MAXIMUM_POSIX_SHMS 1<br>
> +#define CONFIGURE_MEMORY_OVERHEAD 10<br>
> +<br>
> +#define CONFIGURE_POSIX_INIT_THREAD_<wbr>TABLE<br>
> +<br>
> +#include <rtems/confdefs.h><br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/test_driver.c b/testsuites/psxtests/<wbr>psxmmap01/test_driver.c<br>
> new file mode 100644<br>
> index 0000000..87719b9<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/test_driver.c<br>
> @@ -0,0 +1,67 @@<br>
> +/*<br>
> + * Copyright (c) 2017 Kevin Kirspel.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/<wbr>LICENSE</a>.<br>
> + */<br>
> +<br>
> +#ifdef HAVE_CONFIG_H<br>
> +#include "config.h"<br>
> +#endif<br>
> +<br>
> +#include "test_driver.h"<br>
> +<br>
> +#include <rtems/libio.h><br>
> +<br>
> +char test_data[PAGE_SIZE];<br>
> +<br>
> +static int handler_fstat(<br>
> + const rtems_filesystem_location_<wbr>info_t *loc,<br>
> + struct stat *buf<br>
> +)<br>
> +{<br>
> + buf->st_mode = S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO;<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static ssize_t handler_mmap(<br>
> + rtems_libio_t *iop,<br>
> + void **addr,<br>
> + size_t len,<br>
> + int prot,<br>
> + off_t off<br>
> +)<br>
> +{<br>
> + if ( len <= sizeof(test_data) ) {<br>
> + *addr = test_data;<br>
> + } else {<br>
> + *addr = NULL;<br>
> + }<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static const rtems_filesystem_file_<wbr>handlers_r node_handlers = {<br>
> + .open_h = rtems_filesystem_default_open,<br>
> + .close_h = rtems_filesystem_default_<wbr>close,<br>
> + .read_h = rtems_filesystem_default_read,<br>
> + .write_h = rtems_filesystem_default_<wbr>write,<br>
> + .ioctl_h = rtems_filesystem_default_<wbr>ioctl,<br>
> + .lseek_h = rtems_filesystem_default_<wbr>lseek,<br>
> + .fstat_h = handler_fstat,<br>
> + .ftruncate_h = rtems_filesystem_default_<wbr>ftruncate,<br>
> + .fsync_h = rtems_filesystem_default_<wbr>fsync_or_fdatasync,<br>
> + .fdatasync_h = rtems_filesystem_default_<wbr>fsync_or_fdatasync,<br>
> + .fcntl_h = rtems_filesystem_default_<wbr>fcntl,<br>
> + .poll_h = rtems_filesystem_default_poll,<br>
> + .kqfilter_h = rtems_filesystem_default_<wbr>kqfilter,<br>
> + .mmap_h = handler_mmap,<br>
> + .readv_h = rtems_filesystem_default_<wbr>readv,<br>
> + .writev_h = rtems_filesystem_default_<wbr>writev<br>
> +};<br>
> +<br>
> +const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(<br>
> + &node_handlers,<br>
> + IMFS_node_initialize_default,<br>
> + IMFS_node_destroy_default<br>
> +);<br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/test_driver.h b/testsuites/psxtests/<wbr>psxmmap01/test_driver.h<br>
> new file mode 100644<br>
> index 0000000..5afdb9b<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/test_driver.h<br>
> @@ -0,0 +1,14 @@<br>
> +/*<br>
> + * Copyright (c) 2017 Kevin Kirspel.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/<wbr>LICENSE</a>.<br>
> + */<br>
> +<br>
> +#include <rtems.h><br>
> +#include <rtems/imfs.h><br>
> +#include <rtems/libcsupport.h><br>
> +<br>
> +extern const IMFS_node_control node_control;<br>
> +extern char test_data[PAGE_SIZE];<br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/test_helper.c b/testsuites/psxtests/<wbr>psxmmap01/test_helper.c<br>
> new file mode 100644<br>
> index 0000000..cab8e91<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/test_helper.c<br>
> @@ -0,0 +1,32 @@<br>
> +/*<br>
> + * Copyright (c) 2017 Kevin Kirspel.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/<wbr>LICENSE</a>.<br>
> + */<br>
> +<br>
> +#ifdef HAVE_CONFIG_H<br>
> +#include "config.h"<br>
> +#endif<br>
> +<br>
> +#include "test_helper.h"<br>
> +<br>
> +#include <stdio.h><br>
> +#include <stdarg.h><br>
> +<br>
> +void fail_check(<br>
> + const char *file,<br>
> + const size_t line,<br>
> + const char *fmt,<br>
> + ...<br>
> +)<br>
> +{<br>
> + va_list ap;<br>
> +<br>
> + printf( "%s: %d: ", file, line );<br>
> +<br>
> + va_start(ap, fmt);<br>
> + vprintf(fmt, ap);<br>
> + va_end(ap);<br>
> +}<br>
> diff --git a/testsuites/psxtests/<wbr>psxmmap01/test_helper.h b/testsuites/psxtests/<wbr>psxmmap01/test_helper.h<br>
> new file mode 100644<br>
> index 0000000..65ca3c1<br>
> --- /dev/null<br>
> +++ b/testsuites/psxtests/<wbr>psxmmap01/test_helper.h<br>
> @@ -0,0 +1,41 @@<br>
> +/*<br>
> + * Copyright (c) 2017 Kevin Kirspel.<br>
> + *<br>
> + * The license and distribution terms for this file may be<br>
> + * found in the file LICENSE in this distribution or at<br>
> + * <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer" target="_blank">http://www.rtems.org/license/<wbr>LICENSE</a>.<br>
> + */<br>
> +<br>
> +#include <string.h><br>
> +<br>
> +#define mmap_test_assert(__exp, fmt, ...) \<br>
> + do { \<br>
> + if (!(__exp)) { \<br>
> + fail_check(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \<br>
> + rtems_test_exit(0); \<br>
> + } \<br>
> + } while (0)<br>
> +<br>
> +#define mmap_test_check(__exp, fmt, ...) \<br>
> + do { \<br>
> + if (!(__exp)) { \<br>
> + fail_check(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \<br>
> + } else { \<br>
> + rtems_test_assert(__exp); \<br>
> + }\<br>
> + } while (0)<br>
> +<br>
> +#define mmap_test_assert_equal(<wbr>expected, actual, fmt, ...) \<br>
> + mmap_test_assert((expected) == (actual), "%s != %s: " fmt, \<br>
> + #expected, #actual, ##__VA_ARGS__)<br>
> +<br>
> +#define mmap_test_check_equal(<wbr>expected, actual, fmt, ...) \<br>
> + mmap_test_check((expected) == (actual), "%s != %s: " fmt, \<br>
> + #expected, #actual, ##__VA_ARGS__)<br>
> +<br>
> +extern void fail_check(<br>
> + const char *file,<br>
> + const size_t line,<br>
> + const char *fmt,<br>
> + ...<br>
> +);<br>
> --<br>
> 1.9.1<br>
><br>
> ______________________________<wbr>_________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
______________________________<wbr>_________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
</blockquote></div></div>