-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add simple pipe syscall and unit test method for linux syscall #132
Conversation
Pull Request Test Coverage Report for Build 198586745Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Test pipe with vfork and execve is success: testfork: #include<sys/types.h>
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main()
{
pid_t pid;
int cnt = 0;
int pipefd[2];
char buf;
char w[12];
char r[12];
if (pipe(pipefd) == -1) {
printf("pipe");
exit(-1);
}
sprintf(w,"%d",pipefd[1]);
sprintf(r,"%d",pipefd[0]);
pid = vfork();
if(pid<0)
printf("error in fork!\n");
else if(pid == 0)
{
execl("/bin/testec","/bin/testec",r,w,NULL);
exit(0);
}
else if(pid > 0)
{
close(pipefd[1]);
while (read(pipefd[0], &buf, 1) > 0)
write(STDOUT_FILENO, &buf, 1);
write(STDOUT_FILENO, "\n", 1);
close(pipefd[0]);
}
return 0;
} testec: #include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char *argv[])
{
int writefd, readfd;
sscanf(argv[2],"%d",&writefd);
sscanf(argv[1],"%d",&readfd);
close(readfd);
write(writefd, "hello pipe", strlen("hello pipe"));
close(writefd);
exit(0);
} |
Currently you can add c language unit test like this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Add simple pipe syscall and unit test method for linux syscall
TODO:
it seems unit test on ipc may be complex, so here is just user mode test.
after that, here is some possible improvement for pipe, but need more dependencies:
these can be fix in the future, maybe not in this pull-request.