diff --git a/test/Makefile b/test/Makefile index 6947eb6bd..655c08432 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,11 +2,18 @@ OBJS += testee.o OBJS += testee-static.o OBJS += testee-threads.o OBJS += testee-unlinked.o +OBJS += asmem.o PROGS := $(patsubst %.o,%,$(OBJS)) all: $(PROGS) +asmem: asmem.c + $(E) " CC " $(patsubst %.c,%.o,$<) + $(Q) $(CC) -c $(CFLAGS) $< -o $(patsubst %.c,%.o,$<) + $(E) " LINK " $@ + $(Q) $(CC) -o $@ $(patsubst %.c,%.o,$<) + testee: testee.c $(E) " CC " $(patsubst %.c,%.o,$<) $(Q) $(CC) -c $(CFLAGS) $< -o $(patsubst %.c,%.o,$<) diff --git a/test/asmem b/test/asmem new file mode 100755 index 000000000..fe026c833 Binary files /dev/null and b/test/asmem differ diff --git a/test/asmem.c b/test/asmem.c new file mode 100644 index 000000000..4a10bfc57 --- /dev/null +++ b/test/asmem.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +static void *map; + +int main(int argc, char *argv[]) +{ + pid_t pid; + + printf("%s pid %d\n", argv[0], getpid()); + + map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); + if (map == MAP_FAILED) { + printf("mmap failed\n"); + return 0; + } + + memset(map, '-', 32); + ((char *)map)[32] = 0; + + printf("%d: shmem '%s'\n", getpid(), (char *)map); + + pid = fork(); + if (pid == -1) { + printf("fork failed\n"); + return 1; + } + + if (pid == 0) { + while(1) { + printf("%d: shmem '%s'\n", getpid(), (char *)map); + sleep(5); + } + } else { + while(1) { + printf("%d: shmem '%s'\n", getpid(), (char *)map); + sleep(5); + } + } + + return 0; +}