diff --git a/testsuits_alpine/exec b/testsuits_alpine/exec new file mode 100755 index 0000000..64359b4 Binary files /dev/null and b/testsuits_alpine/exec differ diff --git a/testsuits_alpine/exec.c b/testsuits_alpine/exec.c new file mode 100644 index 0000000..81f5128 --- /dev/null +++ b/testsuits_alpine/exec.c @@ -0,0 +1,32 @@ +#include +int main() +{ + int child, grandson; + char *sargs[] = { "/bin/echo", "Son ", "Hello", "World!", NULL}; + char *gargs[] = { "/bin/echo", "Grandson ", "Hello", "World!", NULL}; + + if (!(child = fork())) + { + /* child */ + printf("child:s1: pid %d: %d is my father\n", getpid(), getppid()); + if(!(grandson=fork())) + { + printf("grandson: pid %d: %d is my father\n", getpid(), getppid()); + execve("/bin/echo", gargs, NULL); + printf("pid %d: I am back, something is wrong!\n", getpid()); + }else{ + printf("child:s2: pid %d: %d is my father\n", getpid(), getppid()); + wait4(grandson, NULL, 0, NULL); + execve("/bin/echo", sargs, NULL); + printf("pid %d: I am back, something is wrong!\n", getpid()); + } + } + else + { + int myself = getpid(); + printf("parent: pid %d: %d is my son\n", myself, child); + wait4(child, NULL, 0, NULL); + printf("pid %d: done\n", myself); + } + return 0; +} diff --git a/testsuits_alpine/exec.static b/testsuits_alpine/exec.static new file mode 100755 index 0000000..cc84df2 Binary files /dev/null and b/testsuits_alpine/exec.static differ diff --git a/testsuits_alpine/forktree b/testsuits_alpine/forktree new file mode 100755 index 0000000..19b9a81 Binary files /dev/null and b/testsuits_alpine/forktree differ diff --git a/testsuits_alpine/forktree.c b/testsuits_alpine/forktree.c new file mode 100644 index 0000000..0a27b6a --- /dev/null +++ b/testsuits_alpine/forktree.c @@ -0,0 +1,38 @@ +#include +#include + +#define DEPTH 4 +#define SLEEP_TIME 1 +void forktree(const char *cur); + +void +forkchild(const char *cur, char branch) { + char nxt[DEPTH + 1]; + + if (strlen(cur) >= DEPTH) + return; + + snprintf(nxt, DEPTH + 1, "%s%c", cur, branch); + if (fork() == 0) { + forktree(nxt); + //yield(); + exit(0); + } +} + +void +forktree(const char *cur) { + printf("%04x: I am '%s'\n", getpid(), cur); + + forkchild(cur, '0'); + forkchild(cur, '1'); +} + +int +main(void) { + printf("forktree process will sleep %d ticks\n",SLEEP_TIME); + sleep(SLEEP_TIME); + forktree(""); + return 0; +} + diff --git a/testsuits_alpine/readv b/testsuits_alpine/readv new file mode 100755 index 0000000..393e656 Binary files /dev/null and b/testsuits_alpine/readv differ diff --git a/testsuits_alpine/readv.c b/testsuits_alpine/readv.c new file mode 100644 index 0000000..f808b4b --- /dev/null +++ b/testsuits_alpine/readv.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +char head[1024],foo[48], bar[51], baz[49]; +struct iovec iov[3]; +int main () +{ + + + ssize_t nr; + int fd, i; + + fd = open ("hello.sh", O_RDONLY); + if (fd==-1){ + perror ("open"); + return 1; + } + nr=read(fd, head, sizeof(head)); + if(nr==-1) { + perror("read"); + return 2; + } + + printf ("read size %d, head: %s\n", nr, (char *) head); + + /* set up our iovec structures */ + iov[0].iov_base = foo; + iov[0].iov_len = sizeof (foo); + iov[1].iov_base = bar; + iov[1].iov_len = sizeof (bar); + iov[2].iov_base = baz; + iov[2].iov_len = sizeof (baz); + + /* read into the structures with a single call */ + nr = readv (fd, iov, 3); + if (nr==-1) { + perror ("readv"); + return 1; + } + + for (i = 0; i < 3; i++) + printf ("IOV%d: size:%d %s\n", i, nr, (char *) iov[i].iov_base); + + if (close (fd)) { + perror ("close"); + return 1; + } + + return 0; +}