mirror of
https://github.com/drasko/codezero.git
synced 2026-03-10 06:13:15 +01:00
Added posix code
This commit is contained in:
59
conts/posix/test0/src/clonetest.c
Normal file
59
conts/posix/test0/src/clonetest.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Clone test.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <tests.h>
|
||||
|
||||
int clone_global = 0;
|
||||
|
||||
extern pid_t parent_of_all;
|
||||
|
||||
int my_thread_func(void *arg)
|
||||
{
|
||||
for (int i = 0; i < 25; i++)
|
||||
clone_global++;
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
int clonetest(void)
|
||||
{
|
||||
pid_t childid;
|
||||
void *child_stack;
|
||||
|
||||
/* Parent loops and calls clone() to clone new threads. Children don't come back from the clone() call */
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if ((child_stack = mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, 0, 0)) == MAP_FAILED) {
|
||||
test_printf("MMAP failed.\n");
|
||||
goto out_err;
|
||||
} else {
|
||||
test_printf("Mapped area starting at %p\n", child_stack);
|
||||
}
|
||||
((int *)child_stack)[-1] = 5; /* Test mapped area */
|
||||
|
||||
test_printf("Cloning...\n");
|
||||
|
||||
if ((childid = clone(my_thread_func, child_stack,
|
||||
CLONE_PARENT | CLONE_FS | CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, 0)) < 0) {
|
||||
test_printf("CLONE failed.\n");
|
||||
goto out_err;
|
||||
} else {
|
||||
test_printf("Cloned a new thread with child pid %d\n", childid);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Add wait() or something similar and check that global is 100 */
|
||||
|
||||
if (getpid() == parent_of_all)
|
||||
printf("CLONE TEST -- PASSED --\n");
|
||||
|
||||
return 0;
|
||||
out_err:
|
||||
printf("CLONE TEST -- FAILED --\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
94
conts/posix/test0/src/crt0.S
Normal file
94
conts/posix/test0/src/crt0.S
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Australian Public Licence B (OZPLB)
|
||||
*
|
||||
* Version 1-0
|
||||
*
|
||||
* Copyright (c) 2004 National ICT Australia
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
|
||||
* National ICT Australia
|
||||
* http://www.ertos.nicta.com.au
|
||||
*
|
||||
* Permission is granted by National ICT Australia, free of charge, to
|
||||
* any person obtaining a copy of this software and any associated
|
||||
* documentation files (the "Software") to deal with the Software without
|
||||
* restriction, including (without limitation) the rights to use, copy,
|
||||
* modify, adapt, merge, publish, distribute, communicate to the public,
|
||||
* sublicense, and/or sell, lend or rent out copies of the Software, and
|
||||
* to permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimers.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimers in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* * Neither the name of National ICT Australia, nor the names of its
|
||||
* contributors, may be used to endorse or promote products derived
|
||||
* from this Software without specific prior written permission.
|
||||
*
|
||||
* EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
|
||||
* PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
|
||||
* NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
|
||||
* REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
|
||||
* THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
|
||||
* ERRORS, WHETHER OR NOT DISCOVERABLE.
|
||||
*
|
||||
* TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
|
||||
* NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
|
||||
* THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
|
||||
* LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
|
||||
* OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
|
||||
* OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
|
||||
* OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
|
||||
* CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
|
||||
* CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
|
||||
* DAMAGES OR OTHER LIABILITY.
|
||||
*
|
||||
* If applicable legislation implies representations, warranties, or
|
||||
* conditions, or imposes obligations or liability on National ICT
|
||||
* Australia or one of its contributors in respect of the Software that
|
||||
* cannot be wholly or partly excluded, restricted or modified, the
|
||||
* liability of National ICT Australia or the contributor is limited, to
|
||||
* the full extent permitted by the applicable legislation, at its
|
||||
* option, to:
|
||||
* a. in the case of goods, any one or more of the following:
|
||||
* i. the replacement of the goods or the supply of equivalent goods;
|
||||
* ii. the repair of the goods;
|
||||
* iii. the payment of the cost of replacing the goods or of acquiring
|
||||
* equivalent goods;
|
||||
* iv. the payment of the cost of having the goods repaired; or
|
||||
* b. in the case of services:
|
||||
* i. the supplying of the services again; or
|
||||
* ii. the payment of the cost of having the services supplied again.
|
||||
*
|
||||
* The construction, validity and performance of this licence is governed
|
||||
* by the laws in force in New South Wales, Australia.
|
||||
*/
|
||||
|
||||
#ifdef __thumb__
|
||||
#define bl blx
|
||||
#endif
|
||||
|
||||
.section .text.head
|
||||
.code 32
|
||||
.global _start;
|
||||
.align;
|
||||
_start:
|
||||
ldr sp, =__stack
|
||||
bl platform_init
|
||||
bl __container_init
|
||||
1:
|
||||
b 1b
|
||||
|
||||
210
conts/posix/test0/src/dirtest.c
Normal file
210
conts/posix/test0/src/dirtest.c
Normal file
@@ -0,0 +1,210 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <dirent.h>
|
||||
#include <l4lib/os/posix/readdir.h>
|
||||
#include <tests.h>
|
||||
|
||||
#define DENTS_TOTAL 50
|
||||
|
||||
void print_fsize(struct stat *s)
|
||||
{
|
||||
printf("%lu", s->st_size);
|
||||
}
|
||||
|
||||
void print_flink(struct stat *s)
|
||||
{
|
||||
printf("%d", s->st_nlink);
|
||||
}
|
||||
|
||||
void print_fuser(struct stat *s)
|
||||
{
|
||||
printf("%d", s->st_uid);
|
||||
printf("%c", ' ');
|
||||
printf("%c", ' ');
|
||||
printf("%d", s->st_gid);
|
||||
}
|
||||
|
||||
void print_ftype(struct stat *s)
|
||||
{
|
||||
unsigned int type = s->st_mode & S_IFMT;
|
||||
|
||||
if (type == S_IFDIR)
|
||||
printf("%c", 'd');
|
||||
else if (type == S_IFSOCK)
|
||||
printf("%c", 's');
|
||||
else if (type == S_IFCHR)
|
||||
printf("%c", 'c');
|
||||
else if (type == S_IFLNK)
|
||||
printf("%c", 'l');
|
||||
else if (type == S_IFREG)
|
||||
printf("%c", '-');
|
||||
}
|
||||
|
||||
void print_fperm(struct stat *s)
|
||||
{
|
||||
if (s->st_mode & S_IRUSR)
|
||||
printf("%c", 'r');
|
||||
else
|
||||
printf("%c", '-');
|
||||
if (s->st_mode & S_IWUSR)
|
||||
printf("%c", 'w');
|
||||
else
|
||||
printf("%c", '-');
|
||||
if (s->st_mode & S_IXUSR)
|
||||
printf("%c", 'x');
|
||||
else
|
||||
printf("%c", '-');
|
||||
}
|
||||
|
||||
void print_fstat(struct stat *s)
|
||||
{
|
||||
print_ftype(s);
|
||||
print_fperm(s);
|
||||
printf("%c", ' ');
|
||||
printf("%c", ' ');
|
||||
print_fsize(s);
|
||||
printf("%c", ' ');
|
||||
}
|
||||
|
||||
void print_dirents(char *path, void *buf, int cnt)
|
||||
{
|
||||
int i = 0;
|
||||
struct dirent *dp = buf;
|
||||
// struct stat statbuf;
|
||||
char pathbuf[256];
|
||||
|
||||
strncpy(pathbuf, path, 256);
|
||||
while (cnt > 0) {
|
||||
strcpy(pathbuf, path);
|
||||
strcpy(&pathbuf[strlen(pathbuf)],"/");
|
||||
strcpy(&pathbuf[strlen(pathbuf)],dp->d_name);
|
||||
//printf("Dirent %d:\n", i);
|
||||
//printf("Inode: %d\n", dp->d_ino);
|
||||
//printf("Offset: %d\n", dp->d_off);
|
||||
//printf("Reclen: %d\n", dp->d_reclen);
|
||||
//if (stat(pathbuf, &statbuf) < 0)
|
||||
// perror("STAT");
|
||||
// print_fstat(&statbuf);
|
||||
test_printf("%s\n", dp->d_name);
|
||||
cnt -= dp->d_reclen;
|
||||
dp = (struct dirent *)((void *)dp + dp->d_reclen);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
int lsdir(char *path)
|
||||
{
|
||||
struct dirent dents[DENTS_TOTAL];
|
||||
int bytes;
|
||||
int fd;
|
||||
|
||||
memset(dents, 0, sizeof(struct dirent) * DENTS_TOTAL);
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) < 0) {
|
||||
test_printf("OPEN failed.\n");
|
||||
return -1;
|
||||
} else
|
||||
test_printf("Got fd: %d for opening %s\n", fd, path);
|
||||
|
||||
if ((bytes = os_readdir(fd, dents, sizeof(struct dirent) * DENTS_TOTAL)) < 0) {
|
||||
test_printf("GETDENTS error: %d\n", bytes);
|
||||
return -1;
|
||||
} else {
|
||||
print_dirents(path, dents, bytes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dirtest(void)
|
||||
{
|
||||
if (lsdir(".") < 0) {
|
||||
test_printf("lsdir failed.\n");
|
||||
goto out_err;
|
||||
}
|
||||
if (lsdir("/") < 0) {
|
||||
test_printf("lsdir failed.\n");
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
test_printf("\nCreating directories: usr, etc, tmp, var, home, opt, bin, boot, lib, dev\n");
|
||||
if (mkdir("/usr", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/etc", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/tmp", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/var", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/bin", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/boot", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/lib", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/dev", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/usr/bin", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/home/", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (mkdir("/home/bahadir", 0) < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (chdir("/home/bahadir") < 0) {
|
||||
test_printf("MKDIR: %d\n", errno);
|
||||
goto out_err;
|
||||
}
|
||||
test_printf("Changed curdir to /home/bahadir\n");
|
||||
|
||||
test_printf("\nlsdir root directory:\n");
|
||||
if (lsdir("/") < 0)
|
||||
goto out_err;
|
||||
|
||||
test_printf("\nlsdir /usr:\n");
|
||||
if (lsdir("/usr") < 0)
|
||||
goto out_err;
|
||||
|
||||
test_printf("\nlsdir current directory:\n");
|
||||
if (lsdir(".") < 0)
|
||||
goto out_err;
|
||||
test_printf("\nlsdir /usr/./././bin//\n");
|
||||
if (lsdir("/usr/./././bin//") < 0)
|
||||
goto out_err;
|
||||
|
||||
printf("DIR TEST -- PASSED --\n");
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
printf("DIR TEST -- FAILED --\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
76
conts/posix/test0/src/exectest.c
Normal file
76
conts/posix/test0/src/exectest.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Execve test.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <tests.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern char _start_test_exec[];
|
||||
extern char _end_test_exec[];
|
||||
|
||||
int exectest(void)
|
||||
{
|
||||
int fd, err;
|
||||
void *exec_start = (void *)_start_test_exec;
|
||||
unsigned long size = _end_test_exec - _start_test_exec;
|
||||
int left, cnt;
|
||||
char *argv[5];
|
||||
char filename[128];
|
||||
|
||||
memset(filename, 0, 128);
|
||||
sprintf(filename, "/home/bahadir/execfile%d", getpid());
|
||||
|
||||
/* First create a new file and write the executable data to that file */
|
||||
if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
|
||||
err = errno;
|
||||
test_printf("OPEN: %d, for %s\n", errno, filename);
|
||||
/* If it is a minor error like EEXIST, create one with different name */
|
||||
if (errno == EEXIST) {
|
||||
sprintf(filename, "/home/bahadir/execfile%d-2",
|
||||
getpid());
|
||||
if ((fd = open(filename,
|
||||
O_RDWR | O_CREAT | O_TRUNC, S_IRWXU))
|
||||
< 0) {
|
||||
printf("OPEN: %d, failed twice, "
|
||||
"last time for %s\n",
|
||||
errno, filename);
|
||||
goto out_err;
|
||||
}
|
||||
} else
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
left = size;
|
||||
test_printf("Writing %d bytes to %s\n", left, filename);
|
||||
while (left != 0) {
|
||||
if ((cnt = write(fd, exec_start, left)) < 0)
|
||||
goto out_err;
|
||||
left -= cnt;
|
||||
}
|
||||
|
||||
if ((err = close(fd)) < 0) {
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
/* Set up some arguments */
|
||||
argv[0] = "FIRST ARG";
|
||||
argv[1] = "SECOND ARG";
|
||||
argv[2] = "THIRD ARG";
|
||||
argv[3] = "FOURTH ARG";
|
||||
argv[4] = 0;
|
||||
|
||||
/* Execute the file */
|
||||
err = execve(filename, argv, 0);
|
||||
|
||||
out_err:
|
||||
printf("EXECVE failed with %d\n", err);
|
||||
printf("EXECVE TEST -- FAILED --\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
92
conts/posix/test0/src/fileio.c
Normal file
92
conts/posix/test0/src/fileio.c
Normal file
@@ -0,0 +1,92 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <tests.h>
|
||||
#include <errno.h>
|
||||
|
||||
int fileio(void)
|
||||
{
|
||||
int fd;
|
||||
ssize_t cnt;
|
||||
int err;
|
||||
char buf[128];
|
||||
off_t offset;
|
||||
int tid = getpid();
|
||||
char *str = "I WROTE TO THIS FILE\n";
|
||||
char filename[128];
|
||||
|
||||
memset(buf, 0, 128);
|
||||
memset(filename, 0, 128);
|
||||
sprintf(filename, "/home/bahadir/newfile%d.txt", tid);
|
||||
if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) {
|
||||
test_printf("OPEN: %d", errno);
|
||||
goto out_err;
|
||||
}
|
||||
test_printf("%d: Created %s\n", tid, filename);
|
||||
|
||||
test_printf("%d: write.\n", tid);
|
||||
if ((int)(cnt = write(fd, str, strlen(str))) < 0) {
|
||||
test_printf("WRITE: %d", errno);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
test_printf("%d: lseek.\n", tid);
|
||||
if ((int)(offset = lseek(fd, 0, SEEK_SET)) < 0) {
|
||||
test_printf("LSEEK: %d", errno);
|
||||
goto out_err;
|
||||
}
|
||||
test_printf("%d: read.\n", tid);
|
||||
if ((int)(cnt = read(fd, buf, strlen(str))) < 0) {
|
||||
test_printf("READ: %d", errno);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
test_printf("%d: Read: %d bytes from file.\n", tid, cnt);
|
||||
if (cnt) {
|
||||
test_printf("%d: Read string: %s\n", tid, buf);
|
||||
if (strcmp(buf, str)) {
|
||||
test_printf("Strings not the same:\n");
|
||||
test_printf("Str: %s\n", str);
|
||||
test_printf("Buf: %s\n", buf);
|
||||
goto out_err;
|
||||
}
|
||||
}
|
||||
|
||||
if ((err = close(fd)) < 0) {
|
||||
test_printf("CLOSE: %d", errno);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if (getpid() == parent_of_all)
|
||||
printf("FILE IO TEST -- PASSED --\n");
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
printf("FILE IO TEST -- FAILED --\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(HOST_TESTS)
|
||||
int main(void)
|
||||
{
|
||||
test_printf("File IO test 1:\n");
|
||||
if (fileio() == 0)
|
||||
test_printf("-- PASSED --\n");
|
||||
else
|
||||
test_printf("-- FAILED --\n");
|
||||
|
||||
test_printf("File IO test 2:\n");
|
||||
if (fileio2() == 0)
|
||||
test_printf("-- PASSED --\n");
|
||||
else
|
||||
test_printf("-- FAILED --\n");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
55
conts/posix/test0/src/forktest.c
Normal file
55
conts/posix/test0/src/forktest.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Fork test.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <tests.h>
|
||||
#include <l4/macros.h>
|
||||
|
||||
int global = 0;
|
||||
|
||||
|
||||
int forktest(void)
|
||||
{
|
||||
pid_t myid;
|
||||
|
||||
|
||||
/* 16 forks */
|
||||
for (int i = 0; i < 4; i++) {
|
||||
test_printf("%d: Forking...\n", getpid());
|
||||
if (fork() < 0)
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
myid = getpid();
|
||||
|
||||
if (global != 0) {
|
||||
test_printf("Global not zero.\n");
|
||||
test_printf("-- FAILED --\n");
|
||||
goto out_err;
|
||||
}
|
||||
global += myid;
|
||||
|
||||
if (global != myid)
|
||||
goto out_err;
|
||||
|
||||
|
||||
if (getpid() != parent_of_all) {
|
||||
/* Exit here to exit successful children */
|
||||
//_exit(0);
|
||||
//BUG();
|
||||
}
|
||||
|
||||
if (getpid() == parent_of_all)
|
||||
printf("FORK TEST -- PASSED --\n");
|
||||
|
||||
return 0;
|
||||
|
||||
/* Any erroneous child or parent comes here */
|
||||
out_err:
|
||||
printf("FORK TEST -- FAILED --\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
152
conts/posix/test0/src/ipctest.c
Normal file
152
conts/posix/test0/src/ipctest.c
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Tests for more complex ipc such as full and extended
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
#include <l4lib/arch/syslib.h>
|
||||
#include <l4lib/ipcdefs.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <tests.h>
|
||||
|
||||
/*
|
||||
* Full ipc test. Sends/receives full utcb, done with the pager.
|
||||
*/
|
||||
void ipc_full_test(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* Fill in all of the utcb locations */
|
||||
for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) {
|
||||
//printf("Writing: MR%d: %d\n", i, i);
|
||||
write_mr(i, i);
|
||||
}
|
||||
|
||||
/* Call the pager */
|
||||
if ((ret = l4_sendrecv_full(PAGER_TID, PAGER_TID,
|
||||
L4_IPC_TAG_SYNC_FULL)) < 0) {
|
||||
printf("%s: Failed with %d\n", __FUNCTION__, ret);
|
||||
BUG();
|
||||
}
|
||||
/* Read back updated utcb */
|
||||
for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) {
|
||||
//printf("Read MR%d: %d\n", i, read_mr(i));
|
||||
if (read_mr(i) != 0) {
|
||||
printf("Expected 0 on all mrs. Failed.\n");
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
printf("FULL IPC TEST: -- PASSED --\n");
|
||||
else
|
||||
printf("FULL IPC TEST: -- FAILED --\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* This is an extended ipc test that is done between 2 tasks that fork.
|
||||
*/
|
||||
void ipc_extended_test(void)
|
||||
{
|
||||
pid_t child, parent;
|
||||
void *base;
|
||||
char *ipcbuf;
|
||||
int err;
|
||||
|
||||
/* Get parent pid */
|
||||
parent = getpid();
|
||||
|
||||
/* Fork the current task */
|
||||
if ((child = fork()) < 0) {
|
||||
test_printf("%s: Fork failed with %d\n", __FUNCTION__, errno);
|
||||
goto out_err;
|
||||
}
|
||||
if (child)
|
||||
test_printf("%d: Created child with pid %d\n", getpid(), child);
|
||||
else
|
||||
test_printf("Child %d running.\n", getpid());
|
||||
|
||||
/* This test makes this assumption */
|
||||
BUG_ON(L4_IPC_EXTENDED_MAX_SIZE > PAGE_SIZE);
|
||||
|
||||
/*
|
||||
* Both child and parent gets 2 pages
|
||||
* of privately mapped anonymous memory
|
||||
*/
|
||||
if ((int)(base = mmap(0, PAGE_SIZE*2, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0)) < 0) {
|
||||
printf("%s: mmap for extended ipc buffer failed: %d\n",
|
||||
__FUNCTION__, (int)base);
|
||||
goto out_err;
|
||||
} else
|
||||
test_printf("%s: mmap: Anonymous private buffer at %p\n",
|
||||
__FUNCTION__, base);
|
||||
|
||||
/*
|
||||
* Both tasks read/write both pages
|
||||
* across the page boundary for messages
|
||||
*/
|
||||
ipcbuf = base + PAGE_SIZE - L4_IPC_EXTENDED_MAX_SIZE / 2;
|
||||
|
||||
/* Child sending message */
|
||||
if (child == 0) {
|
||||
/* Child creates a string of maximum extended ipc size */
|
||||
for (int i = 0; i < L4_IPC_EXTENDED_MAX_SIZE; i++) {
|
||||
ipcbuf[i] = 'A' + i % 20;
|
||||
}
|
||||
/* Finish string with newline and null pointer */
|
||||
ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 2] = '\n';
|
||||
ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 1] = '\0';
|
||||
|
||||
/* Send message to parent */
|
||||
test_printf("Child sending message: %s\n", ipcbuf);
|
||||
if ((err = l4_send_extended(parent, L4_IPC_TAG_SYNC_EXTENDED,
|
||||
L4_IPC_EXTENDED_MAX_SIZE,
|
||||
ipcbuf)) < 0) {
|
||||
printf("Extended ipc error: %d\n", err);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
/* Parent receiving message */
|
||||
} else {
|
||||
/*
|
||||
* Parent receives on the buffer - we are sure that the
|
||||
* buffer is not paged in because we did not touch it.
|
||||
* This should prove that page faults are handled during
|
||||
* the ipc.
|
||||
*/
|
||||
test_printf("Parent: extended receiving from child.\n");
|
||||
if ((err = l4_receive_extended(child, L4_IPC_EXTENDED_MAX_SIZE,
|
||||
ipcbuf)) < 0) {
|
||||
printf("Extended ipc error: %d\n", err);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
/* We now print the message created by child. */
|
||||
test_printf("(%d): Message received from child: %s\n",
|
||||
getpid(), ipcbuf);
|
||||
|
||||
/* Check that string received from child is an exact match */
|
||||
for (int i = 0; i < L4_IPC_EXTENDED_MAX_SIZE - 2; i++) {
|
||||
if (ipcbuf[i] != ('A' + i % 20))
|
||||
goto out_err;
|
||||
}
|
||||
if (ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 2] != '\n')
|
||||
goto out_err;
|
||||
if (ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 1] != '\0')
|
||||
goto out_err;
|
||||
|
||||
printf("EXTENDED IPC TEST: -- PASSED --\n");
|
||||
}
|
||||
return;
|
||||
|
||||
out_err:
|
||||
printf("EXTENDED IPC TEST: -- FAILED --\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
56
conts/posix/test0/src/mmaptest.c
Normal file
56
conts/posix/test0/src/mmaptest.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Test mmap/munmap posix calls.
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Bahadir Balban
|
||||
*/
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <tests.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
|
||||
int mmaptest(void)
|
||||
{
|
||||
int fd;
|
||||
void *base;
|
||||
int x = 0x1000;
|
||||
|
||||
if ((fd = open("./mmapfile.txt", O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) < 0)
|
||||
goto out_err;
|
||||
|
||||
/* Extend the file */
|
||||
if ((int)lseek(fd, PAGE_SIZE*16, SEEK_SET) < 0)
|
||||
goto out_err;
|
||||
|
||||
if (write(fd, &x, sizeof(x)) < 0)
|
||||
goto out_err;
|
||||
|
||||
if ((int)(base = mmap(0, PAGE_SIZE*16, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) < 0)
|
||||
goto out_err;
|
||||
|
||||
*(unsigned int *)(base + PAGE_SIZE*2) = 0x1000;
|
||||
if (msync(base + PAGE_SIZE*2, PAGE_SIZE, MS_SYNC) < 0)
|
||||
goto out_err;
|
||||
|
||||
if (munmap(base + PAGE_SIZE*2, PAGE_SIZE) < 0)
|
||||
goto out_err;
|
||||
|
||||
*(unsigned int *)(base + PAGE_SIZE*3) = 0x1000;
|
||||
*(unsigned int *)(base + PAGE_SIZE*1) = 0x1000;
|
||||
|
||||
printf("MMAP TEST -- PASSED --\n");
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
printf("MMAP TEST -- FAILED --\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
60
conts/posix/test0/src/mmaptest.c.orig
Normal file
60
conts/posix/test0/src/mmaptest.c.orig
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Test mmap/munmap posix calls.
|
||||
*
|
||||
* Copyright (C) 2007 - 2008 Bahadir Balban
|
||||
*/
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <tests.h>
|
||||
|
||||
#define PAGE_SIZE 0x1000
|
||||
|
||||
int mmaptest(void)
|
||||
{
|
||||
int fd;
|
||||
void *base;
|
||||
int x = 0x1000;
|
||||
|
||||
if ((fd = open("./newfile.txt", O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) < 0)
|
||||
perror("open:");
|
||||
else
|
||||
printf("open: Success.\n");
|
||||
|
||||
/* Extend the file */
|
||||
if ((int)lseek(fd, PAGE_SIZE*16, SEEK_SET) < 0)
|
||||
perror("lseek");
|
||||
else
|
||||
printf("lseek: Success.\n");
|
||||
|
||||
if (write(fd, &x, sizeof(x)) < 0)
|
||||
perror("write");
|
||||
else
|
||||
printf("write: Success.\n");
|
||||
|
||||
if ((int)(base = mmap(0, PAGE_SIZE*16, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) < 0)
|
||||
perror("mmap");
|
||||
else
|
||||
printf("mmap: Success: %p\n", base);
|
||||
|
||||
*(unsigned int *)(base + PAGE_SIZE*2) = 0x1000;
|
||||
if (msync(base + PAGE_SIZE*2, PAGE_SIZE, MS_SYNC) < 0)
|
||||
perror("msync");
|
||||
else
|
||||
printf("msync: Success: %p\n", base);
|
||||
|
||||
if (munmap(base + PAGE_SIZE*2, PAGE_SIZE) < 0)
|
||||
perror("munmap");
|
||||
else
|
||||
printf("munmap: Success: %p\n", base);
|
||||
*(unsigned int *)(base + PAGE_SIZE*3) = 0x1000;
|
||||
*(unsigned int *)(base + PAGE_SIZE*1) = 0x1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
162
conts/posix/test0/src/mutextest.c
Normal file
162
conts/posix/test0/src/mutextest.c
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Tests for userspace mutexes
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
#include <l4lib/arch/syslib.h>
|
||||
#include <l4lib/ipcdefs.h>
|
||||
#include <l4lib/mutex.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <tests.h>
|
||||
|
||||
/*
|
||||
* This structure is placed at the head of shared memory.
|
||||
* Tasks lock and write to rest of the page. Indicate that
|
||||
* they have run, and the later running task tests that both
|
||||
* processes has run and no data corruption occured on page_rest.
|
||||
*/
|
||||
struct shared_page {
|
||||
struct l4_mutex mutex;
|
||||
int shared_var;
|
||||
};
|
||||
|
||||
static struct shared_page *shared_page;
|
||||
|
||||
/*
|
||||
* This test forks a parent task, creates a shared memory mapping, and makes two tasks
|
||||
* lock and write to almost the whole page 10 times with different values, and makes
|
||||
* the tasks test that the writes are all there without any wrong values. The amount of
|
||||
* time spent should justify a context switch and demonstrate that lock protects the
|
||||
* region.
|
||||
*/
|
||||
int user_mutex_test(void)
|
||||
{
|
||||
pid_t child, parent;
|
||||
int map_size = PAGE_SIZE;
|
||||
void *base;
|
||||
|
||||
/* Get parent pid */
|
||||
parent = getpid();
|
||||
|
||||
|
||||
/*
|
||||
* Create a shared anonymous memory region. This can be
|
||||
* accessed by both parent and child after a fork.
|
||||
*/
|
||||
if ((int)(base = mmap(0, map_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_ANONYMOUS, 0, 0)) < 0) {
|
||||
printf("%s: mmap for extended ipc buffer failed: %d\n",
|
||||
__FUNCTION__, (int)base);
|
||||
goto out_err;
|
||||
} else
|
||||
test_printf("mmap: Anonymous shared buffer at %p\n", base);
|
||||
|
||||
shared_page = base;
|
||||
|
||||
/* Initialize the mutex */
|
||||
l4_mutex_init(&shared_page->mutex);
|
||||
|
||||
/* Initialize the shared variable */
|
||||
shared_page->shared_var = 0;
|
||||
|
||||
/* Fork the current task */
|
||||
if ((child = fork()) < 0) {
|
||||
test_printf("%s: Fork failed with %d\n", __FUNCTION__, errno);
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if (child)
|
||||
test_printf("%d: Created child with pid %d\n", getpid(), child);
|
||||
else
|
||||
test_printf("Child %d running.\n", getpid());
|
||||
|
||||
/* Child locks and produces */
|
||||
if (child == 0) {
|
||||
|
||||
for (int x = 0; x < 2000; x++) {
|
||||
int temp;
|
||||
|
||||
/* Lock page */
|
||||
test_printf("Child locking page.\n");
|
||||
l4_mutex_lock(&shared_page->mutex);
|
||||
|
||||
/* Read variable */
|
||||
test_printf("Child locked page.\n");
|
||||
temp = shared_page->shared_var;
|
||||
|
||||
/* Update local copy */
|
||||
temp++;
|
||||
|
||||
/* Thread switch */
|
||||
l4_thread_switch(0);
|
||||
|
||||
/* Write back the result */
|
||||
shared_page->shared_var = temp;
|
||||
|
||||
test_printf("Child modified. Unlocking...\n");
|
||||
|
||||
/* Unlock */
|
||||
l4_mutex_unlock(&shared_page->mutex);
|
||||
test_printf("Child unlocked page.\n");
|
||||
|
||||
/* Thread switch */
|
||||
l4_thread_switch(0);
|
||||
|
||||
}
|
||||
/* Sync with the parent */
|
||||
l4_send(parent, L4_IPC_TAG_SYNC);
|
||||
|
||||
/* Parent locks and consumes */
|
||||
} else {
|
||||
for (int x = 0; x < 2000; x++) {
|
||||
int temp;
|
||||
|
||||
/* Lock page */
|
||||
test_printf("Parent locking page.\n");
|
||||
l4_mutex_lock(&shared_page->mutex);
|
||||
|
||||
/* Read variable */
|
||||
test_printf("Parent locked page.\n");
|
||||
temp = shared_page->shared_var;
|
||||
|
||||
/* Update local copy */
|
||||
temp--;
|
||||
|
||||
/* Thread switch */
|
||||
l4_thread_switch(0);
|
||||
|
||||
/* Write back the result */
|
||||
shared_page->shared_var = temp;
|
||||
|
||||
test_printf("Parent modified. Unlocking...\n");
|
||||
|
||||
/* Unlock */
|
||||
l4_mutex_unlock(&shared_page->mutex);
|
||||
test_printf("Parent unlocked page.\n");
|
||||
|
||||
/* Thread switch */
|
||||
l4_thread_switch(0);
|
||||
}
|
||||
/* Sync with the child */
|
||||
l4_receive(child);
|
||||
|
||||
test_printf("Parent checking validity of value.\n");
|
||||
if (shared_page->shared_var != 0)
|
||||
goto out_err;
|
||||
|
||||
printf("USER MUTEX TEST: -- PASSED --\n");
|
||||
}
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
printf("USER MUTEX TEST: -- FAILED --\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
71
conts/posix/test0/src/shmtest.c
Normal file
71
conts/posix/test0/src/shmtest.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Test shmget/shmat/shmdt posix calls.
|
||||
*
|
||||
* Copyright (C) 2007 - 2008 Bahadir Balban
|
||||
*/
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <tests.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
int shmtest(void)
|
||||
{
|
||||
//key_t keys[2] = { 5, 10000 };
|
||||
key_t keys[2] = { 2, 3 };
|
||||
void *bases[2] = { 0 , 0 };
|
||||
int shmids[2];
|
||||
|
||||
test_printf("Initiating shmget()\n");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if ((shmids[i] = shmget(keys[i], 27, IPC_CREAT | 0666)) < 0) {
|
||||
test_printf("SHMGET", errno);
|
||||
goto out_err;
|
||||
} else
|
||||
test_printf("SHMID returned: %d\n", shmids[i]);
|
||||
}
|
||||
test_printf("Now shmat()\n");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if ((int)(bases[i] = shmat(shmids[i], NULL, 0)) == -1) {
|
||||
test_printf("SHMAT", errno);
|
||||
goto out_err;
|
||||
} else
|
||||
test_printf("SHM base address returned: %p\n", bases[i]);
|
||||
}
|
||||
/* Write to the bases */
|
||||
*((unsigned int *)bases[0]) = 0xDEADBEEF;
|
||||
*((unsigned int *)bases[1]) = 0xFEEDBEEF;
|
||||
|
||||
test_printf("Now shmdt()\n");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (shmdt(bases[i]) < 0) {
|
||||
test_printf("SHMDT", errno);
|
||||
goto out_err;
|
||||
} else
|
||||
test_printf("SHM detached OK.\n");
|
||||
}
|
||||
test_printf("Now shmat() again\n");
|
||||
for (int i = 0; i < 2; i++) {
|
||||
bases[i] = shmat(shmids[i], NULL, 0);
|
||||
|
||||
/* SHMAT should fail since no refs were left in last detach */
|
||||
if ((int)bases[i] != -1) {
|
||||
test_printf("SHM base address returned: %p, "
|
||||
"but it should have failed\n", bases[i]);
|
||||
goto out_err;
|
||||
}
|
||||
}
|
||||
|
||||
if (getpid() == parent_of_all)
|
||||
printf("SHM TEST -- PASSED --\n");
|
||||
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
printf("SHM TEST -- FAILED --\n");
|
||||
return 0;
|
||||
|
||||
}
|
||||
25
conts/posix/test0/src/test_exec/container.c
Normal file
25
conts/posix/test0/src/test_exec/container.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Container entry point for this task.
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
|
||||
#include <l4lib/types.h>
|
||||
#include <l4lib/init.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <posix_init.h> /* Initialisers for posix library */
|
||||
|
||||
void main(void);
|
||||
|
||||
void __container_init(void)
|
||||
{
|
||||
/* Generic L4 thread initialisation */
|
||||
__l4_init();
|
||||
|
||||
/* Initialise posix library for application */
|
||||
libposix_init();
|
||||
|
||||
/* Entry to main */
|
||||
main();
|
||||
}
|
||||
|
||||
94
conts/posix/test0/src/test_exec/crt0.S
Normal file
94
conts/posix/test0/src/test_exec/crt0.S
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Australian Public Licence B (OZPLB)
|
||||
*
|
||||
* Version 1-0
|
||||
*
|
||||
* Copyright (c) 2004 National ICT Australia
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
|
||||
* National ICT Australia
|
||||
* http://www.ertos.nicta.com.au
|
||||
*
|
||||
* Permission is granted by National ICT Australia, free of charge, to
|
||||
* any person obtaining a copy of this software and any associated
|
||||
* documentation files (the "Software") to deal with the Software without
|
||||
* restriction, including (without limitation) the rights to use, copy,
|
||||
* modify, adapt, merge, publish, distribute, communicate to the public,
|
||||
* sublicense, and/or sell, lend or rent out copies of the Software, and
|
||||
* to permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimers.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimers in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* * Neither the name of National ICT Australia, nor the names of its
|
||||
* contributors, may be used to endorse or promote products derived
|
||||
* from this Software without specific prior written permission.
|
||||
*
|
||||
* EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
|
||||
* PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
|
||||
* NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
|
||||
* REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
|
||||
* THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
|
||||
* ERRORS, WHETHER OR NOT DISCOVERABLE.
|
||||
*
|
||||
* TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
|
||||
* NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
|
||||
* THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
|
||||
* LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
|
||||
* OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
|
||||
* OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
|
||||
* OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
|
||||
* CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
|
||||
* DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
|
||||
* CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
|
||||
* DAMAGES OR OTHER LIABILITY.
|
||||
*
|
||||
* If applicable legislation implies representations, warranties, or
|
||||
* conditions, or imposes obligations or liability on National ICT
|
||||
* Australia or one of its contributors in respect of the Software that
|
||||
* cannot be wholly or partly excluded, restricted or modified, the
|
||||
* liability of National ICT Australia or the contributor is limited, to
|
||||
* the full extent permitted by the applicable legislation, at its
|
||||
* option, to:
|
||||
* a. in the case of goods, any one or more of the following:
|
||||
* i. the replacement of the goods or the supply of equivalent goods;
|
||||
* ii. the repair of the goods;
|
||||
* iii. the payment of the cost of replacing the goods or of acquiring
|
||||
* equivalent goods;
|
||||
* iv. the payment of the cost of having the goods repaired; or
|
||||
* b. in the case of services:
|
||||
* i. the supplying of the services again; or
|
||||
* ii. the payment of the cost of having the services supplied again.
|
||||
*
|
||||
* The construction, validity and performance of this licence is governed
|
||||
* by the laws in force in New South Wales, Australia.
|
||||
*/
|
||||
|
||||
#ifdef __thumb__
|
||||
#define bl blx
|
||||
#endif
|
||||
|
||||
.section .text.head
|
||||
.code 32
|
||||
.global _start;
|
||||
.align;
|
||||
_start:
|
||||
ldr sp, =__stack
|
||||
bl platform_init
|
||||
bl __container_init
|
||||
1:
|
||||
b 1b
|
||||
|
||||
36
conts/posix/test0/src/test_exec/test_exec.c
Normal file
36
conts/posix/test0/src/test_exec/test_exec.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Some tests for posix syscalls.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <l4lib/arch/syslib.h>
|
||||
#include <l4lib/kip.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <l4lib/ipcdefs.h>
|
||||
#include <tests.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void wait_pager(l4id_t partner)
|
||||
{
|
||||
// printf("%s: Syncing with pager.\n", __TASKNAME__);
|
||||
for (int i = 0; i < 6; i++)
|
||||
write_mr(i, i);
|
||||
l4_send(partner, L4_IPC_TAG_SYNC);
|
||||
// printf("Pager synced with us.\n");
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
wait_pager(0);
|
||||
if (getpid() == 2) {
|
||||
printf("EXECVE TEST -- PASSED --\n");
|
||||
printf("\nThread (%d): Continues to sync with the pager...\n\n", getpid());
|
||||
while (1)
|
||||
wait_pager(0);
|
||||
}
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user