OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [test0/] [src/] [test_exec/] [test_exec.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Some tests for posix syscalls.
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <stdio.h>
7
#include <string.h>
8
#include <l4lib/kip.h>
9
#include <l4lib/utcb.h>
10
#include <l4lib/ipcdefs.h>
11
#include <tests.h>
12
#include <unistd.h>
13
#include <sys/types.h>
14
#include <stdlib.h>
15
#include "atoi.h"
16
 
17
void wait_pager(l4id_t partner)
18
{
19
        // printf("%s: Syncing with pager.\n", __TASKNAME__);
20
        for (int i = 0; i < 6; i++)
21
                write_mr(i, i);
22
        l4_send(partner, L4_IPC_TAG_SYNC);
23
        // printf("Pager synced with us.\n");
24
}
25
 
26
l4id_t pagerid;
27
 
28
int main(int argc, char *argv[])
29
{
30
        wait_pager(0);
31
        char *parent_of_all;
32
        char pidbuf[10];
33
 
34
        //      printf("New task started: %d\n", __raw_tid(getpid()));
35
 
36
        /* Convert current pid to string */
37
        sprintf(pidbuf, "%d", getpid());
38
 
39
        if (strcmp(argv[0], "FIRST ARG") ||
40
            strcmp(argv[1], "SECOND ARG") ||
41
            strcmp(argv[2], "THIRD ARG") ||
42
            strcmp(argv[3], "FOURTH ARG")) {
43
                printf("EXECVE TEST         -- FAILED --\n");
44
                goto out;
45
        }
46
 
47
        // printf("New task continues: %d\n", __raw_tid(getpid()));
48
 
49
        /* Get parent of all pid as a string from environment */
50
        parent_of_all = getenv("parent_of_all");
51
        pagerid = ascii_to_int(getenv("pagerid"));
52
 
53
        /* Compare two pid strings. We use strings because we dont have atoi() */
54
        if (!strcmp(pidbuf, parent_of_all)) {
55
                printf("EXECVE TEST         -- PASSED --\n");
56
                printf("\nThread (%x): Continues to sync with the pager...\n\n", __raw_tid(getpid()));
57
                while (1)
58
                        wait_pager(pagerid);
59
        }
60
out:
61
        _exit(0);
62
}
63
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.