Test "mcexec additional options (h, m, n, O, stack-premap)" on arm64

Change-Id: I85d5deb0433cc1208e4b6837dcc6d6dc2a7b7b52
This commit is contained in:
Shiratori, Takehiro
2018-11-23 16:03:33 +09:00
committed by Masamichi Takagi
parent dc1f96fee3
commit 00395d68d4
13 changed files with 866 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
/* allow_oversubscribe.c COPYRIGHT FUJITSU LIMITED 2018 */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#define PROG "/usr/bin/date"
static int
do_fork(int proc_num)
{
int i;
for (i = 0; i < proc_num; i += 1) {
pid_t pid = fork();
if (pid < 0) {
perror("fork failed");
return -1;
}
else if (0 == pid) {
printf("%d: in child (%d/%d)\n",
getpid(), (i+1), proc_num);
execl(PROG, PROG, NULL);
exit(0);
/* NOTREACHED */
}
}
return 0;
}
static int
do_wait(int proc_num)
{
pid_t mypid = getpid();
int i;
printf("%d: in parent\n", mypid);
for (i = 0; i < proc_num; i += 1) {
int status;
pid_t pid = waitpid(-1, &status, 0);
if (pid < 0) {
perror("waitpid failed");
return -1;
}
printf("%d: waited %d (%d/%d)\n",
mypid, pid, (i+1), proc_num);
}
printf("%d: all done\n", mypid);
return 0;
}
int
main(int argc, char *argv[])
{
int result = 0;
int proc_num = atoi(argv[1]);
if (do_fork(proc_num)) {
result = -1;
}
if (do_wait(proc_num)) {
result = -1;
}
return result;
}